hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From syuanji...@apache.org
Subject [06/50] [abbrv] hbase git commit: HBASE-16606 Remove some duplicate code in HTable
Date Mon, 19 Sep 2016 23:17:19 GMT
HBASE-16606 Remove some duplicate code in HTable


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

Branch: refs/heads/hbase-12439
Commit: 2c3b0f2c0b2d47dfd3a22e1f47f7eb1317d3514f
Parents: 7bda515
Author: chenheng <chenheng@apache.org>
Authored: Mon Sep 12 10:57:21 2016 +0800
Committer: chenheng <chenheng@apache.org>
Committed: Mon Sep 12 10:57:21 2016 +0800

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/client/HTable.java  | 44 +++++---------------
 1 file changed, 10 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/2c3b0f2c/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java
index 492714f..e98424c 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java
@@ -479,16 +479,18 @@ public class HTable implements Table {
   @Override
   public void batch(final List<? extends Row> actions, final Object[] results)
       throws InterruptedException, IOException {
-    AsyncRequestFuture ars = multiAp.submitAll(pool, tableName, actions, null, results);
-    ars.waitUntilDone();
-    if (ars.hasError()) {
-      throw ars.getErrors();
-    }
+    batch(actions, results, -1);
   }
 
   public void batch(final List<? extends Row> actions, final Object[] results, int
timeout)
       throws InterruptedException, IOException {
-    AsyncRequestFuture ars = multiAp.submitAll(pool, tableName, actions, null, results, null,
timeout);
+    AsyncRequestFuture ars = null;
+    if (timeout != -1) {
+      ars = multiAp.submitAll(pool, tableName, actions, null, results, null, timeout);
+    } else {
+      // use default timeout in AP
+      ars = multiAp.submitAll(pool, tableName, actions, null, results);
+    }
     ars.waitUntilDone();
     if (ars.hasError()) {
       throw ars.getErrors();
@@ -720,20 +722,7 @@ public class HTable implements Table {
       final byte [] family, final byte [] qualifier, final byte [] value,
       final Put put)
   throws IOException {
-    RegionServerCallable<Boolean> callable =
-        new RegionServerCallable<Boolean>(this.connection, this.rpcControllerFactory,
-            getName(), row) {
-      @Override
-      protected Boolean rpcCall() throws Exception {
-        MutateRequest request = RequestConverter.buildMutateRequest(
-          getLocation().getRegionInfo().getRegionName(), row, family, qualifier,
-          new BinaryComparator(value), CompareType.EQUAL, put);
-        MutateResponse response = getStub().mutate(getRpcController(), request);
-        return Boolean.valueOf(response.getProcessed());
-      }
-    };
-    return rpcCallerFactory.<Boolean> newCaller(this.writeRpcTimeout).
-        callWithRetries(callable, this.operationTimeout);
+    return checkAndPut(row, family, qualifier, CompareOp.EQUAL, value, put);
   }
 
   /**
@@ -768,20 +757,7 @@ public class HTable implements Table {
   public boolean checkAndDelete(final byte [] row, final byte [] family, final byte [] qualifier,
       final byte [] value, final Delete delete)
   throws IOException {
-    RegionServerCallable<Boolean> callable =
-        new RegionServerCallable<Boolean>(this.connection, this.rpcControllerFactory,
-            getName(), row) {
-      @Override
-      protected Boolean rpcCall() throws Exception {
-        MutateRequest request = RequestConverter.buildMutateRequest(
-          getLocation().getRegionInfo().getRegionName(), row, family, qualifier,
-          new BinaryComparator(value), CompareType.EQUAL, delete);
-        MutateResponse response = getStub().mutate(getRpcController(), request);
-        return Boolean.valueOf(response.getProcessed());
-      }
-    };
-    return rpcCallerFactory.<Boolean> newCaller(this.writeRpcTimeout).
-        callWithRetries(callable, this.operationTimeout);
+    return checkAndDelete(row, family, qualifier, CompareOp.EQUAL, value, delete);
   }
 
   /**


Mime
View raw message