HBASE-13286 Minimum timeout for a rpc call could be 1 ms instead of 2 seconds

This commit is contained in:
Nicolas Liochon 2015-03-20 19:09:43 +01:00
parent 34347a3639
commit 6d4460341e
1 changed files with 4 additions and 7 deletions

View File

@ -54,10 +54,7 @@ public class RpcRetryingCallerImpl<T> implements RpcRetryingCaller<T> {
* When we started making calls. * When we started making calls.
*/ */
private long globalStartTime; private long globalStartTime;
/**
* Start and end times for a single call.
*/
private final static int MIN_RPC_TIMEOUT = 2000;
/** How many retries are allowed before we start to log */ /** How many retries are allowed before we start to log */
private final int startLogErrorsCnt; private final int startLogErrorsCnt;
@ -87,11 +84,11 @@ public class RpcRetryingCallerImpl<T> implements RpcRetryingCaller<T> {
if (callTimeout == Integer.MAX_VALUE) return Integer.MAX_VALUE; if (callTimeout == Integer.MAX_VALUE) return Integer.MAX_VALUE;
int remainingTime = (int) (callTimeout - int remainingTime = (int) (callTimeout -
(EnvironmentEdgeManager.currentTime() - this.globalStartTime)); (EnvironmentEdgeManager.currentTime() - this.globalStartTime));
if (remainingTime < MIN_RPC_TIMEOUT) { if (remainingTime < 1) {
// If there is no time left, we're trying anyway. It's too late. // If there is no time left, we're trying anyway. It's too late.
// 0 means no timeout, and it's not the intent here. So we secure both cases by // 0 means no timeout, and it's not the intent here. So we secure both cases by
// resetting to the minimum. // resetting to the minimum.
remainingTime = MIN_RPC_TIMEOUT; remainingTime = 1;
} }
return remainingTime; return remainingTime;
} }
@ -222,7 +219,7 @@ public class RpcRetryingCallerImpl<T> implements RpcRetryingCaller<T> {
} }
// Don't let ServiceException out; its rpc specific. // Don't let ServiceException out; its rpc specific.
t = cause; t = cause;
// t could be a RemoteException so go aaround again. // t could be a RemoteException so go around again.
translateException(t); translateException(t);
} else if (t instanceof DoNotRetryIOException) { } else if (t instanceof DoNotRetryIOException) {
throw (DoNotRetryIOException)t; throw (DoNotRetryIOException)t;