Java Code Examples for org.apache.hadoop.yarn.api.records.Container#getNodeId()

The following examples show how to use org.apache.hadoop.yarn.api.records.Container#getNodeId() . 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: NMClientAsyncImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public StartContainerEvent(Container container,
    ContainerLaunchContext containerLaunchContext) {
  super(container.getId(), container.getNodeId(),
      container.getContainerToken(), ContainerEventType.START_CONTAINER);
  this.container = container;
  this.containerLaunchContext = containerLaunchContext;
}
 
Example 2
Source File: NMClientAsyncImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
public StartContainerEvent(Container container,
    ContainerLaunchContext containerLaunchContext) {
  super(container.getId(), container.getNodeId(),
      container.getContainerToken(), ContainerEventType.START_CONTAINER);
  this.container = container;
  this.containerLaunchContext = containerLaunchContext;
}
 
Example 3
Source File: NMCommunicatorLaunchRequestEvent.java    From incubator-tez with Apache License 2.0 5 votes vote down vote up
public NMCommunicatorLaunchRequestEvent(ContainerLaunchContext clc,
    Container container) {
  super(container.getId(), container.getNodeId(), container
      .getContainerToken(), NMCommunicatorEventType.CONTAINER_LAUNCH_REQUEST);
  this.clc = clc;
  this.container = container;
}
 
Example 4
Source File: ContainerLauncherLaunchRequestEvent.java    From tez with Apache License 2.0 5 votes vote down vote up
public ContainerLauncherLaunchRequestEvent(ContainerLaunchContext clc,
                                           Container container, int launcherId, int schedulerId,
                                           int taskCommId) {
  super(container.getId(), container.getNodeId(), container
      .getContainerToken(), ContainerLauncherEventType.CONTAINER_LAUNCH_REQUEST,
      launcherId, schedulerId, taskCommId);
  this.clc = clc;
  this.container = container;
}
 
Example 5
Source File: NMClientImpl.java    From hadoop with Apache License 2.0 4 votes vote down vote up
protected synchronized StartedContainer createStartedContainer(
    Container container) throws YarnException, IOException {
  StartedContainer startedContainer = new StartedContainer(container.getId(),
      container.getNodeId(), container.getContainerToken());
  return startedContainer;
}
 
Example 6
Source File: NMClientImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
protected synchronized StartedContainer createStartedContainer(
    Container container) throws YarnException, IOException {
  StartedContainer startedContainer = new StartedContainer(container.getId(),
      container.getNodeId(), container.getContainerToken());
  return startedContainer;
}
 
Example 7
Source File: TaskAttemptImpl.java    From incubator-tez with Apache License 2.0 4 votes vote down vote up
@Override
public void transition(TaskAttemptImpl ta, TaskAttemptEvent origEvent) {
  TaskAttemptEventStartedRemotely event = (TaskAttemptEventStartedRemotely) origEvent;

  Container container = ta.appContext.getAllContainers()
      .get(event.getContainerId()).getContainer();

  ta.container = container;
  ta.containerId = event.getContainerId();
  ta.containerNodeId = container.getNodeId();
  ta.nodeHttpAddress = StringInterner.weakIntern(container.getNodeHttpAddress());
  ta.nodeRackName = StringInterner.weakIntern(RackResolver.resolve(ta.containerNodeId.getHost())
      .getNetworkLocation());

  ta.launchTime = ta.clock.getTime();

  // TODO Resolve to host / IP in case of a local address.
  InetSocketAddress nodeHttpInetAddr = NetUtils
      .createSocketAddr(ta.nodeHttpAddress); // TODO: Costly?
  ta.trackerName = StringInterner.weakIntern(nodeHttpInetAddr.getHostName());
  ta.httpPort = nodeHttpInetAddr.getPort();
  ta.sendEvent(createJobCounterUpdateEventTALaunched(ta));

  LOG.info("TaskAttempt: [" + ta.attemptId + "] started."
      + " Is using containerId: [" + ta.containerId + "]" + " on NM: ["
      + ta.containerNodeId + "]");

  // JobHistoryEvent
  ta.logJobHistoryAttemptStarted();

  // TODO Remove after HDFS-5098
  // Compute LOCALITY counter for this task.
  if (ta.taskHosts.contains(ta.containerNodeId.getHost())) {
    ta.localityCounter = DAGCounter.DATA_LOCAL_TASKS;
  } else if (ta.taskRacks.contains(ta.nodeRackName)) {
    ta.localityCounter = DAGCounter.RACK_LOCAL_TASKS;
  } else {
    // Not computing this if the task does not have locality information.
    if (ta.getTaskLocationHint() != null) {
      ta.localityCounter = DAGCounter.OTHER_LOCAL_TASKS;
    }
  }

  // Inform the Task
  ta.sendEvent(new TaskEventTAUpdate(ta.attemptId,
      TaskEventType.T_ATTEMPT_LAUNCHED));

  ta.taskHeartbeatHandler.register(ta.attemptId);
}
 
Example 8
Source File: TaskAttemptImpl.java    From tez with Apache License 2.0 4 votes vote down vote up
@Override
public void transition(TaskAttemptImpl ta, TaskAttemptEvent origEvent) {
  TaskAttemptEventSubmitted event = (TaskAttemptEventSubmitted) origEvent;

  AMContainer amContainer = ta.appContext.getAllContainers().get(event.getContainerId());
  Container container = amContainer.getContainer();

  ta.allocationTime = amContainer.getCurrentTaskAttemptAllocationTime();
  ta.container = container;
  ta.containerId = event.getContainerId();
  ta.containerNodeId = container.getNodeId();
  ta.nodeHttpAddress = StringInterner.weakIntern(container.getNodeHttpAddress());
  ta.nodeRackName = StringInterner.weakIntern(RackResolver.resolve(ta.containerNodeId.getHost())
      .getNetworkLocation());
  ta.lastNotifyProgressTimestamp = ta.clock.getTime();

  ta.setLaunchTime();

  // TODO Resolve to host / IP in case of a local address.
  InetSocketAddress nodeHttpInetAddr = NetUtils
      .createSocketAddr(ta.nodeHttpAddress); // TODO: Costly?
  ta.trackerName = StringInterner.weakIntern(nodeHttpInetAddr.getHostName());
  ta.httpPort = nodeHttpInetAddr.getPort();
  ta.sendEvent(createDAGCounterUpdateEventTALaunched(ta));

  LOG.info("TaskAttempt: [" + ta.attemptId + "] submitted."
      + " Is using containerId: [" + ta.containerId + "]" + " on NM: ["
      + ta.containerNodeId + "]");

  // JobHistoryEvent.
  // The started event represents when the attempt was submitted to the executor.
  ta.logJobHistoryAttemptStarted();

  // TODO Remove after HDFS-5098
  // Compute LOCALITY counter for this task.
  if (ta.taskHosts.contains(ta.containerNodeId.getHost())) {
    ta.localityCounter = DAGCounter.DATA_LOCAL_TASKS;
  } else if (ta.taskRacks.contains(ta.nodeRackName)) {
    ta.localityCounter = DAGCounter.RACK_LOCAL_TASKS;
  } else {
    // Not computing this if the task does not have locality information.
    if (ta.getTaskLocationHint() != null) {
      ta.localityCounter = DAGCounter.OTHER_LOCAL_TASKS;
    }
  }

  // Inform the Task
  ta.sendEvent(new TaskEventTALaunched(ta.attemptId));

  if (ta.isSpeculationEnabled()) {
    ta.sendEvent(new SpeculatorEventTaskAttemptStatusUpdate(ta.attemptId, TaskAttemptState.RUNNING,
        ta.launchTime, true));
  }

  ta.sendEvent(
      new AMSchedulerEventTAStateUpdated(ta, TaskScheduler.SchedulerTaskState.SUBMITTED,
          ta.getVertex().getTaskSchedulerIdentifier()));
  ta.taskHeartbeatHandler.register(ta.attemptId);
}