Search in sources :

Example 1 with RMDelegationTokenSelector

use of org.apache.hadoop.yarn.security.client.RMDelegationTokenSelector in project hadoop by apache.

the class YARNRunner method addHistoryToken.

@VisibleForTesting
void addHistoryToken(Credentials ts) throws IOException, InterruptedException {
    /* check if we have a hsproxy, if not, no need */
    MRClientProtocol hsProxy = clientCache.getInitializedHSProxy();
    if (UserGroupInformation.isSecurityEnabled() && (hsProxy != null)) {
        /*
       * note that get delegation token was called. Again this is hack for oozie
       * to make sure we add history server delegation tokens to the credentials
       */
        RMDelegationTokenSelector tokenSelector = new RMDelegationTokenSelector();
        Text service = resMgrDelegate.getRMDelegationTokenService();
        if (tokenSelector.selectToken(service, ts.getAllTokens()) != null) {
            Text hsService = SecurityUtil.buildTokenService(hsProxy.getConnectAddress());
            if (ts.getToken(hsService) == null) {
                ts.addToken(hsService, getDelegationTokenFromHS(hsProxy));
            }
        }
    }
}
Also used : Text(org.apache.hadoop.io.Text) RMDelegationTokenSelector(org.apache.hadoop.yarn.security.client.RMDelegationTokenSelector) MRClientProtocol(org.apache.hadoop.mapreduce.v2.api.MRClientProtocol) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Text (org.apache.hadoop.io.Text)1 MRClientProtocol (org.apache.hadoop.mapreduce.v2.api.MRClientProtocol)1 RMDelegationTokenSelector (org.apache.hadoop.yarn.security.client.RMDelegationTokenSelector)1