/// <exception cref="System.IO.IOException"/>
        private void ParseConfAndFindOtherNN()
        {
            Configuration conf = GetConf();

            nsId = DFSUtil.GetNamenodeNameServiceId(conf);
            if (!HAUtil.IsHAEnabled(conf, nsId))
            {
                throw new HadoopIllegalArgumentException("HA is not enabled for this namenode.");
            }
            nnId = HAUtil.GetNameNodeId(conf, nsId);
            NameNode.InitializeGenericKeys(conf, nsId, nnId);
            if (!HAUtil.UsesSharedEditsDir(conf))
            {
                throw new HadoopIllegalArgumentException("Shared edits storage is not enabled for this namenode."
                                                         );
            }
            Configuration otherNode = HAUtil.GetConfForOtherNode(conf);

            otherNNId    = HAUtil.GetNameNodeId(otherNode, nsId);
            otherIpcAddr = NameNode.GetServiceAddress(otherNode, true);
            Preconditions.CheckArgument(otherIpcAddr.Port != 0 && !otherIpcAddr.Address.IsAnyLocalAddress
                                            (), "Could not determine valid IPC address for other NameNode (%s)" + ", got: %s"
                                        , otherNNId, otherIpcAddr);
            string scheme = DFSUtil.GetHttpClientScheme(conf);

            otherHttpAddr = DFSUtil.GetInfoServerWithDefaultHost(otherIpcAddr.GetHostName(),
                                                                 otherNode, scheme).ToURL();
            dirsToFormat     = FSNamesystem.GetNamespaceDirs(conf);
            editUrisToFormat = FSNamesystem.GetNamespaceEditsDirs(conf, false);
            sharedEditsUris  = FSNamesystem.GetSharedEditsDirs(conf);
        }
        public static Org.Apache.Hadoop.Hdfs.Tools.DFSZKFailoverController Create(Configuration
                                                                                  conf)
        {
            Configuration localNNConf = DFSHAAdmin.AddSecurityConfiguration(conf);
            string        nsId        = DFSUtil.GetNamenodeNameServiceId(conf);

            if (!HAUtil.IsHAEnabled(localNNConf, nsId))
            {
                throw new HadoopIllegalArgumentException("HA is not enabled for this namenode.");
            }
            string nnId = HAUtil.GetNameNodeId(localNNConf, nsId);

            if (nnId == null)
            {
                string msg = "Could not get the namenode ID of this node. " + "You may run zkfc on the node other than namenode.";
                throw new HadoopIllegalArgumentException(msg);
            }
            NameNode.InitializeGenericKeys(localNNConf, nsId, nnId);
            DFSUtil.SetGenericConf(localNNConf, nsId, nnId, ZkfcConfKeys);
            NNHAServiceTarget localTarget = new NNHAServiceTarget(localNNConf, nsId, nnId);

            return(new Org.Apache.Hadoop.Hdfs.Tools.DFSZKFailoverController(localNNConf, localTarget
                                                                            ));
        }