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

The following examples show how to use org.apache.hadoop.yarn.api.records.ContainerId. 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: AbstractYarnScheduler.java    From hadoop with Apache License 2.0 6 votes vote down vote up
protected void releaseContainers(List<ContainerId> containers,
    SchedulerApplicationAttempt attempt) {
  for (ContainerId containerId : containers) {
    RMContainer rmContainer = getRMContainer(containerId);
    if (rmContainer == null) {
      if (System.currentTimeMillis() - ResourceManager.getClusterTimeStamp()
          < nmExpireInterval) {
        LOG.info(containerId + " doesn't exist. Add the container"
            + " to the release request cache as it maybe on recovery.");
        synchronized (attempt) {
          attempt.getPendingRelease().add(containerId);
        }
      } else {
        RMAuditLogger.logFailure(attempt.getUser(),
          AuditConstants.RELEASE_CONTAINER,
          "Unauthorized access or invalid container", "Scheduler",
          "Trying to release container not owned by app or with invalid id.",
          attempt.getApplicationId(), containerId);
      }
    }
    completedContainer(rmContainer,
      SchedulerUtils.createAbnormalContainerStatus(containerId,
        SchedulerUtils.RELEASED_CONTAINER), RMContainerEventType.RELEASED);
  }
}
 
Example #2
Source File: TestContainerManagerSecurity.java    From big-c with Apache License 2.0 6 votes vote down vote up
private void waitForContainerToFinishOnNM(ContainerId containerId) {
  Context nmContet = yarnCluster.getNodeManager(0).getNMContext();
  int interval = 4 * 60; // Max time for container token to expire.
  Assert.assertNotNull(nmContet.getContainers().containsKey(containerId));
  while ((interval-- > 0)
      && !nmContet.getContainers().get(containerId)
        .cloneAndGetContainerStatus().getState()
        .equals(ContainerState.COMPLETE)) {
    try {
      LOG.info("Waiting for " + containerId + " to complete.");
      Thread.sleep(1000);
    } catch (InterruptedException e) {
    }
  }
  // Normally, Containers will be removed from NM context after they are
  // explicitly acked by RM. Now, manually remove it for testing.
  yarnCluster.getNodeManager(0).getNodeStatusUpdater()
    .addCompletedContainer(containerId);
  nmContet.getContainers().remove(containerId);
}
 
Example #3
Source File: TestDockerContainerExecutor.java    From big-c with Apache License 2.0 6 votes vote down vote up
private int runAndBlock(ContainerId cId, Map<String, String> launchCtxEnv, String... cmd) throws IOException {
  String appId = "APP_" + System.currentTimeMillis();
  Container container = mock(Container.class);
  ContainerLaunchContext context = mock(ContainerLaunchContext.class);

  when(container.getContainerId()).thenReturn(cId);
  when(container.getLaunchContext()).thenReturn(context);
  when(cId.getApplicationAttemptId().getApplicationId().toString()).thenReturn(appId);
  when(context.getEnvironment()).thenReturn(launchCtxEnv);

  String script = writeScriptFile(launchCtxEnv, cmd);

  Path scriptPath = new Path(script);
  Path tokensPath = new Path("/dev/null");
  Path workDir = new Path(workSpace.getAbsolutePath());
  Path pidFile = new Path(workDir, "pid.txt");

  exec.activateContainer(cId, pidFile);
  return exec.launchContainer(container, scriptPath, tokensPath,
      appSubmitter, appId, workDir, dirsHandler.getLocalDirs(),
      dirsHandler.getLogDirs());
}
 
Example #4
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 #5
Source File: RMAppAttemptImpl.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override
public ApplicationAttemptReport createApplicationAttemptReport() {
  this.readLock.lock();
  ApplicationAttemptReport attemptReport = null;
  try {
    // AM container maybe not yet allocated. and also unmangedAM doesn't have
    // am container.
    ContainerId amId =
        masterContainer == null ? null : masterContainer.getId();
    attemptReport = ApplicationAttemptReport.newInstance(this
        .getAppAttemptId(), this.getHost(), this.getRpcPort(), this
        .getTrackingUrl(), this.getOriginalTrackingUrl(), this.getDiagnostics(),
        YarnApplicationAttemptState .valueOf(this.getState().toString()), amId);
  } finally {
    this.readLock.unlock();
  }
  return attemptReport;
}
 
Example #6
Source File: TestYarnClient.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private ContainerReport getContainer(
    ContainerId containerId,
    HashMap<ApplicationAttemptId, List<ContainerReport>> containersToAppAttemptMapping)
    throws YarnException, IOException {
  List<ContainerReport> containersForAppAttempt =
      containersToAppAttemptMapping.get(containerId
          .getApplicationAttemptId());
  if (containersForAppAttempt == null) {
    throw new ApplicationNotFoundException(containerId
        .getApplicationAttemptId().getApplicationId() + " is not found ");
  }
  Iterator<ContainerReport> iterator = containersForAppAttempt.iterator();
  while (iterator.hasNext()) {
    ContainerReport next = iterator.next();
    if (next.getContainerId().equals(containerId)) {
      return next;
    }
  }
  throw new ContainerNotFoundException(containerId + " is not found ");
}
 
Example #7
Source File: TestDAGRecovery.java    From tez with Apache License 2.0 6 votes vote down vote up
/**
 * RecoveryEvents: TaskAttemptStartedEvent -> TaskAttemptFinishedEvent (KILLED)
 * Recover it to KILLED
 */
@Test(timeout=5000)
public void testTARecoverFromKilled() {
  initMockDAGRecoveryDataForTaskAttempt();
  TaskAttemptStartedEvent taStartedEvent = new TaskAttemptStartedEvent(
      ta1t1v1Id, "v1", ta1LaunchTime, mock(ContainerId.class), 
      mock(NodeId.class), "", "", "");
  TaskAttemptFinishedEvent taFinishedEvent = new TaskAttemptFinishedEvent(
      ta1t1v1Id, "v1", ta1FinishedTime, ta1FinishedTime, 
      TaskAttemptState.KILLED, null, TaskAttemptTerminationCause.TERMINATED_BY_CLIENT, "", null,
      null, null, 0L, null, 0L, null, null, null, null, null);
  TaskAttemptRecoveryData taRecoveryData = new TaskAttemptRecoveryData(taStartedEvent, taFinishedEvent);
  doReturn(taRecoveryData).when(dagRecoveryData).getTaskAttemptRecoveryData(ta1t1v1Id);
  
  dag.handle(new DAGEventRecoverEvent(dagId, dagRecoveryData));
  dispatcher.await();
  
  TaskImpl task = (TaskImpl)dag.getVertex(v1Id).getTask(t1v1Id);
  TaskAttemptImpl taskAttempt = (TaskAttemptImpl)task.getAttempt(ta1t1v1Id);
  assertEquals(TaskAttemptStateInternal.KILLED, taskAttempt.getInternalState());
  assertEquals(TaskAttemptTerminationCause.TERMINATED_BY_CLIENT, taskAttempt.getTerminationCause());
  historyEventHandler.verifyHistoryEvent(0, HistoryEventType.TASK_ATTEMPT_FINISHED);
  assertEquals(ta1LaunchTime, taskAttempt.getLaunchTime());
  assertEquals(ta1FinishedTime, taskAttempt.getFinishTime());
}
 
Example #8
Source File: DagAwareYarnTaskScheduler.java    From tez with Apache License 2.0 6 votes vote down vote up
@Override
public void initiateStop() {
  super.initiateStop();
  LOG.debug("Initiating stop of task scheduler");
  stopRequested = true;
  List<ContainerId> releasedLaunchedContainers;
  synchronized (this) {
    releasedLaunchedContainers = new ArrayList<>(heldContainers.size());
    List<HeldContainer> heldList = new ArrayList<>(heldContainers.values());
    for (HeldContainer hc : heldList) {
      if (releaseContainer(hc)) {
        releasedLaunchedContainers.add(hc.getId());
      }
    }

    List<Object> tasks = requestTracker.getTasks();
    for (Object task : tasks) {
      removeTaskRequest(task);
    }
  }

  // perform app callback outside of locks
  for (ContainerId id : releasedLaunchedContainers) {
    getContext().containerBeingReleased(id);
  }
}
 
Example #9
Source File: TestConverterUtils.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testContainerIdWithEpoch() throws URISyntaxException {
  ContainerId id = TestContainerId.newContainerId(0, 0, 0, 25645811);
  String cid = ConverterUtils.toString(id);
  assertEquals("container_0_0000_00_25645811", cid);
  ContainerId gen = ConverterUtils.toContainerId(cid);
  assertEquals(gen.toString(), id.toString());

  long ts = System.currentTimeMillis();
  ContainerId id2 =
      TestContainerId.newContainerId(36473, 4365472, ts, 4298334883325L);
  String cid2 = ConverterUtils.toString(id2);
  assertEquals(
      "container_e03_" + ts + "_36473_4365472_999799999997", cid2);
  ContainerId gen2 = ConverterUtils.toContainerId(cid2);
  assertEquals(gen2.toString(), id2.toString());

  ContainerId id3 =
      TestContainerId.newContainerId(36473, 4365472, ts, 844424930131965L);
  String cid3 = ConverterUtils.toString(id3);
  assertEquals(
      "container_e767_" + ts + "_36473_4365472_1099511627773", cid3);
  ContainerId gen3 = ConverterUtils.toContainerId(cid3);
  assertEquals(gen3.toString(), id3.toString());
}
 
Example #10
Source File: CuneiformEApplicationMaster.java    From Hi-WAY with Apache License 2.0 6 votes vote down vote up
@Override
public void taskSuccess(TaskInstance task, ContainerId containerId) {
	try {
		(new Data(task.getId() + "_reply", containerId.toString())).stageIn();
		JSONObject reply = parseEffiFile(task.getId() + "_reply");
		workflow.addReply(reply);

		writeEntryToLog(new JsonReportEntry(task.getWorkflowId(), task.getTaskId(), task.getTaskName(), task.getLanguageLabel(), Long.valueOf(task.getId()),
		    null, JsonReportEntry.KEY_INVOC_OUTPUT, reply.toString()));
		for (String fileName : RemoteWorkflow.getOutputSet(requests.get(task), reply)) {
			files.put(fileName, new Data(fileName, containerId.toString()));
		}
	} catch (IOException | JSONException e) {
		e.printStackTrace(System.out);
		System.exit(-1);
	}
}
 
Example #11
Source File: TestApplicationHistoryClientService.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testContainerReport() throws IOException, YarnException {
  ApplicationId appId = ApplicationId.newInstance(0, 1);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, 1);
  ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
  GetContainerReportRequest request =
      GetContainerReportRequest.newInstance(containerId);
  GetContainerReportResponse response =
      clientService.getContainerReport(request);
  ContainerReport container = response.getContainerReport();
  Assert.assertNotNull(container);
  Assert.assertEquals(containerId, container.getContainerId());
  Assert.assertEquals("http://0.0.0.0:8188/applicationhistory/logs/" +
      "test host:100/container_0_0001_01_000001/" +
      "container_0_0001_01_000001/user1", container.getLogUrl());
}
 
Example #12
Source File: TestContainerResourceDecrease.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testResourceDecreaseContext() {
  ContainerId containerId = ContainerId
      .newContainerId(ApplicationAttemptId.newInstance(
          ApplicationId.newInstance(1234, 3), 3), 7);
  Resource resource = Resource.newInstance(1023, 3);
  ContainerResourceDecrease ctx = ContainerResourceDecrease.newInstance(
      containerId, resource);

  // get proto and recover to ctx
  ContainerResourceDecreaseProto proto = 
      ((ContainerResourceDecreasePBImpl) ctx).getProto();
  ctx = new ContainerResourceDecreasePBImpl(proto);

  // check values
  Assert.assertEquals(ctx.getCapability(), resource);
  Assert.assertEquals(ctx.getContainerId(), containerId);
}
 
Example #13
Source File: LocalizedResource.java    From hadoop with Apache License 2.0 6 votes vote down vote up
public String toString() {
  StringBuilder sb = new StringBuilder();
  sb.append("{ ").append(rsrc.toString()).append(",")
    .append(getState() == ResourceState.LOCALIZED
        ? getLocalPath() + "," + getSize()
        : "pending").append(",[");
  try {
    this.readLock.lock();
    for (ContainerId c : ref) {
      sb.append("(").append(c.toString()).append(")");
    }
    sb.append("],").append(getTimestamp()).append(",").append(getState())
      .append("}");
    return sb.toString();
  } finally {
    this.readLock.unlock();
  }
}
 
Example #14
Source File: MockDAGAppMaster.java    From tez with Apache License 2.0 6 votes vote down vote up
public MockDAGAppMaster(ApplicationAttemptId applicationAttemptId, ContainerId containerId,
    String nmHost, int nmPort, int nmHttpPort, Clock clock, long appSubmitTime,
    boolean isSession, String workingDirectory, String[] localDirs, String[] logDirs,
    AtomicBoolean launcherGoFlag, boolean initFailFlag, boolean startFailFlag,
    Credentials credentials, String jobUserName, int handlerConcurrency, int numConcurrentContainers) {
  super(applicationAttemptId, containerId, nmHost, nmPort, nmHttpPort, clock, appSubmitTime,
      isSession, workingDirectory, localDirs, logDirs,  new TezApiVersionInfo().getVersion(),
      credentials, jobUserName, null);
  shutdownHandler = new MockDAGAppMasterShutdownHandler();
  this.launcherGoFlag = launcherGoFlag;
  this.initFailFlag = initFailFlag;
  this.startFailFlag = startFailFlag;
  Preconditions.checkArgument(handlerConcurrency > 0);
  this.handlerConcurrency = handlerConcurrency;
  this.numConcurrentContainers = numConcurrentContainers;
}
 
Example #15
Source File: ApplicationAttemptHistoryData.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Public
@Unstable
public static ApplicationAttemptHistoryData newInstance(
    ApplicationAttemptId appAttemptId, String host, int rpcPort,
    ContainerId masterContainerId, String diagnosticsInfo,
    String trackingURL, FinalApplicationStatus finalApplicationStatus,
    YarnApplicationAttemptState yarnApplicationAttemptState) {
  ApplicationAttemptHistoryData appAttemptHD =
      new ApplicationAttemptHistoryData();
  appAttemptHD.setApplicationAttemptId(appAttemptId);
  appAttemptHD.setHost(host);
  appAttemptHD.setRPCPort(rpcPort);
  appAttemptHD.setMasterContainerId(masterContainerId);
  appAttemptHD.setDiagnosticsInfo(diagnosticsInfo);
  appAttemptHD.setTrackingURL(trackingURL);
  appAttemptHD.setFinalApplicationStatus(finalApplicationStatus);
  appAttemptHD.setYarnApplicationAttemptState(yarnApplicationAttemptState);
  return appAttemptHD;
}
 
Example #16
Source File: TestNodeStatusUpdater.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public static ContainerStatus createContainerStatus(int id,
    ContainerState containerState) {
  ApplicationId applicationId = ApplicationId.newInstance(0, 1);
  ApplicationAttemptId applicationAttemptId =
      ApplicationAttemptId.newInstance(applicationId, 1);
  ContainerId contaierId = ContainerId.newContainerId(applicationAttemptId, id);
  ContainerStatus containerStatus =
      BuilderUtils.newContainerStatus(contaierId, containerState,
        "test_containerStatus: id=" + id + ", containerState: "
            + containerState, 0);
  return containerStatus;
}
 
Example #17
Source File: TestContainerLogsPage.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testLogDirWithDriveLetter() throws Exception {
  //To verify that logs paths which include drive letters (Windows)
  //do not lose their drive letter specification
  LocalDirsHandlerService localDirs = mock(LocalDirsHandlerService.class);
  List<String> logDirs = new ArrayList<String>();
  logDirs.add("F:/nmlogs");
  when(localDirs.getLogDirsForRead()).thenReturn(logDirs);
  
  ApplicationIdPBImpl appId = mock(ApplicationIdPBImpl.class);
  when(appId.toString()).thenReturn("app_id_1");
  
  ApplicationAttemptIdPBImpl appAttemptId =
             mock(ApplicationAttemptIdPBImpl.class);
  when(appAttemptId.getApplicationId()).thenReturn(appId);
  
  ContainerId containerId = mock(ContainerIdPBImpl.class);
  when(containerId.getApplicationAttemptId()).thenReturn(appAttemptId);
  
  List<File> logDirFiles = ContainerLogsUtils.getContainerLogDirs(
    containerId, localDirs);
  
  Assert.assertTrue("logDir lost drive letter " +
    logDirFiles.get(0),
    logDirFiles.get(0).toString().indexOf("F:" + File.separator +
      "nmlogs") > -1);
}
 
Example #18
Source File: TestTaskSchedulerManager.java    From tez with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 5000)
public void testTASucceededAfterContainerCleanup() throws Exception {
  Configuration conf = new Configuration(false);
  schedulerHandler.init(conf);
  schedulerHandler.start();

  TaskAttemptImpl mockTaskAttempt = mock(TaskAttemptImpl.class);
  TezTaskAttemptID mockAttemptId = mock(TezTaskAttemptID.class);
  when(mockAttemptId.getId()).thenReturn(0);
  when(mockTaskAttempt.getID()).thenReturn(mockAttemptId);
  Resource resource = Resource.newInstance(1024, 1);
  ContainerContext containerContext =
      new ContainerContext(new HashMap<String, LocalResource>(), new Credentials(),
          new HashMap<String, String>(), "");
  int priority = 10;
  TaskLocationHint locHint = TaskLocationHint.createTaskLocationHint(new HashSet<String>(), null);

  ContainerId mockCId = mock(ContainerId.class);
  Container container = mock(Container.class);
  when(container.getId()).thenReturn(mockCId);

  AMContainer mockAMContainer = mock(AMContainer.class);
  when(mockAMContainer.getContainerId()).thenReturn(mockCId);
  when(mockAMContainer.getState()).thenReturn(AMContainerState.IDLE);

  // Returning null container will replicate container cleanup scenario
  when(mockAMContainerMap.get(mockCId)).thenReturn(null);

  AMSchedulerEventTALaunchRequest lr =
      new AMSchedulerEventTALaunchRequest(mockAttemptId, resource, null, mockTaskAttempt, locHint,
          priority, containerContext, 0, 0, 0);
  schedulerHandler.taskAllocated(0, mockTaskAttempt, lr, container);
  assertEquals(1, mockEventHandler.events.size());
  assertTrue(mockEventHandler.events.get(0) instanceof AMContainerEventAssignTA);
  AMContainerEventAssignTA assignEvent =
      (AMContainerEventAssignTA) mockEventHandler.events.get(0);
  assertEquals(priority, assignEvent.getPriority());
  assertEquals(mockAttemptId, assignEvent.getTaskAttemptId());
}
 
Example #19
Source File: NodeContainerUpdate.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static NodeContainerUpdate newInstance(ContainerId containerId, int memory,int cores,boolean suspend, boolean resume){
	NodeContainerUpdate nodeContainerUpdate =
	        Records.newRecord(NodeContainerUpdate.class);
	nodeContainerUpdate.setContianerId(containerId);
	nodeContainerUpdate.setMemory(memory);
	nodeContainerUpdate.setCores(cores);
	nodeContainerUpdate.setSuspend(suspend);
	nodeContainerUpdate.setResume(resume);
	return nodeContainerUpdate;
}
 
Example #20
Source File: NMLeveldbStateStoreService.java    From big-c with Apache License 2.0 5 votes vote down vote up
private RecoveredContainerState loadContainerState(ContainerId containerId,
    LeveldbIterator iter, String keyPrefix) throws IOException {
  RecoveredContainerState rcs = new RecoveredContainerState();
  rcs.status = RecoveredContainerStatus.REQUESTED;
  while (iter.hasNext()) {
    Entry<byte[],byte[]> entry = iter.peekNext();
    String key = asString(entry.getKey());
    if (!key.startsWith(keyPrefix)) {
      break;
    }
    iter.next();

    String suffix = key.substring(keyPrefix.length()-1);  // start with '/'
    if (suffix.equals(CONTAINER_REQUEST_KEY_SUFFIX)) {
      rcs.startRequest = new StartContainerRequestPBImpl(
          StartContainerRequestProto.parseFrom(entry.getValue()));
    } else if (suffix.equals(CONTAINER_DIAGS_KEY_SUFFIX)) {
      rcs.diagnostics = asString(entry.getValue());
    } else if (suffix.equals(CONTAINER_LAUNCHED_KEY_SUFFIX)) {
      if (rcs.status == RecoveredContainerStatus.REQUESTED) {
        rcs.status = RecoveredContainerStatus.LAUNCHED;
      }
    } else if (suffix.equals(CONTAINER_KILLED_KEY_SUFFIX)) {
      rcs.killed = true;
    } else if (suffix.equals(CONTAINER_EXIT_CODE_KEY_SUFFIX)) {
      rcs.status = RecoveredContainerStatus.COMPLETED;
      rcs.exitCode = Integer.parseInt(asString(entry.getValue()));
    } else {
      throw new IOException("Unexpected container state key: " + key);
    }
  }
  return rcs;
}
 
Example #21
Source File: TestMRAppMaster.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testMRAppMasterMidLock() 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);
  FileSystem fs = FileSystem.get(conf);
  //Create the file, but no end file so we should unregister with an error.
  fs.create(start).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.ERROR, appMaster.forcedState);
  appMaster.stop();

  // verify the final status is FAILED
  verifyFailedStatus((MRAppMasterTest)appMaster, "FAILED");
}
 
Example #22
Source File: AMLauncher.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void launch() throws IOException, YarnException {
  connect();
  ContainerId masterContainerID = masterContainer.getId();
  ApplicationSubmissionContext applicationContext =
    application.getSubmissionContext();
  LOG.info("Setting up container " + masterContainer
      + " for AM " + application.getAppAttemptId());  
  ContainerLaunchContext launchContext =
      createAMContainerLaunchContext(applicationContext, masterContainerID);

  StartContainerRequest scRequest =
      StartContainerRequest.newInstance(launchContext,
        masterContainer.getContainerToken());
  List<StartContainerRequest> list = new ArrayList<StartContainerRequest>();
  list.add(scRequest);
  StartContainersRequest allRequests =
      StartContainersRequest.newInstance(list);

  StartContainersResponse response =
      containerMgrProxy.startContainers(allRequests);
  if (response.getFailedRequests() != null
      && response.getFailedRequests().containsKey(masterContainerID)) {
    Throwable t =
        response.getFailedRequests().get(masterContainerID).deSerialize();
    parseAndThrowException(t);
  } else {
    LOG.info("Done launching container " + masterContainer + " for AM "
        + application.getAppAttemptId());
  }
}
 
Example #23
Source File: ContainerPBImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void setId(ContainerId id) {
  maybeInitBuilder();
  if (id == null)
    builder.clearId();
  this.containerId = id;
}
 
Example #24
Source File: StartContainersResponsePBImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void initSucceededContainers() {
  if (this.succeededContainers != null)
    return;
  StartContainersResponseProtoOrBuilder p = viaProto ? proto : builder;
  List<ContainerIdProto> list = p.getSucceededRequestsList();
  this.succeededContainers = new ArrayList<ContainerId>();
  for (ContainerIdProto c : list) {
    this.succeededContainers.add(convertFromProtoFormat(c));
  }
}
 
Example #25
Source File: NMLeveldbStateStoreService.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void removeContainerToken(ContainerId containerId)
    throws IOException {
  String key = CONTAINER_TOKENS_KEY_PREFIX + containerId;
  try {
    db.delete(bytes(key));
  } catch (DBException e) {
    throw new IOException(e);
  }
}
 
Example #26
Source File: ContainerStopRequest.java    From tez with Apache License 2.0 5 votes vote down vote up
public ContainerStopRequest(NodeId nodeId,
                            ContainerId containerId,
                            Token containerToken, String schedulerName, String taskCommName) {
  super(nodeId, containerId, containerToken);
  this.schedulerName = schedulerName;
  this.taskCommName = taskCommName;
}
 
Example #27
Source File: ContainerLauncherEvent.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public ContainerLauncherEvent(TaskAttemptId taskAttemptID, 
    ContainerId containerID,
    String containerMgrAddress,
    Token containerToken,
    ContainerLauncher.EventType type) {
  super(type);
  this.taskAttemptID = taskAttemptID;
  this.containerID = containerID;
  this.containerMgrAddress = containerMgrAddress;
  this.containerToken = containerToken;
}
 
Example #28
Source File: BuilderUtils.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public static Container newContainer(ContainerId containerId, NodeId nodeId,
    String nodeHttpAddress, Resource resource, Priority priority,
    Token containerToken) {
  Container container = recordFactory.newRecordInstance(Container.class);
  container.setId(containerId);
  container.setNodeId(nodeId);
  container.setNodeHttpAddress(nodeHttpAddress);
  container.setResource(resource);
  container.setPriority(priority);
  container.setContainerToken(containerToken);
  return container;
}
 
Example #29
Source File: NMClientAsyncImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public StatefulContainer(NMClientAsync client, ContainerId containerId) {
  this.nmClientAsync = client;
  this.containerId = containerId;
  stateMachine = stateMachineFactory.make(this);
  ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
  readLock = lock.readLock();
  writeLock = lock.writeLock();
}
 
Example #30
Source File: RMContainerReservedEvent.java    From big-c with Apache License 2.0 5 votes vote down vote up
public RMContainerReservedEvent(ContainerId containerId,
    Resource reservedResource, NodeId reservedNode, 
    Priority reservedPriority) {
  super(containerId, RMContainerEventType.RESERVED);
  this.reservedResource = reservedResource;
  this.reservedNode = reservedNode;
  this.reservedPriority = reservedPriority;
}