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


Java MockRM.finishAMAndVerifyAppState方法代码示例

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


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

示例1: testAppSubmissionWithPreviousToken

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test (timeout = 30000)
public void testAppSubmissionWithPreviousToken() throws Exception{
  MockRM rm = new TestSecurityMockRM(conf, null);
  rm.start();
  final MockNM nm1 =
      new MockNM("127.0.0.1:1234", 15120, rm.getResourceTrackerService());
  nm1.registerNode();

  // create Token1:
  Text userText1 = new Text("user");
  DelegationTokenIdentifier dtId1 =
      new DelegationTokenIdentifier(userText1, new Text("renewer1"),
        userText1);
  final Token<DelegationTokenIdentifier> token1 =
      new Token<DelegationTokenIdentifier>(dtId1.getBytes(),
        "password1".getBytes(), dtId1.getKind(), new Text("service1"));

  Credentials credentials = new Credentials();
  credentials.addToken(userText1, token1);

  // submit app1 with a token, set cancelTokenWhenComplete to false;
  RMApp app1 =
      rm.submitApp(200, "name", "user", null, false, null, 2, credentials,
        null, true, false, false, null, 0, null, false);
  MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm1);
  rm.waitForState(app1.getApplicationId(), RMAppState.RUNNING);

  // submit app2 with the same token, set cancelTokenWhenComplete to true;
  RMApp app2 =
      rm.submitApp(200, "name", "user", null, false, null, 2, credentials,
        null, true, false, false, null, 0, null, true);
  MockAM am2 = MockRM.launchAndRegisterAM(app2, rm, nm1);
  rm.waitForState(app2.getApplicationId(), RMAppState.RUNNING);
  MockRM.finishAMAndVerifyAppState(app2, rm, nm1, am2);
  Assert.assertTrue(rm.getRMContext().getDelegationTokenRenewer()
    .getAllTokens().containsKey(token1));

  MockRM.finishAMAndVerifyAppState(app1, rm, nm1, am1);
  // app2 completes, app1 is still running, check the token is not cancelled
  Assert.assertFalse(Renewer.cancelled);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:42,代码来源:TestDelegationTokenRenewer.java

示例2: testCancelWithMultipleAppSubmissions

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test (timeout = 30000)
public void testCancelWithMultipleAppSubmissions() throws Exception{
  MockRM rm = new TestSecurityMockRM(conf, null);
  rm.start();
  final MockNM nm1 =
      new MockNM("127.0.0.1:1234", 15120, rm.getResourceTrackerService());
  nm1.registerNode();

  //MyFS fs = (MyFS)FileSystem.get(conf);
  //MyToken token1 = fs.getDelegationToken("user123");

  // create Token1:
  Text userText1 = new Text("user");
  DelegationTokenIdentifier dtId1 =
      new DelegationTokenIdentifier(userText1, new Text("renewer1"),
        userText1);
  final Token<DelegationTokenIdentifier> token1 =
      new Token<DelegationTokenIdentifier>(dtId1.getBytes(),
        "password1".getBytes(), dtId1.getKind(), new Text("service1"));

  Credentials credentials = new Credentials();
  credentials.addToken(token1.getService(), token1);

  DelegationTokenRenewer renewer =
      rm.getRMContext().getDelegationTokenRenewer();
  Assert.assertTrue(renewer.getAllTokens().isEmpty());
  Assert.assertFalse(Renewer.cancelled);

  RMApp app1 =
      rm.submitApp(200, "name", "user", null, false, null, 2, credentials,
        null, true, false, false, null, 0, null, true);
  MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm1);
  rm.waitForState(app1.getApplicationId(), RMAppState.RUNNING);

  DelegationTokenToRenew dttr = renewer.getAllTokens().get(token1);
  Assert.assertNotNull(dttr);
  Assert.assertTrue(dttr.referringAppIds.contains(app1.getApplicationId()));
  RMApp app2 =
      rm.submitApp(200, "name", "user", null, false, null, 2, credentials,
        null, true, false, false, null, 0, null, true);
  MockAM am2 = MockRM.launchAndRegisterAM(app2, rm, nm1);
  rm.waitForState(app2.getApplicationId(), RMAppState.RUNNING);
  Assert.assertTrue(renewer.getAllTokens().containsKey(token1));
  Assert.assertTrue(dttr.referringAppIds.contains(app2.getApplicationId()));
  Assert.assertTrue(dttr.referringAppIds.contains(app2.getApplicationId()));
  Assert.assertFalse(Renewer.cancelled);

  MockRM.finishAMAndVerifyAppState(app2, rm, nm1, am2);
  // app2 completes, app1 is still running, check the token is not cancelled
  Assert.assertTrue(renewer.getAllTokens().containsKey(token1));
  Assert.assertTrue(dttr.referringAppIds.contains(app1.getApplicationId()));
  Assert.assertFalse(dttr.referringAppIds.contains(app2.getApplicationId()));
  Assert.assertFalse(dttr.isTimerCancelled());
  Assert.assertFalse(Renewer.cancelled);

  RMApp app3 =
      rm.submitApp(200, "name", "user", null, false, null, 2, credentials,
        null, true, false, false, null, 0, null, true);
  MockAM am3 = MockRM.launchAndRegisterAM(app3, rm, nm1);
  rm.waitForState(app3.getApplicationId(), RMAppState.RUNNING);
  Assert.assertTrue(renewer.getAllTokens().containsKey(token1));
  Assert.assertTrue(dttr.referringAppIds.contains(app1.getApplicationId()));
  Assert.assertTrue(dttr.referringAppIds.contains(app3.getApplicationId()));
  Assert.assertFalse(dttr.isTimerCancelled());
  Assert.assertFalse(Renewer.cancelled);

  MockRM.finishAMAndVerifyAppState(app1, rm, nm1, am1);
  Assert.assertTrue(renewer.getAllTokens().containsKey(token1));
  Assert.assertFalse(dttr.referringAppIds.contains(app1.getApplicationId()));
  Assert.assertTrue(dttr.referringAppIds.contains(app3.getApplicationId()));
  Assert.assertFalse(dttr.isTimerCancelled());
  Assert.assertFalse(Renewer.cancelled);

  MockRM.finishAMAndVerifyAppState(app3, rm, nm1, am3);
  Assert.assertFalse(renewer.getAllTokens().containsKey(token1));
  Assert.assertTrue(dttr.referringAppIds.isEmpty());
  Assert.assertTrue(dttr.isTimerCancelled());
  Assert.assertTrue(Renewer.cancelled);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:80,代码来源:TestDelegationTokenRenewer.java

示例3: testPreemptedAMRestartOnRMRestart

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test(timeout = 20000)
public void testPreemptedAMRestartOnRMRestart() throws Exception {
  YarnConfiguration conf = new YarnConfiguration();
  conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
    ResourceScheduler.class);
  conf.setBoolean(YarnConfiguration.RECOVERY_ENABLED, true);
  conf.setBoolean(YarnConfiguration.RM_WORK_PRESERVING_RECOVERY_ENABLED, false);

  conf.set(YarnConfiguration.RM_STORE, MemoryRMStateStore.class.getName());
  // explicitly set max-am-retry count as 1.
  conf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS, 1);
  MemoryRMStateStore memStore = new MemoryRMStateStore();
  memStore.init(conf);

  MockRM rm1 = new MockRM(conf, memStore);
  rm1.start();
  MockNM nm1 =
      new MockNM("127.0.0.1:1234", 8000, rm1.getResourceTrackerService());
  nm1.registerNode();
  RMApp app1 = rm1.submitApp(200);
  RMAppAttempt attempt1 = app1.getCurrentAppAttempt();
  MockAM am1 = MockRM.launchAndRegisterAM(app1, rm1, nm1);
  CapacityScheduler scheduler =
      (CapacityScheduler) rm1.getResourceScheduler();
  ContainerId amContainer =
      ContainerId.newContainerId(am1.getApplicationAttemptId(), 1);

  // Forcibly preempt the am container;
  scheduler.killContainer(scheduler.getRMContainer(amContainer));

  am1.waitForState(RMAppAttemptState.FAILED);
  Assert.assertTrue(! attempt1.shouldCountTowardsMaxAttemptRetry());
  rm1.waitForState(app1.getApplicationId(), RMAppState.ACCEPTED);

  // state store has 1 attempt stored.
  ApplicationStateData appState =
      memStore.getState().getApplicationState().get(app1.getApplicationId());
  Assert.assertEquals(1, appState.getAttemptCount());
  // attempt stored has the preempted container exit status.
  Assert.assertEquals(ContainerExitStatus.PREEMPTED,
    appState.getAttempt(am1.getApplicationAttemptId())
      .getAMContainerExitStatus());
  // Restart rm.
  MockRM rm2 = new MockRM(conf, memStore);
  nm1.setResourceTrackerService(rm2.getResourceTrackerService());
  nm1.registerNode();
  rm2.start();

  // Restarted RM should re-launch the am.
  MockAM am2 =
      rm2.waitForNewAMToLaunchAndRegister(app1.getApplicationId(), 2, nm1);
  MockRM.finishAMAndVerifyAppState(app1, rm2, nm1, am2);
  RMAppAttempt attempt2 =
      rm2.getRMContext().getRMApps().get(app1.getApplicationId())
        .getCurrentAppAttempt();
  Assert.assertTrue(attempt2.shouldCountTowardsMaxAttemptRetry());
  Assert.assertEquals(ContainerExitStatus.INVALID,
    appState.getAttempt(am2.getApplicationAttemptId())
      .getAMContainerExitStatus());
  rm1.stop();
  rm2.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:63,代码来源:TestAMRestart.java

示例4: testRMRestartOrFailoverNotCountedForAMFailures

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test(timeout = 50000)
public void testRMRestartOrFailoverNotCountedForAMFailures()
    throws Exception {
  YarnConfiguration conf = new YarnConfiguration();
  conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
    ResourceScheduler.class);
  conf.setBoolean(YarnConfiguration.RECOVERY_ENABLED, true);
  conf.setBoolean(YarnConfiguration.RM_WORK_PRESERVING_RECOVERY_ENABLED, false);

  conf.set(YarnConfiguration.RM_STORE, MemoryRMStateStore.class.getName());
  // explicitly set max-am-retry count as 1.
  conf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS, 1);
  MemoryRMStateStore memStore = new MemoryRMStateStore();
  memStore.init(conf);

  MockRM rm1 = new MockRM(conf, memStore);
  rm1.start();
  MockNM nm1 =
      new MockNM("127.0.0.1:1234", 8000, rm1.getResourceTrackerService());
  nm1.registerNode();
  RMApp app1 = rm1.submitApp(200);
  // AM should be restarted even though max-am-attempt is 1.
  MockAM am1 = MockRM.launchAndRegisterAM(app1, rm1, nm1);
  RMAppAttempt attempt1 = app1.getCurrentAppAttempt();
  Assert.assertTrue(((RMAppAttemptImpl) attempt1).mayBeLastAttempt());

  // Restart rm.
  MockRM rm2 = new MockRM(conf, memStore);
  rm2.start();
  ApplicationStateData appState =
      memStore.getState().getApplicationState().get(app1.getApplicationId());
  // re-register the NM
  nm1.setResourceTrackerService(rm2.getResourceTrackerService());
  NMContainerStatus status = Records.newRecord(NMContainerStatus.class);
  status
    .setContainerExitStatus(ContainerExitStatus.KILLED_BY_RESOURCEMANAGER);
  status.setContainerId(attempt1.getMasterContainer().getId());
  status.setContainerState(ContainerState.COMPLETE);
  status.setDiagnostics("");
  nm1.registerNode(Collections.singletonList(status), null);

  rm2.waitForState(attempt1.getAppAttemptId(), RMAppAttemptState.FAILED);
  Assert.assertEquals(ContainerExitStatus.KILLED_BY_RESOURCEMANAGER,
    appState.getAttempt(am1.getApplicationAttemptId())
      .getAMContainerExitStatus());
  // Will automatically start a new AppAttempt in rm2
  rm2.waitForState(app1.getApplicationId(), RMAppState.ACCEPTED);
  MockAM am2 =
      rm2.waitForNewAMToLaunchAndRegister(app1.getApplicationId(), 2, nm1);
  MockRM.finishAMAndVerifyAppState(app1, rm2, nm1, am2);
  RMAppAttempt attempt3 =
      rm2.getRMContext().getRMApps().get(app1.getApplicationId())
        .getCurrentAppAttempt();
  Assert.assertTrue(attempt3.shouldCountTowardsMaxAttemptRetry());
  Assert.assertEquals(ContainerExitStatus.INVALID,
    appState.getAttempt(am2.getApplicationAttemptId())
      .getAMContainerExitStatus());

  rm1.stop();
  rm2.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:62,代码来源:TestAMRestart.java

示例5: testAppSubmissionWithPreviousToken

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test (timeout = 30000)
public void testAppSubmissionWithPreviousToken() throws Exception{
  MockRM rm = new TestSecurityMockRM(conf, null);
  rm.start();
  final MockNM nm1 =
      new MockNM("127.0.0.1:1234", 15120, rm.getResourceTrackerService());
  nm1.registerNode();

  // create Token1:
  Text userText1 = new Text("user");
  DelegationTokenIdentifier dtId1 =
      new DelegationTokenIdentifier(userText1, new Text("renewer1"),
        userText1);
  final Token<DelegationTokenIdentifier> token1 =
      new Token<DelegationTokenIdentifier>(dtId1.getBytes(),
        "password1".getBytes(), dtId1.getKind(), new Text("service1"));

  Credentials credentials = new Credentials();
  credentials.addToken(userText1, token1);

  // submit app1 with a token, set cancelTokenWhenComplete to false;
  Resource resource = Records.newRecord(Resource.class);
  resource.setMemory(200);
  RMApp app1 = rm.submitApp(resource, "name", "user", null, false, null, 2,
      credentials, null, true, false, false, null, 0, null, false, null);
  MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm1);
  rm.waitForState(app1.getApplicationId(), RMAppState.RUNNING);

  // submit app2 with the same token, set cancelTokenWhenComplete to true;
  RMApp app2 = rm.submitApp(resource, "name", "user", null, false, null, 2,
      credentials, null, true, false, false, null, 0, null, true, null);
  MockAM am2 = MockRM.launchAndRegisterAM(app2, rm, nm1);
  rm.waitForState(app2.getApplicationId(), RMAppState.RUNNING);
  MockRM.finishAMAndVerifyAppState(app2, rm, nm1, am2);
  Assert.assertTrue(rm.getRMContext().getDelegationTokenRenewer()
    .getAllTokens().containsKey(token1));

  MockRM.finishAMAndVerifyAppState(app1, rm, nm1, am1);
  // app2 completes, app1 is still running, check the token is not cancelled
  Assert.assertFalse(Renewer.cancelled);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:42,代码来源:TestDelegationTokenRenewer.java

示例6: testCancelWithMultipleAppSubmissions

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test (timeout = 30000)
public void testCancelWithMultipleAppSubmissions() throws Exception{
  MockRM rm = new TestSecurityMockRM(conf, null);
  rm.start();
  final MockNM nm1 =
      new MockNM("127.0.0.1:1234", 15120, rm.getResourceTrackerService());
  nm1.registerNode();

  //MyFS fs = (MyFS)FileSystem.get(conf);
  //MyToken token1 = fs.getDelegationToken("user123");

  // create Token1:
  Text userText1 = new Text("user");
  DelegationTokenIdentifier dtId1 =
      new DelegationTokenIdentifier(userText1, new Text("renewer1"),
        userText1);
  final Token<DelegationTokenIdentifier> token1 =
      new Token<DelegationTokenIdentifier>(dtId1.getBytes(),
        "password1".getBytes(), dtId1.getKind(), new Text("service1"));

  Credentials credentials = new Credentials();
  credentials.addToken(token1.getService(), token1);

  DelegationTokenRenewer renewer =
      rm.getRMContext().getDelegationTokenRenewer();
  Assert.assertTrue(renewer.getAllTokens().isEmpty());
  Assert.assertFalse(Renewer.cancelled);

  Resource resource = Records.newRecord(Resource.class);
  resource.setMemory(200);
  RMApp app1 =
      rm.submitApp(resource, "name", "user", null, false, null, 2, credentials,
        null, true, false, false, null, 0, null, true, null);
  MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm1);
  rm.waitForState(app1.getApplicationId(), RMAppState.RUNNING);

  DelegationTokenToRenew dttr = renewer.getAllTokens().get(token1);
  Assert.assertNotNull(dttr);
  Assert.assertTrue(dttr.referringAppIds.contains(app1.getApplicationId()));
  RMApp app2 = rm.submitApp(resource, "name", "user", null, false, null, 2,
      credentials, null, true, false, false, null, 0, null, true, null);
  MockAM am2 = MockRM.launchAndRegisterAM(app2, rm, nm1);
  rm.waitForState(app2.getApplicationId(), RMAppState.RUNNING);
  Assert.assertTrue(renewer.getAllTokens().containsKey(token1));
  Assert.assertTrue(dttr.referringAppIds.contains(app2.getApplicationId()));
  Assert.assertTrue(dttr.referringAppIds.contains(app2.getApplicationId()));
  Assert.assertFalse(Renewer.cancelled);

  MockRM.finishAMAndVerifyAppState(app2, rm, nm1, am2);
  // app2 completes, app1 is still running, check the token is not cancelled
  Assert.assertTrue(renewer.getAllTokens().containsKey(token1));
  Assert.assertTrue(dttr.referringAppIds.contains(app1.getApplicationId()));
  Assert.assertFalse(dttr.referringAppIds.contains(app2.getApplicationId()));
  Assert.assertFalse(dttr.isTimerCancelled());
  Assert.assertFalse(Renewer.cancelled);

  RMApp app3 = rm.submitApp(resource, "name", "user", null, false, null, 2,
      credentials, null, true, false, false, null, 0, null, true, null);
  MockAM am3 = MockRM.launchAndRegisterAM(app3, rm, nm1);
  rm.waitForState(app3.getApplicationId(), RMAppState.RUNNING);
  Assert.assertTrue(renewer.getAllTokens().containsKey(token1));
  Assert.assertTrue(dttr.referringAppIds.contains(app1.getApplicationId()));
  Assert.assertTrue(dttr.referringAppIds.contains(app3.getApplicationId()));
  Assert.assertFalse(dttr.isTimerCancelled());
  Assert.assertFalse(Renewer.cancelled);

  MockRM.finishAMAndVerifyAppState(app1, rm, nm1, am1);
  Assert.assertTrue(renewer.getAllTokens().containsKey(token1));
  Assert.assertFalse(dttr.referringAppIds.contains(app1.getApplicationId()));
  Assert.assertTrue(dttr.referringAppIds.contains(app3.getApplicationId()));
  Assert.assertFalse(dttr.isTimerCancelled());
  Assert.assertFalse(Renewer.cancelled);

  MockRM.finishAMAndVerifyAppState(app3, rm, nm1, am3);
  Assert.assertFalse(renewer.getAllTokens().containsKey(token1));
  Assert.assertTrue(dttr.referringAppIds.isEmpty());
  Assert.assertTrue(dttr.isTimerCancelled());
  Assert.assertTrue(Renewer.cancelled);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:80,代码来源:TestDelegationTokenRenewer.java


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