ServerName sn = MasterAddressTracker.getMasterAddress(zkw);
if (sn == null) {
String msg =
"ZooKeeper available but no active master location found";
LOG.info(msg);
throw new MasterNotRunningException(msg);
}
InetSocketAddress isa =
new InetSocketAddress(sn.getHostname(), sn.getPort());
MasterProtocol tryMaster = rpcEngine.getProxy(
masterProtocolState.protocolClass,
isa, this.conf, this.rpcTimeout);
if (tryMaster.isMasterRunning(
null, RequestConverter.buildIsMasterRunningRequest()).getIsMasterRunning()) {
return tryMaster;
} else {
String msg = "Can create a proxy to master, but it is not running";
LOG.info(msg);
throw new MasterNotRunningException(msg);
}
} finally {
zkw.close();
}
}