hbase git commit: HBASE-19096 Add RowMutions batch support in AsyncTable

2017-11-28 Thread jerryjch
Repository: hbase
Updated Branches:
  refs/heads/branch-2 8688da9e9 -> 0c4c39553


HBASE-19096 Add RowMutions batch support in AsyncTable

Signed-off-by: Jerry He 


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/0c4c3955
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/0c4c3955
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/0c4c3955

Branch: refs/heads/branch-2
Commit: 0c4c3955380e1927311a8f4b092e23532d2e795f
Parents: 8688da9
Author: Jerry He 
Authored: Tue Nov 28 18:41:23 2017 -0800
Committer: Jerry He 
Committed: Tue Nov 28 18:49:08 2017 -0800

--
 .../client/AsyncBatchRpcRetryingCaller.java |  36 +++--
 .../apache/hadoop/hbase/client/AsyncTable.java  |  12 +-
 .../hbase/client/MultiServerCallable.java   |  62 +++--
 .../hbase/shaded/protobuf/RequestConverter.java | 136 +++
 .../hbase/client/TestAsyncTableBatch.java   |  19 ++-
 5 files changed, 161 insertions(+), 104 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hbase/blob/0c4c3955/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBatchRpcRetryingCaller.java
--
diff --git 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBatchRpcRetryingCaller.java
 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBatchRpcRetryingCaller.java
index 2ae68c4..52eb821 100644
--- 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBatchRpcRetryingCaller.java
+++ 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBatchRpcRetryingCaller.java
@@ -29,6 +29,7 @@ import 
org.apache.hadoop.hbase.shaded.io.netty.util.HashedWheelTimer;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.IdentityHashMap;
 import java.util.List;
 import java.util.Map;
@@ -58,7 +59,6 @@ import 
org.apache.hadoop.hbase.shaded.protobuf.RequestConverter;
 import org.apache.hadoop.hbase.shaded.protobuf.ResponseConverter;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
 import 
org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService;
-import 
org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 
@@ -232,27 +232,19 @@ class AsyncBatchRpcRetryingCaller {
   }
 
   private ClientProtos.MultiRequest buildReq(Map 
actionsByRegion,
-  List cells) throws IOException {
+  List cells, Map rowMutationsIndexMap) 
throws IOException {
 ClientProtos.MultiRequest.Builder multiRequestBuilder = 
ClientProtos.MultiRequest.newBuilder();
 ClientProtos.RegionAction.Builder regionActionBuilder = 
ClientProtos.RegionAction.newBuilder();
 ClientProtos.Action.Builder actionBuilder = 
ClientProtos.Action.newBuilder();
 ClientProtos.MutationProto.Builder mutationBuilder = 
ClientProtos.MutationProto.newBuilder();
 for (Map.Entry entry : actionsByRegion.entrySet()) {
-  // TODO: remove the extra for loop as we will iterate it in 
mutationBuilder.
-  if (!multiRequestBuilder.hasNonceGroup()) {
-for (Action action : entry.getValue().actions) {
-  if (action.hasNonce()) {
-
multiRequestBuilder.setNonceGroup(conn.getNonceGenerator().getNonceGroup());
-break;
-  }
-}
-  }
-  regionActionBuilder.clear();
-  regionActionBuilder.setRegion(
-RequestConverter.buildRegionSpecifier(RegionSpecifierType.REGION_NAME, 
entry.getKey()));
-  regionActionBuilder = 
RequestConverter.buildNoDataRegionAction(entry.getKey(),
-entry.getValue().actions, cells, regionActionBuilder, actionBuilder, 
mutationBuilder);
-  multiRequestBuilder.addRegionAction(regionActionBuilder.build());
+  long nonceGroup = conn.getNonceGenerator().getNonceGroup();
+  // multiRequestBuilder will be populated with region actions.
+  // rowMutationsIndexMap will be non-empty after the call if there is 
RowMutations in the
+  // action list.
+  RequestConverter.buildNoDataRegionActions(entry.getKey(),
+entry.getValue().actions, cells, multiRequestBuilder, 
regionActionBuilder, actionBuilder,
+mutationBuilder, nonceGroup, rowMutationsIndexMap);
 }
 return multiRequestBuilder.build();
   }
@@ -337,8 +329,12 @@ class AsyncBatchRpcRetryingCaller {
   }
   ClientProtos.MultiRequest req;
   List cells = new ArrayList<>();
+  // Map from a created RegionAction to the original index for a 
RowMutations within
+  // the original list of actions. This will be used to process the 
results when there
+  // is RowMutations in t

hbase git commit: HBASE-19096 Add RowMutions batch support in AsyncTable

2017-11-28 Thread jerryjch
Repository: hbase
Updated Branches:
  refs/heads/master 93b91e2cc -> e67a3699c


HBASE-19096 Add RowMutions batch support in AsyncTable

Signed-off-by: Jerry He 


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/e67a3699
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/e67a3699
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/e67a3699

Branch: refs/heads/master
Commit: e67a3699c463a9f222e5d1319d35994fea2a153d
Parents: 93b91e2
Author: Jerry He 
Authored: Tue Nov 28 18:41:23 2017 -0800
Committer: Jerry He 
Committed: Tue Nov 28 18:42:17 2017 -0800

--
 .../client/AsyncBatchRpcRetryingCaller.java |  36 +++--
 .../apache/hadoop/hbase/client/AsyncTable.java  |  12 +-
 .../hbase/client/MultiServerCallable.java   |  62 +++--
 .../hbase/shaded/protobuf/RequestConverter.java | 136 +++
 .../hbase/client/TestAsyncTableBatch.java   |  19 ++-
 5 files changed, 161 insertions(+), 104 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hbase/blob/e67a3699/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBatchRpcRetryingCaller.java
--
diff --git 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBatchRpcRetryingCaller.java
 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBatchRpcRetryingCaller.java
index 2ae68c4..52eb821 100644
--- 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBatchRpcRetryingCaller.java
+++ 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBatchRpcRetryingCaller.java
@@ -29,6 +29,7 @@ import 
org.apache.hadoop.hbase.shaded.io.netty.util.HashedWheelTimer;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.IdentityHashMap;
 import java.util.List;
 import java.util.Map;
@@ -58,7 +59,6 @@ import 
org.apache.hadoop.hbase.shaded.protobuf.RequestConverter;
 import org.apache.hadoop.hbase.shaded.protobuf.ResponseConverter;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
 import 
org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService;
-import 
org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 
@@ -232,27 +232,19 @@ class AsyncBatchRpcRetryingCaller {
   }
 
   private ClientProtos.MultiRequest buildReq(Map 
actionsByRegion,
-  List cells) throws IOException {
+  List cells, Map rowMutationsIndexMap) 
throws IOException {
 ClientProtos.MultiRequest.Builder multiRequestBuilder = 
ClientProtos.MultiRequest.newBuilder();
 ClientProtos.RegionAction.Builder regionActionBuilder = 
ClientProtos.RegionAction.newBuilder();
 ClientProtos.Action.Builder actionBuilder = 
ClientProtos.Action.newBuilder();
 ClientProtos.MutationProto.Builder mutationBuilder = 
ClientProtos.MutationProto.newBuilder();
 for (Map.Entry entry : actionsByRegion.entrySet()) {
-  // TODO: remove the extra for loop as we will iterate it in 
mutationBuilder.
-  if (!multiRequestBuilder.hasNonceGroup()) {
-for (Action action : entry.getValue().actions) {
-  if (action.hasNonce()) {
-
multiRequestBuilder.setNonceGroup(conn.getNonceGenerator().getNonceGroup());
-break;
-  }
-}
-  }
-  regionActionBuilder.clear();
-  regionActionBuilder.setRegion(
-RequestConverter.buildRegionSpecifier(RegionSpecifierType.REGION_NAME, 
entry.getKey()));
-  regionActionBuilder = 
RequestConverter.buildNoDataRegionAction(entry.getKey(),
-entry.getValue().actions, cells, regionActionBuilder, actionBuilder, 
mutationBuilder);
-  multiRequestBuilder.addRegionAction(regionActionBuilder.build());
+  long nonceGroup = conn.getNonceGenerator().getNonceGroup();
+  // multiRequestBuilder will be populated with region actions.
+  // rowMutationsIndexMap will be non-empty after the call if there is 
RowMutations in the
+  // action list.
+  RequestConverter.buildNoDataRegionActions(entry.getKey(),
+entry.getValue().actions, cells, multiRequestBuilder, 
regionActionBuilder, actionBuilder,
+mutationBuilder, nonceGroup, rowMutationsIndexMap);
 }
 return multiRequestBuilder.build();
   }
@@ -337,8 +329,12 @@ class AsyncBatchRpcRetryingCaller {
   }
   ClientProtos.MultiRequest req;
   List cells = new ArrayList<>();
+  // Map from a created RegionAction to the original index for a 
RowMutations within
+  // the original list of actions. This will be used to process the 
results when there
+  // is RowMutations in the a