19
19
package org .apache .accumulo .core .fate ;
20
20
21
21
import static com .google .common .util .concurrent .Uninterruptibles .sleepUninterruptibly ;
22
+ import static java .util .concurrent .TimeUnit .MILLISECONDS ;
22
23
import static java .util .concurrent .TimeUnit .MINUTES ;
23
24
import static java .util .concurrent .TimeUnit .SECONDS ;
24
25
import static org .apache .accumulo .core .fate .ReadOnlyTStore .TStatus .FAILED ;
45
46
import org .apache .accumulo .core .fate .ReadOnlyTStore .TStatus ;
46
47
import org .apache .accumulo .core .logging .FateLogger ;
47
48
import org .apache .accumulo .core .util .ShutdownUtil ;
49
+ import org .apache .accumulo .core .util .Timer ;
48
50
import org .apache .accumulo .core .util .UtilWaitThread ;
49
51
import org .apache .accumulo .core .util .threads .ThreadPools ;
50
52
import org .apache .thrift .TApplicationException ;
@@ -88,7 +90,7 @@ public void run() {
88
90
} else {
89
91
Repo <T > prevOp = null ;
90
92
try {
91
- deferTime = op . isReady (tid , environment );
93
+ deferTime = executeIsReady (tid , op );
92
94
93
95
// Here, deferTime is only used to determine success (zero) or failure (non-zero),
94
96
// proceeding on success and returning to the while loop on failure.
@@ -98,7 +100,7 @@ public void run() {
98
100
if (status == SUBMITTED ) {
99
101
store .setStatus (tid , IN_PROGRESS );
100
102
}
101
- op = op . call (tid , environment );
103
+ op = executeCall (tid , op );
102
104
} else {
103
105
continue ;
104
106
}
@@ -219,11 +221,24 @@ private void undo(long tid, Repo<T> op) {
219
221
}
220
222
221
223
protected long executeIsReady (Long tid , Repo <T > op ) throws Exception {
222
- return op .isReady (tid , environment );
224
+ var startTime = Timer .startNew ();
225
+ var deferTime = op .isReady (tid , environment );
226
+ if (log .isTraceEnabled ()) {
227
+ log .trace ("Running {}.isReady() {} took {} ms and returned {}" , op .getName (),
228
+ FateTxId .formatTid (tid ), startTime .elapsed (MILLISECONDS ), deferTime );
229
+ }
230
+ return deferTime ;
223
231
}
224
232
225
233
protected Repo <T > executeCall (Long tid , Repo <T > op ) throws Exception {
226
- return op .call (tid , environment );
234
+ var startTime = Timer .startNew ();
235
+ var next = op .call (tid , environment );
236
+ if (log .isTraceEnabled ()) {
237
+ log .trace ("Running {}.call() {} took {} ms and returned {}" , op .getName (),
238
+ FateTxId .formatTid (tid ), startTime .elapsed (MILLISECONDS ),
239
+ next == null ? "null" : next .getName ());
240
+ }
241
+ return next ;
227
242
}
228
243
229
244
/**
0 commit comments