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


Java MockRM.launchAM方法代码示例

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


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

示例1: testUpdatePriorityAtRuntime

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test
public void testUpdatePriorityAtRuntime() 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);
  MockRM rm = new MockRM(conf);
  rm.start();

  Priority appPriority1 = Priority.newInstance(5);
  MockNM nm1 = rm.registerNode("127.0.0.1:1234", 16 * GB);
  RMApp app1 = rm.submitApp(1 * GB, appPriority1);

  // kick the scheduler, 1 GB given to AM1, remaining 15GB on nm1
  MockAM am1 = MockRM.launchAM(app1, rm, nm1);
  am1.registerAppAttempt();

  // get scheduler
  CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();

  // Change the priority of App1 to 8
  Priority appPriority2 = Priority.newInstance(8);
  cs.updateApplicationPriority(appPriority2, app1.getApplicationId());

  // get scheduler app
  FiCaSchedulerApp schedulerAppAttempt = cs.getSchedulerApplications()
      .get(app1.getApplicationId()).getCurrentAppAttempt();

  // Verify whether the new priority is updated
  Assert.assertEquals(appPriority2, schedulerAppAttempt.getPriority());
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:34,代码来源:TestApplicationPriority.java

示例2: testUpdateInvalidPriorityAtRuntime

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test
public void testUpdateInvalidPriorityAtRuntime() 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);
  MockRM rm = new MockRM(conf);
  rm.start();

  Priority appPriority1 = Priority.newInstance(5);
  MockNM nm1 = rm.registerNode("127.0.0.1:1234", 16 * GB);
  RMApp app1 = rm.submitApp(1 * GB, appPriority1);

  // kick the scheduler, 1 GB given to AM1, remaining 15GB on nm1
  MockAM am1 = MockRM.launchAM(app1, rm, nm1);
  am1.registerAppAttempt();

  // get scheduler
  CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();

  // Change the priority of App1 to 15
  Priority appPriority2 = Priority.newInstance(15);
  cs.updateApplicationPriority(appPriority2, app1.getApplicationId());

  // get scheduler app
  FiCaSchedulerApp schedulerAppAttempt = cs.getSchedulerApplications()
      .get(app1.getApplicationId()).getCurrentAppAttempt();

  // Verify whether priority 15 is reset to 10
  Priority appPriority3 = Priority.newInstance(10);
  Assert.assertEquals(appPriority3, schedulerAppAttempt.getPriority());
  rm.stop();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:36,代码来源:TestApplicationPriority.java

示例3: testPriorityWithPendingApplications

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test
public void testPriorityWithPendingApplications() 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);
  MockRM rm = new MockRM(conf);
  rm.start();

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

  // kick the scheduler, 1 GB given to AM1, remaining 7GB on nm1
  MockAM am1 = MockRM.launchAM(app1, rm, nm1);
  am1.registerAppAttempt();

  // kick the scheduler, 7 containers will be allocated for App1
  List<Container> allocated1 = am1.allocateAndWaitForContainers("127.0.0.1",
      7, 1 * GB, nm1);

  Assert.assertEquals(7, allocated1.size());
  Assert.assertEquals(1 * GB, allocated1.get(0).getResource().getMemory());

  // check node report, 8 GB used (1 AM and 7 containers) and 0 GB available
  SchedulerNodeReport report_nm1 = rm.getResourceScheduler().getNodeReport(
      nm1.getNodeId());
  Assert.assertEquals(8 * GB, report_nm1.getUsedResource().getMemory());
  Assert.assertEquals(0 * GB, report_nm1.getAvailableResource().getMemory());

  // Submit the second app App2 with priority 7
  Priority appPriority2 = Priority.newInstance(7);
  RMApp app2 = rm.submitApp(1 * GB, appPriority2);

  // Submit the third app App3 with priority 8
  Priority appPriority3 = Priority.newInstance(8);
  RMApp app3 = rm.submitApp(1 * GB, appPriority3);

  // Submit the second app App4 with priority 6
  Priority appPriority4 = Priority.newInstance(6);
  RMApp app4 = rm.submitApp(1 * GB, appPriority4);

  // Only one app can run as AM resource limit restricts it. Kill app1,
  // If app3 (highest priority among rest) gets active, it indicates that
  // priority is working with pendingApplications.
  rm.killApp(app1.getApplicationId());

  // kick the scheduler, app3 (high among pending) gets free space
  MockAM am3 = MockRM.launchAM(app3, rm, nm1);
  am3.registerAppAttempt();

  // check node report, 1 GB used and 7 GB available
  report_nm1 = rm.getResourceScheduler().getNodeReport(nm1.getNodeId());
  Assert.assertEquals(1 * GB, report_nm1.getUsedResource().getMemory());
  Assert.assertEquals(7 * GB, report_nm1.getAvailableResource().getMemory());

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

示例4: testRMRestartWithChangeInPriority

import org.apache.hadoop.yarn.server.resourcemanager.MockRM; //导入方法依赖的package包/类
@Test(timeout = 180000)
public void testRMRestartWithChangeInPriority() throws Exception {
  conf.setBoolean(YarnConfiguration.RECOVERY_ENABLED, true);
  conf.setBoolean(YarnConfiguration.RM_WORK_PRESERVING_RECOVERY_ENABLED,
      false);
  conf.set(YarnConfiguration.RM_STORE, MemoryRMStateStore.class.getName());
  conf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS,
      YarnConfiguration.DEFAULT_RM_AM_MAX_ATTEMPTS);
  conf.setInt(YarnConfiguration.MAX_CLUSTER_LEVEL_APPLICATION_PRIORITY, 10);

  MemoryRMStateStore memStore = new MemoryRMStateStore();
  memStore.init(conf);
  RMState rmState = memStore.getState();
  Map<ApplicationId, ApplicationStateData> rmAppState = rmState
      .getApplicationState();

  // PHASE 1: create state in an RM

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

  MockNM nm1 = new MockNM("127.0.0.1:1234", 15120,
      rm1.getResourceTrackerService());
  nm1.registerNode();

  Priority appPriority1 = Priority.newInstance(5);
  RMApp app1 = rm1.submitApp(1 * GB, appPriority1);

  // kick the scheduler, 1 GB given to AM1, remaining 15GB on nm1
  MockAM am1 = MockRM.launchAM(app1, rm1, nm1);
  am1.registerAppAttempt();

  // get scheduler
  CapacityScheduler cs = (CapacityScheduler) rm1.getResourceScheduler();

  // Change the priority of App1 to 8
  Priority appPriority2 = Priority.newInstance(8);
  cs.updateApplicationPriority(appPriority2, app1.getApplicationId());

  // let things settle down
  Thread.sleep(1000);

  // create new RM to represent restart and recover state
  MockRM rm2 = new MockRM(conf, memStore);

  // start new RM
  rm2.start();
  // change NM to point to new RM
  nm1.setResourceTrackerService(rm2.getResourceTrackerService());

  // Verify RM Apps after this restart
  Assert.assertEquals(1, rm2.getRMContext().getRMApps().size());

  // get scheduler app
  RMApp loadedApp = rm2.getRMContext().getRMApps()
      .get(app1.getApplicationId());

  // Verify whether priority 15 is reset to 10
  Assert.assertEquals(appPriority2, loadedApp.getCurrentAppAttempt()
      .getSubmissionContext().getPriority());

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


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