HBASE-5824 revert changes to single Put case, preserving deprecation for ICV

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1328457 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2012-04-20 17:36:02 +00:00
parent 85842f019e
commit e05c21c0cb
3 changed files with 25 additions and 34 deletions

View File

@ -829,40 +829,21 @@ public class HTable implements HTableInterface {
} }
private void doPut(final List<Put> puts) throws IOException { private void doPut(final List<Put> puts) throws IOException {
if (autoFlush && puts.size() == 1) { int n = 0;
final Put put = puts.get(0); for (Put put : puts) {
validatePut(put); validatePut(put);
new ServerCallable<Void>(connection, tableName, put.getRow(), writeBuffer.add(put);
operationTimeout) { currentWriteBufferSize += put.heapSize();
public Void call() throws IOException {
try { // we need to periodically see if the writebuffer is full instead of waiting until the end of the List
MutateRequest request = RequestConverter.buildMutateRequest( n++;
location.getRegionInfo().getRegionName(), put); if (n % DOPUT_WB_CHECK == 0 && currentWriteBufferSize > writeBufferSize) {
server.mutate(null, request);
} catch (ServiceException se) {
throw ProtobufUtil.getRemoteException(se);
}
return null;
}
}.withRetries();
} else {
int n = 0;
for (Put put : puts) {
validatePut(put);
writeBuffer.add(put);
currentWriteBufferSize += put.heapSize();
// we need to periodically see if the writebuffer is full
// instead of waiting until the end of the List
n++;
if (n % DOPUT_WB_CHECK == 0 && currentWriteBufferSize > writeBufferSize) {
flushCommits();
}
}
if (autoFlush || currentWriteBufferSize > writeBufferSize) {
flushCommits(); flushCommits();
} }
} }
if (autoFlush || currentWriteBufferSize > writeBufferSize) {
flushCommits();
}
} }
/** /**

View File

@ -17,10 +17,13 @@
*/ */
package org.apache.hadoop.hbase.constraint; package org.apache.hadoop.hbase.constraint;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.util.List;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HBaseTestingUtility;
@ -29,6 +32,7 @@ import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.MediumTests; import org.apache.hadoop.hbase.MediumTests;
import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
@ -114,8 +118,13 @@ public class TestConstraint {
try { try {
table.put(put); table.put(put);
fail("This put should not have suceeded - AllFailConstraint was not run!"); fail("This put should not have suceeded - AllFailConstraint was not run!");
} catch (Throwable t) { } catch (RetriesExhaustedWithDetailsException e) {
assertTrue(t instanceof ConstraintException); List<Throwable> causes = e.getCauses();
assertEquals(
"More than one failure cause - should only be the failure constraint exception",
1, causes.size());
Throwable t = causes.get(0);
assertEquals(ConstraintException.class, t.getClass());
} }
table.close(); table.close();
} }

View File

@ -26,6 +26,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.*; import org.apache.hadoop.hbase.*;
import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
import org.apache.hadoop.hbase.regionserver.HRegionServer; import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.regionserver.wal.WALEdit; import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
@ -111,12 +112,12 @@ public class TestRegionServerCoprocessorExceptionWithRemove {
Put put = new Put(ROW); Put put = new Put(ROW);
put.add(TEST_FAMILY, ROW, ROW); put.add(TEST_FAMILY, ROW, ROW);
table.put(put); table.put(put);
} catch (Throwable t) { } catch (RetriesExhaustedWithDetailsException e) {
// below, could call instead : // below, could call instead :
// startsWith("Failed 1 action: DoNotRetryIOException.") // startsWith("Failed 1 action: DoNotRetryIOException.")
// But that might be too brittle if client-side // But that might be too brittle if client-side
// DoNotRetryIOException-handler changes its message. // DoNotRetryIOException-handler changes its message.
assertTrue(t instanceof DoNotRetryIOException); assertTrue(e.getMessage().contains("DoNotRetryIOException"));
threwDNRE = true; threwDNRE = true;
} finally { } finally {
assertTrue(threwDNRE); assertTrue(threwDNRE);