Skip to content

Commit 4900b0d

Browse files
committed
make start run timestamp as call's field.
1 parent d425138 commit 4900b0d

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtobufRpcEngine2.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,11 @@ static class ProtobufRpcEngineCallbackImpl
426426
private final RPC.Server server;
427427
private final Call call;
428428
private final String methodName;
429-
private final long callStartNanos;
430429

431430
ProtobufRpcEngineCallbackImpl() {
432431
this.server = CURRENT_CALL_INFO.get().getServer();
433432
this.call = Server.getCurCall().get();
434433
this.methodName = CURRENT_CALL_INFO.get().getMethodName();
435-
this.callStartNanos = Server.getCurCallStartnanos().get();
436434
}
437435

438436
private void updateProcessingDetails(Call rpcCall, long deltaNanos) {
@@ -446,15 +444,15 @@ private void updateProcessingDetails(Call rpcCall, long deltaNanos) {
446444

447445
@Override
448446
public void setResponse(Message message) {
449-
long deltaNanos = Time.monotonicNowNanos() - callStartNanos;
447+
long deltaNanos = Time.monotonicNowNanos() - call.getStartHandleTimestampNanos();
450448
updateProcessingDetails(call, deltaNanos);
451449
call.setDeferredResponse(RpcWritable.wrap(message));
452450
server.updateDeferredMetrics(call, methodName, deltaNanos);
453451
}
454452

455453
@Override
456454
public void error(Throwable t) {
457-
long deltaNanos = Time.monotonicNowNanos() - callStartNanos;
455+
long deltaNanos = Time.monotonicNowNanos() - call.getStartHandleTimestampNanos();
458456
updateProcessingDetails(call, deltaNanos);
459457
call.setDeferredError(t);
460458
String detailedMetricsName = t.getClass().getSimpleName();

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,7 @@ public static class Call implements Schedulable,
10021002
final int callId; // the client's call id
10031003
final int retryCount; // the retry count of the call
10041004
private final long timestampNanos; // time the call was received
1005+
protected long startHandleTimestampNanos; // time the call was run
10051006
long responseTimestampNanos; // time the call was served
10061007
private AtomicInteger responseWaitCount = new AtomicInteger(1);
10071008
final RPC.RpcKind rpcKind;
@@ -1206,6 +1207,15 @@ public void setDeferredError(Throwable t) {
12061207
public long getTimestampNanos() {
12071208
return timestampNanos;
12081209
}
1210+
1211+
1212+
public long getStartHandleTimestampNanos() {
1213+
return startHandleTimestampNanos;
1214+
}
1215+
1216+
public void setStartHandleTimestampNanos(long startHandleTimestampNanos) {
1217+
this.startHandleTimestampNanos = startHandleTimestampNanos;
1218+
}
12091219
}
12101220

12111221
/** A RPC extended call queued for handling. */
@@ -1282,7 +1292,7 @@ public Void run() throws Exception {
12821292
}
12831293

12841294
long startNanos = Time.monotonicNowNanos();
1285-
CUR_CALL_STARTNANOS.set(startNanos);
1295+
this.setStartHandleTimestampNanos(startNanos);
12861296
Writable value = null;
12871297
ResponseParams responseParams = new ResponseParams();
12881298

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestProtoBufRpcServerHandoff.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void setUp() throws IOException {
7676
long serverStartTime = System.currentTimeMillis();
7777
LOG.info("Server started at: " + address + " at time: " + serverStartTime);
7878
}
79-
79+
8080
@Test(timeout = 20000)
8181
public void test() throws Exception {
8282
final TestProtoBufRpcServerHandoffProtocol client = RPC.getProxy(

0 commit comments

Comments
 (0)