gpt4 book ai didi

org.apache.hadoop.yarn.client.api.YarnClient.getRMDelegationToken()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 19:54:40 27 4
gpt4 key购买 nike

本文整理了Java中org.apache.hadoop.yarn.client.api.YarnClient.getRMDelegationToken()方法的一些代码示例,展示了YarnClient.getRMDelegationToken()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YarnClient.getRMDelegationToken()方法的具体详情如下:
包路径:org.apache.hadoop.yarn.client.api.YarnClient
类名称:YarnClient
方法名:getRMDelegationToken

YarnClient.getRMDelegationToken介绍

[英]Get a delegation token so as to be able to talk to YARN using those tokens.
[中]获取一个委派令牌,以便能够使用这些令牌与纱线对话。

代码示例

代码示例来源:origin: com.github.jiayuhan-it/hadoop-mapreduce-client-jobclient

@Override
public org.apache.hadoop.yarn.api.records.Token getRMDelegationToken(
  Text renewer) throws YarnException, IOException {
 return client.getRMDelegationToken(renewer);
}

代码示例来源:origin: org.apache.hadoop/hadoop-mapreduce-client-jobclient

@Override
public org.apache.hadoop.yarn.api.records.Token getRMDelegationToken(
  Text renewer) throws YarnException, IOException {
 return client.getRMDelegationToken(renewer);
}

代码示例来源:origin: org.apache.tez/tez-mapreduce

@SuppressWarnings("rawtypes")
public Token getDelegationToken(Text renewer) throws IOException,
  InterruptedException {
 try {
  // Remove rmAddress after YARN-868 is addressed
  return ConverterUtils.convertFromYarn(
   client.getRMDelegationToken(renewer), rmAddress);
 } catch (YarnException e) {
  throw new IOException(e);
 }
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-mapreduce-client-jobclient

@SuppressWarnings("rawtypes")
public Token getDelegationToken(Text renewer) throws IOException,
  InterruptedException {
 try {
  return ConverterUtils.convertFromYarn(
    client.getRMDelegationToken(renewer), getRMDelegationTokenService());
 } catch (YarnException e) {
  throw new IOException(e);
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-mapreduce-client-jobclient

@SuppressWarnings("rawtypes")
public Token getDelegationToken(Text renewer) throws IOException,
  InterruptedException {
 try {
  return ConverterUtils.convertFromYarn(
    client.getRMDelegationToken(renewer), getRMDelegationTokenService());
 } catch (YarnException e) {
  throw new IOException(e);
 }
}

代码示例来源:origin: org.apache.apex/apex-engine

public void addRMDelegationToken(final String renewer, final Credentials credentials) throws IOException, YarnException
{
 // Get the ResourceManager delegation rmToken
 final org.apache.hadoop.yarn.api.records.Token rmDelegationToken = clientRM.getRMDelegationToken(new Text(renewer));
 Token<RMDelegationTokenIdentifier> token;
 // TODO: Use the utility method getRMDelegationTokenService in ClientRMProxy to remove the separate handling of
 // TODO: HA and non-HA cases when hadoop dependency is changed to hadoop 2.4 or above
 if (ConfigUtils.isRMHAEnabled(conf)) {
  LOG.info("Yarn Resource Manager HA is enabled");
  token = getRMHAToken(rmDelegationToken);
 } else {
  LOG.info("Yarn Resource Manager HA is not enabled");
  InetSocketAddress rmAddress = conf.getSocketAddr(YarnConfiguration.RM_ADDRESS,
    YarnConfiguration.DEFAULT_RM_ADDRESS,
    YarnConfiguration.DEFAULT_RM_PORT);
  token = ConverterUtils.convertFromYarn(rmDelegationToken, rmAddress);
 }
 LOG.info("RM dt {}", token);
 credentials.addToken(token.getService(), token);
}

代码示例来源:origin: linkedin/TonY

throw new RuntimeException("Failed to get RM principal.");
final Token<?> rmToken = ConverterUtils.convertFromYarn(yarnClient.getRMDelegationToken(new Text(tokenRenewer)),
                        yarnConf.getSocketAddr(YarnConfiguration.RM_ADDRESS,
                                   YarnConfiguration.DEFAULT_RM_ADDRESS,

代码示例来源:origin: caskdata/cdap

org.apache.hadoop.yarn.api.records.Token rmDelegationToken = yarnClient.getRMDelegationToken(renewer);

代码示例来源:origin: org.apache.twill/twill-yarn

org.apache.hadoop.yarn.api.records.Token rmDelegationToken = yarnClient.getRMDelegationToken(renewer);

代码示例来源:origin: co.cask.cdap/cdap-common

org.apache.hadoop.yarn.api.records.Token rmDelegationToken = yarnClient.getRMDelegationToken(renewer);

代码示例来源:origin: org.apache.slider/slider-core

/**
 * Create and add an RM delegation token to the credentials
 * @param yarnClient Yarn Client
 * @param credentials to add token to
 * @return the token which was added
 * @throws IOException
 * @throws YarnException
 */
public static Token<TokenIdentifier> addRMDelegationToken(YarnClient yarnClient,
  Credentials credentials)
  throws IOException, YarnException {
 Configuration conf = yarnClient.getConfig();
 Text rmPrincipal = new Text(CredentialUtils.getRMPrincipal(conf));
 Text rmDTService = ClientRMProxy.getRMDelegationTokenService(conf);
 Token<TokenIdentifier> rmDelegationToken =
   ConverterUtils.convertFromYarn(
     yarnClient.getRMDelegationToken(rmPrincipal),
     rmDTService);
 credentials.addToken(rmDelegationToken.getService(), rmDelegationToken);
 return rmDelegationToken;
}

代码示例来源:origin: apache/twill

org.apache.hadoop.yarn.api.records.Token rmDelegationToken = yarnClient.getRMDelegationToken(renewer);

代码示例来源:origin: apache/incubator-slider

/**
 * Create and add an RM delegation token to the credentials
 * @param yarnClient Yarn Client
 * @param credentials to add token to
 * @return the token which was added
 * @throws IOException
 * @throws YarnException
 */
public static Token<TokenIdentifier> addRMDelegationToken(YarnClient yarnClient,
  Credentials credentials)
  throws IOException, YarnException {
 Configuration conf = yarnClient.getConfig();
 Text rmPrincipal = new Text(CredentialUtils.getRMPrincipal(conf));
 Text rmDTService = ClientRMProxy.getRMDelegationTokenService(conf);
 Token<TokenIdentifier> rmDelegationToken =
   ConverterUtils.convertFromYarn(
     yarnClient.getRMDelegationToken(rmPrincipal),
     rmDTService);
 credentials.addToken(rmDelegationToken.getService(), rmDelegationToken);
 return rmDelegationToken;
}

代码示例来源:origin: org.apache.twill/twill-yarn

/**
 * Adds RM delegation token to the given {@link ContainerLaunchContext} so that the AM can authenticate itself
 * with RM using the delegation token.
 */
protected void addRMToken(ContainerLaunchContext context, YarnClient yarnClient, ApplicationId appId) {
 if (!UserGroupInformation.isSecurityEnabled()) {
  return;
 }
 try {
  Credentials credentials = YarnUtils.decodeCredentials(context.getTokens());
  Configuration config = yarnClient.getConfig();
  Token<TokenIdentifier> token = ConverterUtils.convertFromYarn(
   yarnClient.getRMDelegationToken(new Text(YarnUtils.getYarnTokenRenewer(config))),
   YarnUtils.getRMAddress(config));
  LOG.debug("Added RM delegation token {} for application {}", token, appId);
  credentials.addToken(token.getService(), token);
  context.setTokens(YarnUtils.encodeCredentials(credentials));
 } catch (YarnException | IOException e) {
  throw new RuntimeException("Failed to acquire RM delegation token", e);
 }
}

代码示例来源:origin: apache/twill

/**
 * Adds RM delegation token to the given {@link ContainerLaunchContext} so that the AM can authenticate itself
 * with RM using the delegation token.
 */
protected void addRMToken(ContainerLaunchContext context, YarnClient yarnClient, ApplicationId appId) {
 if (!UserGroupInformation.isSecurityEnabled()) {
  return;
 }
 try {
  Credentials credentials = YarnUtils.decodeCredentials(context.getTokens());
  Configuration config = yarnClient.getConfig();
  Token<TokenIdentifier> token = ConverterUtils.convertFromYarn(
   yarnClient.getRMDelegationToken(new Text(YarnUtils.getYarnTokenRenewer(config))),
   YarnUtils.getRMAddress(config));
  LOG.debug("Added RM delegation token {} for application {}", token, appId);
  credentials.addToken(token.getService(), token);
  context.setTokens(YarnUtils.encodeCredentials(credentials));
 } catch (YarnException | IOException e) {
  throw new RuntimeException("Failed to acquire RM delegation token", e);
 }
}

代码示例来源:origin: apache/oozie

/**
 * Add an RM_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
 * @throws Exception thrown if failed
 */
@Override
public void updateCredentials(Credentials credentials, Configuration config, CredentialsProperties props,
               ActionExecutor.Context context) throws Exception {
  Text rmDelegationTokenService = ClientRMProxy.getRMDelegationTokenService(config);
  if (rmDelegationTokenService == null) {
    throw new CredentialException(ErrorCode.E0512, "Can't create RMDelegationTokenService");
  }
  try (YarnClient yarnClient = Services.get().get(HadoopAccessorService.class)
      .createYarnClient(context.getWorkflow().getUser(), config)) {
    org.apache.hadoop.yarn.api.records.Token rmDelegationToken =
        yarnClient.getRMDelegationToken(new Text(new HadoopTokenHelper().getServerPrincipal(config)));
    if (rmDelegationToken == null) {
      throw new CredentialException(ErrorCode.E0512, "Returned token is null");
    }
    Token<TokenIdentifier> rmToken = ConverterUtils.convertFromYarn(rmDelegationToken, rmDelegationTokenService);
    credentials.addToken(rmDelegationTokenService, rmToken);
  } catch (Exception e) {
    XLog.getLog(getClass()).debug("Exception in updateCredentials", e);
    throw e;
  }
}

代码示例来源:origin: org.apache.oozie/oozie-core

/**
 * Add an RM_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
 * @throws Exception thrown if failed
 */
@Override
public void updateCredentials(Credentials credentials, Configuration config, CredentialsProperties props,
               ActionExecutor.Context context) throws Exception {
  Text rmDelegationTokenService = ClientRMProxy.getRMDelegationTokenService(config);
  if (rmDelegationTokenService == null) {
    throw new CredentialException(ErrorCode.E0512, "Can't create RMDelegationTokenService");
  }
  try (YarnClient yarnClient = Services.get().get(HadoopAccessorService.class)
      .createYarnClient(context.getWorkflow().getUser(), config)) {
    org.apache.hadoop.yarn.api.records.Token rmDelegationToken =
        yarnClient.getRMDelegationToken(new Text(new HadoopTokenHelper().getServerPrincipal(config)));
    if (rmDelegationToken == null) {
      throw new CredentialException(ErrorCode.E0512, "Returned token is null");
    }
    Token<TokenIdentifier> rmToken = ConverterUtils.convertFromYarn(rmDelegationToken, rmDelegationTokenService);
    credentials.addToken(rmDelegationTokenService, rmToken);
  } catch (Exception e) {
    XLog.getLog(getClass()).debug("Exception in updateCredentials", e);
    throw e;
  }
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com