use of org.apache.hadoop.yarn.client.RMHAServiceTarget in project hadoop by apache.
the class RMHAUtils method getHAState.
private static HAServiceState getHAState(YarnConfiguration yarnConf) throws Exception {
HAServiceTarget haServiceTarget;
int rpcTimeoutForChecks = yarnConf.getInt(CommonConfigurationKeys.HA_FC_CLI_CHECK_TIMEOUT_KEY, CommonConfigurationKeys.HA_FC_CLI_CHECK_TIMEOUT_DEFAULT);
yarnConf.set(CommonConfigurationKeys.HADOOP_SECURITY_SERVICE_USER_NAME_KEY, yarnConf.get(YarnConfiguration.RM_PRINCIPAL, ""));
haServiceTarget = new RMHAServiceTarget(yarnConf);
HAServiceProtocol proto = haServiceTarget.getProxy(yarnConf, rpcTimeoutForChecks);
HAServiceState haState = proto.getServiceStatus().getState();
return haState;
}
use of org.apache.hadoop.yarn.client.RMHAServiceTarget in project cdap by caskdata.
the class YarnInfo method getHAWebURL.
/**
* Should only be called when HA is enabled.
*/
private URL getHAWebURL() throws IOException {
InetSocketAddress activeRM = null;
Collection<String> rmIds = HAUtil.getRMHAIds(conf);
if (rmIds.isEmpty()) {
throw new IllegalStateException("Resource Manager HA web URL requested in non-HA mode.");
}
for (String rmId : rmIds) {
try {
YarnConfiguration yarnConf = new YarnConfiguration(conf);
yarnConf.set(YarnConfiguration.RM_HA_ID, rmId);
yarnConf.set(CommonConfigurationKeys.HADOOP_SECURITY_SERVICE_USER_NAME_KEY, conf.get(YarnConfiguration.RM_PRINCIPAL, ""));
RMHAServiceTarget rmhaServiceTarget = new RMHAServiceTarget(yarnConf);
HAServiceProtocol proxy = rmhaServiceTarget.getProxy(yarnConf, 10000);
HAServiceStatus serviceStatus = proxy.getServiceStatus();
if (HAServiceProtocol.HAServiceState.ACTIVE != serviceStatus.getState()) {
continue;
}
activeRM = rmhaServiceTarget.getAddress();
} catch (ConnectException e) {
LOG.trace("Connection refused when attempting to connect to ResourceManager {}. " + "Assuming that it is not available.", rmId);
}
}
if (activeRM == null) {
throw new IllegalStateException("Could not find an active resource manager");
}
return adminToWebappAddress(activeRM);
}
use of org.apache.hadoop.yarn.client.RMHAServiceTarget in project hadoop by apache.
the class RMAdminCLI method resolveTarget.
@Override
protected HAServiceTarget resolveTarget(String rmId) {
Collection<String> rmIds = HAUtil.getRMHAIds(getConf());
if (!rmIds.contains(rmId)) {
StringBuilder msg = new StringBuilder();
msg.append(rmId + " is not a valid serviceId. It should be one of ");
for (String id : rmIds) {
msg.append(id + " ");
}
throw new IllegalArgumentException(msg.toString());
}
try {
YarnConfiguration conf = new YarnConfiguration(getConf());
conf.set(YarnConfiguration.RM_HA_ID, rmId);
return new RMHAServiceTarget(conf);
} catch (IllegalArgumentException iae) {
throw new YarnRuntimeException("Could not connect to " + rmId + "; the configuration for it might be missing");
} catch (IOException ioe) {
throw new YarnRuntimeException("Could not connect to RM HA Admin for node " + rmId);
}
}
Aggregations