1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.client;
20
21 import java.lang.reflect.Constructor;
22
23 import org.apache.commons.logging.Log;
24 import org.apache.commons.logging.LogFactory;
25 import org.apache.hadoop.conf.Configuration;
26 import org.apache.hadoop.hbase.HConstants;
27 import org.apache.hadoop.hbase.classification.InterfaceAudience;
28
29
30
31
32
33
34
35
36 @InterfaceAudience.Private
37 class RetryingCallerInterceptorFactory {
38 private static final Log LOG = LogFactory
39 .getLog(RetryingCallerInterceptorFactory.class);
40 private Configuration conf;
41 private final boolean failFast;
42 public static final RetryingCallerInterceptor NO_OP_INTERCEPTOR =
43 new NoOpRetryableCallerInterceptor(null);
44
45 public RetryingCallerInterceptorFactory(Configuration conf) {
46 this.conf = conf;
47 failFast = conf.getBoolean(HConstants.HBASE_CLIENT_FAST_FAIL_MODE_ENABLED,
48 HConstants.HBASE_CLIENT_ENABLE_FAST_FAIL_MODE_DEFAULT);
49 }
50
51
52
53
54
55
56
57
58
59
60
61
62 public RetryingCallerInterceptor build() {
63 RetryingCallerInterceptor ret = NO_OP_INTERCEPTOR;
64 if (failFast) {
65 try {
66 Class<?> c = conf.getClass(
67 HConstants.HBASE_CLIENT_FAST_FAIL_INTERCEPTOR_IMPL,
68 PreemptiveFastFailInterceptor.class);
69 Constructor<?> constructor = c
70 .getDeclaredConstructor(Configuration.class);
71 constructor.setAccessible(true);
72 ret = (RetryingCallerInterceptor) constructor.newInstance(conf);
73 } catch (Exception e) {
74 ret = new PreemptiveFastFailInterceptor(conf);
75 }
76 }
77 LOG.trace("Using " + ret.toString() + " for intercepting the RpcRetryingCaller");
78 return ret;
79 }
80 }