HADOOP-13473. Tracing in IPC Server is broken. Contributed by Daryn Sharp.
(cherry picked from commit caf800d529
)
This commit is contained in:
parent
705307eda3
commit
47293d951f
|
@ -69,7 +69,7 @@ public class ProtobufRpcEngine implements RpcEngine {
|
||||||
|
|
||||||
static { // Register the rpcRequest deserializer for WritableRpcEngine
|
static { // Register the rpcRequest deserializer for WritableRpcEngine
|
||||||
org.apache.hadoop.ipc.Server.registerProtocolEngine(
|
org.apache.hadoop.ipc.Server.registerProtocolEngine(
|
||||||
RPC.RpcKind.RPC_PROTOCOL_BUFFER, RpcWritable.Buffer.class,
|
RPC.RpcKind.RPC_PROTOCOL_BUFFER, RpcProtobufRequest.class,
|
||||||
new Server.ProtoBufRpcInvoker());
|
new Server.ProtoBufRpcInvoker());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,9 +613,8 @@ public class ProtobufRpcEngine implements RpcEngine {
|
||||||
*/
|
*/
|
||||||
public Writable call(RPC.Server server, String protocol,
|
public Writable call(RPC.Server server, String protocol,
|
||||||
Writable writableRequest, long receiveTime) throws Exception {
|
Writable writableRequest, long receiveTime) throws Exception {
|
||||||
RpcWritable.Buffer request = (RpcWritable.Buffer) writableRequest;
|
RpcProtobufRequest request = (RpcProtobufRequest) writableRequest;
|
||||||
RequestHeaderProto rpcRequest =
|
RequestHeaderProto rpcRequest = request.getRequestHeader();
|
||||||
request.getValue(RequestHeaderProto.getDefaultInstance());
|
|
||||||
String methodName = rpcRequest.getMethodName();
|
String methodName = rpcRequest.getMethodName();
|
||||||
String protoName = rpcRequest.getDeclaringClassProtocolName();
|
String protoName = rpcRequest.getDeclaringClassProtocolName();
|
||||||
long clientVersion = rpcRequest.getClientProtocolVersion();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue