diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFailoverController.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFailoverController.java index 55cfc56af72..bd406059276 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFailoverController.java +++ b/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 */ diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-3042.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-3042.txt index 7a345c63b73..c41f7d3a0b8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-3042.txt +++ b/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) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSZKFailoverController.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSZKFailoverController.java index 894f3a0bcc2..a3c44455034 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSZKFailoverController.java +++ b/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); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDFSZKFailoverController.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDFSZKFailoverController.java index 802bbd486a9..1bd41ffd2ef 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDFSZKFailoverController.java +++ b/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());