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 54fbfe9..fbd9f51 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 @@ -440,7 +440,7 @@ public class HTable implements Table { connConfiguration.getRetriesNumber(), operationTimeout, connConfiguration.getPrimaryCallTimeoutMicroSecond()); - return callable.call(); + return callable.call(operationTimeout); } diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerWithReadReplicas.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerWithReadReplicas.java index 425d314..65dbb10 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerWithReadReplicas.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerWithReadReplicas.java @@ -27,6 +27,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -188,7 +189,7 @@ public class RpcRetryingCallerWithReadReplicas { * Globally, the number of retries, timeout and so on still applies, but it's per replica, * not global. We continue until all retries are done, or all timeouts are exceeded. */ - public synchronized Result call() + public Result call(int operationTimeout) throws DoNotRetryIOException, InterruptedIOException, RetriesExhaustedException { boolean isTargetReplicaSpecified = (get.getReplicaId() >= 0); @@ -221,10 +222,17 @@ public class RpcRetryingCallerWithReadReplicas { try { try { - Future f = cs.take(); - return f.get(); + long start = EnvironmentEdgeManager.currentTime(); + Future f = cs.poll(operationTimeout, TimeUnit.MILLISECONDS); + long duration = EnvironmentEdgeManager.currentTime() - start; + if (f == null) { + throw new RetriesExhaustedException("timed out after " + duration + " ms"); + } + return f.get(operationTimeout - duration, TimeUnit.MILLISECONDS); } catch (ExecutionException e) { throwEnrichedException(e, retries); + } catch (TimeoutException te) { + throw new RetriesExhaustedException("timed out after " + operationTimeout + " ms"); } } catch (CancellationException e) { throw new InterruptedIOException(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionReplicaFailover.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionReplicaFailover.java index b3b04c2..3f32b86 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionReplicaFailover.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionReplicaFailover.java @@ -67,7 +67,6 @@ import org.junit.runners.Parameterized.Parameters; @RunWith(Parameterized.class) @Category(LargeTests.class) public class TestRegionReplicaFailover { - private static final Log LOG = LogFactory.getLog(TestRegionReplicaReplicationEndpoint.class); static {