From de5dd8ad896b3ad451bdde41e9717b2425cbede2 Mon Sep 17 00:00:00 2001 From: Tsz-wo Sze Date: Mon, 16 Jan 2012 04:54:16 +0000 Subject: [PATCH] svn merge -c 1229877 from trunk for HDFS-2739. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23-PB@1231837 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 + ...amenodeProtocolServerSideTranslatorPB.java | 2 +- .../NamenodeProtocolTranslatorPB.java | 45 +++---------------- .../hdfs/server/namenode/BackupNode.java | 9 ++-- .../server/namenode/SecondaryNameNode.java | 8 +--- .../src/main/proto/NamenodeProtocol.proto | 2 +- 6 files changed, 15 insertions(+), 53 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 508ce7ea6e5..524a8b64840 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -102,6 +102,8 @@ Release 0.23-PB - Unreleased HDFS-2700. Fix failing TestDataNodeMultipleRegistrations in trunk (Uma Maheswara Rao G via todd) + HDFS-2739. SecondaryNameNode doesn't start up. (jitendra) + Release 0.23.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/NamenodeProtocolServerSideTranslatorPB.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/NamenodeProtocolServerSideTranslatorPB.java index fadb64a3921..5ffe8e59100 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/NamenodeProtocolServerSideTranslatorPB.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/NamenodeProtocolServerSideTranslatorPB.java @@ -97,7 +97,7 @@ public class NamenodeProtocolServerSideTranslatorPB implements } @Override - public GetTransactionIdResponseProto getTransationId(RpcController unused, + public GetTransactionIdResponseProto getTransactionId(RpcController unused, GetTransactionIdRequestProto request) throws ServiceException { long txid; try { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/NamenodeProtocolTranslatorPB.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/NamenodeProtocolTranslatorPB.java index 99bd3e687fe..51a74746b2f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/NamenodeProtocolTranslatorPB.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolPB/NamenodeProtocolTranslatorPB.java @@ -92,46 +92,13 @@ public class NamenodeProtocolTranslatorPB implements NamenodeProtocol, final private NamenodeProtocolPB rpcProxy; - private static NamenodeProtocolPB createNamenode( - InetSocketAddress nameNodeAddr, Configuration conf, - UserGroupInformation ugi) throws IOException { - RPC.setProtocolEngine(conf, NamenodeProtocolPB.class, - ProtobufRpcEngine.class); - return RPC.getProxy(NamenodeProtocolPB.class, - RPC.getProtocolVersion(NamenodeProtocolPB.class), nameNodeAddr, ugi, - conf, NetUtils.getSocketFactory(conf, NamenodeProtocolPB.class)); - } - - /** Create a {@link NameNode} proxy */ - static NamenodeProtocolPB createNamenodeWithRetry( - NamenodeProtocolPB rpcNamenode) { - RetryPolicy createPolicy = RetryPolicies - .retryUpToMaximumCountWithFixedSleep(5, - HdfsConstants.LEASE_SOFTLIMIT_PERIOD, TimeUnit.MILLISECONDS); - Map, RetryPolicy> remoteExceptionToPolicyMap = - new HashMap, RetryPolicy>(); - remoteExceptionToPolicyMap.put(AlreadyBeingCreatedException.class, - createPolicy); - - Map, RetryPolicy> exceptionToPolicyMap = - new HashMap, RetryPolicy>(); - exceptionToPolicyMap.put(RemoteException.class, RetryPolicies - .retryByRemoteException(RetryPolicies.TRY_ONCE_THEN_FAIL, - remoteExceptionToPolicyMap)); - RetryPolicy methodPolicy = RetryPolicies.retryByException( - RetryPolicies.TRY_ONCE_THEN_FAIL, exceptionToPolicyMap); - Map methodNameToPolicyMap = - new HashMap(); - - methodNameToPolicyMap.put("create", methodPolicy); - - return (NamenodeProtocolPB) RetryProxy.create(NamenodeProtocolPB.class, - rpcNamenode, methodNameToPolicyMap); - } - public NamenodeProtocolTranslatorPB(InetSocketAddress nameNodeAddr, Configuration conf, UserGroupInformation ugi) throws IOException { - rpcProxy = createNamenodeWithRetry(createNamenode(nameNodeAddr, conf, ugi)); + RPC.setProtocolEngine(conf, NamenodeProtocolPB.class, + ProtobufRpcEngine.class); + rpcProxy = RPC.getProxy(NamenodeProtocolPB.class, + RPC.getProtocolVersion(NamenodeProtocolPB.class), nameNodeAddr, ugi, + conf, NetUtils.getSocketFactory(conf, NamenodeProtocolPB.class)); } public NamenodeProtocolTranslatorPB(NamenodeProtocolPB rpcProxy) { @@ -182,7 +149,7 @@ public class NamenodeProtocolTranslatorPB implements NamenodeProtocol, @Override public long getTransactionID() throws IOException { try { - return rpcProxy.getTransationId(NULL_CONTROLLER, GET_TRANSACTIONID) + return rpcProxy.getTransactionId(NULL_CONTROLLER, GET_TRANSACTIONID) .getTxId(); } catch (ServiceException e) { throw ProtobufHelper.getRemoteException(e); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupNode.java index 8dc299ec22a..738b12dc49f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupNode.java @@ -31,7 +31,6 @@ import org.apache.hadoop.hdfs.protocol.HdfsConstants; import org.apache.hadoop.hdfs.protocol.proto.JournalProtocolProtos.JournalProtocolService; import org.apache.hadoop.hdfs.protocolPB.JournalProtocolPB; import org.apache.hadoop.hdfs.protocolPB.JournalProtocolServerSideTranslatorPB; -import org.apache.hadoop.hdfs.protocolPB.NamenodeProtocolPB; import org.apache.hadoop.hdfs.protocolPB.NamenodeProtocolTranslatorPB; import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.NamenodeRole; import org.apache.hadoop.hdfs.server.common.Storage; @@ -43,6 +42,7 @@ import org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration; import org.apache.hadoop.hdfs.server.protocol.NamespaceInfo; import org.apache.hadoop.ipc.RPC; import org.apache.hadoop.net.NetUtils; +import org.apache.hadoop.security.UserGroupInformation; import com.google.protobuf.BlockingService; @@ -294,11 +294,8 @@ public class BackupNode extends NameNode { private NamespaceInfo handshake(Configuration conf) throws IOException { // connect to name node InetSocketAddress nnAddress = NameNode.getServiceAddress(conf, true); - NamenodeProtocolPB proxy = - RPC.waitForProxy(NamenodeProtocolPB.class, - RPC.getProtocolVersion(NamenodeProtocolPB.class), - nnAddress, conf); - this.namenode = new NamenodeProtocolTranslatorPB(proxy); + this.namenode = new NamenodeProtocolTranslatorPB(nnAddress, conf, + UserGroupInformation.getCurrentUser()); this.nnRpcAddress = getHostPortString(nnAddress); this.nnHttpAddress = getHostPortString(super.getHttpServerAddress(conf)); // get version and id info from the name-node diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java index 11f77cc08b0..d84b1a2dd03 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java @@ -48,7 +48,6 @@ import org.apache.hadoop.hdfs.DFSUtil; import org.apache.hadoop.hdfs.DFSUtil.ErrorSimulator; import org.apache.hadoop.hdfs.HdfsConfiguration; import org.apache.hadoop.hdfs.protocol.HdfsConstants; -import org.apache.hadoop.hdfs.protocolPB.NamenodeProtocolPB; import org.apache.hadoop.hdfs.protocolPB.NamenodeProtocolTranslatorPB; import org.apache.hadoop.hdfs.server.common.HdfsServerConstants; import org.apache.hadoop.hdfs.server.common.InconsistentFSStateException; @@ -60,7 +59,6 @@ import org.apache.hadoop.hdfs.server.protocol.RemoteEditLog; import org.apache.hadoop.hdfs.server.protocol.RemoteEditLogManifest; import org.apache.hadoop.http.HttpServer; import org.apache.hadoop.io.MD5Hash; -import org.apache.hadoop.ipc.RPC; import org.apache.hadoop.ipc.RemoteException; import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; import org.apache.hadoop.metrics2.source.JvmMetrics; @@ -219,10 +217,8 @@ public class SecondaryNameNode implements Runnable { nameNodeAddr = NameNode.getServiceAddress(conf, true); this.conf = conf; - NamenodeProtocolPB proxy = - RPC.waitForProxy(NamenodeProtocolPB.class, - RPC.getProtocolVersion(NamenodeProtocolPB.class), nameNodeAddr, conf); - this.namenode = new NamenodeProtocolTranslatorPB(proxy); + this.namenode = new NamenodeProtocolTranslatorPB(nameNodeAddr, conf, + UserGroupInformation.getCurrentUser()); // initialize checkpoint directories fsName = getInfoServer(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/proto/NamenodeProtocol.proto b/hadoop-hdfs-project/hadoop-hdfs/src/main/proto/NamenodeProtocol.proto index da1d125d3db..e1ddcf0b4d7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/proto/NamenodeProtocol.proto +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/proto/NamenodeProtocol.proto @@ -185,7 +185,7 @@ service NamenodeProtocolService { /** * Get the transaction ID of the most recently persisted editlog record */ - rpc getTransationId(GetTransactionIdRequestProto) + rpc getTransactionId(GetTransactionIdRequestProto) returns(GetTransactionIdResponseProto); /**