You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ki...@apache.org on 2016/09/01 21:21:27 UTC
hadoop git commit: HADOOP-13473. Tracing in IPC Server is broken.
Contributed by Daryn Sharp.
Repository: hadoop
Updated Branches:
refs/heads/branch-2.8 2ff6b13e6 -> af26fba62
HADOOP-13473. Tracing in IPC Server is broken. Contributed by Daryn Sharp.
(cherry picked from commit caf800d5290d8618003b764afb0b3ef8d9a5a0a8)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/af26fba6
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/af26fba6
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/af26fba6
Branch: refs/heads/branch-2.8
Commit: af26fba62e82c32dbf96e1c00691366622cf888a
Parents: 2ff6b13
Author: Kihwal Lee <ki...@apache.org>
Authored: Tue Aug 9 14:36:26 2016 -0500
Committer: Kihwal Lee <ki...@apache.org>
Committed: Thu Sep 1 16:19:10 2016 -0500
----------------------------------------------------------------------
.../apache/hadoop/ipc/ProtobufRpcEngine.java | 36 +++++++++++++++++---
1 file changed, 32 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/af26fba6/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtobufRpcEngine.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtobufRpcEngine.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtobufRpcEngine.java
index cfdf8ab..3bec5af 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtobufRpcEngine.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtobufRpcEngine.java
@@ -69,7 +69,7 @@ public class ProtobufRpcEngine implements RpcEngine {
static { // Register the rpcRequest deserializer for WritableRpcEngine
org.apache.hadoop.ipc.Server.registerProtocolEngine(
- RPC.RpcKind.RPC_PROTOCOL_BUFFER, RpcWritable.Buffer.class,
+ RPC.RpcKind.RPC_PROTOCOL_BUFFER, RpcProtobufRequest.class,
new Server.ProtoBufRpcInvoker());
}
@@ -613,9 +613,8 @@ public class ProtobufRpcEngine implements RpcEngine {
*/
public Writable call(RPC.Server server, String protocol,
Writable writableRequest, long receiveTime) throws Exception {
- RpcWritable.Buffer request = (RpcWritable.Buffer) writableRequest;
- RequestHeaderProto rpcRequest =
- request.getValue(RequestHeaderProto.getDefaultInstance());
+ RpcProtobufRequest request = (RpcProtobufRequest) writableRequest;
+ RequestHeaderProto rpcRequest = request.getRequestHeader();
String methodName = rpcRequest.getMethodName();
String protoName = rpcRequest.getDeclaringClassProtocolName();
long clientVersion = rpcRequest.getClientProtocolVersion();
@@ -668,4 +667,33 @@ public class ProtobufRpcEngine implements RpcEngine {
}
}
}
+
+ // htrace in the ipc layer creates the span name based on toString()
+ // which uses the rpc header. in the normal case we want to defer decoding
+ // the rpc header until needed by the rpc engine.
+ static class RpcProtobufRequest extends RpcWritable.Buffer {
+ private RequestHeaderProto lazyHeader;
+
+ public RpcProtobufRequest() {
+ }
+
+ synchronized RequestHeaderProto getRequestHeader() throws IOException {
+ if (lazyHeader == null) {
+ lazyHeader = getValue(RequestHeaderProto.getDefaultInstance());
+ }
+ return lazyHeader;
+ }
+
+ // this is used by htrace to name the span.
+ @Override
+ public String toString() {
+ try {
+ RequestHeaderProto header = getRequestHeader();
+ return header.getDeclaringClassProtocolName() + "." +
+ header.getMethodName();
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org