From 266a0f1de9811d031c6f56ff32185d65c5a9aaa0 Mon Sep 17 00:00:00 2001 From: Sanjay Radia Date: Wed, 23 May 2012 21:16:39 +0000 Subject: [PATCH] HADOOP-8367 Improve documentation of declaringClassProtocolName in rpc headers (Sanjay Radia) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1342051 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop-common/CHANGES.txt | 3 ++ .../apache/hadoop/ipc/ProtobufRpcEngine.java | 34 +++++++++++++++---- .../src/main/proto/hadoop_rpc.proto | 16 ++++++++- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index d4c003074e..057f97fa6f 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -70,6 +70,9 @@ Trunk (unreleased changes) HADOOP-8360. empty-configuration.xml fails xml validation (Radim Kolar via harsh) + HADOOP-8367 Improve documentation of declaringClassProtocolName in rpc headers + (Sanjay Radia) + BUG FIXES HADOOP-8177. MBeans shouldn't try to register when it fails to create MBeanName. 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 2d3f91e5e4..1338419a17 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 @@ -396,24 +396,44 @@ private static ProtoClassProtoImpl getProtocolImpl(RPC.Server server, * it is. * */ - public Writable call(RPC.Server server, String protocol, + public Writable call(RPC.Server server, String connectionProtocolName, Writable writableRequest, long receiveTime) throws Exception { RpcRequestWritable request = (RpcRequestWritable) writableRequest; HadoopRpcRequestProto rpcRequest = request.message; String methodName = rpcRequest.getMethodName(); - String protoName = rpcRequest.getDeclaringClassProtocolName(); + + + /** + * RPCs for a particular interface (ie protocol) are done using a + * IPC connection that is setup using rpcProxy. + * The rpcProxy's has a declared protocol name that is + * sent form client to server at connection time. + * + * Each Rpc call also sends a protocol name + * (called declaringClassprotocolName). This name is usually the same + * as the connection protocol name except in some cases. + * For example metaProtocols such ProtocolInfoProto which get info + * about the protocol reuse the connection but need to indicate that + * the actual protocol is different (i.e. the protocol is + * ProtocolInfoProto) since they reuse the connection; in this case + * the declaringClassProtocolName field is set to the ProtocolInfoProto. + */ + + String declaringClassProtoName = + rpcRequest.getDeclaringClassProtocolName(); long clientVersion = rpcRequest.getClientProtocolVersion(); if (server.verbose) - LOG.info("Call: protocol=" + protocol + ", method=" + methodName); + LOG.info("Call: connectionProtocolName=" + connectionProtocolName + + ", method=" + methodName); - ProtoClassProtoImpl protocolImpl = getProtocolImpl(server, protoName, - clientVersion); + ProtoClassProtoImpl protocolImpl = getProtocolImpl(server, + declaringClassProtoName, clientVersion); BlockingService service = (BlockingService) protocolImpl.protocolImpl; MethodDescriptor methodDescriptor = service.getDescriptorForType() .findMethodByName(methodName); if (methodDescriptor == null) { - String msg = "Unknown method " + methodName + " called on " + protocol - + " protocol."; + String msg = "Unknown method " + methodName + " called on " + + connectionProtocolName + " protocol."; LOG.warn(msg); throw new RpcServerException(msg); } diff --git a/hadoop-common-project/hadoop-common/src/main/proto/hadoop_rpc.proto b/hadoop-common-project/hadoop-common/src/main/proto/hadoop_rpc.proto index 41d075cb73..d694e228c0 100644 --- a/hadoop-common-project/hadoop-common/src/main/proto/hadoop_rpc.proto +++ b/hadoop-common-project/hadoop-common/src/main/proto/hadoop_rpc.proto @@ -38,7 +38,21 @@ message HadoopRpcRequestProto { /** Bytes corresponding to the client protobuf request */ optional bytes request = 2; - /** protocol name of class declaring the called method */ + /** + * RPCs for a particular interface (ie protocol) are done using a + * IPC connection that is setup using rpcProxy. + * The rpcProxy's has a declared protocol name that is + * sent form client to server at connection time. + * + * Each Rpc call also sends a protocol name + * (called declaringClassprotocolName). This name is usually the same + * as the connection protocol name except in some cases. + * For example metaProtocols such ProtocolInfoProto which get metainfo + * about the protocol reuse the connection but need to indicate that + * the actual protocol is different (i.e. the protocol is + * ProtocolInfoProto) since they reuse the connection; in this case + * the declaringClassProtocolName field is set to the ProtocolInfoProto + */ required string declaringClassProtocolName = 3; /** protocol version of class declaring the called method */