当前位置: 首页>>代码示例>>Java>>正文


Java RMDelegationTokenIdentifier类代码示例

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


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

示例1: recover

import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier; //导入依赖的package包/类
@Override
public void recover(RMState rmState) throws Exception {

  LOG.info("recovering RMDelegationTokenSecretManager.");
  // recover RMDTMasterKeys
  for (DelegationKey dtKey : rmState.getRMDTSecretManagerState()
    .getMasterKeyState()) {
    addKey(dtKey);
  }

  // recover RMDelegationTokens
  Map<RMDelegationTokenIdentifier, Long> rmDelegationTokens =
      rmState.getRMDTSecretManagerState().getTokenState();
  this.delegationTokenSequenceNumber =
      rmState.getRMDTSecretManagerState().getDTSequenceNumber();
  for (Map.Entry<RMDelegationTokenIdentifier, Long> entry : rmDelegationTokens
    .entrySet()) {
    addPersistedDelegationToken(entry.getKey(), entry.getValue());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:RMDelegationTokenSecretManager.java

示例2: renewDelegationToken

import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier; //导入依赖的package包/类
@Override
public RenewDelegationTokenResponse renewDelegationToken(
    RenewDelegationTokenRequest request) throws YarnException {
  try {
    if (!isAllowedDelegationTokenOp()) {
      throw new IOException(
          "Delegation Token can be renewed only with kerberos authentication");
    }
    
    org.apache.hadoop.yarn.api.records.Token protoToken = request.getDelegationToken();
    Token<RMDelegationTokenIdentifier> token = new Token<RMDelegationTokenIdentifier>(
        protoToken.getIdentifier().array(), protoToken.getPassword().array(),
        new Text(protoToken.getKind()), new Text(protoToken.getService()));

    String user = getRenewerForToken(token);
    long nextExpTime = rmDTSecretManager.renewToken(token, user);
    RenewDelegationTokenResponse renewResponse = Records
        .newRecord(RenewDelegationTokenResponse.class);
    renewResponse.setNextExpirationTime(nextExpTime);
    return renewResponse;
  } catch (IOException e) {
    throw RPCUtil.getRemoteException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:ClientRMService.java

示例3: cancelDelegationToken

import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier; //导入依赖的package包/类
@Override
public CancelDelegationTokenResponse cancelDelegationToken(
    CancelDelegationTokenRequest request) throws YarnException {
  try {
    if (!isAllowedDelegationTokenOp()) {
      throw new IOException(
          "Delegation Token can be cancelled only with kerberos authentication");
    }
    org.apache.hadoop.yarn.api.records.Token protoToken = request.getDelegationToken();
    Token<RMDelegationTokenIdentifier> token = new Token<RMDelegationTokenIdentifier>(
        protoToken.getIdentifier().array(), protoToken.getPassword().array(),
        new Text(protoToken.getKind()), new Text(protoToken.getService()));

    String user = UserGroupInformation.getCurrentUser().getUserName();
    rmDTSecretManager.cancelToken(token, user);
    return Records.newRecord(CancelDelegationTokenResponse.class);
  } catch (IOException e) {
    throw RPCUtil.getRemoteException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:ClientRMService.java

示例4: removeRMDelegationTokenState

import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier; //导入依赖的package包/类
@Override
protected synchronized void removeRMDelegationTokenState(
    RMDelegationTokenIdentifier rmDTIdentifier) throws Exception {
  String nodeRemovePath =
      getNodePath(delegationTokensRootPath, DELEGATION_TOKEN_PREFIX
          + rmDTIdentifier.getSequenceNumber());
  if (LOG.isDebugEnabled()) {
    LOG.debug("Removing RMDelegationToken_"
        + rmDTIdentifier.getSequenceNumber());
  }
  if (existsWithRetries(nodeRemovePath, false) != null) {
    ArrayList<Op> opList = new ArrayList<Op>();
    opList.add(Op.delete(nodeRemovePath, -1));
    doDeleteMultiWithRetries(opList);
  } else {
    LOG.debug("Attempted to delete a non-existing znode " + nodeRemovePath);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:ZKRMStateStore.java

示例5: updateRMDelegationTokenState

import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier; //导入依赖的package包/类
@Override
protected synchronized void updateRMDelegationTokenState(
    RMDelegationTokenIdentifier rmDTIdentifier, Long renewDate)
    throws Exception {
  ArrayList<Op> opList = new ArrayList<Op>();
  String nodeRemovePath =
      getNodePath(delegationTokensRootPath, DELEGATION_TOKEN_PREFIX
          + rmDTIdentifier.getSequenceNumber());
  if (existsWithRetries(nodeRemovePath, false) == null) {
    // in case znode doesn't exist
    addStoreOrUpdateOps(opList, rmDTIdentifier, renewDate, false);
    LOG.debug("Attempted to update a non-existing znode " + nodeRemovePath);
  } else {
    // in case znode exists
    addStoreOrUpdateOps(opList, rmDTIdentifier, renewDate, true);
  }
  doStoreMultiWithRetries(opList);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:ZKRMStateStore.java

示例6: storeOrUpdateRMDT

import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier; //导入依赖的package包/类
private void storeOrUpdateRMDT(RMDelegationTokenIdentifier rmDTIdentifier,
    Long renewDate, boolean isUpdate) throws Exception {
  Map<RMDelegationTokenIdentifier, Long> rmDTState =
      state.rmSecretManagerState.getTokenState();
  if (rmDTState.containsKey(rmDTIdentifier)) {
    IOException e = new IOException("RMDelegationToken: " + rmDTIdentifier
        + "is already stored.");
    LOG.info("Error storing info for RMDelegationToken: " + rmDTIdentifier, e);
    throw e;
  }
  rmDTState.put(rmDTIdentifier, renewDate);
  if(!isUpdate) {
    state.rmSecretManagerState.dtSequenceNumber = 
        rmDTIdentifier.getSequenceNumber();
  }
  LOG.info("Store RMDT with sequence number "
           + rmDTIdentifier.getSequenceNumber());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:MemoryRMStateStore.java

示例7: RMDelegationTokenIdentifierForTest

import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier; //导入依赖的package包/类
public RMDelegationTokenIdentifierForTest(RMDelegationTokenIdentifier token,
    String message) {
  if (token.getOwner() != null) {
    setOwner(new Text(token.getOwner()));
  }
  if (token.getRenewer() != null) {
    setRenewer(new Text(token.getRenewer()));
  }
  if (token.getRealUser() != null) {
    setRealUser(new Text(token.getRealUser()));
  }
  setIssueDate(token.getIssueDate());
  setMaxDate(token.getMaxDate());
  setSequenceNumber(token.getSequenceNumber());
  setMasterKeyId(token.getMasterKeyId());
  builder.setMessage(message);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:RMDelegationTokenIdentifierForTest.java

示例8: assertTokenCancelled

import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier; //导入依赖的package包/类
private void assertTokenCancelled(String encodedToken) throws Exception {
  Token<RMDelegationTokenIdentifier> realToken =
      new Token<RMDelegationTokenIdentifier>();
  realToken.decodeFromUrlString(encodedToken);
  RMDelegationTokenIdentifier ident = rm.getRMContext()
    .getRMDelegationTokenSecretManager().decodeTokenIdentifier(realToken);
  boolean exceptionCaught = false;
  try {
    rm.getRMContext().getRMDelegationTokenSecretManager()
      .verifyToken(ident, realToken.getPassword());
  } catch (InvalidToken it) {
    exceptionCaught = true;
  }
  assertTrue("InvalidToken exception not thrown", exceptionCaught);
  assertFalse(rm.getRMContext().getRMDelegationTokenSecretManager()
    .getAllTokens().containsKey(ident));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestRMWebServicesDelegationTokens.java

示例9: checkTokenRenewal

import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier; //导入依赖的package包/类
private void checkTokenRenewal(UserGroupInformation owner,
    UserGroupInformation renewer) throws IOException, YarnException {
  RMDelegationTokenIdentifier tokenIdentifier =
      new RMDelegationTokenIdentifier(
          new Text(owner.getUserName()), new Text(renewer.getUserName()), null);
  Token<?> token =
      new Token<RMDelegationTokenIdentifier>(tokenIdentifier, dtsm);
  org.apache.hadoop.yarn.api.records.Token dToken = BuilderUtils.newDelegationToken(
      token.getIdentifier(), token.getKind().toString(),
      token.getPassword(), token.getService().toString());
  RenewDelegationTokenRequest request =
      Records.newRecord(RenewDelegationTokenRequest.class);
  request.setDelegationToken(dToken);

  RMContext rmContext = mock(RMContext.class);
  ClientRMService rmService = new ClientRMService(
      rmContext, null, null, null, null, dtsm);
  rmService.renewDelegationToken(request);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestClientRMService.java

示例10: checkTokenCancellation

import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier; //导入依赖的package包/类
private void checkTokenCancellation(ClientRMService rmService,
    UserGroupInformation owner, UserGroupInformation renewer)
    throws IOException, YarnException {
  RMDelegationTokenIdentifier tokenIdentifier =
      new RMDelegationTokenIdentifier(new Text(owner.getUserName()),
        new Text(renewer.getUserName()), null);
  Token<?> token =
      new Token<RMDelegationTokenIdentifier>(tokenIdentifier, dtsm);
  org.apache.hadoop.yarn.api.records.Token dToken =
      BuilderUtils.newDelegationToken(token.getIdentifier(), token.getKind()
        .toString(), token.getPassword(), token.getService().toString());
  CancelDelegationTokenRequest request =
      Records.newRecord(CancelDelegationTokenRequest.class);
  request.setDelegationToken(dToken);
  rmService.cancelDelegationToken(request);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestClientRMService.java

示例11: updateRMDelegationTokenState

import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier; //导入依赖的package包/类
@Override
protected synchronized void updateRMDelegationTokenState(
    RMDelegationTokenIdentifier rmDTIdentifier, Long renewDate)
    throws Exception {
  SafeTransaction trx = new SafeTransaction();
  String nodeRemovePath =
      getNodePath(delegationTokensRootPath, DELEGATION_TOKEN_PREFIX
          + rmDTIdentifier.getSequenceNumber());
  if (exists(nodeRemovePath)) {
    // in case znode exists
    addStoreOrUpdateOps(trx, rmDTIdentifier, renewDate, true);
  } else {
    // in case znode doesn't exist
    addStoreOrUpdateOps(trx, rmDTIdentifier, renewDate, false);
    LOG.debug("Attempted to update a non-existing znode " + nodeRemovePath);
  }
  trx.commit();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:19,代码来源:ZKRMStateStore.java

示例12: checkTokenCancellation

import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier; //导入依赖的package包/类
private void checkTokenCancellation(ClientRMService rmService,
    UserGroupInformation owner, UserGroupInformation renewer)
    throws IOException, YarnException {
  RMDelegationTokenIdentifier tokenIdentifier =
      new RMDelegationTokenIdentifier(new Text(owner.getUserName()),
          new Text(renewer.getUserName()), null);
  Token<?> token =
      new Token<RMDelegationTokenIdentifier>(tokenIdentifier, dtsm);
  org.apache.hadoop.yarn.api.records.Token dToken =
      BuilderUtils.newDelegationToken(token.getIdentifier(), token.getKind()
          .toString(), token.getPassword(), token.getService().toString());
  CancelDelegationTokenRequest request =
      Records.newRecord(CancelDelegationTokenRequest.class);
  request.setDelegationToken(dToken);
  rmService.cancelDelegationToken(request);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:17,代码来源:TestTokenClientRMService.java

示例13: storeNewToken

import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier; //导入依赖的package包/类
@Override
protected void storeNewToken(RMDelegationTokenIdentifier identifier,
    long renewDate) {
  try {
    LOG.info("storing RMDelegation token with sequence number: "
        + identifier.getSequenceNumber());
    rmContext.getStateStore().storeRMDelegationToken(identifier, renewDate);
  } catch (Exception e) {
    LOG.error("Error in storing RMDelegationToken with sequence number: "
        + identifier.getSequenceNumber());
    ExitUtil.terminate(1, e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:RMDelegationTokenSecretManager.java

示例14: updateStoredToken

import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier; //导入依赖的package包/类
@Override
protected void updateStoredToken(RMDelegationTokenIdentifier id,
    long renewDate) {
  try {
    LOG.info("updating RMDelegation token with sequence number: "
        + id.getSequenceNumber());
    rmContext.getStateStore().updateRMDelegationToken(id, renewDate);
  } catch (Exception e) {
    LOG.error("Error in updating persisted RMDelegationToken" +
              " with sequence number: " + id.getSequenceNumber());
    ExitUtil.terminate(1, e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:RMDelegationTokenSecretManager.java

示例15: removeStoredToken

import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier; //导入依赖的package包/类
@Override
protected void removeStoredToken(RMDelegationTokenIdentifier ident)
    throws IOException {
  try {
    LOG.info("removing RMDelegation token with sequence number: "
        + ident.getSequenceNumber());
    rmContext.getStateStore().removeRMDelegationToken(ident);
  } catch (Exception e) {
    LOG.error("Error in removing RMDelegationToken with sequence number: "
        + ident.getSequenceNumber());
    ExitUtil.terminate(1, e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:RMDelegationTokenSecretManager.java


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