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


Java MockRM.stop方法代码示例

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


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

示例1: testMaxPriorityValidation

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test
public void testMaxPriorityValidation() throws Exception {

  Configuration conf = new Configuration();
  conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
      ResourceScheduler.class);
  // Set Max Application Priority as 10
  conf.setInt(YarnConfiguration.MAX_CLUSTER_LEVEL_APPLICATION_PRIORITY, 10);
  Priority maxPriority = Priority.newInstance(10);
  MockRM rm = new MockRM(conf);
  rm.start();

  Priority appPriority1 = Priority.newInstance(15);
  rm.registerNode("127.0.0.1:1234", 8 * GB);
  RMApp app1 = rm.submitApp(1 * GB, appPriority1);

  // Application submission should be successful and verify priority
  Assert.assertEquals(app1.getApplicationSubmissionContext().getPriority(),
      maxPriority);
  rm.stop();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:22,代码来源:TestApplicationPriority.java

示例2: testBlackListNodes

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test
public void testBlackListNodes() throws Exception {
  Configuration conf = new Configuration();
  conf.setClass(YarnConfiguration.RM_SCHEDULER, FifoScheduler.class,
      ResourceScheduler.class);
  MockRM rm = new MockRM(conf);
  rm.start();
  FifoScheduler fs = (FifoScheduler) rm.getResourceScheduler();

  String host = "127.0.0.1";
  RMNode node =
      MockNodes.newNodeInfo(0, MockNodes.newResource(4 * GB), 1, host);
  fs.handle(new NodeAddedSchedulerEvent(node));

  ApplicationId appId = BuilderUtils.newApplicationId(100, 1);
  ApplicationAttemptId appAttemptId = BuilderUtils.newApplicationAttemptId(
      appId, 1);

  createMockRMApp(appAttemptId, rm.getRMContext());

  SchedulerEvent appEvent =
      new AppAddedSchedulerEvent(appId, "default",
        "user");
  fs.handle(appEvent);
  SchedulerEvent attemptEvent =
      new AppAttemptAddedSchedulerEvent(appAttemptId, false);
  fs.handle(attemptEvent);

  // Verify the blacklist can be updated independent of requesting containers
  fs.allocate(appAttemptId, Collections.<ResourceRequest>emptyList(),
      Collections.<ContainerId>emptyList(),
      Collections.singletonList(host), null);
  Assert.assertTrue(fs.getApplicationAttempt(appAttemptId).isBlacklisted(host));
  fs.allocate(appAttemptId, Collections.<ResourceRequest>emptyList(),
      Collections.<ContainerId>emptyList(), null,
      Collections.singletonList(host));
  Assert.assertFalse(fs.getApplicationAttempt(appAttemptId).isBlacklisted(host));
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:40,代码来源:TestFifoScheduler.java

示例3: testApplicationType

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test(timeout = 30000)
public void testApplicationType() throws Exception {
  Logger rootLogger = LogManager.getRootLogger();
  rootLogger.setLevel(Level.DEBUG);
  MockRM rm = new MockRM();
  rm.start();
  RMApp app = rm.submitApp(2000);
  RMApp app1 =
      rm.submitApp(200, "name", "user",
        new HashMap<ApplicationAccessType, String>(), false, "default", -1,
        null, "MAPREDUCE");
  Assert.assertEquals("YARN", app.getApplicationType());
  Assert.assertEquals("MAPREDUCE", app1.getApplicationType());
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:TestYarnClient.java

示例4: testApplicationTypeLimit

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test(timeout = 30000)
public void testApplicationTypeLimit() throws Exception {
  Logger rootLogger = LogManager.getRootLogger();
  rootLogger.setLevel(Level.DEBUG);
  MockRM rm = new MockRM();
  rm.start();
  RMApp app1 =
      rm.submitApp(200, "name", "user",
        new HashMap<ApplicationAccessType, String>(), false, "default", -1,
        null, "MAPREDUCE-LENGTH-IS-20");
  Assert.assertEquals("MAPREDUCE-LENGTH-IS-", app1.getApplicationType());
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:TestYarnClient.java

示例5: testLogAggregationContextPassedIntoContainerToken

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test
public void testLogAggregationContextPassedIntoContainerToken()
    throws Exception {
  MockRM rm1 = new MockRM(conf);
  rm1.start();
  MockNM nm1 = rm1.registerNode("127.0.0.1:1234", 8000);
  MockNM nm2 = rm1.registerNode("127.0.0.1:2345", 8000);
  // LogAggregationContext is set as null
  Assert
    .assertNull(getLogAggregationContextFromContainerToken(rm1, nm1, null));

  // create a not-null LogAggregationContext
  LogAggregationContext logAggregationContext =
      LogAggregationContext.newInstance(
        "includePattern", "excludePattern",
        "rolledLogsIncludePattern",
        "rolledLogsExcludePattern");
  LogAggregationContext returned =
      getLogAggregationContextFromContainerToken(rm1, nm2,
        logAggregationContext);
  Assert.assertEquals("includePattern", returned.getIncludePattern());
  Assert.assertEquals("excludePattern", returned.getExcludePattern());
  Assert.assertEquals("rolledLogsIncludePattern",
    returned.getRolledLogsIncludePattern());
  Assert.assertEquals("rolledLogsExcludePattern",
    returned.getRolledLogsExcludePattern());
  rm1.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:TestContainerAllocation.java

示例6: testcheckRemoveFromClusterNodeLabelsOfQueue

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test(timeout = 60000)
public void testcheckRemoveFromClusterNodeLabelsOfQueue() throws Exception {
  class TestRMLabelManger extends RMNodeLabelsManager {
    @Override
    protected void checkRemoveFromClusterNodeLabelsOfQueue(
        Collection<String> labelsToRemove) throws IOException {
      checkQueueCall = true;
      // Do nothing
    }

  }
  lmgr = new TestRMLabelManger();
  Configuration conf = new Configuration();
  File tempDir = File.createTempFile("nlb", ".tmp");
  tempDir.delete();
  tempDir.mkdirs();
  tempDir.deleteOnExit();
  conf.set(YarnConfiguration.FS_NODE_LABELS_STORE_ROOT_DIR,
      tempDir.getAbsolutePath());
  conf.setBoolean(YarnConfiguration.NODE_LABELS_ENABLED, true);
  MockRM rm = new MockRM(conf) {
    @Override
    public RMNodeLabelsManager createNodeLabelManager() {
      return lmgr;
    }
  };
  lmgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("a"));
  lmgr.removeFromClusterNodeLabels(Arrays.asList(new String[] { "a" }));
  rm.getRMContext().setNodeLabelManager(lmgr);
  rm.start();
  lmgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("a"));
  Assert.assertEquals(false, checkQueueCall);
  lmgr.removeFromClusterNodeLabels(Arrays.asList(new String[] { "a" }));
  Assert.assertEquals(true, checkQueueCall);
  lmgr.stop();
  lmgr.close();
  rm.stop();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:39,代码来源:TestRMNodeLabelsManager.java

示例7: testWithNodeLabelUpdateEnabled

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test
public void testWithNodeLabelUpdateEnabled() throws Exception {
  conf.setLong(YarnConfiguration.RM_NODE_LABELS_PROVIDER_FETCH_INTERVAL_MS,
      1000);
  MockRM rm = new MockRM(conf);
  rm.init(conf);
  rm.getRMContext().getRMDelegatedNodeLabelsUpdater().nodeLabelsUpdateInterval
      = 3 * 1000;
  rm.start();

  RMNodeLabelsManager mgr = rm.getRMContext().getNodeLabelManager();
  mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x", "y"));

  NodeId nodeId = toNodeId("h1:1234");
  assertEquals(0, mgr.getLabelsOnNode(nodeId).size());
  updateNodeLabels(nodeId, "x");
  registerNode(rm, nodeId);
  Thread.sleep(4000);
  assertCollectionEquals(ImmutableSet.of("x"), mgr.getLabelsOnNode(nodeId));

  // Ensure that node labels are updated if NodeLabelsProvider
  // gives different labels
  updateNodeLabels(nodeId, "y");
  Thread.sleep(4000);
  assertCollectionEquals(ImmutableSet.of("y"), mgr.getLabelsOnNode(nodeId));

  rm.stop();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:29,代码来源:TestRMDelegatedNodeLabelsUpdater.java

示例8: testNodeUpdateBeforeAppAttemptInit

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test(timeout = 60000)
public void testNodeUpdateBeforeAppAttemptInit() throws Exception {
  FifoScheduler scheduler = new FifoScheduler();
  MockRM rm = new MockRM(conf);
  scheduler.setRMContext(rm.getRMContext());
  scheduler.init(conf);
  scheduler.start();
  scheduler.reinitialize(conf, rm.getRMContext());

  RMNode node =
      MockNodes.newNodeInfo(1, Resources.createResource(1024, 4), 1,
          "127.0.0.1");
  scheduler.handle(new NodeAddedSchedulerEvent(node));

  ApplicationId appId = ApplicationId.newInstance(0, 1);
  scheduler.addApplication(appId, "queue1", "user1", false);

  NodeUpdateSchedulerEvent updateEvent = new NodeUpdateSchedulerEvent(node);
  try {
    scheduler.handle(updateEvent);
  } catch (NullPointerException e) {
    Assert.fail();
  }

  ApplicationAttemptId attId = ApplicationAttemptId.newInstance(appId, 1);
  scheduler.addApplicationAttempt(attId, false, false);

  rm.stop();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:30,代码来源:TestFifoScheduler.java

示例9: testContainerTokenGeneratedOnPullRequest

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test
public void testContainerTokenGeneratedOnPullRequest() throws Exception {
  MockRM rm1 = new MockRM(conf);
  rm1.start();
  MockNM nm1 = rm1.registerNode("127.0.0.1:1234", 8000);
  RMApp app1 = rm1.submitApp(200);
  MockAM am1 = MockRM.launchAndRegisterAM(app1, rm1, nm1);
  // request a container.
  am1.allocate("127.0.0.1", 1024, 1, new ArrayList<ContainerId>());
  ContainerId containerId2 =
      ContainerId.newContainerId(am1.getApplicationAttemptId(), 2);
  rm1.waitForState(nm1, containerId2, RMContainerState.ALLOCATED);

  RMContainer container =
      rm1.getResourceScheduler().getRMContainer(containerId2);
  // no container token is generated.
  Assert.assertEquals(containerId2, container.getContainerId());
  Assert.assertNull(container.getContainer().getContainerToken());

  // acquire the container.
  List<Container> containers =
      am1.allocate(new ArrayList<ResourceRequest>(),
        new ArrayList<ContainerId>()).getAllocatedContainers();
  Assert.assertEquals(containerId2, containers.get(0).getId());
  // container token is generated.
  Assert.assertNotNull(containers.get(0).getContainerToken());
  rm1.stop();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:29,代码来源:TestContainerAllocation.java

示例10: testRMDTMasterKeyStateOnRollingMasterKey

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的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

示例11: testRMWritingMassiveHistory

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
private void testRMWritingMassiveHistory(MockRM rm) throws Exception {
  rm.start();
  MockNM nm = rm.registerNode("127.0.0.1:1234", 1024 * 10100);

  RMApp app = rm.submitApp(1024);
  nm.nodeHeartbeat(true);
  RMAppAttempt attempt = app.getCurrentAppAttempt();
  MockAM am = rm.sendAMLaunched(attempt.getAppAttemptId());
  am.registerAppAttempt();

  int request = 10000;
  am.allocate("127.0.0.1", 1024, request, new ArrayList<ContainerId>());
  nm.nodeHeartbeat(true);
  List<Container> allocated =
      am.allocate(new ArrayList<ResourceRequest>(),
        new ArrayList<ContainerId>()).getAllocatedContainers();
  int waitCount = 0;
  int allocatedSize = allocated.size();
  while (allocatedSize < request && waitCount++ < 200) {
    Thread.sleep(300);
    allocated =
        am.allocate(new ArrayList<ResourceRequest>(),
          new ArrayList<ContainerId>()).getAllocatedContainers();
    allocatedSize += allocated.size();
    nm.nodeHeartbeat(true);
  }
  Assert.assertEquals(request, allocatedSize);

  am.unregisterAppAttempt();
  am.waitForState(RMAppAttemptState.FINISHING);
  nm.nodeHeartbeat(am.getApplicationAttemptId(), 1, ContainerState.COMPLETE);
  am.waitForState(RMAppAttemptState.FINISHED);

  NodeHeartbeatResponse resp = nm.nodeHeartbeat(true);
  List<ContainerId> cleaned = resp.getContainersToCleanup();
  int cleanedSize = cleaned.size();
  waitCount = 0;
  while (cleanedSize < allocatedSize && waitCount++ < 200) {
    Thread.sleep(300);
    resp = nm.nodeHeartbeat(true);
    cleaned = resp.getContainersToCleanup();
    cleanedSize += cleaned.size();
  }
  Assert.assertEquals(allocatedSize, cleanedSize);
  rm.waitForState(app.getApplicationId(), RMAppState.FINISHED);

  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:49,代码来源:TestRMApplicationHistoryWriter.java

示例12: 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

示例13: 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

示例14: testResetTimer

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test(timeout = 10000)
public void testResetTimer() throws Exception {
  YarnConfiguration conf = new YarnConfiguration();
  UserGroupInformation.setConfiguration(conf);
  conf.set(YarnConfiguration.RECOVERY_ENABLED, "true");
  conf.set(YarnConfiguration.RM_STORE, MemoryRMStateStore.class.getName());
  conf.setBoolean(YarnConfiguration.RM_WORK_PRESERVING_RECOVERY_ENABLED, true);
  conf.setInt(YarnConfiguration.RM_AM_EXPIRY_INTERVAL_MS, 6000);
  final ControlledClock clock = new ControlledClock(new SystemClock());
  clock.setTime(0);
  MemoryRMStateStore memStore = new MemoryRMStateStore() {
    @Override
    public synchronized RMState loadState() throws Exception {
      clock.setTime(8000);
      return super.loadState();
    }
  };
  memStore.init(conf);
  final ApplicationAttemptId attemptId = mock(ApplicationAttemptId.class);
  final Dispatcher dispatcher = mock(Dispatcher.class);
  final boolean[] expired = new boolean[]{false};
  final AMLivelinessMonitor monitor = new AMLivelinessMonitor(
      dispatcher, clock) {
    @Override
    protected void expire(ApplicationAttemptId id) {
      Assert.assertEquals(id, attemptId);
      expired[0] = true;
    }
  };
  monitor.register(attemptId);
  MockRM rm = new MockRM(conf, memStore) {
    @Override
    protected AMLivelinessMonitor createAMLivelinessMonitor() {
      return monitor;
    }
  };
  rm.start();
  // make sure that monitor has started
  while (monitor.getServiceState() != Service.STATE.STARTED) {
    Thread.sleep(100);
  }
  // expired[0] would be set to true without resetTimer
  Assert.assertFalse(expired[0]);
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:46,代码来源:TestAMLivelinessMonitor.java

示例15: testMaxAllocationAfterUpdateNodeResource

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test
public void testMaxAllocationAfterUpdateNodeResource() throws IOException {
  final int configuredMaxVCores = 20;
  final int configuredMaxMemory = 10 * 1024;
  Resource configuredMaximumResource = Resource.newInstance
      (configuredMaxMemory, configuredMaxVCores, configuredMaxVCores);

  configureScheduler();
  YarnConfiguration conf = getConf();
  conf.setInt(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
      configuredMaxVCores);
  conf.setInt(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
      configuredMaxMemory);
  conf.setLong(
      YarnConfiguration.RM_WORK_PRESERVING_RECOVERY_SCHEDULING_WAIT_MS,
      0);

  MockRM rm = new MockRM(conf);
  try {
    rm.start();
    AbstractYarnScheduler scheduler = (AbstractYarnScheduler) rm
        .getResourceScheduler();
    verifyMaximumResourceCapability(configuredMaximumResource, scheduler);

    Resource resource1 = Resource.newInstance(2048, 5, 5);
    Resource resource2 = Resource.newInstance(4096, 10, 10);
    Resource resource3 = Resource.newInstance(512, 1, 1);
    Resource resource4 = Resource.newInstance(1024, 2, 2);

    RMNode node1 = MockNodes.newNodeInfo(
        0, resource1, 1, "127.0.0.2");
    scheduler.handle(new NodeAddedSchedulerEvent(node1));
    RMNode node2 = MockNodes.newNodeInfo(
        0, resource3, 2, "127.0.0.3");
    scheduler.handle(new NodeAddedSchedulerEvent(node2));
    verifyMaximumResourceCapability(resource1, scheduler);

    // increase node1 resource
    scheduler.updateNodeResource(node1, ResourceOption.newInstance(
        resource2, 0));
    verifyMaximumResourceCapability(resource2, scheduler);

    // decrease node1 resource
    scheduler.updateNodeResource(node1, ResourceOption.newInstance(
        resource1, 0));
    verifyMaximumResourceCapability(resource1, scheduler);

    // increase node2 resource
    scheduler.updateNodeResource(node2, ResourceOption.newInstance(
        resource4, 0));
    verifyMaximumResourceCapability(resource1, scheduler);

    // decrease node2 resource
    scheduler.updateNodeResource(node2, ResourceOption.newInstance(
        resource3, 0));
    verifyMaximumResourceCapability(resource1, scheduler);
  } finally {
    rm.stop();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:61,代码来源:TestAbstractYarnScheduler.java


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