HADOOP-14732. ProtobufRpcEngine should use Time.monotonicNow to measure durations. Contributed by Hanisha Koneru.
This commit is contained in:
parent
5558792894
commit
8bef4eca28
|
@ -190,7 +190,7 @@ public class ProtobufRpcEngine implements RpcEngine {
|
||||||
throws ServiceException {
|
throws ServiceException {
|
||||||
long startTime = 0;
|
long startTime = 0;
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
startTime = Time.now();
|
startTime = Time.monotonicNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length != 2) { // RpcController + Message
|
if (args.length != 2) { // RpcController + Message
|
||||||
|
@ -245,7 +245,7 @@ public class ProtobufRpcEngine implements RpcEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
long callTime = Time.now() - startTime;
|
long callTime = Time.monotonicNow() - startTime;
|
||||||
LOG.debug("Call: " + method.getName() + " took " + callTime + "ms");
|
LOG.debug("Call: " + method.getName() + " took " + callTime + "ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,19 +373,19 @@ public class ProtobufRpcEngine implements RpcEngine {
|
||||||
this.server = currentCallInfo.get().server;
|
this.server = currentCallInfo.get().server;
|
||||||
this.call = Server.getCurCall().get();
|
this.call = Server.getCurCall().get();
|
||||||
this.methodName = currentCallInfo.get().methodName;
|
this.methodName = currentCallInfo.get().methodName;
|
||||||
this.setupTime = Time.now();
|
this.setupTime = Time.monotonicNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setResponse(Message message) {
|
public void setResponse(Message message) {
|
||||||
long processingTime = Time.now() - setupTime;
|
long processingTime = Time.monotonicNow() - setupTime;
|
||||||
call.setDeferredResponse(RpcWritable.wrap(message));
|
call.setDeferredResponse(RpcWritable.wrap(message));
|
||||||
server.updateDeferredMetrics(methodName, processingTime);
|
server.updateDeferredMetrics(methodName, processingTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void error(Throwable t) {
|
public void error(Throwable t) {
|
||||||
long processingTime = Time.now() - setupTime;
|
long processingTime = Time.monotonicNow() - setupTime;
|
||||||
String detailedMetricsName = t.getClass().getSimpleName();
|
String detailedMetricsName = t.getClass().getSimpleName();
|
||||||
server.updateDeferredMetrics(detailedMetricsName, processingTime);
|
server.updateDeferredMetrics(detailedMetricsName, processingTime);
|
||||||
call.setDeferredError(t);
|
call.setDeferredError(t);
|
||||||
|
@ -513,7 +513,7 @@ public class ProtobufRpcEngine implements RpcEngine {
|
||||||
Message param = request.getValue(prototype);
|
Message param = request.getValue(prototype);
|
||||||
|
|
||||||
Message result;
|
Message result;
|
||||||
long startTime = Time.now();
|
long startTime = Time.monotonicNow();
|
||||||
int qTime = (int) (startTime - receiveTime);
|
int qTime = (int) (startTime - receiveTime);
|
||||||
Exception exception = null;
|
Exception exception = null;
|
||||||
boolean isDeferred = false;
|
boolean isDeferred = false;
|
||||||
|
@ -537,7 +537,7 @@ public class ProtobufRpcEngine implements RpcEngine {
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
currentCallInfo.set(null);
|
currentCallInfo.set(null);
|
||||||
int processingTime = (int) (Time.now() - startTime);
|
int processingTime = (int) (Time.monotonicNow() - startTime);
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
String msg =
|
String msg =
|
||||||
"Served: " + methodName + (isDeferred ? ", deferred" : "") +
|
"Served: " + methodName + (isDeferred ? ", deferred" : "") +
|
||||||
|
|
Loading…
Reference in New Issue