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


Java GetDelegationTokenResponse.getRMDelegationToken方法代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse.getRMDelegationToken方法的典型用法代码示例。如果您正苦于以下问题:Java GetDelegationTokenResponse.getRMDelegationToken方法的具体用法?Java GetDelegationTokenResponse.getRMDelegationToken怎么用?Java GetDelegationTokenResponse.getRMDelegationToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse的用法示例。


在下文中一共展示了GetDelegationTokenResponse.getRMDelegationToken方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRMDelegationToken

import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse; //导入方法依赖的package包/类
@Override
public Token getRMDelegationToken(Text renewer)
    throws YarnException, IOException {
  /* get the token from RM */
  GetDelegationTokenRequest rmDTRequest =
      Records.newRecord(GetDelegationTokenRequest.class);
  rmDTRequest.setRenewer(renewer.toString());
  GetDelegationTokenResponse response =
      rmClient.getDelegationToken(rmDTRequest);
  return response.getRMDelegationToken();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:YarnClientImpl.java

示例2: testRMDTMasterKeyStateOnRollingMasterKey

import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse; //导入方法依赖的package包/类
@Test(timeout = 15000)
public void testRMDTMasterKeyStateOnRollingMasterKey() throws Exception {
  MemoryRMStateStore memStore = new MemoryRMStateStore();
  memStore.init(conf);
  RMState rmState = memStore.getState();

  Map<RMDelegationTokenIdentifier, Long> rmDTState =
      rmState.getRMDTSecretManagerState().getTokenState();
  Set<DelegationKey> rmDTMasterKeyState =
      rmState.getRMDTSecretManagerState().getMasterKeyState();

  MockRM rm1 = new MyMockRM(conf, memStore);
  rm1.start();
  // on rm start, two master keys are created.
  // One is created at RMDTSecretMgr.startThreads.updateCurrentKey();
  // the other is created on the first run of
  // tokenRemoverThread.rollMasterKey()

  RMDelegationTokenSecretManager dtSecretManager =
      rm1.getRMContext().getRMDelegationTokenSecretManager();
  // assert all master keys are saved
  Assert.assertEquals(dtSecretManager.getAllMasterKeys(), rmDTMasterKeyState);
  Set<DelegationKey> expiringKeys = new HashSet<DelegationKey>();
  expiringKeys.addAll(dtSecretManager.getAllMasterKeys());


  // request to generate a RMDelegationToken
  GetDelegationTokenRequest request = mock(GetDelegationTokenRequest.class);
  when(request.getRenewer()).thenReturn("renewer1");
  GetDelegationTokenResponse response =
      rm1.getClientRMService().getDelegationToken(request);
  org.apache.hadoop.yarn.api.records.Token delegationToken =
      response.getRMDelegationToken();
  Token<RMDelegationTokenIdentifier> token1 =
      ConverterUtils.convertFromYarn(delegationToken, (Text) null);
  RMDelegationTokenIdentifier dtId1 = token1.decodeIdentifier();

  // For all keys that still remain in memory, we should have them stored
  // in state-store also.
  while (((TestRMDelegationTokenSecretManager) dtSecretManager).numUpdatedKeys
    .get() < 3) {
    ((TestRMDelegationTokenSecretManager) dtSecretManager)
      .checkCurrentKeyInStateStore(rmDTMasterKeyState);
    Thread.sleep(100);
  }

  // wait for token to expire and remove from state-store
  // rollMasterKey is called every 1 second.
  int count = 0;
  while (rmDTState.containsKey(dtId1) && count < 100) {
    Thread.sleep(100);
    count++;
  }
  rm1.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:56,代码来源:TestRMDelegationTokens.java

示例3: testRMDTMasterKeyStateOnRollingMasterKey

import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse; //导入方法依赖的package包/类
@Test(timeout = 15000)
public void testRMDTMasterKeyStateOnRollingMasterKey() throws Exception {
  Configuration conf = new Configuration();
  conf.set("hadoop.security.authentication", "kerberos");
  UserGroupInformation.setConfiguration(conf);
  MemoryRMStateStore memStore = new MemoryRMStateStore();
  memStore.init(conf);
  RMState rmState = memStore.getState();

  Map<RMDelegationTokenIdentifier, Long> rmDTState =
      rmState.getRMDTSecretManagerState().getTokenState();
  Set<DelegationKey> rmDTMasterKeyState =
      rmState.getRMDTSecretManagerState().getMasterKeyState();

  MockRM rm1 = new MyMockRM(conf, memStore);
  rm1.start();
  // on rm start, two master keys are created.
  // One is created at RMDTSecretMgr.startThreads.updateCurrentKey();
  // the other is created on the first run of
  // tokenRemoverThread.rollMasterKey()

  RMDelegationTokenSecretManager dtSecretManager =
      rm1.getRMContext().getRMDelegationTokenSecretManager();
  // assert all master keys are saved
  Assert.assertEquals(dtSecretManager.getAllMasterKeys(), rmDTMasterKeyState);
  Set<DelegationKey> expiringKeys = new HashSet<DelegationKey>();
  expiringKeys.addAll(dtSecretManager.getAllMasterKeys());


  // request to generate a RMDelegationToken
  GetDelegationTokenRequest request = mock(GetDelegationTokenRequest.class);
  when(request.getRenewer()).thenReturn("renewer1");
  GetDelegationTokenResponse response =
      rm1.getClientRMService().getDelegationToken(request);
  org.apache.hadoop.yarn.api.records.Token delegationToken =
      response.getRMDelegationToken();
  Token<RMDelegationTokenIdentifier> token1 =
      ConverterUtils.convertFromYarn(delegationToken, (Text) null);
  RMDelegationTokenIdentifier dtId1 = token1.decodeIdentifier();

  // For all keys that still remain in memory, we should have them stored
  // in state-store also.
  while (((TestRMDelegationTokenSecretManager) dtSecretManager).numUpdatedKeys
    .get() < 3) {
    ((TestRMDelegationTokenSecretManager) dtSecretManager)
      .checkCurrentKeyInStateStore(rmDTMasterKeyState);
    Thread.sleep(100);
  }

  // wait for token to expire and remove from state-store
  // rollMasterKey is called every 1 second.
  int count = 0;
  while (rmDTState.containsKey(dtId1) && count < 100) {
    Thread.sleep(100);
    count++;
  }
  rm1.stop();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:59,代码来源:TestRMDelegationTokens.java

示例4: testRMDTMasterKeyStateOnRollingMasterKey

import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse; //导入方法依赖的package包/类
@Test(timeout = 15000)
public void testRMDTMasterKeyStateOnRollingMasterKey() throws Exception {
  MemoryRMStateStore memStore = new MemoryRMStateStore();
  memStore.init(conf);
  RMState rmState = memStore.getState();

  Map<RMDelegationTokenIdentifier, Long> rmDTState =
      rmState.getRMDTSecretManagerState().getTokenState();
  Set<DelegationKey> rmDTMasterKeyState =
      rmState.getRMDTSecretManagerState().getMasterKeyState();

  MockRM rm1 = new MyMockRM(conf, memStore);
  rm1.start();
  // on rm start, two master keys are created.
  // One is created at RMDTSecretMgr.startThreads.updateCurrentKey();
  // the other is created on the first run of
  // tokenRemoverThread.rollMasterKey()

  RMDelegationTokenSecretManager dtSecretManager = rm1.getRMDTSecretManager();
  // assert all master keys are saved
  Assert.assertEquals(dtSecretManager.getAllMasterKeys(), rmDTMasterKeyState);
  Set<DelegationKey> expiringKeys = new HashSet<DelegationKey>();
  expiringKeys.addAll(dtSecretManager.getAllMasterKeys());

  // record the current key
  DelegationKey oldCurrentKey =
      ((TestRMDelegationTokenSecretManager) dtSecretManager).getCurrentKey();

  // request to generate a RMDelegationToken
  GetDelegationTokenRequest request = mock(GetDelegationTokenRequest.class);
  when(request.getRenewer()).thenReturn("renewer1");
  GetDelegationTokenResponse response =
      rm1.getClientRMService().getDelegationToken(request);
  org.apache.hadoop.yarn.api.records.Token delegationToken =
      response.getRMDelegationToken();
  Token<RMDelegationTokenIdentifier> token1 =
      ConverterUtils.convertFromYarn(delegationToken, null);
  RMDelegationTokenIdentifier dtId1 = token1.decodeIdentifier();

  // wait for the first rollMasterKey
  while (((TestRMDelegationTokenSecretManager) dtSecretManager).numUpdatedKeys
    .get() < 1){
    Thread.sleep(200);
  }

  // assert old-current-key and new-current-key exist
  Assert.assertTrue(rmDTMasterKeyState.contains(oldCurrentKey));
  DelegationKey newCurrentKey =
      ((TestRMDelegationTokenSecretManager) dtSecretManager).getCurrentKey();
  Assert.assertTrue(rmDTMasterKeyState.contains(newCurrentKey));

  // wait for token to expire
  // rollMasterKey is called every 1 second.
  while (((TestRMDelegationTokenSecretManager) dtSecretManager).numUpdatedKeys
    .get() < 6) {
    Thread.sleep(200);
  }

  Assert.assertFalse(rmDTState.containsKey(dtId1));
  rm1.stop();
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:62,代码来源:TestRMDelegationTokens.java

示例5: testRMDTMasterKeyStateOnRollingMasterKey

import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse; //导入方法依赖的package包/类
@Test(timeout = 1500000)
public void testRMDTMasterKeyStateOnRollingMasterKey() throws Exception {
  Configuration conf = new Configuration(this.conf);
  conf.set("hadoop.security.authentication", "kerberos");
  UserGroupInformation.setLoginUser(null);
  UserGroupInformation.setConfiguration(conf);

  MockRM rm1 = new MyMockRM(conf);
  rm1.start();
  // on rm start, two master keys are created.
  // One is created at RMDTSecretMgr.startThreads.updateCurrentKey();
  // the other is created on the first run of
  // tokenRemoverThread.rollMasterKey()

  RMDelegationTokenSecretManager dtSecretManager =
      rm1.getRMContext().getRMDelegationTokenSecretManager();
  // assert all master keys are saved
  RMState rmState = rm1.getRMContext().getStateStore().loadState();
  Set<DelegationKey> rmDTMasterKeyState =
      rmState.getRMDTSecretManagerState().getMasterKeyState();
  for(DelegationKey expectedKey:dtSecretManager.getAllMasterKeys()){
    boolean foundIt=false;
    for(DelegationKey gotKey:rmDTMasterKeyState){
      if(expectedKey.getKeyId()== gotKey.getKeyId() &&
              Arrays.equals(expectedKey.getEncodedKey(),gotKey.getEncodedKey())){
        foundIt=true;
        break;
      }
    }
    Assert.assertTrue(foundIt);
  }

  // request to generate a RMDelegationToken
  GetDelegationTokenRequest request = mock(GetDelegationTokenRequest.class);
  when(request.getRenewer()).thenReturn("renewer1");
  GetDelegationTokenResponse response =
      rm1.getClientRMService().getDelegationToken(request);
  org.apache.hadoop.yarn.api.records.Token delegationToken =
      response.getRMDelegationToken();
  Token<RMDelegationTokenIdentifier> token1 =
      ConverterUtils.convertFromYarn(delegationToken, (Text) null);
  RMDelegationTokenIdentifier dtId1 = token1.decodeIdentifier();

  // For all keys that still remain in memory, we should have them stored
  // in state-store also.
  while (((TestRMDelegationTokenSecretManager) dtSecretManager).numUpdatedKeys
          .get() < 3) {
    do {
      rmState = rm1.getRMContext().getStateStore().loadState();
      rmDTMasterKeyState = rmState.getRMDTSecretManagerState().
              getMasterKeyState();
    } while (rmDTMasterKeyState == null);
    ((TestRMDelegationTokenSecretManager) dtSecretManager)
            .checkCurrentKeyInStateStore(rmDTMasterKeyState);
    Thread.sleep(100);
  }

  // wait for token to expire and remove from state-store
  // rollMasterKey is called every 1 second.
  int count = 0;
  rmState = rm1.getRMContext().getStateStore().loadState();
  Map<RMDelegationTokenIdentifier, Long> rmDTState =
      rmState.getRMDTSecretManagerState().getTokenState();
  while (rmDTState.containsKey(dtId1) && count < 100) {
    Thread.sleep(100);
    count++;
  }
  rm1.stop();
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:70,代码来源:TestRMDelegationTokens.java

示例6: testRMDTMasterKeyStateOnRollingMasterKey

import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse; //导入方法依赖的package包/类
@Test(timeout = 15000)
public void testRMDTMasterKeyStateOnRollingMasterKey() throws Exception {
  MemoryRMStateStore memStore = new MemoryRMStateStore();
  memStore.init(conf);
  RMState rmState = memStore.getState();

  Map<RMDelegationTokenIdentifier, Long> rmDTState =
      rmState.getRMDTSecretManagerState().getTokenState();
  Set<DelegationKey> rmDTMasterKeyState =
      rmState.getRMDTSecretManagerState().getMasterKeyState();

  MockRM rm1 = new MyMockRM(conf, memStore);
  rm1.start();
  // on rm start, two master keys are created.
  // One is created at RMDTSecretMgr.startThreads.updateCurrentKey();
  // the other is created on the first run of
  // tokenRemoverThread.rollMasterKey()

  RMDelegationTokenSecretManager dtSecretManager =
      rm1.getRMContext().getRMDelegationTokenSecretManager();
  // assert all master keys are saved
  Assert.assertEquals(dtSecretManager.getAllMasterKeys(), rmDTMasterKeyState);
  Set<DelegationKey> expiringKeys = new HashSet<DelegationKey>();
  expiringKeys.addAll(dtSecretManager.getAllMasterKeys());

  // record the current key
  DelegationKey oldCurrentKey =
      ((TestRMDelegationTokenSecretManager) dtSecretManager).getCurrentKey();

  // request to generate a RMDelegationToken
  GetDelegationTokenRequest request = mock(GetDelegationTokenRequest.class);
  when(request.getRenewer()).thenReturn("renewer1");
  GetDelegationTokenResponse response =
      rm1.getClientRMService().getDelegationToken(request);
  org.apache.hadoop.yarn.api.records.Token delegationToken =
      response.getRMDelegationToken();
  Token<RMDelegationTokenIdentifier> token1 =
      ConverterUtils.convertFromYarn(delegationToken, (Text) null);
  RMDelegationTokenIdentifier dtId1 = token1.decodeIdentifier();

  // wait for the first rollMasterKey
  while (((TestRMDelegationTokenSecretManager) dtSecretManager).numUpdatedKeys
    .get() < 1){
    Thread.sleep(200);
  }

  // assert old-current-key and new-current-key exist
  Assert.assertTrue(rmDTMasterKeyState.contains(oldCurrentKey));
  DelegationKey newCurrentKey =
      ((TestRMDelegationTokenSecretManager) dtSecretManager).getCurrentKey();
  Assert.assertTrue(rmDTMasterKeyState.contains(newCurrentKey));

  // wait for token to expire
  // rollMasterKey is called every 1 second.
  while (((TestRMDelegationTokenSecretManager) dtSecretManager).numUpdatedKeys
    .get() < 6) {
    Thread.sleep(200);
  }

  Assert.assertFalse(rmDTState.containsKey(dtId1));
  rm1.stop();
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:63,代码来源:TestRMDelegationTokens.java


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