Repository: hbase Updated Branches: refs/heads/master c000f29e4 -> 0d05c7518
HBASE-16510 Reset RpcController before retry Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/0d05c751 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/0d05c751 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/0d05c751 Branch: refs/heads/master Commit: 0d05c75184557d0961aacb0a6923cf804ff2a74c Parents: c000f29 Author: zhangduo <[email protected]> Authored: Mon Aug 29 22:54:29 2016 +0800 Committer: zhangduo <[email protected]> Committed: Tue Aug 30 16:56:28 2016 +0800 ---------------------------------------------------------------------- .../hadoop/hbase/client/MasterCallable.java | 3 ++- .../client/NoncedRegionServerCallable.java | 5 ++--- .../hbase/client/RegionServerCallable.java | 22 ++++++++++---------- .../hbase/client/TestRpcControllerFactory.java | 9 ++++---- 4 files changed, 20 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/0d05c751/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MasterCallable.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MasterCallable.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MasterCallable.java index 8c4da68..e279a39 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MasterCallable.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MasterCallable.java @@ -92,6 +92,7 @@ abstract class MasterCallable<V> implements RetryingCallable<V>, Closeable { public V call(int callTimeout) throws IOException { try { if (this.rpcController != null) { + this.rpcController.reset(); this.rpcController.setCallTimeout(callTimeout); } return rpcCall(); @@ -129,7 +130,7 @@ abstract class MasterCallable<V> implements RetryingCallable<V>, Closeable { /** * @param regionName RegionName. If hbase:meta, we'll set high priority. */ - void setPriority(final byte [] regionName) { + void setPriority(final byte[] regionName) { if (isMetaRegion(regionName)) { setPriority(TableName.META_TABLE_NAME); } http://git-wip-us.apache.org/repos/asf/hbase/blob/0d05c751/hbase-client/src/main/java/org/apache/hadoop/hbase/client/NoncedRegionServerCallable.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/NoncedRegionServerCallable.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/NoncedRegionServerCallable.java index 21e77bd..8fbaa90 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/NoncedRegionServerCallable.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/NoncedRegionServerCallable.java @@ -63,9 +63,6 @@ public abstract class NoncedRegionServerCallable<T> extends AbstractRegionServer TableName tableName, byte [] row) { super(connection, tableName, row); this.rpcController = rpcController; - if (this.rpcController != null) { - this.rpcController.setPriority(tableName); - } this.nonce = getConnection().getNonceGenerator().newNonce(); } @@ -96,6 +93,8 @@ public abstract class NoncedRegionServerCallable<T> extends AbstractRegionServer @Override public T call(int callTimeout) throws IOException { if (this.rpcController != null) { + this.rpcController.reset(); + this.rpcController.setPriority(tableName); this.rpcController.setCallTimeout(callTimeout); } try { http://git-wip-us.apache.org/repos/asf/hbase/blob/0d05c751/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionServerCallable.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionServerCallable.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionServerCallable.java index 3771c50..baf99a0 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionServerCallable.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionServerCallable.java @@ -70,12 +70,6 @@ public abstract class RegionServerCallable<T> extends AbstractRegionServerCallab TableName tableName, byte [] row) { super(connection, tableName, row); this.rpcController = rpcController; - // If it is an instance of PayloadCarryingRpcController, we can set priority on the - // controller based off the tableName. RpcController may be null in tests when mocking so allow - // for null controller. - if (this.rpcController != null && this.rpcController instanceof PayloadCarryingRpcController) { - ((PayloadCarryingRpcController)this.rpcController).setPriority(tableName); - } } void setClientByServiceName(ServerName service) throws IOException { @@ -106,11 +100,17 @@ public abstract class RegionServerCallable<T> extends AbstractRegionServerCallab @Override public T call(int callTimeout) throws IOException { try { - if (this.rpcController != null && - this.rpcController instanceof PayloadCarryingRpcController) { - ((PayloadCarryingRpcController)this.rpcController).setCallTimeout(callTimeout); - // Do a reset of the CellScanner in case we are carrying any Cells since last time through. - setRpcControllerCellScanner(null); + if (this.rpcController != null) { + // Do a reset to clear previous states, such as CellScanner. + this.rpcController.reset(); + if (this.rpcController instanceof PayloadCarryingRpcController) { + PayloadCarryingRpcController pcrc = (PayloadCarryingRpcController)this.rpcController; + // If it is an instance of PayloadCarryingRpcController, we can set priority on the + // controller based off the tableName. RpcController may be null in tests when mocking so allow + // for null controller. + pcrc.setPriority(tableName); + pcrc.setCallTimeout(callTimeout); + } } return rpcCall(); } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/hbase/blob/0d05c751/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRpcControllerFactory.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRpcControllerFactory.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRpcControllerFactory.java index 34d3c91..1f093fe 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRpcControllerFactory.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRpcControllerFactory.java @@ -20,6 +20,9 @@ package org.apache.hadoop.hbase.client; import static org.apache.hadoop.hbase.HBaseTestingUtility.fam1; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import com.google.common.collect.Lists; import java.io.IOException; import java.util.List; @@ -44,8 +47,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; -import com.google.common.collect.Lists; - @Category({MediumTests.class, ClientTests.class}) public class TestRpcControllerFactory { @@ -202,9 +203,9 @@ public class TestRpcControllerFactory { } int verifyCount(Integer counter) { - assertEquals(counter.intValue(), CountingRpcController.TABLE_PRIORITY.get()); + assertTrue(CountingRpcController.TABLE_PRIORITY.get() >= counter.intValue()); assertEquals(0, CountingRpcController.INT_PRIORITY.get()); - return counter + 1; + return CountingRpcController.TABLE_PRIORITY.get() + 1; } @Test
