Example usage for org.apache.hadoop.mapreduce.v2.api MRClientProtocol getConnectAddress

List of usage examples for org.apache.hadoop.mapreduce.v2.api MRClientProtocol getConnectAddress

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce.v2.api MRClientProtocol getConnectAddress.

Prototype

public InetSocketAddress getConnectAddress();

Source Link

Document

Address to which the client is connected

Usage

From source file:org.apache.oozie.action.hadoop.JHSCredentials.java

License:Apache License

/**
 * Add an MR_DELEGATION_TOKEN to the {@link Credentials} provided.
 * @param credentials the credentials object which is updated
 * @param config launcher AM configuration
 * @param props properties for getting credential token or certificate
 * @param context workflow context//from   ww  w. ja v a2 s  .c  o m
 * @throws Exception thrown if failed
 */
@Override
public void updateCredentials(Credentials credentials, Configuration config, CredentialsProperties props,
        ActionExecutor.Context context) throws Exception {
    try {
        LOG.debug("Instantiating JHS Proxy");
        MRClientProtocol hsProxy = instantiateHistoryProxy(config, context);
        Text hsService = SecurityUtil.buildTokenService(hsProxy.getConnectAddress());
        LOG.debug("Getting delegation token for {0}", hsService.toString());
        Token<?> jhsToken = getDelegationTokenFromJHS(hsProxy,
                new HadoopTokenHelper().getServerPrincipal(config));
        LOG.debug("Acquired token {0}", jhsToken);
        credentials.addToken(hsService, jhsToken);
    } catch (IOException | InterruptedException ex) {
        LOG.debug("exception in updateCredentials", ex);
        throw new CredentialException(ErrorCode.E0512, ex.getMessage(), ex);
    }
}

From source file:org.apache.oozie.action.hadoop.JHSCredentials.java

License:Apache License

/**
 * Get a Delegation token from the JHS.//from w w w  .j av a2s. co m
 * Copied over from YARNRunner in Hadoop.
 * @param hsProxy protcol used to get the token
 * @return The RM_DELEGATION_TOKEN that can be used to talk to JHS
 * @throws IOException
 * @throws InterruptedException
 */
private Token<?> getDelegationTokenFromJHS(final MRClientProtocol hsProxy, final String renewer)
        throws IOException, InterruptedException {
    GetDelegationTokenRequest request = RecordFactoryProvider.getRecordFactory(null)
            .newRecordInstance(GetDelegationTokenRequest.class);
    LOG.debug("Creating requsest to JHS using renewer [{0}]", renewer);
    request.setRenewer(renewer);
    org.apache.hadoop.yarn.api.records.Token mrDelegationToken = hsProxy.getDelegationToken(request)
            .getDelegationToken();
    LOG.debug("Got token to JHS : {0}. Converting token.", mrDelegationToken);
    return ConverterUtils.convertFromYarn(mrDelegationToken, hsProxy.getConnectAddress());
}