Browse Source

HDFS-2523. Small NN fixes to include HAServiceProtocol and prevent NPE on shutdown. Contributed by Todd Lipcon.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-1623@1195753 13f79535-47bb-0310-9956-ffa450edef68
Todd Lipcon 13 years ago
parent
commit
3ab295994a

+ 2 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt

@@ -19,3 +19,5 @@ HDFS-2231. Configuration changes for HA namenode. (suresh)
 HDFS-2418. Change ConfiguredFailoverProxyProvider to take advantage of HDFS-2231. (atm)
 
 HDFS-2393. Mark appropriate methods of ClientProtocol with the idempotent annotation. (atm)
+
+HDFS-2523. Small NN fixes to include HAServiceProtocol and prevent NPE on shutdown. (todd)

+ 3 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java

@@ -572,7 +572,9 @@ public class NameNode {
       stopRequested = true;
     }
     try {
-      state.exitState(haContext);
+      if (state != null) {
+        state.exitState(haContext);
+      }
     } catch (ServiceFailedException e) {
       LOG.warn("Encountered exception while exiting state ", e);
     }

+ 4 - 0
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java

@@ -39,6 +39,7 @@ import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.permission.PermissionStatus;
 import static org.apache.hadoop.hdfs.DFSConfigKeys.*;
 
+import org.apache.hadoop.ha.HAServiceProtocol;
 import org.apache.hadoop.ha.HealthCheckFailedException;
 import org.apache.hadoop.ha.ServiceFailedException;
 import org.apache.hadoop.hdfs.HDFSPolicyProvider;
@@ -156,6 +157,7 @@ class NameNodeRpcServer implements NamenodeProtocols {
     this.server.addProtocol(RefreshAuthorizationPolicyProtocol.class, this);
     this.server.addProtocol(RefreshUserMappingsProtocol.class, this);
     this.server.addProtocol(GetUserMappingsProtocol.class, this);
+    this.server.addProtocol(HAServiceProtocol.class, this);
     
 
     // set service-level authorization security policy
@@ -225,6 +227,8 @@ class NameNodeRpcServer implements NamenodeProtocols {
       return RefreshUserMappingsProtocol.versionID;
     } else if (protocol.equals(GetUserMappingsProtocol.class.getName())){
       return GetUserMappingsProtocol.versionID;
+    } else if (protocol.equals(HAServiceProtocol.class.getName())) {
+      return HAServiceProtocol.versionID;
     } else {
       throw new IOException("Unknown protocol to name node: " + protocol);
     }