1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.client;
19
20 import org.apache.commons.lang.mutable.MutableBoolean;
21 import org.apache.hadoop.hbase.ServerName;
22 import org.apache.hadoop.hbase.classification.InterfaceAudience;
23
24 @InterfaceAudience.Private
25 class FastFailInterceptorContext extends
26 RetryingCallerInterceptorContext {
27
28
29
30 private MutableBoolean couldNotCommunicateWithServer = new MutableBoolean(
31 false);
32
33
34 private boolean didTry = false;
35
36
37
38 private FailureInfo fInfo = null;
39
40
41
42
43
44 private boolean retryDespiteFastFailMode = false;
45
46
47 private ServerName server;
48
49
50 private int tries;
51
52 public MutableBoolean getCouldNotCommunicateWithServer() {
53 return couldNotCommunicateWithServer;
54 }
55
56 public FailureInfo getFailureInfo() {
57 return fInfo;
58 }
59
60 public ServerName getServer() {
61 return server;
62 }
63
64 public int getTries() {
65 return tries;
66 }
67
68 public boolean didTry() {
69 return didTry;
70 }
71
72 public boolean isRetryDespiteFastFailMode() {
73 return retryDespiteFastFailMode;
74 }
75
76 public void setCouldNotCommunicateWithServer(
77 MutableBoolean couldNotCommunicateWithServer) {
78 this.couldNotCommunicateWithServer = couldNotCommunicateWithServer;
79 }
80
81 public void setDidTry(boolean didTry) {
82 this.didTry = didTry;
83 }
84
85 public void setFailureInfo(FailureInfo fInfo) {
86 this.fInfo = fInfo;
87 }
88
89 public void setRetryDespiteFastFailMode(boolean retryDespiteFastFailMode) {
90 this.retryDespiteFastFailMode = retryDespiteFastFailMode;
91 }
92
93 public void setServer(ServerName server) {
94 this.server = server;
95 }
96
97 public void setTries(int tries) {
98 this.tries = tries;
99 }
100
101 public void clear() {
102 server = null;
103 fInfo = null;
104 didTry = false;
105 couldNotCommunicateWithServer.setValue(false);
106 retryDespiteFastFailMode = false;
107 tries = 0;
108 }
109
110 public FastFailInterceptorContext prepare(RetryingCallable<?> callable) {
111 return prepare(callable, 0);
112 }
113
114 public FastFailInterceptorContext prepare(RetryingCallable<?> callable,
115 int tries) {
116 if (callable instanceof RegionServerCallable) {
117 RegionServerCallable<?> retryingCallable = (RegionServerCallable<?>) callable;
118 server = retryingCallable.getLocation().getServerName();
119 }
120 this.tries = tries;
121 return this;
122 }
123 }