Forráskód Böngészése

HDFS-3200. Scope all ZKFC configurations by nameservice. Contributed by Todd Lipcon.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-3042@1310165 13f79535-47bb-0310-9956-ffa450edef68
Todd Lipcon 13 éve
szülő
commit
844faefd08

+ 13 - 1
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFailoverController.java

@@ -44,7 +44,6 @@ public abstract class ZKFailoverController implements Tool {
 
   static final Log LOG = LogFactory.getLog(ZKFailoverController.class);
   
-  // TODO: this should be namespace-scoped
   public static final String ZK_QUORUM_KEY = "ha.zookeeper.quorum";
   private static final String ZK_SESSION_TIMEOUT_KEY = "ha.zookeeper.session-timeout.ms";
   private static final int ZK_SESSION_TIMEOUT_DEFAULT = 5*1000;
@@ -54,6 +53,19 @@ public abstract class ZKFailoverController implements Tool {
   public static final String ZK_AUTH_KEY = "ha.zookeeper.auth";
   static final String ZK_PARENT_ZNODE_DEFAULT = "/hadoop-ha";
 
+  /**
+   * All of the conf keys used by the ZKFC. This is used in order to allow
+   * them to be overridden on a per-nameservice or per-namenode basis.
+   */
+  protected static final String[] ZKFC_CONF_KEYS = new String[] {
+    ZK_QUORUM_KEY,
+    ZK_SESSION_TIMEOUT_KEY,
+    ZK_PARENT_ZNODE_KEY,
+    ZK_ACL_KEY,
+    ZK_AUTH_KEY
+  };
+  
+
   /** Unable to format the parent znode in ZK */
   static final int ERR_CODE_FORMAT_DENIED = 2;
   /** The parent znode doesn't exist in ZK */

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

@@ -5,3 +5,5 @@ branch is merged.
 ------------------------------
 
 HDFS-2185. HDFS portion of ZK-based FailoverController (todd)
+
+HDFS-3200. Scope all ZKFC configurations by nameservice (todd)

+ 1 - 0
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSZKFailoverController.java

@@ -94,6 +94,7 @@ public class DFSZKFailoverController extends ZKFailoverController {
     }
     String nnId = HAUtil.getNameNodeId(localNNConf, nsId);
     NameNode.initializeGenericKeys(localNNConf, nsId, nnId);
+    DFSUtil.setGenericConf(localNNConf, nsId, nnId, ZKFC_CONF_KEYS);
     
     localTarget = new NNHAServiceTarget(localNNConf, nsId, nnId);
     

+ 3 - 1
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDFSZKFailoverController.java

@@ -53,7 +53,9 @@ public class TestDFSZKFailoverController extends ClientBaseWithFixes {
   @Before
   public void setup() throws Exception {
     conf = new Configuration();
-    conf.set(ZKFailoverController.ZK_QUORUM_KEY, hostPort);
+    // Specify the quorum per-nameservice, to ensure that these configs
+    // can be nameservice-scoped.
+    conf.set(ZKFailoverController.ZK_QUORUM_KEY + ".ns1", hostPort);
     conf.set(NodeFencer.CONF_METHODS_KEY,
         AlwaysSucceedFencer.class.getName());