Java Code Examples for org.apache.hadoop.yarn.server.resourcemanager.scheduler.AbstractYarnScheduler#moveApplication()

The following examples show how to use org.apache.hadoop.yarn.server.resourcemanager.scheduler.AbstractYarnScheduler#moveApplication() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestCapacityScheduler.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test
public void testMoveAppBasic() throws Exception {
  MockRM rm = setUpMove();
  AbstractYarnScheduler scheduler =
      (AbstractYarnScheduler) rm.getResourceScheduler();

  // submit an app
  RMApp app = rm.submitApp(GB, "test-move-1", "user_0", null, "a1");
  ApplicationAttemptId appAttemptId =
      rm.getApplicationReport(app.getApplicationId())
          .getCurrentApplicationAttemptId();

  // check preconditions
  List<ApplicationAttemptId> appsInA1 = scheduler.getAppsInQueue("a1");
  assertEquals(1, appsInA1.size());
  String queue =
      scheduler.getApplicationAttempt(appsInA1.get(0)).getQueue()
          .getQueueName();
  Assert.assertTrue(queue.equals("a1"));

  List<ApplicationAttemptId> appsInA = scheduler.getAppsInQueue("a");
  assertTrue(appsInA.contains(appAttemptId));
  assertEquals(1, appsInA.size());

  List<ApplicationAttemptId> appsInRoot = scheduler.getAppsInQueue("root");
  assertTrue(appsInRoot.contains(appAttemptId));
  assertEquals(1, appsInRoot.size());

  List<ApplicationAttemptId> appsInB1 = scheduler.getAppsInQueue("b1");
  assertTrue(appsInB1.isEmpty());

  List<ApplicationAttemptId> appsInB = scheduler.getAppsInQueue("b");
  assertTrue(appsInB.isEmpty());

  // now move the app
  scheduler.moveApplication(app.getApplicationId(), "b1");

  // check postconditions
  appsInB1 = scheduler.getAppsInQueue("b1");
  assertEquals(1, appsInB1.size());
  queue =
      scheduler.getApplicationAttempt(appsInB1.get(0)).getQueue()
          .getQueueName();
  Assert.assertTrue(queue.equals("b1"));

  appsInB = scheduler.getAppsInQueue("b");
  assertTrue(appsInB.contains(appAttemptId));
  assertEquals(1, appsInB.size());

  appsInRoot = scheduler.getAppsInQueue("root");
  assertTrue(appsInRoot.contains(appAttemptId));
  assertEquals(1, appsInRoot.size());

  appsInA1 = scheduler.getAppsInQueue("a1");
  assertTrue(appsInA1.isEmpty());

  appsInA = scheduler.getAppsInQueue("a");
  assertTrue(appsInA.isEmpty());

  rm.stop();
}
 
Example 2
Source File: TestCapacityScheduler.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test
public void testMoveAppSameParent() throws Exception {
  MockRM rm = setUpMove();
  AbstractYarnScheduler scheduler =
      (AbstractYarnScheduler) rm.getResourceScheduler();

  // submit an app
  RMApp app = rm.submitApp(GB, "test-move-1", "user_0", null, "a1");
  ApplicationAttemptId appAttemptId =
      rm.getApplicationReport(app.getApplicationId())
          .getCurrentApplicationAttemptId();

  // check preconditions
  List<ApplicationAttemptId> appsInA1 = scheduler.getAppsInQueue("a1");
  assertEquals(1, appsInA1.size());
  String queue =
      scheduler.getApplicationAttempt(appsInA1.get(0)).getQueue()
          .getQueueName();
  Assert.assertTrue(queue.equals("a1"));

  List<ApplicationAttemptId> appsInA = scheduler.getAppsInQueue("a");
  assertTrue(appsInA.contains(appAttemptId));
  assertEquals(1, appsInA.size());

  List<ApplicationAttemptId> appsInRoot = scheduler.getAppsInQueue("root");
  assertTrue(appsInRoot.contains(appAttemptId));
  assertEquals(1, appsInRoot.size());

  List<ApplicationAttemptId> appsInA2 = scheduler.getAppsInQueue("a2");
  assertTrue(appsInA2.isEmpty());

  // now move the app
  scheduler.moveApplication(app.getApplicationId(), "a2");

  // check postconditions
  appsInA2 = scheduler.getAppsInQueue("a2");
  assertEquals(1, appsInA2.size());
  queue =
      scheduler.getApplicationAttempt(appsInA2.get(0)).getQueue()
          .getQueueName();
  Assert.assertTrue(queue.equals("a2"));

  appsInA1 = scheduler.getAppsInQueue("a1");
  assertTrue(appsInA1.isEmpty());

  appsInA = scheduler.getAppsInQueue("a");
  assertTrue(appsInA.contains(appAttemptId));
  assertEquals(1, appsInA.size());

  appsInRoot = scheduler.getAppsInQueue("root");
  assertTrue(appsInRoot.contains(appAttemptId));
  assertEquals(1, appsInRoot.size());

  rm.stop();
}
 
Example 3
Source File: TestCapacityScheduler.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void testMoveAppBasic() throws Exception {
  MockRM rm = setUpMove();
  AbstractYarnScheduler scheduler =
      (AbstractYarnScheduler) rm.getResourceScheduler();

  // submit an app
  RMApp app = rm.submitApp(GB, "test-move-1", "user_0", null, "a1");
  ApplicationAttemptId appAttemptId =
      rm.getApplicationReport(app.getApplicationId())
          .getCurrentApplicationAttemptId();

  // check preconditions
  List<ApplicationAttemptId> appsInA1 = scheduler.getAppsInQueue("a1");
  assertEquals(1, appsInA1.size());
  String queue =
      scheduler.getApplicationAttempt(appsInA1.get(0)).getQueue()
          .getQueueName();
  Assert.assertTrue(queue.equals("a1"));

  List<ApplicationAttemptId> appsInA = scheduler.getAppsInQueue("a");
  assertTrue(appsInA.contains(appAttemptId));
  assertEquals(1, appsInA.size());

  List<ApplicationAttemptId> appsInRoot = scheduler.getAppsInQueue("root");
  assertTrue(appsInRoot.contains(appAttemptId));
  assertEquals(1, appsInRoot.size());

  List<ApplicationAttemptId> appsInB1 = scheduler.getAppsInQueue("b1");
  assertTrue(appsInB1.isEmpty());

  List<ApplicationAttemptId> appsInB = scheduler.getAppsInQueue("b");
  assertTrue(appsInB.isEmpty());

  // now move the app
  scheduler.moveApplication(app.getApplicationId(), "b1");

  // check postconditions
  appsInB1 = scheduler.getAppsInQueue("b1");
  assertEquals(1, appsInB1.size());
  queue =
      scheduler.getApplicationAttempt(appsInB1.get(0)).getQueue()
          .getQueueName();
  Assert.assertTrue(queue.equals("b1"));

  appsInB = scheduler.getAppsInQueue("b");
  assertTrue(appsInB.contains(appAttemptId));
  assertEquals(1, appsInB.size());

  appsInRoot = scheduler.getAppsInQueue("root");
  assertTrue(appsInRoot.contains(appAttemptId));
  assertEquals(1, appsInRoot.size());

  appsInA1 = scheduler.getAppsInQueue("a1");
  assertTrue(appsInA1.isEmpty());

  appsInA = scheduler.getAppsInQueue("a");
  assertTrue(appsInA.isEmpty());

  rm.stop();
}
 
Example 4
Source File: TestCapacityScheduler.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void testMoveAppSameParent() throws Exception {
  MockRM rm = setUpMove();
  AbstractYarnScheduler scheduler =
      (AbstractYarnScheduler) rm.getResourceScheduler();

  // submit an app
  RMApp app = rm.submitApp(GB, "test-move-1", "user_0", null, "a1");
  ApplicationAttemptId appAttemptId =
      rm.getApplicationReport(app.getApplicationId())
          .getCurrentApplicationAttemptId();

  // check preconditions
  List<ApplicationAttemptId> appsInA1 = scheduler.getAppsInQueue("a1");
  assertEquals(1, appsInA1.size());
  String queue =
      scheduler.getApplicationAttempt(appsInA1.get(0)).getQueue()
          .getQueueName();
  Assert.assertTrue(queue.equals("a1"));

  List<ApplicationAttemptId> appsInA = scheduler.getAppsInQueue("a");
  assertTrue(appsInA.contains(appAttemptId));
  assertEquals(1, appsInA.size());

  List<ApplicationAttemptId> appsInRoot = scheduler.getAppsInQueue("root");
  assertTrue(appsInRoot.contains(appAttemptId));
  assertEquals(1, appsInRoot.size());

  List<ApplicationAttemptId> appsInA2 = scheduler.getAppsInQueue("a2");
  assertTrue(appsInA2.isEmpty());

  // now move the app
  scheduler.moveApplication(app.getApplicationId(), "a2");

  // check postconditions
  appsInA2 = scheduler.getAppsInQueue("a2");
  assertEquals(1, appsInA2.size());
  queue =
      scheduler.getApplicationAttempt(appsInA2.get(0)).getQueue()
          .getQueueName();
  Assert.assertTrue(queue.equals("a2"));

  appsInA1 = scheduler.getAppsInQueue("a1");
  assertTrue(appsInA1.isEmpty());

  appsInA = scheduler.getAppsInQueue("a");
  assertTrue(appsInA.contains(appAttemptId));
  assertEquals(1, appsInA.size());

  appsInRoot = scheduler.getAppsInQueue("root");
  assertTrue(appsInRoot.contains(appAttemptId));
  assertEquals(1, appsInRoot.size());

  rm.stop();
}