Search in sources :

Example 1 with RMHAServiceTarget

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;
}
Also used : RMHAServiceTarget(org.apache.hadoop.yarn.client.RMHAServiceTarget) HAServiceProtocol(org.apache.hadoop.ha.HAServiceProtocol) HAServiceState(org.apache.hadoop.ha.HAServiceProtocol.HAServiceState) HAServiceTarget(org.apache.hadoop.ha.HAServiceTarget) RMHAServiceTarget(org.apache.hadoop.yarn.client.RMHAServiceTarget)

Example 2 with RMHAServiceTarget

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);
}
Also used : RMHAServiceTarget(org.apache.hadoop.yarn.client.RMHAServiceTarget) HAServiceProtocol(org.apache.hadoop.ha.HAServiceProtocol) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) InetSocketAddress(java.net.InetSocketAddress) HAServiceStatus(org.apache.hadoop.ha.HAServiceStatus) ConnectException(java.net.ConnectException)

Example 3 with RMHAServiceTarget

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);
    }
}
Also used : YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) RMHAServiceTarget(org.apache.hadoop.yarn.client.RMHAServiceTarget) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) IOException(java.io.IOException)

Aggregations

RMHAServiceTarget (org.apache.hadoop.yarn.client.RMHAServiceTarget)3 HAServiceProtocol (org.apache.hadoop.ha.HAServiceProtocol)2 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)2 IOException (java.io.IOException)1 ConnectException (java.net.ConnectException)1 InetSocketAddress (java.net.InetSocketAddress)1 HAServiceState (org.apache.hadoop.ha.HAServiceProtocol.HAServiceState)1 HAServiceStatus (org.apache.hadoop.ha.HAServiceStatus)1 HAServiceTarget (org.apache.hadoop.ha.HAServiceTarget)1 YarnRuntimeException (org.apache.hadoop.yarn.exceptions.YarnRuntimeException)1