/** * Try to map the given namenode ID to its service address. */ @Override protected HAServiceTarget resolveTarget(String nnId) { HdfsConfiguration conf = (HdfsConfiguration)getConf(); return new NNHAServiceTarget(conf, nameserviceId, nnId); }
@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; } }
@Override protected HAServiceTarget dataToTarget(byte[] data) { ActiveNodeInfo proto; try { proto = ActiveNodeInfo.parseFrom(data); } catch (InvalidProtocolBufferException e) { throw new RuntimeException("Invalid data in ZK: " + StringUtils.byteToHexString(data)); } NNHAServiceTarget ret = new NNHAServiceTarget( conf, proto.getNameserviceId(), proto.getNamenodeId()); InetSocketAddress addressFromProtobuf = new InetSocketAddress( proto.getHostname(), proto.getPort()); if (!addressFromProtobuf.equals(ret.getAddress())) { throw new RuntimeException("Mismatched address stored in ZK for " + ret + ": Stored protobuf was " + proto + ", address from our own " + "configuration for this NameNode was " + ret.getAddress()); } ret.setZkfcPort(proto.getZkfcPort()); return ret; }
public static 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, ZKFC_CONF_KEYS); NNHAServiceTarget localTarget = new NNHAServiceTarget( localNNConf, nsId, nnId); return new DFSZKFailoverController(localNNConf, localTarget); }
/** * Try to map the given namenode ID to its service address. */ @Override protected HAServiceTarget resolveTarget(String nnId) { HdfsConfiguration conf = (HdfsConfiguration)getConf(); return new NNHAServiceTarget(conf, nameserviceId, nnId); }
/** * Try to map the given namenode ID to its service address. */ @Override protected HAServiceTarget resolveTarget(String nnId) { HdfsConfiguration conf = (HdfsConfiguration)getConf(); return new NNHAServiceTarget(conf, nameserviceId, nnId); }
@Override protected HAServiceTarget dataToTarget(byte[] data) { ActiveNodeInfo proto; try { proto = ActiveNodeInfo.parseFrom(data); } catch (InvalidProtocolBufferException e) { throw new RuntimeException("Invalid data in ZK: " + StringUtils.byteToHexString(data)); } NNHAServiceTarget ret = new NNHAServiceTarget( conf, proto.getNameserviceId(), proto.getNamenodeId()); InetSocketAddress addressFromProtobuf = new InetSocketAddress( proto.getHostname(), proto.getPort()); if (!addressFromProtobuf.equals(ret.getAddress())) { throw new RuntimeException("Mismatched address stored in ZK for " + ret + ": Stored protobuf was " + proto + ", address from our own " + "configuration for this NameNode was " + ret.getAddress()); } ret.setZkfcPort(proto.getZkfcPort()); return ret; }
@Override protected HAServiceTarget dataToTarget(byte[] data) { ActiveNodeInfo proto; try { proto = ActiveNodeInfo.parseFrom(data); } catch (InvalidProtocolBufferException e) { throw new RuntimeException("Invalid data in ZK: " + StringUtils.byteToHexString(data)); } NNHAServiceTarget ret = new NNHAServiceTarget( conf, proto.getNameserviceId(), proto.getNamenodeId()); InetSocketAddress addressFromProtobuf = new InetSocketAddress( proto.getHostname(), proto.getPort()); if (!addressFromProtobuf.equals(ret.getAddress())) { throw new RuntimeException("Mismatched address stored in ZK for " + ret + ": Stored protobuf was " + proto + ", address from our own " + "configuration for this NameNode was " + ret.getAddress()); } ret.setZkfcPort(proto.getZkfcPort()); return ret; }
public static 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, ZKFC_CONF_KEYS); NNHAServiceTarget localTarget = new NNHAServiceTarget( localNNConf, nsId, nnId); return new DFSZKFailoverController(localNNConf, localTarget); }
public static 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, ZKFC_CONF_KEYS); NNHAServiceTarget localTarget = new NNHAServiceTarget( localNNConf, nsId, nnId); return new DFSZKFailoverController(localNNConf, localTarget); }