@Override public List<HAServiceTarget> getAllOtherNodes() { String nsId = DFSUtil.getNamenodeNameServiceId(conf); List<String> otherNn = HAUtil.getNameNodeIdOfOtherNodes(conf, nsId); List<HAServiceTarget> targets = new ArrayList<HAServiceTarget>(otherNn.size()); for (String nnId : otherNn) { targets.add(new NNHAServiceTarget(conf, nsId, nnId)); } return targets; } }
/** * Given the configuration for this node, return a list of configurations * for the other nodes in an HA setup. * * @param myConf the configuration of this node * @return a list of configuration of other nodes in an HA setup */ public static List<Configuration> getConfForOtherNodes( Configuration myConf) { String nsId = DFSUtil.getNamenodeNameServiceId(myConf); List<String> otherNodes = getNameNodeIdOfOtherNodes(myConf, nsId); // Look up the address of the other NNs List<Configuration> confs = new ArrayList<Configuration>(otherNodes.size()); myConf = new Configuration(myConf); // unset independent properties for (String idpKey : HA_SPECIAL_INDEPENDENT_KEYS) { myConf.unset(idpKey); } for (String nn : otherNodes) { Configuration confForOtherNode = new Configuration(myConf); NameNode.initializeGenericKeys(confForOtherNode, nsId, nn); confs.add(confForOtherNode); } return confs; }