31
31
import java .util .concurrent .Executors ;
32
32
import java .util .concurrent .Future ;
33
33
34
- import org .apache .commons .logging .Log ;
35
- import org .apache .commons .logging .LogFactory ;
36
34
import org .apache .hadoop .conf .Configuration ;
37
35
import org .apache .hadoop .ipc .RemoteException ;
38
36
import org .apache .hadoop .ipc .StandbyException ;
39
37
40
38
import com .google .common .annotations .VisibleForTesting ;
41
39
import org .apache .hadoop .io .retry .MultiException ;
40
+ import org .slf4j .Logger ;
41
+ import org .slf4j .LoggerFactory ;
42
42
43
43
/**
44
44
* A FailoverProxyProvider implementation that technically does not "failover"
51
51
public class RequestHedgingProxyProvider <T > extends
52
52
ConfiguredFailoverProxyProvider <T > {
53
53
54
- private static final Log LOG =
55
- LogFactory . getLog (RequestHedgingProxyProvider .class );
54
+ public static final Logger LOG =
55
+ LoggerFactory . getLogger (RequestHedgingProxyProvider .class );
56
56
57
57
class RequestHedgingInvocationHandler implements InvocationHandler {
58
58
@@ -100,6 +100,8 @@ public RequestHedgingInvocationHandler(
100
100
Callable <Object > c = new Callable <Object >() {
101
101
@ Override
102
102
public Object call () throws Exception {
103
+ LOG .trace ("Invoking method {} on proxy {}" , method ,
104
+ pEntry .getValue ().proxyInfo );
103
105
return method .invoke (pEntry .getValue ().proxy , args );
104
106
}
105
107
};
@@ -114,15 +116,14 @@ public Object call() throws Exception {
114
116
try {
115
117
retVal = callResultFuture .get ();
116
118
successfulProxy = proxyMap .get (callResultFuture );
117
- if (LOG .isDebugEnabled ()) {
118
- LOG .debug ("Invocation successful on ["
119
- + successfulProxy .proxyInfo + "]" );
120
- }
119
+ LOG .debug ("Invocation successful on [{}]" ,
120
+ successfulProxy .proxyInfo );
121
121
return retVal ;
122
122
} catch (Exception ex ) {
123
123
ProxyInfo <T > tProxyInfo = proxyMap .get (callResultFuture );
124
124
logProxyException (ex , tProxyInfo .proxyInfo );
125
125
badResults .put (tProxyInfo .proxyInfo , ex );
126
+ LOG .trace ("Unsuccessful invocation on [{}]" , tProxyInfo .proxyInfo );
126
127
numAttempts --;
127
128
}
128
129
}
@@ -136,6 +137,7 @@ public Object call() throws Exception {
136
137
}
137
138
} finally {
138
139
if (executor != null ) {
140
+ LOG .trace ("Shutting down threadpool executor" );
139
141
executor .shutdownNow ();
140
142
}
141
143
}
@@ -193,12 +195,9 @@ public synchronized void performFailover(T currentProxy) {
193
195
*/
194
196
private void logProxyException (Exception ex , String proxyInfo ) {
195
197
if (isStandbyException (ex )) {
196
- if (LOG .isDebugEnabled ()) {
197
- LOG .debug ("Invocation returned standby exception on [" +
198
- proxyInfo + "]" );
199
- }
198
+ LOG .debug ("Invocation returned standby exception on [{}]" , proxyInfo );
200
199
} else {
201
- LOG .warn ("Invocation returned exception on [" + proxyInfo + "]" );
200
+ LOG .warn ("Invocation returned exception on [{}]" , proxyInfo );
202
201
}
203
202
}
204
203
0 commit comments