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

The following examples show how to use org.apache.hadoop.yarn.server.resourcemanager.scheduler.AbstractYarnScheduler#getAppsInQueue() . 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 hadoop with Apache License 2.0 4 votes vote down vote up
@Test
public void testMoveAllApps() 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());

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

  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.moveAllApps("a1", "b1");

  // check postconditions
  Thread.sleep(1000);
  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 hadoop with Apache License 2.0 4 votes vote down vote up
@Test
public void testMoveAllAppsInvalidDestination() 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());

  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
  try {
    scheduler.moveAllApps("a1", "DOES_NOT_EXIST");
    Assert.fail();
  } catch (YarnException e) {
    // expected
  }

  // check postconditions, app should still be in a1
  appsInA1 = scheduler.getAppsInQueue("a1");
  assertEquals(1, appsInA1.size());

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

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

  appsInB1 = scheduler.getAppsInQueue("b1");
  assertTrue(appsInB1.isEmpty());

  appsInB = scheduler.getAppsInQueue("b");
  assertTrue(appsInB.isEmpty());

  rm.stop();
}
 
Example 5
Source File: TestCapacityScheduler.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test
public void testMoveAllAppsInvalidSource() 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());

  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
  try {
    scheduler.moveAllApps("DOES_NOT_EXIST", "b1");
    Assert.fail();
  } catch (YarnException e) {
    // expected
  }

  // check postconditions, app should still be in a1
  appsInA1 = scheduler.getAppsInQueue("a1");
  assertEquals(1, appsInA1.size());

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

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

  appsInB1 = scheduler.getAppsInQueue("b1");
  assertTrue(appsInB1.isEmpty());

  appsInB = scheduler.getAppsInQueue("b");
  assertTrue(appsInB.isEmpty());

  rm.stop();
}
 
Example 6
Source File: TestCapacityScheduler.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test
public void testKillAllAppsInQueue() 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());

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

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

  // now kill the app
  scheduler.killAllAppsInQueue("a1");

  // check postconditions
  rm.waitForState(app.getApplicationId(), RMAppState.KILLED);
  appsInRoot = scheduler.getAppsInQueue("root");
  assertTrue(appsInRoot.isEmpty());

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

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

  rm.stop();
}
 
Example 7
Source File: TestCapacityScheduler.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test
public void testKillAllAppsInvalidSource() 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());

  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());

  // now kill the app
  try {
    scheduler.killAllAppsInQueue("DOES_NOT_EXIST");
    Assert.fail();
  } catch (YarnException e) {
    // expected
  }

  // check postconditions, app should still be in a1
  appsInA1 = scheduler.getAppsInQueue("a1");
  assertEquals(1, appsInA1.size());

  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 8
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 9
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();
}
 
Example 10
Source File: TestCapacityScheduler.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void testMoveAllApps() 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());

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

  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.moveAllApps("a1", "b1");

  // check postconditions
  Thread.sleep(1000);
  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 11
Source File: TestCapacityScheduler.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void testMoveAllAppsInvalidDestination() 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());

  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
  try {
    scheduler.moveAllApps("a1", "DOES_NOT_EXIST");
    Assert.fail();
  } catch (YarnException e) {
    // expected
  }

  // check postconditions, app should still be in a1
  appsInA1 = scheduler.getAppsInQueue("a1");
  assertEquals(1, appsInA1.size());

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

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

  appsInB1 = scheduler.getAppsInQueue("b1");
  assertTrue(appsInB1.isEmpty());

  appsInB = scheduler.getAppsInQueue("b");
  assertTrue(appsInB.isEmpty());

  rm.stop();
}
 
Example 12
Source File: TestCapacityScheduler.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void testMoveAllAppsInvalidSource() 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());

  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
  try {
    scheduler.moveAllApps("DOES_NOT_EXIST", "b1");
    Assert.fail();
  } catch (YarnException e) {
    // expected
  }

  // check postconditions, app should still be in a1
  appsInA1 = scheduler.getAppsInQueue("a1");
  assertEquals(1, appsInA1.size());

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

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

  appsInB1 = scheduler.getAppsInQueue("b1");
  assertTrue(appsInB1.isEmpty());

  appsInB = scheduler.getAppsInQueue("b");
  assertTrue(appsInB.isEmpty());

  rm.stop();
}
 
Example 13
Source File: TestCapacityScheduler.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void testKillAllAppsInQueue() 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());

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

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

  // now kill the app
  scheduler.killAllAppsInQueue("a1");

  // check postconditions
  rm.waitForState(app.getApplicationId(), RMAppState.KILLED);
  appsInRoot = scheduler.getAppsInQueue("root");
  assertTrue(appsInRoot.isEmpty());

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

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

  rm.stop();
}
 
Example 14
Source File: TestCapacityScheduler.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void testKillAllAppsInvalidSource() 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());

  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());

  // now kill the app
  try {
    scheduler.killAllAppsInQueue("DOES_NOT_EXIST");
    Assert.fail();
  } catch (YarnException e) {
    // expected
  }

  // check postconditions, app should still be in a1
  appsInA1 = scheduler.getAppsInQueue("a1");
  assertEquals(1, appsInA1.size());

  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();
}