gpt4 book ai didi

org.apache.twill.internal.yarn.YarnUtils.addDelegationTokens()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 04:03:31 25 4
gpt4 key购买 nike

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

YarnUtils.addDelegationTokens介绍

[英]Helper method to get delegation tokens for the given LocationFactory.
[中]方法来获取给定LocationFactory的委派令牌。

代码示例

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

/**
 * Creates a {@link Credentials} for the application submission.
 */
private Credentials createSubmissionCredentials() {
 Credentials credentials = new Credentials();
 try {
  // Acquires delegation token for the location
  List<Token<?>> tokens = YarnUtils.addDelegationTokens(config, appLocation.getLocationFactory(), credentials);
  if (LOG.isDebugEnabled()) {
   for (Token<?> token : tokens) {
    LOG.debug("Delegation token acquired for {}, {}", appLocation, token);
   }
  }
 } catch (IOException e) {
  LOG.warn("Failed to acquire delegation token for location {}", appLocation);
 }
 // Copy the user provided credentials.
 // It will override the location delegation tokens acquired above if user supplies it.
 credentials.addAll(this.credentials);
 return credentials;
}

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

/**
 * Creates a {@link Credentials} for the application submission.
 */
private Credentials createSubmissionCredentials() {
 Credentials credentials = new Credentials();
 try {
  // Acquires delegation token for the location
  List<Token<?>> tokens = YarnUtils.addDelegationTokens(config, appLocation.getLocationFactory(), credentials);
  if (LOG.isDebugEnabled()) {
   for (Token<?> token : tokens) {
    LOG.debug("Delegation token acquired for {}, {}", appLocation, token);
   }
  }
 } catch (IOException e) {
  LOG.warn("Failed to acquire delegation token for location {}", appLocation);
 }
 // Copy the user provided credentials.
 // It will override the location delegation tokens acquired above if user supplies it.
 credentials.addAll(this.credentials);
 return credentials;
}

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

@Override
 public void renew(String application, RunId runId, SecureStoreWriter secureStoreWriter) throws IOException {
  Credentials credentials = new Credentials();
  YarnUtils.addDelegationTokens(configuration, locationFactory, credentials);
  secureStoreWriter.write(YarnSecureStore.create(credentials));
 }
}

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

@Override
 public void renew(String application, RunId runId, SecureStoreWriter secureStoreWriter) throws IOException {
  Credentials credentials = new Credentials();
  YarnUtils.addDelegationTokens(configuration, locationFactory, credentials);
  secureStoreWriter.write(YarnSecureStore.create(credentials));
 }
}

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

/**
 * Creates a {@link Credentials} that contains delegation tokens of the current user for all services that CDAP uses.
 */
public Credentials createCredentials() {
 try {
  Credentials refreshedCredentials = new Credentials();
  if (User.isSecurityEnabled()) {
   YarnTokenUtils.obtainToken(yarnConf, refreshedCredentials);
  }
  if (User.isHBaseSecurityEnabled(yarnConf)) {
   HBaseTokenUtils.obtainToken(yarnConf, refreshedCredentials);
  }
  if (secureExplore) {
   HiveTokenUtils.obtainTokens(cConf, refreshedCredentials);
   JobHistoryServerTokenUtils.obtainToken(yarnConf, refreshedCredentials);
  }
  if (secureStore instanceof DelegationTokensUpdater) {
   String renewer = UserGroupInformation.getCurrentUser().getShortUserName();
   ((DelegationTokensUpdater) secureStore).addDelegationTokens(renewer, refreshedCredentials);
  }
  YarnUtils.addDelegationTokens(yarnConf, locationFactory, refreshedCredentials);
  return refreshedCredentials;
 } catch (IOException ioe) {
  throw Throwables.propagate(ioe);
 }
}

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

/**
 * Creates a {@link Credentials} that contains delegation tokens of the current user for all services that CDAP uses.
 */
public Credentials createCredentials() {
 try {
  Credentials refreshedCredentials = new Credentials();
  if (User.isSecurityEnabled()) {
   YarnTokenUtils.obtainToken(yarnConf, refreshedCredentials);
  }
  if (User.isHBaseSecurityEnabled(yarnConf)) {
   HBaseTokenUtils.obtainToken(yarnConf, refreshedCredentials);
  }
  if (secureExplore) {
   HiveTokenUtils.obtainTokens(cConf, refreshedCredentials);
   JobHistoryServerTokenUtils.obtainToken(yarnConf, refreshedCredentials);
  }
  if (secureStore instanceof DelegationTokensUpdater) {
   String renewer = UserGroupInformation.getCurrentUser().getShortUserName();
   ((DelegationTokensUpdater) secureStore).addDelegationTokens(renewer, refreshedCredentials);
  }
  YarnUtils.addDelegationTokens(yarnConf, locationFactory, refreshedCredentials);
  return refreshedCredentials;
 } catch (IOException ioe) {
  throw Throwables.propagate(ioe);
 }
}

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