當前位置: 首頁>>代碼示例>>Java>>正文


Java ConverterUtils.convertFromYarn方法代碼示例

本文整理匯總了Java中org.apache.hadoop.yarn.util.ConverterUtils.convertFromYarn方法的典型用法代碼示例。如果您正苦於以下問題:Java ConverterUtils.convertFromYarn方法的具體用法?Java ConverterUtils.convertFromYarn怎麽用?Java ConverterUtils.convertFromYarn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.yarn.util.ConverterUtils的用法示例。


在下文中一共展示了ConverterUtils.convertFromYarn方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: newProxy

import org.apache.hadoop.yarn.util.ConverterUtils; //導入方法依賴的package包/類
@Private
@VisibleForTesting
protected ContainerManagementProtocol newProxy(final YarnRPC rpc,
    String containerManagerBindAddr, ContainerId containerId, Token token)
    throws InvalidToken {

  if (token == null) {
    throw new InvalidToken("No NMToken sent for "
        + containerManagerBindAddr);
  }
  
  final InetSocketAddress cmAddr =
      NetUtils.createSocketAddr(containerManagerBindAddr);
  LOG.info("Opening proxy : " + containerManagerBindAddr);
  // the user in createRemoteUser in this context has to be ContainerID
  UserGroupInformation user =
      UserGroupInformation.createRemoteUser(containerId
          .getApplicationAttemptId().toString());

  org.apache.hadoop.security.token.Token<NMTokenIdentifier> nmToken =
      ConverterUtils.convertFromYarn(token, cmAddr);
  user.addToken(nmToken);

  return NMProxy.createNMProxy(conf, ContainerManagementProtocol.class,
    user, rpc, cmAddr);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:27,代碼來源:ContainerManagementProtocolProxy.java

示例2: getDelegationTokenFromHS

import org.apache.hadoop.yarn.util.ConverterUtils; //導入方法依賴的package包/類
@VisibleForTesting
Token<?> getDelegationTokenFromHS(MRClientProtocol hsProxy) throws IOException, InterruptedException {
	GetDelegationTokenRequest request = recordFactory.newRecordInstance(GetDelegationTokenRequest.class);
	request.setRenewer(Master.getMasterPrincipal(conf));
	org.apache.hadoop.yarn.api.records.Token mrDelegationToken;
	mrDelegationToken = hsProxy.getDelegationToken(request).getDelegationToken();
	return ConverterUtils.convertFromYarn(mrDelegationToken, hsProxy.getConnectAddress());
}
 
開發者ID:liuhaozzu,項目名稱:big_data,代碼行數:9,代碼來源:YARNRunner.java

示例3: testAppSubmissionWithOldDelegationTokenAfterRMRestart

import org.apache.hadoop.yarn.util.ConverterUtils; //導入方法依賴的package包/類
@Test (timeout = 60000)
public void testAppSubmissionWithOldDelegationTokenAfterRMRestart()
    throws Exception {
  conf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS, 2);
  conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION,
      "kerberos");
  conf.set(YarnConfiguration.RM_ADDRESS, "localhost:8032");
  UserGroupInformation.setConfiguration(conf);
  MemoryRMStateStore memStore = new MemoryRMStateStore();
  memStore.init(conf);

  MockRM rm1 = new TestSecurityMockRM(conf, memStore);
  rm1.start();

  GetDelegationTokenRequest request1 =
      GetDelegationTokenRequest.newInstance("renewer1");
  UserGroupInformation.getCurrentUser().setAuthenticationMethod(
      AuthMethod.KERBEROS);
  GetDelegationTokenResponse response1 =
      rm1.getClientRMService().getDelegationToken(request1);
  Token<RMDelegationTokenIdentifier> token1 =
      ConverterUtils.convertFromYarn(response1.getRMDelegationToken(), rmAddr);

  // start new RM
  MockRM rm2 = new TestSecurityMockRM(conf, memStore);
  rm2.start();

  // submit an app with the old delegation token got from previous RM.
  Credentials ts = new Credentials();
  ts.addToken(token1.getService(), token1);
  RMApp app = rm2.submitApp(200, "name", "user",
      new HashMap<ApplicationAccessType, String>(), false, "default", 1, ts);
  rm2.waitForState(app.getApplicationId(), RMAppState.ACCEPTED);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:35,代碼來源:TestRMRestart.java

示例4: getDelegationToken

import org.apache.hadoop.yarn.util.ConverterUtils; //導入方法依賴的package包/類
@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);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:11,代碼來源:ResourceMgrDelegate.java

示例5: getDelegationTokenFromHS

import org.apache.hadoop.yarn.util.ConverterUtils; //導入方法依賴的package包/類
@VisibleForTesting
Token<?> getDelegationTokenFromHS(MRClientProtocol hsProxy)
    throws IOException, InterruptedException {
  GetDelegationTokenRequest request = recordFactory
    .newRecordInstance(GetDelegationTokenRequest.class);
  request.setRenewer(Master.getMasterPrincipal(conf));
  org.apache.hadoop.yarn.api.records.Token mrDelegationToken;
  mrDelegationToken = hsProxy.getDelegationToken(request)
      .getDelegationToken();
  return ConverterUtils.convertFromYarn(mrDelegationToken,
      hsProxy.getConnectAddress());
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:13,代碼來源:YARNRunner.java

示例6: getNMTokenId

import org.apache.hadoop.yarn.util.ConverterUtils; //導入方法依賴的package包/類
private NMTokenIdentifier getNMTokenId(
    org.apache.hadoop.yarn.api.records.Token token) throws IOException {
  Token<NMTokenIdentifier> convertedToken =
      ConverterUtils.convertFromYarn(token, (Text) null);
  return convertedToken.decodeIdentifier();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:7,代碼來源:TestNMTokenSecretManagerInNM.java

示例7: testNMProxyRetry

import org.apache.hadoop.yarn.util.ConverterUtils; //導入方法依賴的package包/類
@Test(timeout = 20000)
public void testNMProxyRetry() throws Exception {
  containerManager.start();
  containerManager.setBlockNewContainerRequests(false);
  StartContainersRequest allRequests =
      Records.newRecord(StartContainersRequest.class);
  ApplicationId appId = ApplicationId.newInstance(1, 1);
  ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(appId, 1);

  org.apache.hadoop.yarn.api.records.Token nmToken =
      context.getNMTokenSecretManager().createNMToken(attemptId,
        context.getNodeId(), user);
  final InetSocketAddress address =
      conf.getSocketAddr(YarnConfiguration.NM_BIND_HOST,
        YarnConfiguration.NM_ADDRESS, YarnConfiguration.DEFAULT_NM_ADDRESS,
        YarnConfiguration.DEFAULT_NM_PORT);
  Token<NMTokenIdentifier> token =
      ConverterUtils.convertFromYarn(nmToken,
        SecurityUtil.buildTokenService(address));
  UserGroupInformation ugi = UserGroupInformation.createRemoteUser(user);
  ugi.addToken(token);

  ContainerManagementProtocol proxy =
      NMProxy.createNMProxy(conf, ContainerManagementProtocol.class, ugi,
        YarnRPC.create(conf), address);

  retryCount = 0;
  shouldThrowNMNotYetReadyException = false;
  proxy.startContainers(allRequests);
  Assert.assertEquals(5, retryCount);

  retryCount = 0;
  shouldThrowNMNotYetReadyException = false;
  proxy.stopContainers(Records.newRecord(StopContainersRequest.class));
  Assert.assertEquals(5, retryCount);

  retryCount = 0;
  shouldThrowNMNotYetReadyException = false;
  proxy.getContainerStatuses(Records
    .newRecord(GetContainerStatusesRequest.class));
  Assert.assertEquals(5, retryCount);

  retryCount = 0;
  shouldThrowNMNotYetReadyException = true;
  proxy.startContainers(allRequests);
  Assert.assertEquals(5, retryCount);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:48,代碼來源:TestNMProxy.java

示例8: testRMDTMasterKeyStateOnRollingMasterKey

import org.apache.hadoop.yarn.util.ConverterUtils; //導入方法依賴的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


注:本文中的org.apache.hadoop.yarn.util.ConverterUtils.convertFromYarn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。