org.apache.hadoop.yarn.api.records.ApplicationAttemptId Java Examples

The following examples show how to use org.apache.hadoop.yarn.api.records.ApplicationAttemptId. 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: TestAHSClient.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 10000)
public void testGetApplicationAttempt() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final AHSClient client = new MockAHSClient();
  client.init(conf);
  client.start();

  List<ApplicationReport> expectedReports =
      ((MockAHSClient) client).getReports();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(applicationId, 1);
  ApplicationAttemptReport report =
      client.getApplicationAttemptReport(appAttemptId);
  Assert.assertNotNull(report);
  Assert.assertEquals(report.getApplicationAttemptId().toString(),
    expectedReports.get(0).getCurrentApplicationAttemptId().toString());
  client.stop();
}
 
Example #2
Source File: TestRMAppAttemptTransitions.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * {@link RMAppAttemptState#SCHEDULED}
 */
@SuppressWarnings("unchecked")
private void testAppAttemptScheduledState() {
  RMAppAttemptState expectedState;
  int expectedAllocateCount;
  if(unmanagedAM) {
    expectedState = RMAppAttemptState.LAUNCHED;
    expectedAllocateCount = 0;
  } else {
    expectedState = RMAppAttemptState.SCHEDULED;
    expectedAllocateCount = 1;
  }

  assertEquals(expectedState, 
      applicationAttempt.getAppAttemptState());
  verify(scheduler, times(expectedAllocateCount)).
  allocate(any(ApplicationAttemptId.class), 
      any(List.class), any(List.class), any(List.class), any(List.class));

  assertEquals(0,applicationAttempt.getJustFinishedContainers().size());
  assertNull(applicationAttempt.getMasterContainer());
  assertEquals(0.0, (double)applicationAttempt.getProgress(), 0.0001);
  assertEquals(0, application.getRanNodes().size());
  assertNull(applicationAttempt.getFinalApplicationStatus());
}
 
Example #3
Source File: TestAMRMClientOnRMRestart.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized Allocation allocate(
    ApplicationAttemptId applicationAttemptId, List<ResourceRequest> ask,
    List<ContainerId> release, List<String> blacklistAdditions,
    List<String> blacklistRemovals) {
  List<ResourceRequest> askCopy = new ArrayList<ResourceRequest>();
  for (ResourceRequest req : ask) {
    ResourceRequest reqCopy =
        ResourceRequest.newInstance(req.getPriority(),
            req.getResourceName(), req.getCapability(),
            req.getNumContainers(), req.getRelaxLocality());
    askCopy.add(reqCopy);
  }
  lastAsk = ask;
  lastRelease = release;
  lastBlacklistAdditions = blacklistAdditions;
  lastBlacklistRemovals = blacklistRemovals;
  return super.allocate(applicationAttemptId, askCopy, release,
      blacklistAdditions, blacklistRemovals);
}
 
Example #4
Source File: TestAHSWebServices.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testInvalidContainer() throws Exception {
  ApplicationId appId = ApplicationId.newInstance(0, 1);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, 1);
  ContainerId containerId = ContainerId.newContainerId(appAttemptId,
      MAX_APPS + 1);
  WebResource r = resource();
  ClientResponse response =
      r.path("ws").path("v1").path("applicationhistory").path("apps")
        .path(appId.toString()).path("appattempts")
        .path(appAttemptId.toString()).path("containers")
        .path(containerId.toString())
        .queryParam("user.name", USERS[round])
        .accept(MediaType.APPLICATION_JSON)
        .get(ClientResponse.class);
  if (round == 1) {
    assertEquals(
        Status.FORBIDDEN, response.getClientResponseStatus());
    return;
  }
  assertEquals("404 not found expected", Status.NOT_FOUND,
          response.getClientResponseStatus());
}
 
Example #5
Source File: TestRMContainerAllocator.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized Allocation allocate(
    ApplicationAttemptId applicationAttemptId, List<ResourceRequest> ask,
    List<ContainerId> release, 
    List<String> blacklistAdditions, List<String> blacklistRemovals) {
  List<ResourceRequest> askCopy = new ArrayList<ResourceRequest>();
  for (ResourceRequest req : ask) {
    ResourceRequest reqCopy = ResourceRequest.newInstance(req
        .getPriority(), req.getResourceName(), req.getCapability(), req
        .getNumContainers(), req.getRelaxLocality());
    askCopy.add(reqCopy);
  }
  SecurityUtil.setTokenServiceUseIp(false);
  lastAsk = ask;
  lastRelease = release;
  lastBlacklistAdditions = blacklistAdditions;
  lastBlacklistRemovals = blacklistRemovals;
  return super.allocate(
      applicationAttemptId, askCopy, release, 
      blacklistAdditions, blacklistRemovals);
}
 
Example #6
Source File: TestFSAppAttempt.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
/**
 * Ensure that when negative paramaters are given (signaling delay scheduling
 * no tin use), the least restrictive locality level is returned.
 */
public void testLocalityLevelWithoutDelays() {
  FSLeafQueue queue = Mockito.mock(FSLeafQueue.class);
  Priority prio = Mockito.mock(Priority.class);
  Mockito.when(prio.getPriority()).thenReturn(1);

  RMContext rmContext = resourceManager.getRMContext();
  ApplicationAttemptId applicationAttemptId = createAppAttemptId(1, 1);
  FSAppAttempt schedulerApp =
      new FSAppAttempt(scheduler, applicationAttemptId, "user1", queue ,
          null, rmContext);
  assertEquals(NodeType.OFF_SWITCH, schedulerApp.getAllowedLocalityLevel(
      prio, 10, -1.0, -1.0));
}
 
Example #7
Source File: TestFileSystemApplicationHistoryStore.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testMassiveWriteContainerHistoryData() throws IOException {
  LOG.info("Starting testMassiveWriteContainerHistoryData");
  long mb = 1024 * 1024;
  long usedDiskBefore = fs.getContentSummary(fsWorkingPath).getLength() / mb;
  ApplicationId appId = ApplicationId.newInstance(0, 1);
  writeApplicationStartData(appId);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, 1);
  for (int i = 1; i <= 100000; ++i) {
    ContainerId containerId = ContainerId.newContainerId(appAttemptId, i);
    writeContainerStartData(containerId);
    writeContainerFinishData(containerId);
  }
  writeApplicationFinishData(appId);
  long usedDiskAfter = fs.getContentSummary(fsWorkingPath).getLength() / mb;
  Assert.assertTrue((usedDiskAfter - usedDiskBefore) < 20);
}
 
Example #8
Source File: TestContainerLaunch.java    From big-c with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
@Test (timeout = 10000)
public void testCallFailureWithNullLocalizedResources() {
  Container container = mock(Container.class);
  when(container.getContainerId()).thenReturn(ContainerId.newContainerId(
      ApplicationAttemptId.newInstance(ApplicationId.newInstance(
          System.currentTimeMillis(), 1), 1), 1));
  ContainerLaunchContext clc = mock(ContainerLaunchContext.class);
  when(clc.getCommands()).thenReturn(Collections.<String>emptyList());
  when(container.getLaunchContext()).thenReturn(clc);
  when(container.getLocalizedResources()).thenReturn(null);
  Dispatcher dispatcher = mock(Dispatcher.class);
  EventHandler eventHandler = new EventHandler() {
    public void handle(Event event) {
      Assert.assertTrue(event instanceof ContainerExitEvent);
      ContainerExitEvent exitEvent = (ContainerExitEvent) event;
      Assert.assertEquals(ContainerEventType.CONTAINER_EXITED_WITH_FAILURE,
          exitEvent.getType());
    }
  };
  when(dispatcher.getEventHandler()).thenReturn(eventHandler);
  ContainerLaunch launch = new ContainerLaunch(context, new Configuration(),
      dispatcher, exec, null, container, dirsHandler, containerManager);
  launch.call();
}
 
Example #9
Source File: TestWorkPreservingRMRestart.java    From big-c with Apache License 2.0 6 votes vote down vote up
public static void waitForNumContainersToRecover(int num, MockRM rm,
    ApplicationAttemptId attemptId) throws Exception {
  AbstractYarnScheduler scheduler =
      (AbstractYarnScheduler) rm.getResourceScheduler();
  SchedulerApplicationAttempt attempt =
      scheduler.getApplicationAttempt(attemptId);
  while (attempt == null) {
    System.out.println("Wait for scheduler attempt " + attemptId
        + " to be created");
    Thread.sleep(200);
    attempt = scheduler.getApplicationAttempt(attemptId);
  }
  while (attempt.getLiveContainers().size() < num) {
    System.out.println("Wait for " + num
        + " containers to recover. currently: "
        + attempt.getLiveContainers().size());
    Thread.sleep(200);
  }
}
 
Example #10
Source File: TestFairScheduler.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test (expected = YarnException.class)
public void testMoveWouldViolateMaxAppsConstraints() throws Exception {
  scheduler.init(conf);
  scheduler.start();
  scheduler.reinitialize(conf, resourceManager.getRMContext());

  QueueManager queueMgr = scheduler.getQueueManager();
  queueMgr.getLeafQueue("queue2", true);
  scheduler.getAllocationConfiguration().queueMaxApps.put("root.queue2", 0);
  
  ApplicationAttemptId appAttId =
      createSchedulingRequest(1024, 1, 1, "queue1", "user1", 3);
  
  scheduler.moveApplication(appAttId.getApplicationId(), "queue2");
}
 
Example #11
Source File: TestRMRestart.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void
    updateApplicationAttemptStateInternal(
        ApplicationAttemptId attemptId,
        ApplicationAttemptStateData attemptStateData)
        throws Exception {
  updateAttempt = ++count;
  super.updateApplicationAttemptStateInternal(attemptId,
    attemptStateData);
}
 
Example #12
Source File: NMTokenSecretManagerInNM.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public synchronized void recover()
    throws IOException {
  RecoveredNMTokensState state = stateStore.loadNMTokensState();
  MasterKey key = state.getCurrentMasterKey();
  if (key != null) {
    super.currentMasterKey =
        new MasterKeyData(key, createSecretKey(key.getBytes().array()));
  }

  key = state.getPreviousMasterKey();
  if (key != null) {
    previousMasterKey =
        new MasterKeyData(key, createSecretKey(key.getBytes().array()));
  }

  // restore the serial number from the current master key
  if (super.currentMasterKey != null) {
    super.serialNo = super.currentMasterKey.getMasterKey().getKeyId() + 1;
  }

  for (Map.Entry<ApplicationAttemptId, MasterKey> entry :
       state.getApplicationMasterKeys().entrySet()) {
    key = entry.getValue();
    oldMasterKeys.put(entry.getKey(),
        new MasterKeyData(key, createSecretKey(key.getBytes().array())));
  }

  // reconstruct app to app attempts map
  appToAppAttemptMap.clear();
  for (ApplicationAttemptId attempt : oldMasterKeys.keySet()) {
    ApplicationId app = attempt.getApplicationId();
    List<ApplicationAttemptId> attempts = appToAppAttemptMap.get(app);
    if (attempts == null) {
      attempts = new ArrayList<ApplicationAttemptId>();
      appToAppAttemptMap.put(app, attempts);
    }
    attempts.add(attempt);
  }
}
 
Example #13
Source File: TestRecoveryParser.java    From tez with Apache License 2.0 5 votes vote down vote up
@Test(timeout=5000)
public void testRecoverableSummary_VertexInCommitting() throws IOException {
  ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
  TezDAGID dagID = TezDAGID.getInstance(appId, 1);
  AppContext appContext = mock(AppContext.class);
  when(appContext.getCurrentRecoveryDir()).thenReturn(new Path(recoveryPath+"/1"));
  when(appContext.getClock()).thenReturn(new SystemClock());
  when(mockDAGImpl.getID()).thenReturn(dagID);

  RecoveryService rService = new RecoveryService(appContext);
  Configuration conf = new Configuration();
  conf.setBoolean(RecoveryService.TEZ_TEST_RECOVERY_DRAIN_EVENTS_WHEN_STOPPED, true);
  rService.init(conf);
  rService.start();

  DAGPlan dagPlan = TestDAGImpl.createTestDAGPlan();
  // write a DAGSubmittedEvent first to initialize summaryStream
  rService.handle(new DAGHistoryEvent(dagID,
      new DAGSubmittedEvent(dagID, 1L, dagPlan, ApplicationAttemptId.newInstance(appId, 1),
          null, "user", new Configuration(), null, null)));
  // It should be fine to skip other events, just for testing.
  rService.handle(new DAGHistoryEvent(dagID,
      new VertexCommitStartedEvent(TezVertexID.getInstance(dagID, 0), 0L)));
  rService.stop();

  DAGRecoveryData dagData = parser.parseRecoveryData();
  assertEquals(dagID, dagData.recoveredDagID);
  assertTrue(dagData.nonRecoverable);
  assertTrue(dagData.reason.contains("Vertex Commit was in progress"));
}
 
Example #14
Source File: RMAppImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public RMAppAttempt getRMAppAttempt(ApplicationAttemptId appAttemptId) {
  this.readLock.lock();

  try {
    return this.attempts.get(appAttemptId);
  } finally {
    this.readLock.unlock();
  }
}
 
Example #15
Source File: TestMRJobsWithHistoryService.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void verifyJobReport(JobReport jobReport, JobId jobId) {
  List<AMInfo> amInfos = jobReport.getAMInfos();
  Assert.assertEquals(1, amInfos.size());
  AMInfo amInfo = amInfos.get(0);
  ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(jobId.getAppId(), 1);
  ContainerId amContainerId = ContainerId.newContainerId(appAttemptId, 1);
  Assert.assertEquals(appAttemptId, amInfo.getAppAttemptId());
  Assert.assertEquals(amContainerId, amInfo.getContainerId());
  Assert.assertTrue(jobReport.getSubmitTime() > 0);
  Assert.assertTrue(jobReport.getStartTime() > 0
      && jobReport.getStartTime() >= jobReport.getSubmitTime());
  Assert.assertTrue(jobReport.getFinishTime() > 0
      && jobReport.getFinishTime() >= jobReport.getStartTime());
}
 
Example #16
Source File: TestMRAppMaster.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testMRAppMasterFailLock() throws IOException,
    InterruptedException {
  String applicationAttemptIdStr = "appattempt_1317529182569_0004_000002";
  String containerIdStr = "container_1317529182569_0004_000002_1";
  String userName = "TestAppMasterUser";
  JobConf conf = new JobConf();
  conf.set(MRJobConfig.MR_AM_STAGING_DIR, stagingDir);
  ApplicationAttemptId applicationAttemptId = ConverterUtils
      .toApplicationAttemptId(applicationAttemptIdStr);
  JobId jobId =  TypeConverter.toYarn(
      TypeConverter.fromYarn(applicationAttemptId.getApplicationId()));
  Path start = MRApps.getStartJobCommitFile(conf, userName, jobId);
  Path end = MRApps.getEndJobCommitFailureFile(conf, userName, jobId);
  FileSystem fs = FileSystem.get(conf);
  fs.create(start).close();
  fs.create(end).close();
  ContainerId containerId = ConverterUtils.toContainerId(containerIdStr);
  MRAppMaster appMaster =
      new MRAppMasterTest(applicationAttemptId, containerId, "host", -1, -1,
          System.currentTimeMillis(), false, false);
  boolean caught = false;
  try {
    MRAppMaster.initAndStartAppMaster(appMaster, conf, userName);
  } catch (IOException e) {
    //The IO Exception is expected
    LOG.info("Caught expected Exception", e);
    caught = true;
  }
  assertTrue(caught);
  assertTrue(appMaster.errorHappenedShutDown);
  assertEquals(JobStateInternal.FAILED, appMaster.forcedState);
  appMaster.stop();

  // verify the final status is FAILED
  verifyFailedStatus((MRAppMasterTest)appMaster, "FAILED");
}
 
Example #17
Source File: BuilderUtils.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static ApplicationReport newApplicationReport(
    ApplicationId applicationId, ApplicationAttemptId applicationAttemptId,
    String user, String queue, String name, String host, int rpcPort,
    Token clientToAMToken, YarnApplicationState state, String diagnostics,
    String url, long startTime, long finishTime,
    FinalApplicationStatus finalStatus,
    ApplicationResourceUsageReport appResources, String origTrackingUrl,
    float progress, String appType, Token amRmToken, Set<String> tags) {
  ApplicationReport report = recordFactory
      .newRecordInstance(ApplicationReport.class);
  report.setApplicationId(applicationId);
  report.setCurrentApplicationAttemptId(applicationAttemptId);
  report.setUser(user);
  report.setQueue(queue);
  report.setName(name);
  report.setHost(host);
  report.setRpcPort(rpcPort);
  report.setClientToAMToken(clientToAMToken);
  report.setYarnApplicationState(state);
  report.setDiagnostics(diagnostics);
  report.setTrackingUrl(url);
  report.setStartTime(startTime);
  report.setFinishTime(finishTime);
  report.setFinalApplicationStatus(finalStatus);
  report.setApplicationResourceUsageReport(appResources);
  report.setOriginalTrackingUrl(origTrackingUrl);
  report.setProgress(progress);
  report.setApplicationType(appType);
  report.setAMRMToken(amRmToken);
  report.setApplicationTags(tags);
  return report;
}
 
Example #18
Source File: TestTaskScheduler.java    From incubator-tez with Apache License 2.0 5 votes vote down vote up
private Container createContainer(int id, String host, Resource resource,
    Priority priority) {
  ContainerId containerID = ContainerId.newInstance(
      ApplicationAttemptId.newInstance(ApplicationId.newInstance(1, 1), 1),
      id);
  NodeId nodeID = NodeId.newInstance(host, 0);
  Container container = Container.newInstance(containerID, nodeID, host
      + ":0", resource, priority, null);
  return container;
}
 
Example #19
Source File: RMAppImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public RMAppAttempt getRMAppAttempt(ApplicationAttemptId appAttemptId) {
  this.readLock.lock();

  try {
    return this.attempts.get(appAttemptId);
  } finally {
    this.readLock.unlock();
  }
}
 
Example #20
Source File: AMRMTokenIdentifier.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Private
public ApplicationAttemptId getApplicationAttemptId() {
  if (!proto.hasAppAttemptId()) {
    return null;
  }
  return new ApplicationAttemptIdPBImpl(proto.getAppAttemptId());
}
 
Example #21
Source File: YarnJobValidationTool.java    From samza with Apache License 2.0 5 votes vote down vote up
public ApplicationAttemptId validateRunningAttemptId(ApplicationId appId) throws Exception {
  ApplicationAttemptId attemptId = this.client.getApplicationReport(appId).getCurrentApplicationAttemptId();
  ApplicationAttemptReport attemptReport = this.client.getApplicationAttemptReport(attemptId);
  if (attemptReport.getYarnApplicationAttemptState() == YarnApplicationAttemptState.RUNNING) {
    log.info("Job is running. AttempId " + attemptId.toString());
    return attemptId;
  } else {
    throw new SamzaException("Job not running " + this.jobName);
  }
}
 
Example #22
Source File: TestFairScheduler.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Two apps on one queue, one app on another
 */
@Test
public void testBasicDRFWithQueues() throws Exception {
  scheduler.init(conf);
  scheduler.start();
  scheduler.reinitialize(conf, resourceManager.getRMContext());

  RMNode node = MockNodes.newNodeInfo(1, BuilderUtils.newResource(8192, 7),
      1, "127.0.0.1");
  NodeAddedSchedulerEvent nodeEvent = new NodeAddedSchedulerEvent(node);
  scheduler.handle(nodeEvent);

  ApplicationAttemptId appAttId1 = createSchedulingRequest(3072, 1, "queue1",
      "user1", 2);
  FSAppAttempt app1 = scheduler.getSchedulerApp(appAttId1);
  ApplicationAttemptId appAttId2 = createSchedulingRequest(2048, 2, "queue1",
      "user1", 2);
  FSAppAttempt app2 = scheduler.getSchedulerApp(appAttId2);
  ApplicationAttemptId appAttId3 = createSchedulingRequest(1024, 2, "queue2",
      "user1", 2);
  FSAppAttempt app3 = scheduler.getSchedulerApp(appAttId3);
  
  DominantResourceFairnessPolicy drfPolicy = new DominantResourceFairnessPolicy();
  drfPolicy.initialize(scheduler.getClusterResource());
  scheduler.getQueueManager().getQueue("root").setPolicy(drfPolicy);
  scheduler.getQueueManager().getQueue("queue1").setPolicy(drfPolicy);
  scheduler.update();

  NodeUpdateSchedulerEvent updateEvent = new NodeUpdateSchedulerEvent(node);
  scheduler.handle(updateEvent);
  Assert.assertEquals(1, app1.getLiveContainers().size());
  scheduler.handle(updateEvent);
  Assert.assertEquals(1, app3.getLiveContainers().size());
  scheduler.handle(updateEvent);
  Assert.assertEquals(2, app3.getLiveContainers().size());
  scheduler.handle(updateEvent);
  Assert.assertEquals(1, app2.getLiveContainers().size());
}
 
Example #23
Source File: NMMemoryStateStoreService.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void storeNMTokenApplicationMasterKey(
    ApplicationAttemptId attempt, MasterKey key) throws IOException {
  MasterKeyPBImpl keypb = (MasterKeyPBImpl) key;
  nmTokenState.applicationMasterKeys.put(attempt,
      new MasterKeyPBImpl(keypb.getProto()));
}
 
Example #24
Source File: TestContainerManager.java    From big-c with Apache License 2.0 5 votes vote down vote up
private ContainerId createContainerId(int id) {
  ApplicationId appId = ApplicationId.newInstance(0, 0);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, 1);
  ContainerId containerId = ContainerId.newContainerId(appAttemptId, id);
  return containerId;
}
 
Example #25
Source File: TestApplicationHistoryClientService.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testApplicationAttemptReport() throws IOException, YarnException {
  ApplicationId appId = ApplicationId.newInstance(0, 1);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, 1);
  GetApplicationAttemptReportRequest request =
      GetApplicationAttemptReportRequest.newInstance(appAttemptId);
  GetApplicationAttemptReportResponse response =
      clientService.getApplicationAttemptReport(request);
  ApplicationAttemptReport attemptReport =
      response.getApplicationAttemptReport();
  Assert.assertNotNull(attemptReport);
  Assert.assertEquals("appattempt_0_0001_000001", attemptReport
    .getApplicationAttemptId().toString());
}
 
Example #26
Source File: TestContainerManagerSecurity.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void
    getContainerStatus(YarnRPC rpc,
        org.apache.hadoop.yarn.api.records.Token nmToken,
        ContainerId containerId,
        ApplicationAttemptId appAttemptId, NodeId nodeId,
        boolean isExceptionExpected) throws Exception {
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  GetContainerStatusesRequest request =
      GetContainerStatusesRequest.newInstance(containerIds);
  ContainerManagementProtocol proxy = null;
  try {
    proxy =
        getContainerManagementProtocolProxy(rpc, nmToken, nodeId,
            appAttemptId.toString());
    GetContainerStatusesResponse statuses = proxy.getContainerStatuses(request);
    if (statuses.getFailedRequests() != null
        && statuses.getFailedRequests().containsKey(containerId)) {
      parseAndThrowException(statuses.getFailedRequests().get(containerId)
        .deSerialize());
    }
  } finally {
    if (proxy != null) {
      rpc.stopProxy(proxy, conf);
    }
  }
}
 
Example #27
Source File: MockRM.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public void sendAMLaunchFailed(ApplicationAttemptId appAttemptId)
    throws Exception {
  MockAM am = new MockAM(getRMContext(), masterService, appAttemptId);
  am.waitForState(RMAppAttemptState.ALLOCATED);
  getRMContext().getDispatcher().getEventHandler()
      .handle(new RMAppAttemptLaunchFailedEvent(appAttemptId, "Failed"));
}
 
Example #28
Source File: TestYarnClient.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 10000)
public void testGetContainerReport() throws YarnException, IOException {
  Configuration conf = new Configuration();
  conf.setBoolean(YarnConfiguration.APPLICATION_HISTORY_ENABLED,
      true);
  final YarnClient client = new MockYarnClient();
  client.init(conf);
  client.start();

  List<ApplicationReport> expectedReports = ((MockYarnClient) client)
      .getReports();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(
      applicationId, 1);
  ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
  ContainerReport report = client.getContainerReport(containerId);
  Assert.assertNotNull(report);
  Assert.assertEquals(report.getContainerId().toString(),
      (ContainerId.newContainerId(expectedReports.get(0)
          .getCurrentApplicationAttemptId(), 1)).toString());
  containerId = ContainerId.newContainerId(appAttemptId, 3);
  report = client.getContainerReport(containerId);
  Assert.assertNotNull(report);
  Assert.assertEquals(report.getContainerId().toString(),
      (ContainerId.newContainerId(expectedReports.get(0)
          .getCurrentApplicationAttemptId(), 3)).toString());
  client.stop();
}
 
Example #29
Source File: TestAHSClient.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public List<ContainerReport>
    getContainers(ApplicationAttemptId appAttemptId) throws YarnException,
        IOException {
  when(mockContainersResponse.getContainerList()).thenReturn(
    getContainersReport(appAttemptId));
  return super.getContainers(appAttemptId);
}
 
Example #30
Source File: TestRuntimeEstimators.java    From hadoop with Apache License 2.0 5 votes vote down vote up
MyAppContext(int numberMaps, int numberReduces) {
  myApplicationID = ApplicationId.newInstance(clock.getTime(), 1);

  myAppAttemptID = ApplicationAttemptId.newInstance(myApplicationID, 0);
  myJobID = recordFactory.newRecordInstance(JobId.class);
  myJobID.setAppId(myApplicationID);

  Job myJob
      = new MyJobImpl(myJobID, numberMaps, numberReduces);

  allJobs = Collections.singletonMap(myJobID, myJob);
}