Example usage for org.apache.hadoop.mapreduce.v2.api.protocolrecords CancelDelegationTokenRequest setDelegationToken

List of usage examples for org.apache.hadoop.mapreduce.v2.api.protocolrecords CancelDelegationTokenRequest setDelegationToken

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce.v2.api.protocolrecords CancelDelegationTokenRequest setDelegationToken.

Prototype

void setDelegationToken(Token dToken);

Source Link

Usage

From source file:azkaban.security.HadoopSecurityManager_H_2_0.java

License:Apache License

private void cancelJhsToken(final Token<? extends TokenIdentifier> t, String userToProxy)
        throws HadoopSecurityManagerException {
    // it appears yarn would clean up this token after app finish, after a long
    // while though.
    org.apache.hadoop.yarn.api.records.Token token = org.apache.hadoop.yarn.api.records.Token
            .newInstance(t.getIdentifier(), t.getKind().toString(), t.getPassword(), t.getService().toString());
    final YarnRPC rpc = YarnRPC.create(conf);
    final InetSocketAddress jhsAddress = SecurityUtil.getTokenServiceAddr(t);
    MRClientProtocol jhsProxy = null;/*from w w w  . j  a  va 2 s .co m*/
    try {
        jhsProxy = UserGroupInformation.getCurrentUser().doAs(new PrivilegedAction<MRClientProtocol>() {
            @Override
            public MRClientProtocol run() {
                return (MRClientProtocol) rpc.getProxy(HSClientProtocol.class, jhsAddress, conf);
            }
        });
        CancelDelegationTokenRequest request = Records.newRecord(CancelDelegationTokenRequest.class);
        request.setDelegationToken(token);
        jhsProxy.cancelDelegationToken(request);
    } catch (Exception e) {
        throw new HadoopSecurityManagerException("Failed to cancel token. " + e.getMessage() + e.getCause(), e);
    } finally {
        RPC.stopProxy(jhsProxy);
    }

}

From source file:azkaban.security.HadoopSecurityManager_H_2_0.java

License:Apache License

private void cancelDelegationTokenFromHS(final org.apache.hadoop.yarn.api.records.Token t,
        HSClientProtocol hsProxy) throws IOException, InterruptedException {
    CancelDelegationTokenRequest request = recordFactory.newRecordInstance(CancelDelegationTokenRequest.class);
    request.setDelegationToken(t);
    hsProxy.cancelDelegationToken(request);
}