• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TimelineDelegationTokenIdentifier类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier的典型用法代码示例。如果您正苦于以下问题:Java TimelineDelegationTokenIdentifier类的具体用法?Java TimelineDelegationTokenIdentifier怎么用?Java TimelineDelegationTokenIdentifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TimelineDelegationTokenIdentifier类属于org.apache.hadoop.yarn.security.client包,在下文中一共展示了TimelineDelegationTokenIdentifier类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getDelegationToken

import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Token<TimelineDelegationTokenIdentifier> getDelegationToken(
    final String renewer) throws IOException, YarnException {
  PrivilegedExceptionAction<Token<TimelineDelegationTokenIdentifier>> getDTAction =
      new PrivilegedExceptionAction<Token<TimelineDelegationTokenIdentifier>>() {

        @Override
        public Token<TimelineDelegationTokenIdentifier> run()
            throws Exception {
          DelegationTokenAuthenticatedURL authUrl =
              new DelegationTokenAuthenticatedURL(authenticator,
                  connConfigurator);
          return (Token) authUrl.getDelegationToken(
              resURI.toURL(), token, renewer, doAsUser);
        }
      };
  return (Token<TimelineDelegationTokenIdentifier>) operateDelegationToken(getDTAction);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TimelineClientImpl.java


示例2: cancelDelegationToken

import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void cancelDelegationToken(
    final Token<TimelineDelegationTokenIdentifier> timelineDT)
        throws IOException, YarnException {
  final boolean isTokenServiceAddrEmpty =
      timelineDT.getService().toString().isEmpty();
  final String scheme = isTokenServiceAddrEmpty ? null
      : (YarnConfiguration.useHttps(this.getConfig()) ? "https" : "http");
  final InetSocketAddress address = isTokenServiceAddrEmpty ? null
      : SecurityUtil.getTokenServiceAddr(timelineDT);
  PrivilegedExceptionAction<Void> cancelDTAction =
      new PrivilegedExceptionAction<Void>() {

        @Override
        public Void run() throws Exception {
          // If the timeline DT to cancel is different than cached, replace it.
          // Token to set every time for retry, because when exception happens,
          // DelegationTokenAuthenticatedURL will reset it to null;
          if (!timelineDT.equals(token.getDelegationToken())) {
            token.setDelegationToken((Token) timelineDT);
          }
          DelegationTokenAuthenticatedURL authUrl =
              new DelegationTokenAuthenticatedURL(authenticator,
                  connConfigurator);
          // If the token service address is not available, fall back to use
          // the configured service address.
          final URI serviceURI = isTokenServiceAddrEmpty ? resURI
              : new URI(scheme, null, address.getHostName(),
              address.getPort(), RESOURCE_URI_STR, null, null);
          authUrl.cancelDelegationToken(serviceURI.toURL(), token, doAsUser);
          return null;
        }
      };
  operateDelegationToken(cancelDTAction);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:37,代码来源:TimelineClientImpl.java


示例3: storeToken

import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; //导入依赖的package包/类
@Override
public void storeToken(TimelineDelegationTokenIdentifier tokenId,
    Long renewDate) throws IOException {
  DataOutputStream ds = null;
  WriteBatch batch = null;
  try {
    byte[] k = createTokenEntryKey(tokenId.getSequenceNumber());
    if (db.get(k) != null) {
      throw new IOException(tokenId + " already exists");
    }
    byte[] v = buildTokenData(tokenId, renewDate);
    ByteArrayOutputStream bs = new ByteArrayOutputStream();
    ds = new DataOutputStream(bs);
    ds.writeInt(tokenId.getSequenceNumber());
    batch = db.createWriteBatch();
    batch.put(k, v);
    batch.put(LATEST_SEQUENCE_NUMBER_KEY, bs.toByteArray());
    db.write(batch);
  } catch (DBException e) {
    throw new IOException(e);
  } finally {
    IOUtils.cleanup(LOG, ds);
    IOUtils.cleanup(LOG, batch);
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:26,代码来源:LeveldbTimelineStateStore.java


示例4: getDelegationToken

import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Token<TimelineDelegationTokenIdentifier> getDelegationToken(
    final String renewer) throws IOException, YarnException {
  boolean isProxyAccess =
      UserGroupInformation.getCurrentUser().getAuthenticationMethod()
      == UserGroupInformation.AuthenticationMethod.PROXY;
  final String doAsUser = isProxyAccess ?
      UserGroupInformation.getCurrentUser().getShortUserName() : null;
  PrivilegedExceptionAction<Token<TimelineDelegationTokenIdentifier>> getDTAction =
      new PrivilegedExceptionAction<Token<TimelineDelegationTokenIdentifier>>() {

        @Override
        public Token<TimelineDelegationTokenIdentifier> run()
            throws Exception {
          DelegationTokenAuthenticatedURL authUrl =
              new DelegationTokenAuthenticatedURL(authenticator,
                  connConfigurator);
          return (Token) authUrl.getDelegationToken(
              resURI.toURL(), token, renewer, doAsUser);
        }
      };
  return (Token<TimelineDelegationTokenIdentifier>) operateDelegationToken(getDTAction);
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:25,代码来源:TimelineClientImpl.java


示例5: renewDelegationToken

import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public long renewDelegationToken(
    final Token<TimelineDelegationTokenIdentifier> timelineDT)
        throws IOException, YarnException {
  final boolean isTokenServiceAddrEmpty =
      timelineDT.getService().toString().isEmpty();
  final String scheme = isTokenServiceAddrEmpty ? null
      : (YarnConfiguration.useHttps(this.getConfig()) ? "https" : "http");
  final InetSocketAddress address = isTokenServiceAddrEmpty ? null
      : SecurityUtil.getTokenServiceAddr(timelineDT);
  PrivilegedExceptionAction<Long> renewDTAction =
      new PrivilegedExceptionAction<Long>() {

        @Override
        public Long run() throws Exception {
          // If the timeline DT to renew is different than cached, replace it.
          // Token to set every time for retry, because when exception happens,
          // DelegationTokenAuthenticatedURL will reset it to null;
          if (!timelineDT.equals(token.getDelegationToken())) {
            token.setDelegationToken((Token) timelineDT);
          }
          DelegationTokenAuthenticatedURL authUrl =
              new DelegationTokenAuthenticatedURL(authenticator,
                  connConfigurator);
          // If the token service address is not available, fall back to use
          // the configured service address.
          final URI serviceURI = isTokenServiceAddrEmpty ? resURI
              : new URI(scheme, null, address.getHostName(),
              address.getPort(), RESOURCE_URI_STR, null, null);
          return authUrl
              .renewDelegationToken(serviceURI.toURL(), token, doAsUser);
        }
      };
  return (Long) operateDelegationToken(renewDTAction);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:37,代码来源:TimelineClientImpl.java


示例6: testParseTimelineDelegationTokenIdentifierRenewer

import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; //导入依赖的package包/类
@Test
public void testParseTimelineDelegationTokenIdentifierRenewer() throws IOException {
  // Server side when generation a timeline DT
  Configuration conf = new YarnConfiguration();
  conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTH_TO_LOCAL,
      "RULE:[2:[email protected]$0]([nr][email protected]*EXAMPLE.COM)s/.*/yarn/");
  HadoopKerberosName.setConfiguration(conf);
  Text owner = new Text("owner");
  Text renewer = new Text("rm/[email protected]");
  Text realUser = new Text("realUser");
  TimelineDelegationTokenIdentifier token =
      new TimelineDelegationTokenIdentifier(owner, renewer, realUser);
  Assert.assertEquals(new Text("yarn"), token.getRenewer());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:TestYARNTokenIdentifier.java


示例7: storeNewToken

import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; //导入依赖的package包/类
@Override
protected void storeNewToken(TimelineDelegationTokenIdentifier tokenId,
    long renewDate) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Storing token " + tokenId.getSequenceNumber());
  }
  try {
    if (stateStore != null) {
      stateStore.storeToken(tokenId, renewDate);
    }
  } catch (IOException e) {
    LOG.error("Unable to store token " + tokenId.getSequenceNumber(), e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:TimelineDelegationTokenSecretManagerService.java


示例8: removeStoredToken

import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; //导入依赖的package包/类
@Override
protected void removeStoredToken(TimelineDelegationTokenIdentifier tokenId)
    throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Storing token " + tokenId.getSequenceNumber());
  }
  try {
    if (stateStore != null) {
      stateStore.removeToken(tokenId);
    }
  } catch (IOException e) {
    LOG.error("Unable to remove token " + tokenId.getSequenceNumber(), e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:TimelineDelegationTokenSecretManagerService.java


示例9: updateStoredToken

import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; //导入依赖的package包/类
@Override
protected void updateStoredToken(TimelineDelegationTokenIdentifier tokenId,
    long renewDate) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Updating token " + tokenId.getSequenceNumber());
  }
  try {
    if (stateStore != null) {
      stateStore.updateToken(tokenId, renewDate);
    }
  } catch (IOException e) {
    LOG.error("Unable to update token " + tokenId.getSequenceNumber(), e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:TimelineDelegationTokenSecretManagerService.java


示例10: recover

import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; //导入依赖的package包/类
public void recover(TimelineServiceState state) throws IOException {
  LOG.info("Recovering " + getClass().getSimpleName());
  for (DelegationKey key : state.getTokenMasterKeyState()) {
    addKey(key);
  }
  this.delegationTokenSequenceNumber = state.getLatestSequenceNumber();
  for (Entry<TimelineDelegationTokenIdentifier, Long> entry :
      state.getTokenState().entrySet()) {
    addPersistedDelegationToken(entry.getKey(), entry.getValue());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:TimelineDelegationTokenSecretManagerService.java


示例11: getTokenIdentifier

import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; //导入依赖的package包/类
public TimelineDelegationTokenIdentifier getTokenIdentifier()
    throws IOException {
  ByteArrayInputStream in =
      new ByteArrayInputStream(builder.getTokenIdentifier().toByteArray());
  TimelineDelegationTokenIdentifier identifer =
      new TimelineDelegationTokenIdentifier();
  identifer.readFields(new DataInputStream(in));
  return identifer;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:TimelineDelegationTokenIdentifierData.java


示例12: updateToken

import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; //导入依赖的package包/类
@Override
public void updateToken(TimelineDelegationTokenIdentifier tokenId,
    Long renewDate) throws IOException {
  try {
    byte[] k = createTokenEntryKey(tokenId.getSequenceNumber());
    if (db.get(k) == null) {
      throw new IOException(tokenId + " doesn't exist");
    }
    byte[] v = buildTokenData(tokenId, renewDate);
    db.put(k, v);
  } catch (DBException e) {
    throw new IOException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:LeveldbTimelineStateStore.java


示例13: removeToken

import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; //导入依赖的package包/类
@Override
public void removeToken(TimelineDelegationTokenIdentifier tokenId)
    throws IOException {
  try {
    byte[] key = createTokenEntryKey(tokenId.getSequenceNumber());
    db.delete(key);
  } catch (DBException e) {
    throw new IOException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:LeveldbTimelineStateStore.java


示例14: buildTokenData

import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; //导入依赖的package包/类
private static byte[] buildTokenData(
    TimelineDelegationTokenIdentifier tokenId, Long renewDate)
    throws IOException {
  TimelineDelegationTokenIdentifierData data =
      new TimelineDelegationTokenIdentifierData(tokenId, renewDate);
  return data.toByteArray();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:8,代码来源:LeveldbTimelineStateStore.java


示例15: storeToken

import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; //导入依赖的package包/类
@Override
public void storeToken(TimelineDelegationTokenIdentifier tokenId,
    Long renewDate) throws IOException {
  if (state.tokenState.containsKey(tokenId)) {
    throw new IOException("token " + tokenId + " was stored twice");
  }
  state.tokenState.put(tokenId, renewDate);
  state.latestSequenceNumber = tokenId.getSequenceNumber();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:MemoryTimelineStateStore.java


示例16: updateToken

import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; //导入依赖的package包/类
@Override
public void updateToken(TimelineDelegationTokenIdentifier tokenId,
    Long renewDate) throws IOException {
  if (!state.tokenState.containsKey(tokenId)) {
    throw new IOException("token " + tokenId + " not in store");
  }
  state.tokenState.put(tokenId, renewDate);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:MemoryTimelineStateStore.java


示例17: addTimelineDelegationToken

import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; //导入依赖的package包/类
private void addTimelineDelegationToken(
    ContainerLaunchContext clc) throws YarnException, IOException {
  Credentials credentials = new Credentials();
  DataInputByteBuffer dibb = new DataInputByteBuffer();
  ByteBuffer tokens = clc.getTokens();
  if (tokens != null) {
    dibb.reset(tokens);
    credentials.readTokenStorageStream(dibb);
    tokens.rewind();
  }
  // If the timeline delegation token is already in the CLC, no need to add
  // one more
  for (org.apache.hadoop.security.token.Token<? extends TokenIdentifier> token : credentials
      .getAllTokens()) {
    if (token.getKind().equals(TimelineDelegationTokenIdentifier.KIND_NAME)) {
      return;
    }
  }
  org.apache.hadoop.security.token.Token<TimelineDelegationTokenIdentifier>
      timelineDelegationToken = getTimelineDelegationToken();
  if (timelineDelegationToken == null) {
    return;
  }
  credentials.addToken(timelineService, timelineDelegationToken);
  if (LOG.isDebugEnabled()) {
    LOG.debug("Add timline delegation token into credentials: "
        + timelineDelegationToken);
  }
  DataOutputBuffer dob = new DataOutputBuffer();
  credentials.writeTokenStorageToStream(dob);
  tokens = ByteBuffer.wrap(dob.getData(), 0, dob.getLength());
  clc.setTokens(tokens);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:34,代码来源:YarnClientImpl.java


示例18: getTimelineDelegationToken

import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; //导入依赖的package包/类
@VisibleForTesting
org.apache.hadoop.security.token.Token<TimelineDelegationTokenIdentifier>
    getTimelineDelegationToken() throws IOException, YarnException {
      try {
        return timelineClient.getDelegationToken(timelineDTRenewer);
      } catch (Exception e ) {
        if (timelineServiceBestEffort) {
          LOG.warn("Failed to get delegation token from the timeline server: "
              + e.getMessage());
          return null;
        }
        throw e;
      }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:YarnClientImpl.java



注:本文中的org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AsyncProvider类代码示例发布时间:2022-05-22
下一篇:
Java SaslDataTransferClient类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap