Java Code Examples for org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState#ACCEPTED

The following examples show how to use org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState#ACCEPTED . These examples are extracted from open source projects. 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 Project: hadoop   File: TestQueueMappings.java    License: Apache License 2.0 6 votes vote down vote up
private void checkAppQueue(MockRM resourceManager, String user,
    String submissionQueue, String expected)
    throws Exception {
  RMApp app = resourceManager.submitApp(200, "name", user,
      new HashMap<ApplicationAccessType, String>(), false, submissionQueue, -1,
      null, "MAPREDUCE", false);
  RMAppState expectedState = expected.isEmpty() ? RMAppState.FAILED
      : RMAppState.ACCEPTED;
  resourceManager.waitForState(app.getApplicationId(), expectedState);
  // get scheduler app
  CapacityScheduler cs = (CapacityScheduler)
      resourceManager.getResourceScheduler();
  SchedulerApplication schedulerApp =
      cs.getSchedulerApplications().get(app.getApplicationId());
  String queue = "";
  if (schedulerApp != null) {
    queue = schedulerApp.getQueue().getQueueName();
  }
  Assert.assertTrue("expected " + expected + " actual " + queue,
      expected.equals(queue));
  Assert.assertEquals(expected, app.getQueue());
}
 
Example 2
Source Project: hadoop   File: TestMoveApplication.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testMoveRejectedByScheduler() throws Exception {
  failMove = true;
  
  // Submit application
  Application application = new Application("user1", resourceManager);
  application.submit();

  // Wait for app to be accepted
  RMApp app = resourceManager.rmContext.getRMApps()
          .get(application.getApplicationId());
  while (app.getState() != RMAppState.ACCEPTED) {
    Thread.sleep(100);
  }

  ClientRMService clientRMService = resourceManager.getClientRMService();
  try {
    // FIFO scheduler does not support moves
    clientRMService.moveApplicationAcrossQueues(
        MoveApplicationAcrossQueuesRequest.newInstance(
            application.getApplicationId(), "newqueue"));
    fail("Should have hit exception");
  } catch (YarnException ex) {
    assertEquals("Move not supported", ex.getCause().getMessage());
  }
}
 
Example 3
Source Project: big-c   File: TestQueueMappings.java    License: Apache License 2.0 6 votes vote down vote up
private void checkAppQueue(MockRM resourceManager, String user,
    String submissionQueue, String expected)
    throws Exception {
  RMApp app = resourceManager.submitApp(200, "name", user,
      new HashMap<ApplicationAccessType, String>(), false, submissionQueue, -1,
      null, "MAPREDUCE", false);
  RMAppState expectedState = expected.isEmpty() ? RMAppState.FAILED
      : RMAppState.ACCEPTED;
  resourceManager.waitForState(app.getApplicationId(), expectedState);
  // get scheduler app
  CapacityScheduler cs = (CapacityScheduler)
      resourceManager.getResourceScheduler();
  SchedulerApplication schedulerApp =
      cs.getSchedulerApplications().get(app.getApplicationId());
  String queue = "";
  if (schedulerApp != null) {
    queue = schedulerApp.getQueue().getQueueName();
  }
  Assert.assertTrue("expected " + expected + " actual " + queue,
      expected.equals(queue));
  Assert.assertEquals(expected, app.getQueue());
}
 
Example 4
Source Project: big-c   File: TestMoveApplication.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testMoveRejectedByScheduler() throws Exception {
  failMove = true;
  
  // Submit application
  Application application = new Application("user1", resourceManager);
  application.submit();

  // Wait for app to be accepted
  RMApp app = resourceManager.rmContext.getRMApps()
          .get(application.getApplicationId());
  while (app.getState() != RMAppState.ACCEPTED) {
    Thread.sleep(100);
  }

  ClientRMService clientRMService = resourceManager.getClientRMService();
  try {
    // FIFO scheduler does not support moves
    clientRMService.moveApplicationAcrossQueues(
        MoveApplicationAcrossQueuesRequest.newInstance(
            application.getApplicationId(), "newqueue"));
    fail("Should have hit exception");
  } catch (YarnException ex) {
    assertEquals("Move not supported", ex.getCause().getMessage());
  }
}
 
Example 5
Source Project: hadoop   File: TestAppManager.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testRMAppRetireSomeDifferentStates() throws Exception {
  long now = System.currentTimeMillis();

  // these parameters don't matter, override applications below
  RMContext rmContext = mockRMContext(10, now - 20000);
  Configuration conf = new YarnConfiguration();
  conf.setInt(YarnConfiguration.RM_STATE_STORE_MAX_COMPLETED_APPLICATIONS, 2);
  conf.setInt(YarnConfiguration.RM_MAX_COMPLETED_APPLICATIONS, 2);

  TestRMAppManager appMonitor = new TestRMAppManager(rmContext, conf);

  // clear out applications map
  rmContext.getRMApps().clear();
  Assert.assertEquals("map isn't empty", 0, rmContext.getRMApps().size());

  // 6 applications are in final state, 4 are not in final state.
  // / set with various finished states
  RMApp app = new MockRMApp(0, now - 20000, RMAppState.KILLED);
  rmContext.getRMApps().put(app.getApplicationId(), app);
  app = new MockRMApp(1, now - 200000, RMAppState.FAILED);
  rmContext.getRMApps().put(app.getApplicationId(), app);
  app = new MockRMApp(2, now - 30000, RMAppState.FINISHED);
  rmContext.getRMApps().put(app.getApplicationId(), app);
  app = new MockRMApp(3, now - 20000, RMAppState.RUNNING);
  rmContext.getRMApps().put(app.getApplicationId(), app);
  app = new MockRMApp(4, now - 20000, RMAppState.NEW);
  rmContext.getRMApps().put(app.getApplicationId(), app);

  // make sure it doesn't expire these since still running
  app = new MockRMApp(5, now - 10001, RMAppState.KILLED);
  rmContext.getRMApps().put(app.getApplicationId(), app);
  app = new MockRMApp(6, now - 30000, RMAppState.ACCEPTED);
  rmContext.getRMApps().put(app.getApplicationId(), app);
  app = new MockRMApp(7, now - 20000, RMAppState.SUBMITTED);
  rmContext.getRMApps().put(app.getApplicationId(), app);
  app = new MockRMApp(8, now - 10001, RMAppState.FAILED);
  rmContext.getRMApps().put(app.getApplicationId(), app);
  app = new MockRMApp(9, now - 20000, RMAppState.FAILED);
  rmContext.getRMApps().put(app.getApplicationId(), app);

  Assert.assertEquals("Number of apps incorrect before", 10, rmContext
      .getRMApps().size());

  // add them to completed apps list
  addToCompletedApps(appMonitor, rmContext);

  // shouldn't  have to many apps
  appMonitor.checkAppNumCompletedLimit();
  Assert.assertEquals("Number of apps incorrect after # completed check", 6,
      rmContext.getRMApps().size());
  Assert.assertEquals("Number of completed apps incorrect after check", 2,
      appMonitor.getCompletedAppsListSize());
  // 6 applications in final state, 4 of them are removed
  verify(rmContext.getStateStore(), times(4)).removeApplication(
    isA(RMApp.class));
}
 
Example 6
Source Project: hadoop   File: AMSimulator.java    License: Apache License 2.0 4 votes vote down vote up
private void submitApp()
        throws YarnException, InterruptedException, IOException {
  // ask for new application
  GetNewApplicationRequest newAppRequest =
      Records.newRecord(GetNewApplicationRequest.class);
  GetNewApplicationResponse newAppResponse = 
      rm.getClientRMService().getNewApplication(newAppRequest);
  appId = newAppResponse.getApplicationId();
  
  // submit the application
  final SubmitApplicationRequest subAppRequest =
      Records.newRecord(SubmitApplicationRequest.class);
  ApplicationSubmissionContext appSubContext = 
      Records.newRecord(ApplicationSubmissionContext.class);
  appSubContext.setApplicationId(appId);
  appSubContext.setMaxAppAttempts(1);
  appSubContext.setQueue(queue);
  appSubContext.setPriority(Priority.newInstance(0));
  ContainerLaunchContext conLauContext = 
      Records.newRecord(ContainerLaunchContext.class);
  conLauContext.setApplicationACLs(
      new HashMap<ApplicationAccessType, String>());
  conLauContext.setCommands(new ArrayList<String>());
  conLauContext.setEnvironment(new HashMap<String, String>());
  conLauContext.setLocalResources(new HashMap<String, LocalResource>());
  conLauContext.setServiceData(new HashMap<String, ByteBuffer>());
  appSubContext.setAMContainerSpec(conLauContext);
  appSubContext.setUnmanagedAM(true);
  subAppRequest.setApplicationSubmissionContext(appSubContext);
  UserGroupInformation ugi = UserGroupInformation.createRemoteUser(user);
  ugi.doAs(new PrivilegedExceptionAction<Object>() {
    @Override
    public Object run() throws YarnException {
      rm.getClientRMService().submitApplication(subAppRequest);
      return null;
    }
  });
  LOG.info(MessageFormat.format("Submit a new application {0}", appId));
  
  // waiting until application ACCEPTED
  RMApp app = rm.getRMContext().getRMApps().get(appId);
  while(app.getState() != RMAppState.ACCEPTED) {
    Thread.sleep(10);
  }

  // Waiting until application attempt reach LAUNCHED
  // "Unmanaged AM must register after AM attempt reaches LAUNCHED state"
  this.appAttemptId = rm.getRMContext().getRMApps().get(appId)
      .getCurrentAppAttempt().getAppAttemptId();
  RMAppAttempt rmAppAttempt = rm.getRMContext().getRMApps().get(appId)
      .getCurrentAppAttempt();
  while (rmAppAttempt.getAppAttemptState() != RMAppAttemptState.LAUNCHED) {
    Thread.sleep(10);
  }
}
 
Example 7
Source Project: big-c   File: TestAppManager.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testRMAppRetireSomeDifferentStates() throws Exception {
  long now = System.currentTimeMillis();

  // these parameters don't matter, override applications below
  RMContext rmContext = mockRMContext(10, now - 20000);
  Configuration conf = new YarnConfiguration();
  conf.setInt(YarnConfiguration.RM_STATE_STORE_MAX_COMPLETED_APPLICATIONS, 2);
  conf.setInt(YarnConfiguration.RM_MAX_COMPLETED_APPLICATIONS, 2);

  TestRMAppManager appMonitor = new TestRMAppManager(rmContext, conf);

  // clear out applications map
  rmContext.getRMApps().clear();
  Assert.assertEquals("map isn't empty", 0, rmContext.getRMApps().size());

  // 6 applications are in final state, 4 are not in final state.
  // / set with various finished states
  RMApp app = new MockRMApp(0, now - 20000, RMAppState.KILLED);
  rmContext.getRMApps().put(app.getApplicationId(), app);
  app = new MockRMApp(1, now - 200000, RMAppState.FAILED);
  rmContext.getRMApps().put(app.getApplicationId(), app);
  app = new MockRMApp(2, now - 30000, RMAppState.FINISHED);
  rmContext.getRMApps().put(app.getApplicationId(), app);
  app = new MockRMApp(3, now - 20000, RMAppState.RUNNING);
  rmContext.getRMApps().put(app.getApplicationId(), app);
  app = new MockRMApp(4, now - 20000, RMAppState.NEW);
  rmContext.getRMApps().put(app.getApplicationId(), app);

  // make sure it doesn't expire these since still running
  app = new MockRMApp(5, now - 10001, RMAppState.KILLED);
  rmContext.getRMApps().put(app.getApplicationId(), app);
  app = new MockRMApp(6, now - 30000, RMAppState.ACCEPTED);
  rmContext.getRMApps().put(app.getApplicationId(), app);
  app = new MockRMApp(7, now - 20000, RMAppState.SUBMITTED);
  rmContext.getRMApps().put(app.getApplicationId(), app);
  app = new MockRMApp(8, now - 10001, RMAppState.FAILED);
  rmContext.getRMApps().put(app.getApplicationId(), app);
  app = new MockRMApp(9, now - 20000, RMAppState.FAILED);
  rmContext.getRMApps().put(app.getApplicationId(), app);

  Assert.assertEquals("Number of apps incorrect before", 10, rmContext
      .getRMApps().size());

  // add them to completed apps list
  addToCompletedApps(appMonitor, rmContext);

  // shouldn't  have to many apps
  appMonitor.checkAppNumCompletedLimit();
  Assert.assertEquals("Number of apps incorrect after # completed check", 6,
      rmContext.getRMApps().size());
  Assert.assertEquals("Number of completed apps incorrect after check", 2,
      appMonitor.getCompletedAppsListSize());
  // 6 applications in final state, 4 of them are removed
  verify(rmContext.getStateStore(), times(4)).removeApplication(
    isA(RMApp.class));
}
 
Example 8
Source Project: big-c   File: AMSimulator.java    License: Apache License 2.0 4 votes vote down vote up
private void submitApp()
        throws YarnException, InterruptedException, IOException {
  // ask for new application
  GetNewApplicationRequest newAppRequest =
      Records.newRecord(GetNewApplicationRequest.class);
  GetNewApplicationResponse newAppResponse = 
      rm.getClientRMService().getNewApplication(newAppRequest);
  appId = newAppResponse.getApplicationId();
  
  // submit the application
  final SubmitApplicationRequest subAppRequest =
      Records.newRecord(SubmitApplicationRequest.class);
  ApplicationSubmissionContext appSubContext = 
      Records.newRecord(ApplicationSubmissionContext.class);
  appSubContext.setApplicationId(appId);
  appSubContext.setMaxAppAttempts(1);
  appSubContext.setQueue(queue);
  appSubContext.setPriority(Priority.newInstance(0));
  ContainerLaunchContext conLauContext = 
      Records.newRecord(ContainerLaunchContext.class);
  conLauContext.setApplicationACLs(
      new HashMap<ApplicationAccessType, String>());
  conLauContext.setCommands(new ArrayList<String>());
  conLauContext.setEnvironment(new HashMap<String, String>());
  conLauContext.setLocalResources(new HashMap<String, LocalResource>());
  conLauContext.setServiceData(new HashMap<String, ByteBuffer>());
  appSubContext.setAMContainerSpec(conLauContext);
  appSubContext.setUnmanagedAM(true);
  subAppRequest.setApplicationSubmissionContext(appSubContext);
  UserGroupInformation ugi = UserGroupInformation.createRemoteUser(user);
  ugi.doAs(new PrivilegedExceptionAction<Object>() {
    @Override
    public Object run() throws YarnException {
      rm.getClientRMService().submitApplication(subAppRequest);
      return null;
    }
  });
  LOG.info(MessageFormat.format("Submit a new application {0}", appId));
  
  // waiting until application ACCEPTED
  RMApp app = rm.getRMContext().getRMApps().get(appId);
  while(app.getState() != RMAppState.ACCEPTED) {
    Thread.sleep(10);
  }

  // Waiting until application attempt reach LAUNCHED
  // "Unmanaged AM must register after AM attempt reaches LAUNCHED state"
  this.appAttemptId = rm.getRMContext().getRMApps().get(appId)
      .getCurrentAppAttempt().getAppAttemptId();
  RMAppAttempt rmAppAttempt = rm.getRMContext().getRMApps().get(appId)
      .getCurrentAppAttempt();
  while (rmAppAttempt.getAppAttemptState() != RMAppAttemptState.LAUNCHED) {
    Thread.sleep(10);
  }
}