HBASE-9990 HTable uses the conf for each call creation
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1572522 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3600a9a973
commit
4bc7fe0d67
|
@ -29,7 +29,6 @@ import java.util.List;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
|
||||||
import org.apache.hadoop.hbase.DoNotRetryIOException;
|
import org.apache.hadoop.hbase.DoNotRetryIOException;
|
||||||
import org.apache.hadoop.hbase.HConstants;
|
import org.apache.hadoop.hbase.HConstants;
|
||||||
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
|
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
|
||||||
|
@ -62,12 +61,9 @@ public class RpcRetryingCaller<T> {
|
||||||
private final long pause;
|
private final long pause;
|
||||||
private final int retries;
|
private final int retries;
|
||||||
|
|
||||||
public RpcRetryingCaller(Configuration conf) {
|
public RpcRetryingCaller(long pause, int retries) {
|
||||||
this.pause = conf.getLong(HConstants.HBASE_CLIENT_PAUSE,
|
this.pause = pause;
|
||||||
HConstants.DEFAULT_HBASE_CLIENT_PAUSE);
|
this.retries = retries;
|
||||||
this.retries =
|
|
||||||
conf.getInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER,
|
|
||||||
HConstants.DEFAULT_HBASE_CLIENT_RETRIES_NUMBER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getRemainingTime(int callTimeout) {
|
private int getRemainingTime(int callTimeout) {
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.hadoop.hbase.client;
|
package org.apache.hadoop.hbase.client;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.hadoop.hbase.HConstants;
|
||||||
import org.apache.hadoop.hbase.util.ReflectionUtils;
|
import org.apache.hadoop.hbase.util.ReflectionUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,13 +29,21 @@ public class RpcRetryingCallerFactory {
|
||||||
/** Configuration key for a custom {@link RpcRetryingCaller} */
|
/** Configuration key for a custom {@link RpcRetryingCaller} */
|
||||||
public static final String CUSTOM_CALLER_CONF_KEY = "hbase.rpc.callerfactory.class";
|
public static final String CUSTOM_CALLER_CONF_KEY = "hbase.rpc.callerfactory.class";
|
||||||
protected final Configuration conf;
|
protected final Configuration conf;
|
||||||
|
private final long pause;
|
||||||
|
private final int retries;
|
||||||
|
|
||||||
public RpcRetryingCallerFactory(Configuration conf) {
|
public RpcRetryingCallerFactory(Configuration conf) {
|
||||||
this.conf = conf;
|
this.conf = conf;
|
||||||
|
pause = conf.getLong(HConstants.HBASE_CLIENT_PAUSE,
|
||||||
|
HConstants.DEFAULT_HBASE_CLIENT_PAUSE);
|
||||||
|
retries = conf.getInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER,
|
||||||
|
HConstants.DEFAULT_HBASE_CLIENT_RETRIES_NUMBER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> RpcRetryingCaller<T> newCaller() {
|
public <T> RpcRetryingCaller<T> newCaller() {
|
||||||
return new RpcRetryingCaller<T>(conf);
|
// We store the values in the factory instance. This way, constructing new objects
|
||||||
|
// is cheap as it does not require parsing a complex structure.
|
||||||
|
return new RpcRetryingCaller<T>(pause, retries);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RpcRetryingCallerFactory instantiate(Configuration configuration) {
|
public static RpcRetryingCallerFactory instantiate(Configuration configuration) {
|
||||||
|
|
|
@ -147,7 +147,7 @@ public class TestAsyncProcess {
|
||||||
protected RpcRetryingCaller<MultiResponse> createCaller(MultiServerCallable<Row> callable) {
|
protected RpcRetryingCaller<MultiResponse> createCaller(MultiServerCallable<Row> callable) {
|
||||||
final MultiResponse mr = createMultiResponse(
|
final MultiResponse mr = createMultiResponse(
|
||||||
callable.getMulti(), nbMultiResponse, nbActions);
|
callable.getMulti(), nbMultiResponse, nbActions);
|
||||||
return new RpcRetryingCaller<MultiResponse>(conf) {
|
return new RpcRetryingCaller<MultiResponse>(100, 10) {
|
||||||
@Override
|
@Override
|
||||||
public MultiResponse callWithoutRetries(RetryingCallable<MultiResponse> callable,
|
public MultiResponse callWithoutRetries(RetryingCallable<MultiResponse> callable,
|
||||||
int callTimeout)
|
int callTimeout)
|
||||||
|
|
Loading…
Reference in New Issue