use of org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.ActiveRMInfoProto in project phoenix by apache.
the class PhoenixMRJobUtil method getActiveResourceManagerHost.
public static String getActiveResourceManagerHost(Configuration config, String zkQuorum) throws IOException, InterruptedException, JSONException, KeeperException, InvalidProtocolBufferException, ZooKeeperConnectionException {
ZooKeeperWatcher zkw = null;
ZooKeeper zk = null;
String activeRMHost = null;
try {
zkw = new ZooKeeperWatcher(config, "get-active-yarnmanager", null);
zk = new ZooKeeper(zkQuorum, 30000, zkw, false);
List<String> children = zk.getChildren(YARN_LEADER_ELECTION, zkw);
for (String subEntry : children) {
List<String> subChildern = zk.getChildren(YARN_LEADER_ELECTION + "/" + subEntry, zkw);
for (String eachEntry : subChildern) {
if (eachEntry.contains(ACTIVE_STANDBY_ELECTOR_LOCK)) {
String path = YARN_LEADER_ELECTION + "/" + subEntry + "/" + ACTIVE_STANDBY_ELECTOR_LOCK;
byte[] data = zk.getData(path, zkw, new Stat());
ActiveRMInfoProto proto = ActiveRMInfoProto.parseFrom(data);
proto.getRmId();
LOG.info("Active RmId : " + proto.getRmId());
activeRMHost = config.get(YarnConfiguration.RM_HOSTNAME + "." + proto.getRmId());
LOG.info("activeResourceManagerHostname = " + activeRMHost);
}
}
}
} finally {
if (zkw != null)
zkw.close();
if (zk != null)
zk.close();
}
return activeRMHost;
}
Aggregations