From 7d8e9d696049f4a7d6bdf1e78965e14a5c65263f Mon Sep 17 00:00:00 2001 From: Sanjay Radia Date: Wed, 21 Sep 2011 04:25:55 +0000 Subject: [PATCH] HADOOP-7524 Change RPC to allow multiple protocols including multuple versions of the same protocol (sanjay Radia) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1173488 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 ++ .../org/apache/hadoop/hdfs/server/datanode/DataNode.java | 8 ++++++-- .../hadoop/hdfs/server/namenode/NameNodeRpcServer.java | 9 ++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index a44d09ec32..f56807302c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -38,6 +38,8 @@ Trunk (unreleased changes) not use ArrayWritable for writing non-array items. (Uma Maheswara Rao G via szetszwo) + HDFS-2351 Change Namenode and Datanode to register each of their protocols seperately (Sanjay Radia) + BUG FIXES HDFS-2287. TestParallelRead has a small off-by-one bug. (todd) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java index 73fbe50e53..b6ec0c05b4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java @@ -425,7 +425,7 @@ void refreshNamenodes(Configuration conf) private List plugins; // For InterDataNodeProtocol - public Server ipcServer; + public RPC.Server ipcServer; private SecureResources secureResources = null; private AbstractList dataDirs; @@ -575,11 +575,15 @@ private void startPlugins(Configuration conf) { private void initIpcServer(Configuration conf) throws IOException { InetSocketAddress ipcAddr = NetUtils.createSocketAddr( conf.get("dfs.datanode.ipc.address")); - ipcServer = RPC.getServer(DataNode.class, this, ipcAddr.getHostName(), + + // Add all the RPC protocols that the Datanode implements + ipcServer = RPC.getServer(ClientDatanodeProtocol.class, this, ipcAddr.getHostName(), ipcAddr.getPort(), conf.getInt(DFS_DATANODE_HANDLER_COUNT_KEY, DFS_DATANODE_HANDLER_COUNT_DEFAULT), false, conf, blockPoolTokenSecretManager); + ipcServer.addProtocol(InterDatanodeProtocol.class, this); + // set service-level authorization security policy if (conf.getBoolean( CommonConfigurationKeys.HADOOP_SECURITY_AUTHORIZATION, false)) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java index a461c5bd7d..92924279ef 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java @@ -142,10 +142,17 @@ public NameNodeRpcServer(Configuration conf, NameNode nn) serviceRpcServer = null; serviceRPCAddress = null; } - this.server = RPC.getServer(NamenodeProtocols.class, this, + // Add all the RPC protocols that the namenode implements + this.server = RPC.getServer(ClientProtocol.class, this, socAddr.getHostName(), socAddr.getPort(), handlerCount, false, conf, namesystem.getDelegationTokenSecretManager()); + this.server.addProtocol(DatanodeProtocol.class, this); + this.server.addProtocol(NamenodeProtocol.class, this); + this.server.addProtocol(RefreshAuthorizationPolicyProtocol.class, this); + this.server.addProtocol(RefreshUserMappingsProtocol.class, this); + this.server.addProtocol(GetUserMappingsProtocol.class, this); + // set service-level authorization security policy if (serviceAuthEnabled =