You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2013/10/05 01:38:42 UTC
svn commit: r1529348 [3/3] - in /hbase/trunk:
hbase-client/src/main/java/org/apache/hadoop/hbase/client/
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/
hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/
hbase-client/src/test/java/org...
Modified: hbase/trunk/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/RPCProtos.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/RPCProtos.java?rev=1529348&r1=1529347&r2=1529348&view=diff
==============================================================================
--- hbase/trunk/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/RPCProtos.java (original)
+++ hbase/trunk/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/RPCProtos.java Fri Oct 4 23:38:41 2013
@@ -3662,6 +3662,26 @@ public final class RPCProtos {
* </pre>
*/
org.apache.hadoop.hbase.protobuf.generated.RPCProtos.CellBlockMetaOrBuilder getCellBlockMetaOrBuilder();
+
+ // optional uint32 priority = 6;
+ /**
+ * <code>optional uint32 priority = 6;</code>
+ *
+ * <pre>
+ * 0 is NORMAL priority. 100 is HIGH. If no priority, treat it as NORMAL.
+ * See HConstants.
+ * </pre>
+ */
+ boolean hasPriority();
+ /**
+ * <code>optional uint32 priority = 6;</code>
+ *
+ * <pre>
+ * 0 is NORMAL priority. 100 is HIGH. If no priority, treat it as NORMAL.
+ * See HConstants.
+ * </pre>
+ */
+ int getPriority();
}
/**
* Protobuf type {@code RequestHeader}
@@ -3759,6 +3779,11 @@ public final class RPCProtos {
bitField0_ |= 0x00000010;
break;
}
+ case 48: {
+ bitField0_ |= 0x00000020;
+ priority_ = input.readUInt32();
+ break;
+ }
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
@@ -3946,12 +3971,39 @@ public final class RPCProtos {
return cellBlockMeta_;
}
+ // optional uint32 priority = 6;
+ public static final int PRIORITY_FIELD_NUMBER = 6;
+ private int priority_;
+ /**
+ * <code>optional uint32 priority = 6;</code>
+ *
+ * <pre>
+ * 0 is NORMAL priority. 100 is HIGH. If no priority, treat it as NORMAL.
+ * See HConstants.
+ * </pre>
+ */
+ public boolean hasPriority() {
+ return ((bitField0_ & 0x00000020) == 0x00000020);
+ }
+ /**
+ * <code>optional uint32 priority = 6;</code>
+ *
+ * <pre>
+ * 0 is NORMAL priority. 100 is HIGH. If no priority, treat it as NORMAL.
+ * See HConstants.
+ * </pre>
+ */
+ public int getPriority() {
+ return priority_;
+ }
+
private void initFields() {
callId_ = 0;
traceInfo_ = org.apache.hadoop.hbase.protobuf.generated.TracingProtos.RPCTInfo.getDefaultInstance();
methodName_ = "";
requestParam_ = false;
cellBlockMeta_ = org.apache.hadoop.hbase.protobuf.generated.RPCProtos.CellBlockMeta.getDefaultInstance();
+ priority_ = 0;
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
@@ -3980,6 +4032,9 @@ public final class RPCProtos {
if (((bitField0_ & 0x00000010) == 0x00000010)) {
output.writeMessage(5, cellBlockMeta_);
}
+ if (((bitField0_ & 0x00000020) == 0x00000020)) {
+ output.writeUInt32(6, priority_);
+ }
getUnknownFields().writeTo(output);
}
@@ -4009,6 +4064,10 @@ public final class RPCProtos {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(5, cellBlockMeta_);
}
+ if (((bitField0_ & 0x00000020) == 0x00000020)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeUInt32Size(6, priority_);
+ }
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
return size;
@@ -4057,6 +4116,11 @@ public final class RPCProtos {
result = result && getCellBlockMeta()
.equals(other.getCellBlockMeta());
}
+ result = result && (hasPriority() == other.hasPriority());
+ if (hasPriority()) {
+ result = result && (getPriority()
+ == other.getPriority());
+ }
result = result &&
getUnknownFields().equals(other.getUnknownFields());
return result;
@@ -4090,6 +4154,10 @@ public final class RPCProtos {
hash = (37 * hash) + CELL_BLOCK_META_FIELD_NUMBER;
hash = (53 * hash) + getCellBlockMeta().hashCode();
}
+ if (hasPriority()) {
+ hash = (37 * hash) + PRIORITY_FIELD_NUMBER;
+ hash = (53 * hash) + getPriority();
+ }
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
@@ -4223,6 +4291,8 @@ public final class RPCProtos {
cellBlockMetaBuilder_.clear();
}
bitField0_ = (bitField0_ & ~0x00000010);
+ priority_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000020);
return this;
}
@@ -4279,6 +4349,10 @@ public final class RPCProtos {
} else {
result.cellBlockMeta_ = cellBlockMetaBuilder_.build();
}
+ if (((from_bitField0_ & 0x00000020) == 0x00000020)) {
+ to_bitField0_ |= 0x00000020;
+ }
+ result.priority_ = priority_;
result.bitField0_ = to_bitField0_;
onBuilt();
return result;
@@ -4312,6 +4386,9 @@ public final class RPCProtos {
if (other.hasCellBlockMeta()) {
mergeCellBlockMeta(other.getCellBlockMeta());
}
+ if (other.hasPriority()) {
+ setPriority(other.getPriority());
+ }
this.mergeUnknownFields(other.getUnknownFields());
return this;
}
@@ -4781,6 +4858,59 @@ public final class RPCProtos {
return cellBlockMetaBuilder_;
}
+ // optional uint32 priority = 6;
+ private int priority_ ;
+ /**
+ * <code>optional uint32 priority = 6;</code>
+ *
+ * <pre>
+ * 0 is NORMAL priority. 100 is HIGH. If no priority, treat it as NORMAL.
+ * See HConstants.
+ * </pre>
+ */
+ public boolean hasPriority() {
+ return ((bitField0_ & 0x00000020) == 0x00000020);
+ }
+ /**
+ * <code>optional uint32 priority = 6;</code>
+ *
+ * <pre>
+ * 0 is NORMAL priority. 100 is HIGH. If no priority, treat it as NORMAL.
+ * See HConstants.
+ * </pre>
+ */
+ public int getPriority() {
+ return priority_;
+ }
+ /**
+ * <code>optional uint32 priority = 6;</code>
+ *
+ * <pre>
+ * 0 is NORMAL priority. 100 is HIGH. If no priority, treat it as NORMAL.
+ * See HConstants.
+ * </pre>
+ */
+ public Builder setPriority(int value) {
+ bitField0_ |= 0x00000020;
+ priority_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional uint32 priority = 6;</code>
+ *
+ * <pre>
+ * 0 is NORMAL priority. 100 is HIGH. If no priority, treat it as NORMAL.
+ * See HConstants.
+ * </pre>
+ */
+ public Builder clearPriority() {
+ bitField0_ = (bitField0_ & ~0x00000020);
+ priority_ = 0;
+ onChanged();
+ return this;
+ }
+
// @@protoc_insertion_point(builder_scope:RequestHeader)
}
@@ -5797,15 +5927,15 @@ public final class RPCProtos {
"\001(\r\"|\n\021ExceptionResponse\022\034\n\024exception_cl" +
"ass_name\030\001 \001(\t\022\023\n\013stack_trace\030\002 \001(\t\022\020\n\010h" +
"ostname\030\003 \001(\t\022\014\n\004port\030\004 \001(\005\022\024\n\014do_not_re",
- "try\030\005 \001(\010\"\224\001\n\rRequestHeader\022\017\n\007call_id\030\001" +
+ "try\030\005 \001(\010\"\246\001\n\rRequestHeader\022\017\n\007call_id\030\001" +
" \001(\r\022\035\n\ntrace_info\030\002 \001(\0132\t.RPCTInfo\022\023\n\013m" +
"ethod_name\030\003 \001(\t\022\025\n\rrequest_param\030\004 \001(\010\022" +
"\'\n\017cell_block_meta\030\005 \001(\0132\016.CellBlockMeta" +
- "\"q\n\016ResponseHeader\022\017\n\007call_id\030\001 \001(\r\022%\n\te" +
- "xception\030\002 \001(\0132\022.ExceptionResponse\022\'\n\017ce" +
- "ll_block_meta\030\003 \001(\0132\016.CellBlockMetaB<\n*o" +
- "rg.apache.hadoop.hbase.protobuf.generate" +
- "dB\tRPCProtosH\001\240\001\001"
+ "\022\020\n\010priority\030\006 \001(\r\"q\n\016ResponseHeader\022\017\n\007" +
+ "call_id\030\001 \001(\r\022%\n\texception\030\002 \001(\0132\022.Excep" +
+ "tionResponse\022\'\n\017cell_block_meta\030\003 \001(\0132\016." +
+ "CellBlockMetaB<\n*org.apache.hadoop.hbase" +
+ ".protobuf.generatedB\tRPCProtosH\001\240\001\001"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@@ -5841,7 +5971,7 @@ public final class RPCProtos {
internal_static_RequestHeader_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_RequestHeader_descriptor,
- new java.lang.String[] { "CallId", "TraceInfo", "MethodName", "RequestParam", "CellBlockMeta", });
+ new java.lang.String[] { "CallId", "TraceInfo", "MethodName", "RequestParam", "CellBlockMeta", "Priority", });
internal_static_ResponseHeader_descriptor =
getDescriptor().getMessageTypes().get(5);
internal_static_ResponseHeader_fieldAccessorTable = new
Modified: hbase/trunk/hbase-protocol/src/main/protobuf/Client.proto
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-protocol/src/main/protobuf/Client.proto?rev=1529348&r1=1529347&r2=1529348&view=diff
==============================================================================
--- hbase/trunk/hbase-protocol/src/main/protobuf/Client.proto (original)
+++ hbase/trunk/hbase-protocol/src/main/protobuf/Client.proto Fri Oct 4 23:38:41 2013
@@ -38,7 +38,10 @@ message Column {
}
/**
- * The protocol buffer version of Get
+ * The protocol buffer version of Get.
+ * Unless existence_only is specified, return all the requested data
+ * for the row that matches exactly, or the one that immediately
+ * precedes it if closest_row_before is specified.
*/
message Get {
required bytes row = 1;
@@ -50,6 +53,14 @@ message Get {
optional bool cache_blocks = 7 [default = true];
optional uint32 store_limit = 8;
optional uint32 store_offset = 9;
+
+ // The result isn't asked for, just check for
+ // the existence.
+ optional bool existence_only = 10 [default = false];
+
+ // If the row to get doesn't exist, return the
+ // closest row before.
+ optional bool closest_row_before = 11 [default = false];
}
message Result {
@@ -63,56 +74,22 @@ message Result {
// ours. NOTE: This is different from the pb managed cell_count of the
// 'cell' field above which is non-null when the cells are pb'd.
optional int32 associated_cell_count = 2;
+
+ // used for Get to check existence only. Not set if existence_only was not set to true
+ // in the query.
+ optional bool exists = 3;
}
/**
* The get request. Perform a single Get operation.
- * Unless existence_only is specified, return all the requested data
- * for the row that matches exactly, or the one that immediately
- * precedes it if closest_row_before is specified.
- *
- * If existence_only is set, only the existence will be returned.
*/
message GetRequest {
required RegionSpecifier region = 1;
required Get get = 2;
-
- // If the row to get doesn't exist, return the
- // closest row before.
- optional bool closest_row_before = 3;
-
- // The result isn't asked for, just check for
- // the existence. If closest_row_before specified,
- // this will be ignored
- optional bool existence_only = 4;
-}
-
-message MultiGetRequest {
- required RegionSpecifier region = 1;
- repeated Get get = 2;
-
- // If the row to get doesn't exist, return the
- // closest row before.
- optional bool closest_row_before = 3;
-
- // The result isn't asked for, just check for
- // the existence. If closest_row_before specified,
- // this will be ignored
- optional bool existence_only = 4;
}
message GetResponse {
optional Result result = 1;
-
- // used for Get to check existence only
- optional bool exists = 2;
-}
-
-message MultiGetResponse {
- repeated Result result = 1;
-
- // used for Get to check existence only
- repeated bool exists = 2;
}
/**
@@ -318,43 +295,60 @@ message CoprocessorServiceResponse {
required NameBytesPair value = 2;
}
+// Either a Get or a Mutation
+message Action {
+ // If part of a multi action, useful aligning
+ // result with what was originally submitted.
+ optional uint32 index = 1;
+ optional MutationProto mutation = 2;
+ optional Get get = 3;
+}
+
+/**
+ * Actions to run against a Region.
+ */
+message RegionAction {
+ required RegionSpecifier region = 1;
+ // When set, run mutations as atomic unit.
+ optional bool atomic = 2;
+ repeated Action action = 3;
+}
+
/**
- * An action that is part of MultiRequest.
- * This is a union type - exactly one of the fields will be set.
+ * Either a Result or an Exception NameBytesPair (keyed by
+ * exception name whose value is the exception stringified)
+ * or maybe empty if no result and no exception.
*/
-message MultiAction {
- optional MutationProto mutation = 1;
- optional Get get = 2;
+message ResultOrException {
+ // If part of a multi call, save original index of the list of all
+ // passed so can align this response w/ original request.
+ optional uint32 index = 1;
+ optional Result result = 2;
+ optional NameBytesPair exception = 3;
}
/**
- * An individual action result. The result will in the
- * same order as the action in the request. If an action
- * returns a value, it is set in value field. If it doesn't
- * return anything, the result will be empty. If an action
- * fails to execute due to any exception, the exception
- * is returned as a stringified parameter.
+ * The result of a RegionAction.
*/
-message ActionResult {
- optional Result value = 1;
+message RegionActionResult {
+ repeated ResultOrException resultOrException = 1;
+ // If the operation failed globally for this region, this exception is set
optional NameBytesPair exception = 2;
}
/**
- * You can execute a list of actions on a given region in order.
- *
- * If it is a list of mutate actions, atomic can be set
- * to make sure they can be processed atomically, just like
- * RowMutations.
+ * Execute a list of actions on a given region in order.
+ * Nothing prevents a request to contains a set of RegionAction on the same region.
+ * For this reason, the matching between the MultiRequest and the MultiResponse is not
+ * done by the region specifier but by keeping the order of the RegionActionResult vs.
+ * the order of the RegionAction.
*/
message MultiRequest {
- required RegionSpecifier region = 1;
- repeated MultiAction action = 2;
- optional bool atomic = 3;
+ repeated RegionAction regionAction = 1;
}
message MultiResponse {
- repeated ActionResult result = 1;
+ repeated RegionActionResult regionActionResult = 1;
}
@@ -362,9 +356,6 @@ service ClientService {
rpc Get(GetRequest)
returns(GetResponse);
- rpc MultiGet(MultiGetRequest)
- returns(MultiGetResponse);
-
rpc Mutate(MutateRequest)
returns(MutateResponse);
Modified: hbase/trunk/hbase-protocol/src/main/protobuf/RPC.proto
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-protocol/src/main/protobuf/RPC.proto?rev=1529348&r1=1529347&r2=1529348&view=diff
==============================================================================
--- hbase/trunk/hbase-protocol/src/main/protobuf/RPC.proto (original)
+++ hbase/trunk/hbase-protocol/src/main/protobuf/RPC.proto Fri Oct 4 23:38:41 2013
@@ -119,7 +119,9 @@ message RequestHeader {
optional bool request_param = 4;
// If present, then an encoded data block follows.
optional CellBlockMeta cell_block_meta = 5;
- // TODO: Have client specify priority
+ // 0 is NORMAL priority. 100 is HIGH. If no priority, treat it as NORMAL.
+ // See HConstants.
+ optional uint32 priority = 6;
}
message ResponseHeader {
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/AnnotationReadingPriorityFunction.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/AnnotationReadingPriorityFunction.java?rev=1529348&r1=1529347&r2=1529348&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/AnnotationReadingPriorityFunction.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/AnnotationReadingPriorityFunction.java Fri Oct 4 23:38:41 2013
@@ -83,8 +83,7 @@ class AnnotationReadingPriorityFunction
CompactRegionRequest.class,
GetRequest.class,
MutateRequest.class,
- ScanRequest.class,
- MultiRequest.class
+ ScanRequest.class
};
// Some caches for helping performance
@@ -101,7 +100,7 @@ class AnnotationReadingPriorityFunction
if (p != null) {
// Since we protobuf'd, and then subsequently, when we went with pb style, method names
// are capitalized. This meant that this brittle compare of method names gotten by
- // reflection no longer matched the method names comeing in over pb. TODO: Get rid of this
+ // reflection no longer matched the method names coming in over pb. TODO: Get rid of this
// check. For now, workaround is to capitalize the names we got from reflection so they
// have chance of matching the pb ones.
String capitalizedMethodName = capitalize(m.getName());
@@ -109,7 +108,6 @@ class AnnotationReadingPriorityFunction
}
}
this.annotatedQos = qosMap;
-
if (methodMap.get("getRegion") == null) {
methodMap.put("hasRegion", new HashMap<Class<? extends Message>, Method>());
methodMap.put("getRegion", new HashMap<Class<? extends Message>, Method>());
@@ -148,10 +146,14 @@ class AnnotationReadingPriorityFunction
if (priorityByAnnotation != null) {
return priorityByAnnotation;
}
-
if (param == null) {
return HConstants.NORMAL_QOS;
}
+ if (methodName.equalsIgnoreCase("multi") && param instanceof MultiRequest) {
+ // The multi call has its priority set in the header. All calls should work this way but
+ // only this one has been converted so far. No priority == NORMAL_QOS.
+ return header.hasPriority()? header.getPriority(): HConstants.NORMAL_QOS;
+ }
String cls = param.getClass().getName();
Class<? extends Message> rpcArgClass = argumentToClassMap.get(cls);
RegionSpecifier regionSpecifier = null;
@@ -201,4 +203,4 @@ class AnnotationReadingPriorityFunction
void setRegionServer(final HRegionServer hrs) {
this.hRegionServer = hrs;
}
-}
\ No newline at end of file
+}
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1529348&r1=1529347&r2=1529348&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Fri Oct 4 23:38:41 2013
@@ -73,16 +73,16 @@ import org.apache.hadoop.hbase.DroppedSn
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.NotServingRegionException;
-import org.apache.hadoop.hbase.RegionTooBusyException;
-import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.UnknownScannerException;
import org.apache.hadoop.hbase.HConstants.OperationStatusCode;
import org.apache.hadoop.hbase.HDFSBlocksDistribution;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValueUtil;
+import org.apache.hadoop.hbase.NotServingRegionException;
+import org.apache.hadoop.hbase.RegionTooBusyException;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.UnknownScannerException;
import org.apache.hadoop.hbase.backup.HFileArchiver;
import org.apache.hadoop.hbase.client.Append;
import org.apache.hadoop.hbase.client.Delete;
@@ -113,11 +113,9 @@ import org.apache.hadoop.hbase.ipc.RpcSe
import org.apache.hadoop.hbase.master.AssignmentManager;
import org.apache.hadoop.hbase.monitoring.MonitoredTask;
import org.apache.hadoop.hbase.monitoring.TaskMonitor;
-import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.GetRegionInfoResponse.CompactionState;
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.WALEntry;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceCall;
-import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
import org.apache.hadoop.hbase.protobuf.generated.WALProtos.CompactionDescriptor;
@@ -4331,7 +4329,7 @@ public class HRegion implements HeapSize
}
}
List<Cell> results = get(get, true);
- return Result.create(results);
+ return Result.create(results, get.isCheckExistenceOnly() ? !results.isEmpty() : null);
}
/*
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1529348&r1=1529347&r2=1529348&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Fri Oct 4 23:38:41 2013
@@ -63,6 +63,7 @@ import org.apache.hadoop.hbase.Chore;
import org.apache.hadoop.hbase.ClockOutOfSyncException;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HBaseIOException;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
@@ -149,7 +150,6 @@ import org.apache.hadoop.hbase.protobuf.
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.UpdateFavoredNodesResponse;
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.WALEntry;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos;
-import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ActionResult;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.BulkLoadHFileRequest;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.BulkLoadHFileRequest.FamilyPath;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.BulkLoadHFileResponse;
@@ -158,14 +158,15 @@ import org.apache.hadoop.hbase.protobuf.
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CoprocessorServiceResponse;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetRequest;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetResponse;
-import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiGetRequest;
-import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiGetResponse;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiRequest;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiResponse;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutateRequest;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutateResponse;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType;
+import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.RegionAction;
+import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.RegionActionResult;
+import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ResultOrException;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse;
import org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos;
@@ -2757,7 +2758,7 @@ public class HRegionServer implements Cl
Boolean existence = null;
Result r = null;
- if (request.getClosestRowBefore()) {
+ if (get.hasClosestRowBefore() && get.getClosestRowBefore()) {
if (get.getColumnCount() != 1) {
throw new DoNotRetryIOException(
"get ClosestRowBefore supports one and only one family now, not "
@@ -2768,13 +2769,13 @@ public class HRegionServer implements Cl
r = region.getClosestRowBefore(row, family);
} else {
Get clientGet = ProtobufUtil.toGet(get);
- if (request.getExistenceOnly() && region.getCoprocessorHost() != null) {
+ if (get.getExistenceOnly() && region.getCoprocessorHost() != null) {
existence = region.getCoprocessorHost().preExists(clientGet);
}
if (existence == null) {
r = region.get(clientGet);
- if (request.getExistenceOnly()) {
- boolean exists = r != null && !r.isEmpty();
+ if (get.getExistenceOnly()) {
+ boolean exists = r.getExists();
if (region.getCoprocessorHost() != null) {
exists = region.getCoprocessorHost().postExists(clientGet, exists);
}
@@ -2782,9 +2783,10 @@ public class HRegionServer implements Cl
}
}
}
- if (existence != null) {
- builder.setExists(existence.booleanValue());
- } else if (r != null) {
+ if (existence != null){
+ ClientProtos.Result pbr = ProtobufUtil.toResult(existence);
+ builder.setResult(pbr);
+ }else if (r != null) {
ClientProtos.Result pbr = ProtobufUtil.toResult(r);
builder.setResult(pbr);
}
@@ -2796,62 +2798,6 @@ public class HRegionServer implements Cl
}
}
- /**
- * Get multi data from a table.
- *
- * @param controller the RPC controller
- * @param request multi-the get request
- * @throws ServiceException
- */
- @Override
- public MultiGetResponse multiGet(final RpcController controller, final MultiGetRequest request)
- throws ServiceException {
- long before = EnvironmentEdgeManager.currentTimeMillis();
- try {
- requestCount.add(request.getGetCount());
- HRegion region = getRegion(request.getRegion());
- MultiGetResponse.Builder builder = MultiGetResponse.newBuilder();
- for (ClientProtos.Get get: request.getGetList()) {
- Boolean existence = null;
- Result r = null;
- if (request.getClosestRowBefore()) {
- if (get.getColumnCount() != 1) {
- throw new DoNotRetryIOException(
- "get ClosestRowBefore supports one and only one family now, not "
- + get.getColumnCount() + " families");
- }
- byte[] row = get.getRow().toByteArray();
- byte[] family = get.getColumn(0).getFamily().toByteArray();
- r = region.getClosestRowBefore(row, family);
- } else {
- Get clientGet = ProtobufUtil.toGet(get);
- if (request.getExistenceOnly() && region.getCoprocessorHost() != null) {
- existence = region.getCoprocessorHost().preExists(clientGet);
- }
- if (existence == null) {
- r = region.get(clientGet);
- if (request.getExistenceOnly()) {
- boolean exists = r != null && !r.isEmpty();
- if (region.getCoprocessorHost() != null) {
- exists = region.getCoprocessorHost().postExists(clientGet, exists);
- }
- existence = exists;
- }
- }
- }
- if (existence != null) {
- builder.addExists(existence.booleanValue());
- } else if (r != null) {
- builder.addResult(ProtobufUtil.toResult(r));
- }
- }
- return builder.build();
- } catch (IOException ie) {
- throw new ServiceException(ie);
- } finally {
- metricsRegionServer.updateGet(EnvironmentEdgeManager.currentTimeMillis() - before);
- }
- }
/**
* Mutate data in a table.
@@ -3300,106 +3246,134 @@ public class HRegionServer implements Cl
// It is also the conduit via which we pass back data.
PayloadCarryingRpcController controller = (PayloadCarryingRpcController)rpcc;
CellScanner cellScanner = controller != null ? controller.cellScanner(): null;
- // Clear scanner so we are not holding on to reference across call.
if (controller != null) controller.setCellScanner(null);
+
+ // this will contain all the cells that we need to return. It's created later, if needed.
List<CellScannable> cellsToReturn = null;
- try {
- HRegion region = getRegion(request.getRegion());
- MultiResponse.Builder builder = MultiResponse.newBuilder();
- List<MutationProto> mutations = new ArrayList<MutationProto>(request.getActionCount());
- // Do a bunch of mutations atomically. Mutations are Puts and Deletes. NOT Gets.
- if (request.hasAtomic() && request.getAtomic()) {
- // MultiAction is union type. Has a Get or a Mutate.
- for (ClientProtos.MultiAction actionUnion : request.getActionList()) {
- if (actionUnion.hasMutation()) {
- mutations.add(actionUnion.getMutation());
- } else {
- throw new DoNotRetryIOException("Unsupported atomic action type: " + actionUnion);
- }
+ MultiResponse.Builder responseBuilder = MultiResponse.newBuilder();
+
+ for (RegionAction regionAction : request.getRegionActionList()) {
+ this.requestCount.add(regionAction.getActionCount());
+ RegionActionResult.Builder regionActionResultBuilder = RegionActionResult.newBuilder();
+ HRegion region;
+ try {
+ region = getRegion(regionAction.getRegion());
+ } catch (IOException e) {
+ regionActionResultBuilder.setException(ResponseConverter.buildException(e));
+ responseBuilder.addRegionActionResult(regionActionResultBuilder.build());
+ continue; // For this region it's a failure.
+ }
+
+ if (regionAction.hasAtomic() && regionAction.getAtomic()) {
+ // How does this call happen? It may need some work to play well w/ the surroundings.
+ // Need to return an item per Action along w/ Action index. TODO.
+ try {
+ mutateRows(region, regionAction.getActionList(), cellScanner);
+ } catch (IOException e) {
+ // As it's atomic, we may expect it's a global failure.
+ regionActionResultBuilder.setException(ResponseConverter.buildException(e));
}
- // TODO: We are not updating a metric here. Should we up requestCount?
- if (!mutations.isEmpty()) mutateRows(region, mutations, cellScanner);
} else {
- // Do a bunch of Actions.
- ActionResult.Builder resultBuilder = null;
- cellsToReturn = new ArrayList<CellScannable>(request.getActionCount());
- for (ClientProtos.MultiAction actionUnion : request.getActionList()) {
- this.requestCount.increment();
- ClientProtos.Result result = null;
- try {
- if (actionUnion.hasGet()) {
- Get get = ProtobufUtil.toGet(actionUnion.getGet());
- Result r = region.get(get);
- if (r != null) {
- // Get a result with no data. The data will be carried alongside pbs, not as pbs.
- result = ProtobufUtil.toResultNoData(r);
- // Add the Result to controller so it gets serialized apart from pb. Get
- // Results could be big so good if they are not serialized as pb.
- cellsToReturn.add(r);
- }
- } else if (actionUnion.hasMutation()) {
- MutationProto mutation = actionUnion.getMutation();
- MutationType type = mutation.getMutateType();
- if (type != MutationType.PUT && type != MutationType.DELETE) {
- if (!mutations.isEmpty()) {
- doBatchOp(builder, region, mutations, cellScanner);
- mutations.clear();
- } else if (!region.getRegionInfo().isMetaTable()) {
- cacheFlusher.reclaimMemStoreMemory();
- }
- }
- Result r = null;
- switch (type) {
- case APPEND:
- r = append(region, mutation, cellScanner);
- break;
- case INCREMENT:
- r = increment(region, mutation, cellScanner);
- break;
- case PUT:
- case DELETE:
- mutations.add(mutation);
- break;
- default:
- throw new DoNotRetryIOException("Unsupported mutate type: " + type.name());
- }
- if (r != null) {
- // Put the data into the cellsToReturn and the metadata about the result is all that
- // we will pass back in the protobuf result.
- result = ProtobufUtil.toResultNoData(r);
- cellsToReturn.add(r);
- }
- } else {
- LOG.warn("Error: invalid action: " + actionUnion + ". "
- + "it must be a Get, Mutate, or Exec.");
- throw new DoNotRetryIOException("Invalid action, "
- + "it must be a Get, Mutate, or Exec.");
- }
- if (result != null) {
- if (resultBuilder == null) {
- resultBuilder = ActionResult.newBuilder();
- } else {
- resultBuilder.clear();
- }
- resultBuilder.setValue(result);
- builder.addResult(resultBuilder.build());
+ // doNonAtomicRegionMutation manages the exception internally
+ cellsToReturn = doNonAtomicRegionMutation(region, regionAction, cellScanner,
+ regionActionResultBuilder, cellsToReturn);
+ }
+ responseBuilder.addRegionActionResult(regionActionResultBuilder.build());
+ }
+ // Load the controller with the Cells to return.
+ if (cellsToReturn != null && !cellsToReturn.isEmpty() && controller != null) {
+ controller.setCellScanner(CellUtil.createCellScanner(cellsToReturn));
+ }
+ return responseBuilder.build();
+ }
+
+ /**
+ * Run through the regionMutation <code>rm</code> and per Mutation, do the work, and then when
+ * done, add an instance of a {@link ResultOrException} that corresponds to each Mutation.
+ * @param region
+ * @param actions
+ * @param cellScanner
+ * @param builder
+ * @param cellsToReturn Could be null. May be allocated in this method. This is what this
+ * method returns as a 'result'.
+ * @return Return the <code>cellScanner</code> passed
+ */
+ private List<CellScannable> doNonAtomicRegionMutation(final HRegion region,
+ final RegionAction actions, final CellScanner cellScanner,
+ final RegionActionResult.Builder builder, List<CellScannable> cellsToReturn) {
+ // Gather up CONTIGUOUS Puts and Deletes in this mutations List. Idea is that rather than do
+ // one at a time, we instead pass them in batch. Be aware that the corresponding
+ // ResultOrException instance that matches each Put or Delete is then added down in the
+ // doBatchOp call. We should be staying aligned though the Put and Delete are deferred/batched
+ List<ClientProtos.Action> mutations = null;
+ for (ClientProtos.Action action: actions.getActionList()) {
+ ClientProtos.ResultOrException.Builder resultOrExceptionBuilder = null;
+ try {
+ Result r = null;
+ if (action.hasGet()) {
+ Get get = ProtobufUtil.toGet(action.getGet());
+ r = region.get(get);
+ } else if (action.hasMutation()) {
+ MutationType type = action.getMutation().getMutateType();
+ if (type != MutationType.PUT && type != MutationType.DELETE && mutations != null &&
+ !mutations.isEmpty()) {
+ // Flush out any Puts or Deletes already collected.
+ doBatchOp(builder, region, mutations, cellScanner);
+ mutations.clear();
+ }
+ switch (type) {
+ case APPEND:
+ r = append(region, action.getMutation(), cellScanner);
+ break;
+ case INCREMENT:
+ r = increment(region, action.getMutation(), cellScanner);
+ break;
+ case PUT:
+ case DELETE:
+ // Collect the individual mutations and apply in a batch
+ if (mutations == null) {
+ mutations = new ArrayList<ClientProtos.Action>(actions.getActionCount());
}
- } catch (IOException ie) {
- builder.addResult(ResponseConverter.buildActionResult(ie));
+ mutations.add(action);
+ break;
+ default:
+ throw new DoNotRetryIOException("Unsupported mutate type: " + type.name());
}
+ } else {
+ throw new HBaseIOException("Unexpected Action type");
}
- if (!mutations.isEmpty()) {
- doBatchOp(builder, region, mutations, cellScanner);
+ if (r != null) {
+ ClientProtos.Result pbResult = null;
+ if (isClientCellBlockSupport()) {
+ pbResult = ProtobufUtil.toResultNoData(r);
+ // Hard to guess the size here. Just make a rough guess.
+ if (cellsToReturn == null) cellsToReturn = new ArrayList<CellScannable>();
+ cellsToReturn.add(r);
+ } else {
+ pbResult = ProtobufUtil.toResult(r);
+ }
+ resultOrExceptionBuilder =
+ ClientProtos.ResultOrException.newBuilder().setResult(pbResult);
}
+ // Could get to here and there was no result and no exception. Presumes we added
+ // a Put or Delete to the collecting Mutations List for adding later. In this
+ // case the corresponding ResultOrException instance for the Put or Delete will be added
+ // down in the doBatchOp method call rather than up here.
+ } catch (IOException ie) {
+ resultOrExceptionBuilder = ResultOrException.newBuilder().
+ setException(ResponseConverter.buildException(ie));
}
- // Load the controller with the Cells to return.
- if (cellsToReturn != null && !cellsToReturn.isEmpty() && controller != null) {
- controller.setCellScanner(CellUtil.createCellScanner(cellsToReturn));
+ if (resultOrExceptionBuilder != null) {
+ // Propagate index.
+ resultOrExceptionBuilder.setIndex(action.getIndex());
+ builder.addResultOrException(resultOrExceptionBuilder.build());
}
- return builder.build();
- } catch (IOException ie) {
- throw new ServiceException(ie);
}
+ // Finish up any outstanding mutations
+ if (mutations != null && !mutations.isEmpty()) {
+ doBatchOp(builder, region, mutations, cellScanner);
+ }
+ return cellsToReturn;
}
// End Client methods
@@ -3877,20 +3851,19 @@ public class HRegionServer implements Cl
try {
checkOpen();
List<WALEntry> entries = request.getEntryList();
- if(entries == null || entries.isEmpty()) {
+ if (entries == null || entries.isEmpty()) {
// empty input
return ReplicateWALEntryResponse.newBuilder().build();
}
-
HRegion region = this.getRegionByEncodedName(
entries.get(0).getKey().getEncodedRegionName().toStringUtf8());
RegionCoprocessorHost coprocessorHost = region.getCoprocessorHost();
List<Pair<HLogKey, WALEdit>> walEntries = new ArrayList<Pair<HLogKey, WALEdit>>();
List<Pair<MutationType, Mutation>> mutations = new ArrayList<Pair<MutationType, Mutation>>();
for (WALEntry entry : entries) {
- Pair<HLogKey, WALEdit> walEntry = (coprocessorHost == null) ? null :
+ Pair<HLogKey, WALEdit> walEntry = (coprocessorHost == null) ? null :
new Pair<HLogKey, WALEdit>();
- List<Pair<MutationType, Mutation>> edits = HLogSplitter.getMutationsFromWALEntry(entry,
+ List<Pair<MutationType, Mutation>> edits = HLogSplitter.getMutationsFromWALEntry(entry,
cells, walEntry);
if (coprocessorHost != null) {
// Start coprocessor replay here. The coprocessor is for each WALEdit instead of a
@@ -4062,17 +4035,17 @@ public class HRegionServer implements Cl
* @param region
* @param mutations
*/
- protected void doBatchOp(final MultiResponse.Builder builder, final HRegion region,
- final List<MutationProto> mutations, final CellScanner cells) {
+ protected void doBatchOp(final RegionActionResult.Builder builder, final HRegion region,
+ final List<ClientProtos.Action> mutations, final CellScanner cells) {
Mutation[] mArray = new Mutation[mutations.size()];
long before = EnvironmentEdgeManager.currentTimeMillis();
boolean batchContainsPuts = false, batchContainsDelete = false;
try {
- ActionResult.Builder resultBuilder = ActionResult.newBuilder();
- resultBuilder.setValue(ClientProtos.Result.newBuilder().build());
- ActionResult result = resultBuilder.build();
int i = 0;
- for (MutationProto m : mutations) {
+ for (ClientProtos.Action action: mutations) {
+ ClientProtos.ResultOrException.Builder resultOrExceptionBuilder =
+ ClientProtos.ResultOrException.newBuilder();
+ MutationProto m = action.getMutation();
Mutation mutation;
if (m.getMutateType() == MutationType.PUT) {
mutation = ProtobufUtil.toPut(m, cells);
@@ -4082,7 +4055,6 @@ public class HRegionServer implements Cl
batchContainsDelete = true;
}
mArray[i++] = mutation;
- builder.addResult(result);
}
requestCount.add(mutations.size());
@@ -4092,33 +4064,33 @@ public class HRegionServer implements Cl
OperationStatus codes[] = region.batchMutate(mArray, false);
for (i = 0; i < codes.length; i++) {
+ int index = mutations.get(i).getIndex();
+ Exception e = null;
switch (codes[i].getOperationStatusCode()) {
case BAD_FAMILY:
- result = ResponseConverter.buildActionResult(
- new NoSuchColumnFamilyException(codes[i].getExceptionMsg()));
- builder.setResult(i, result);
+ e = new NoSuchColumnFamilyException(codes[i].getExceptionMsg());
+ builder.addResultOrException(getResultOrException(e, index));
break;
case SANITY_CHECK_FAILURE:
- result = ResponseConverter.buildActionResult(
- new FailedSanityCheckException(codes[i].getExceptionMsg()));
- builder.setResult(i, result);
+ e = new FailedSanityCheckException(codes[i].getExceptionMsg());
+ builder.addResultOrException(getResultOrException(e, index));
break;
default:
- result = ResponseConverter.buildActionResult(
- new DoNotRetryIOException(codes[i].getExceptionMsg()));
- builder.setResult(i, result);
+ e = new DoNotRetryIOException(codes[i].getExceptionMsg());
+ builder.addResultOrException(getResultOrException(e, index));
break;
case SUCCESS:
+ builder.addResultOrException(getResultOrException(ClientProtos.Result.getDefaultInstance(), index));
break;
}
}
} catch (IOException ie) {
- ActionResult result = ResponseConverter.buildActionResult(ie);
+ ResultOrException resultOrException = ResponseConverter.buildActionResult(ie).build();
for (int i = 0; i < mutations.size(); i++) {
- builder.setResult(i, result);
+ builder.addResultOrException(resultOrException);
}
}
long after = EnvironmentEdgeManager.currentTimeMillis();
@@ -4129,6 +4101,18 @@ public class HRegionServer implements Cl
metricsRegionServer.updateDelete(after - before);
}
}
+ private static ResultOrException getResultOrException(final ClientProtos.Result r,
+ final int index) {
+ return getResultOrException(ResponseConverter.buildActionResult(r), index);
+ }
+ private static ResultOrException getResultOrException(final Exception e, final int index) {
+ return getResultOrException(ResponseConverter.buildActionResult(e), index);
+ }
+
+ private static ResultOrException getResultOrException(final ResultOrException.Builder builder,
+ final int index) {
+ return builder.setIndex(index).build();
+ }
/**
* Execute a list of Put/Delete mutations. The function returns OperationStatus instead of
@@ -4140,8 +4124,9 @@ public class HRegionServer implements Cl
* exceptionMessage if any
* @throws IOException
*/
- protected OperationStatus[] doBatchOp(final HRegion region,
- final List<Pair<MutationType, Mutation>> mutations, boolean isReplay) throws IOException {
+ protected OperationStatus [] doBatchOp(final HRegion region,
+ final List<Pair<MutationType, Mutation>> mutations, boolean isReplay)
+ throws IOException {
Mutation[] mArray = new Mutation[mutations.size()];
long before = EnvironmentEdgeManager.currentTimeMillis();
boolean batchContainsPuts = false, batchContainsDelete = false;
@@ -4175,32 +4160,35 @@ public class HRegionServer implements Cl
* Mutate a list of rows atomically.
*
* @param region
- * @param mutations
+ * @param actions
* @param cellScanner if non-null, the mutation data -- the Cell content.
* @throws IOException
*/
- protected void mutateRows(final HRegion region, final List<MutationProto> mutations,
+ protected void mutateRows(final HRegion region, final List<ClientProtos.Action> actions,
final CellScanner cellScanner)
throws IOException {
- MutationProto firstMutate = mutations.get(0);
if (!region.getRegionInfo().isMetaTable()) {
cacheFlusher.reclaimMemStoreMemory();
}
- byte [] row = firstMutate.getRow().toByteArray();
- RowMutations rm = new RowMutations(row);
- for (MutationProto mutate: mutations) {
- MutationType type = mutate.getMutateType();
- switch (mutate.getMutateType()) {
+ RowMutations rm = null;
+ for (ClientProtos.Action action: actions) {
+ if (action.hasGet()) {
+ throw new DoNotRetryIOException("Atomic put and/or delete only, not a Get=" +
+ action.getGet());
+ }
+ MutationType type = action.getMutation().getMutateType();
+ if (rm == null) {
+ rm = new RowMutations(action.getMutation().getRow().toByteArray());
+ }
+ switch (type) {
case PUT:
- rm.add(ProtobufUtil.toPut(mutate, cellScanner));
+ rm.add(ProtobufUtil.toPut(action.getMutation(), cellScanner));
break;
case DELETE:
- rm.add(ProtobufUtil.toDelete(mutate, cellScanner));
+ rm.add(ProtobufUtil.toDelete(action.getMutation(), cellScanner));
break;
default:
- throw new DoNotRetryIOException(
- "mutate supports atomic put and/or delete, not "
- + type.name());
+ throw new DoNotRetryIOException("Atomic put and/or delete only, not " + type.name());
}
}
region.mutateRow(rm);
@@ -4402,7 +4390,6 @@ public class HRegionServer implements Cl
/**
* Return the last failed RS name under /hbase/recovering-regions/encodedRegionName
* @param encodedRegionName
- * @throws IOException
* @throws KeeperException
*/
private String getLastFailedRSFromZK(String encodedRegionName) throws KeeperException {
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEditsReplaySink.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEditsReplaySink.java?rev=1529348&r1=1529347&r2=1529348&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEditsReplaySink.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEditsReplaySink.java Fri Oct 4 23:38:41 2013
@@ -23,8 +23,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.NavigableMap;
-import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.logging.Log;
@@ -32,35 +30,23 @@ import org.apache.commons.logging.LogFac
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.CellScanner;
-import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HRegionLocation;
-import org.apache.hadoop.hbase.client.Action;
+import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.HConnection;
import org.apache.hadoop.hbase.client.RegionServerCallable;
-import org.apache.hadoop.hbase.client.Row;
-import org.apache.hadoop.hbase.client.RpcRetryingCaller;
import org.apache.hadoop.hbase.client.RpcRetryingCallerFactory;
import org.apache.hadoop.hbase.ipc.PayloadCarryingRpcController;
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.protobuf.ReplicationProtbufUtil;
-import org.apache.hadoop.hbase.protobuf.RequestConverter;
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos;
-import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.ReplicateWALEntryResponse;
-import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos;
-import org.apache.hadoop.hbase.protobuf.generated.WALProtos;
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.AdminService;
-import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ActionResult;
-import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiRequest;
-import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiResponse;
-import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException;
+import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.ReplicateWALEntryResponse;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.Pair;
-import com.google.protobuf.ByteString;
import com.google.protobuf.ServiceException;
/**
@@ -118,7 +104,7 @@ public class WALEditsReplaySink {
HRegionLocation loc = null;
HLog.Entry entry = null;
List<HLog.Entry> regionEntries = null;
- // Build the action list.
+ // Build the action list.
for (int i = 0; i < batchSize; i++) {
loc = entries.get(i).getFirst();
entry = entries.get(i).getSecond();
@@ -130,7 +116,7 @@ public class WALEditsReplaySink {
}
regionEntries.add(entry);
}
-
+
long startTime = EnvironmentEdgeManager.currentTimeMillis();
// replaying edits by region
@@ -143,7 +129,7 @@ public class WALEditsReplaySink {
for (; replayedActions < totalActions;) {
curBatchSize = (totalActions > (MAX_BATCH_SIZE + replayedActions)) ? MAX_BATCH_SIZE
: (totalActions - replayedActions);
- replayEdits(loc, curRegion, allActions.subList(replayedActions,
+ replayEdits(loc, curRegion, allActions.subList(replayedActions,
replayedActions + curBatchSize));
replayedActions += curBatchSize;
}
@@ -185,7 +171,7 @@ public class WALEditsReplaySink {
}
}
}
-
+
/**
* Callable that handles the <code>replay</code> method call going against a single regionserver
* @param <R>
@@ -202,7 +188,7 @@ public class WALEditsReplaySink {
this.regionInfo = regionInfo;
setLocation(regionLoc);
}
-
+
@Override
public ReplicateWALEntryResponse call() throws IOException {
try {
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java?rev=1529348&r1=1529347&r2=1529348&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java Fri Oct 4 23:38:41 2013
@@ -4356,8 +4356,7 @@ public class TestFromClientSide {
d.deleteColumns(FAMILY, QUALIFIERS[0]);
arm.add(d);
// TODO: Trying mutateRow again. The batch was failing with a one try only.
- // t.mutateRow(arm);
- t.batch(Arrays.asList((Row)arm));
+ t.mutateRow(arm);
r = t.get(g);
assertEquals(0, Bytes.compareTo(VALUE, r.getValue(FAMILY, QUALIFIERS[1])));
assertNull(r.getValue(FAMILY, QUALIFIERS[0]));
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java?rev=1529348&r1=1529347&r2=1529348&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java Fri Oct 4 23:38:41 2013
@@ -43,7 +43,6 @@ import java.util.concurrent.atomic.Atomi
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
@@ -51,12 +50,12 @@ import org.apache.hadoop.hbase.HRegionIn
import org.apache.hadoop.hbase.HRegionLocation;
import org.apache.hadoop.hbase.MediumTests;
import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.Waiter;
import org.apache.hadoop.hbase.client.HConnectionManager.HConnectionImplementation;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.filter.FilterBase;
-import org.apache.hadoop.hbase.master.ClusterStatusPublisher;
import org.apache.hadoop.hbase.master.HMaster;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.regionserver.HRegionServer;
@@ -447,12 +446,12 @@ public class TestHCM {
try {
table.put(put3);
Assert.fail("Unreachable point");
- }catch (RetriesExhaustedWithDetailsException e){
+ } catch (RetriesExhaustedWithDetailsException e){
LOG.info("Put done, exception caught: " + e.getClass());
Assert.assertEquals(1, e.getNumExceptions());
Assert.assertArrayEquals(e.getRow(0).getRow(), ROW);
}
- Assert.assertNotNull(conn.getCachedLocation(TABLE_NAME, ROW));
+ Assert.assertNotNull("Cached connection is null", conn.getCachedLocation(TABLE_NAME, ROW));
Assert.assertEquals(
"Previous server was "+curServer.getServerName().getHostAndPort(),
destServerName.getPort(), conn.getCachedLocation(TABLE_NAME, ROW).getPort());
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMultiParallel.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMultiParallel.java?rev=1529348&r1=1529347&r2=1529348&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMultiParallel.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMultiParallel.java Fri Oct 4 23:38:41 2013
@@ -179,7 +179,6 @@ public class TestMultiParallel {
for (Row get : gets) {
singleRes.add(table.get((Get) get));
}
-
// Compare results
Assert.assertEquals(singleRes.size(), multiRes.length);
for (int i = 0; i < singleRes.size(); i++) {
@@ -332,16 +331,20 @@ public class TestMultiParallel {
validateSizeAndEmpty(results, KEYS.length);
if (true) {
- int liveRScount = UTIL.getMiniHBaseCluster().getLiveRegionServerThreads()
- .size();
+ int liveRScount = UTIL.getMiniHBaseCluster().getLiveRegionServerThreads().size();
assert liveRScount > 0;
- JVMClusterUtil.RegionServerThread liveRS = UTIL.getMiniHBaseCluster()
- .getLiveRegionServerThreads().get(0);
- liveRS.getRegionServer().abort("Aborting for tests",
- new Exception("testBatchWithPut"));
-
+ JVMClusterUtil.RegionServerThread liveRS =
+ UTIL.getMiniHBaseCluster().getLiveRegionServerThreads().get(0);
+ liveRS.getRegionServer().abort("Aborting for tests", new Exception("testBatchWithPut"));
puts = constructPutRequests();
- results = table.batch(puts);
+ try {
+ results = table.batch(puts);
+ } catch (RetriesExhaustedWithDetailsException ree) {
+ LOG.info(ree.getExhaustiveDescription());
+ throw ree;
+ } finally {
+ table.close();
+ }
validateSizeAndEmpty(results, KEYS.length);
}
@@ -597,6 +600,4 @@ public class TestMultiParallel {
validateEmpty(result);
}
}
-
-}
-
+}
\ No newline at end of file
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestIPC.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestIPC.java?rev=1529348&r1=1529347&r2=1529348&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestIPC.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestIPC.java Fri Oct 4 23:38:41 2013
@@ -21,12 +21,9 @@ package org.apache.hadoop.hbase.ipc;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.internal.verification.VerificationModeFactory.times;
@@ -36,12 +33,9 @@ import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
import javax.net.SocketFactory;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
@@ -64,6 +58,7 @@ import org.apache.hadoop.hbase.ipc.proto
import org.apache.hadoop.hbase.ipc.protobuf.generated.TestRpcServiceProtos;
import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler;
import org.apache.hadoop.hbase.protobuf.RequestConverter;
+import org.apache.hadoop.hbase.protobuf.generated.ClientProtos;
import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Pair;
@@ -72,11 +67,12 @@ import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.util.StringUtils;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import org.mockito.Matchers;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
import com.google.protobuf.BlockingService;
import com.google.protobuf.Descriptors.MethodDescriptor;
import com.google.protobuf.Message;
@@ -321,7 +317,7 @@ public class TestIPC {
for (int i = 0; i < cycles; i++) {
List<CellScannable> cells = new ArrayList<CellScannable>();
// Message param = RequestConverter.buildMultiRequest(HConstants.EMPTY_BYTE_ARRAY, rm);
- Message param = RequestConverter.buildNoDataMultiRequest(
+ ClientProtos.RegionAction.Builder builder = RequestConverter.buildNoDataRegionAction(
HConstants.EMPTY_BYTE_ARRAY, rm, cells);
CellScanner cellScanner = CellUtil.createCellScanner(cells);
if (i % 1000 == 0) {
@@ -331,7 +327,7 @@ public class TestIPC {
// "Thread dump " + Thread.currentThread().getName());
}
Pair<Message, CellScanner> response =
- client.call(null, param, cellScanner, null, user, address, 0);
+ client.call(null, builder.build(), cellScanner, null, user, address, 0);
/*
int count = 0;
while (p.getSecond().advance()) {
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java?rev=1529348&r1=1529347&r2=1529348&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java Fri Oct 4 23:38:41 2013
@@ -79,10 +79,7 @@ import org.apache.hadoop.hbase.protobuf.
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.BulkLoadHFileResponse;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetRequest;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetResponse;
-import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiGetRequest;
-import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiGetResponse;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiRequest;
-import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiResponse;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutateRequest;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutateResponse;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest;
@@ -346,20 +343,7 @@ ClientProtos.ClientService.BlockingInter
return builder.build();
}
- @Override
- public MultiGetResponse multiGet(RpcController controller, MultiGetRequest requests)
- throws ServiceException {
- byte[] regionName = requests.getRegion().getValue().toByteArray();
- Map<byte [], Result> m = this.gets.get(regionName);
- MultiGetResponse.Builder builder = MultiGetResponse.newBuilder();
- if (m != null) {
- for (ClientProtos.Get get: requests.getGetList()) {
- byte[] row = get.getRow().toByteArray();
- builder.addResult(ProtobufUtil.toResult(m.get(row)));
- }
- }
- return builder.build();
- }
+
@Override
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestSnapshotFromMaster.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestSnapshotFromMaster.java?rev=1529348&r1=1529347&r2=1529348&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestSnapshotFromMaster.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestSnapshotFromMaster.java Fri Oct 4 23:38:41 2013
@@ -289,6 +289,9 @@ public class TestSnapshotFromMaster {
UTIL.createTable(htd, new byte[][] { TEST_FAM }, UTIL.getConfiguration());
// load the table (creates 4 hfiles)
UTIL.loadTable(new HTable(UTIL.getConfiguration(), TABLE_NAME), TEST_FAM);
+ UTIL.flush(TABLE_NAME);
+ // Put some more data into the table so for sure we get more storefiles.
+ UTIL.loadTable(new HTable(UTIL.getConfiguration(), TABLE_NAME), TEST_FAM);
// disable the table so we can take a snapshot
admin.disableTable(TABLE_NAME);
@@ -299,7 +302,6 @@ public class TestSnapshotFromMaster {
byte[] snapshotNameBytes = Bytes.toBytes(snapshotName);
admin.snapshot(snapshotNameBytes, TABLE_NAME);
- Configuration conf = master.getConfiguration();
LOG.info("After snapshot File-System state");
FSUtils.logFileSystemState(fs, rootDir, LOG);
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionBusyWait.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionBusyWait.java?rev=1529348&r1=1529347&r2=1529348&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionBusyWait.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionBusyWait.java Fri Oct 4 23:38:41 2013
@@ -48,7 +48,7 @@ public class TestHRegionBusyWait extends
/**
* Test RegionTooBusyException thrown when region is busy
*/
- @Test (timeout=2000)
+ @Test (timeout=6000)
public void testRegionTooBusy() throws IOException {
String method = "testRegionTooBusy";
byte[] tableName = Bytes.toBytes(method);
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestQosFunction.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestQosFunction.java?rev=1529348&r1=1529347&r2=1529348&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestQosFunction.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestQosFunction.java Fri Oct 4 23:38:41 2013
@@ -20,8 +20,8 @@ import static org.junit.Assert.assertEqu
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.SmallTests;
+import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiRequest;
import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.RequestHeader;
-import org.apache.hadoop.hbase.util.Pair;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.mockito.Mockito;
@@ -43,11 +43,19 @@ public class TestQosFunction {
checkMethod("ReplicateWALEntry", HConstants.REPLICATION_QOS, qosFunction);
// Set method name in pb style with the method name capitalized.
checkMethod("OpenRegion", HConstants.HIGH_QOS, qosFunction);
+ // Check multi works.
+ checkMethod("Multi", HConstants.NORMAL_QOS, qosFunction, MultiRequest.getDefaultInstance());
}
- private void checkMethod(final String methodName, final int expected, final AnnotationReadingPriorityFunction qosf) {
+ private void checkMethod(final String methodName, final int expected,
+ final AnnotationReadingPriorityFunction qosf) {
+ checkMethod(methodName, expected, qosf, null);
+ }
+
+ private void checkMethod(final String methodName, final int expected,
+ final AnnotationReadingPriorityFunction qosf, final Message param) {
RequestHeader.Builder builder = RequestHeader.newBuilder();
builder.setMethodName(methodName);
- assertEquals(methodName, expected, qosf.getPriority(builder.build(), null));
+ assertEquals(methodName, expected, qosf.getPriority(builder.build(), param));
}
}
\ No newline at end of file
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestResourceFilter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestResourceFilter.java?rev=1529348&r1=1529347&r2=1529348&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestResourceFilter.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestResourceFilter.java Fri Oct 4 23:38:41 2013
@@ -20,7 +20,7 @@ package org.apache.hadoop.hbase.rest;
import static org.junit.Assert.assertEquals;
import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.SmallTests;
+import org.apache.hadoop.hbase.MediumTests;
import org.apache.hadoop.hbase.rest.client.Client;
import org.apache.hadoop.hbase.rest.client.Cluster;
import org.apache.hadoop.hbase.rest.client.Response;
@@ -29,7 +29,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-@Category(SmallTests.class)
+@Category(MediumTests.class)
public class TestResourceFilter {
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();