Search in sources :

Example 6 with ContainerAllocatorEvent

use of org.apache.hadoop.mapreduce.v2.app.rm.ContainerAllocatorEvent in project hadoop by apache.

the class RMContainerAllocator method serviceStart.

@Override
protected void serviceStart() throws Exception {
    this.eventHandlingThread = new Thread() {

        @SuppressWarnings("unchecked")
        @Override
        public void run() {
            ContainerAllocatorEvent event;
            while (!stopped.get() && !Thread.currentThread().isInterrupted()) {
                try {
                    event = RMContainerAllocator.this.eventQueue.take();
                } catch (InterruptedException e) {
                    if (!stopped.get()) {
                        LOG.error("Returning, interrupted : " + e);
                    }
                    return;
                }
                try {
                    handleEvent(event);
                } catch (Throwable t) {
                    LOG.error("Error in handling event type " + event.getType() + " to the ContainreAllocator", t);
                    // Kill the AM
                    eventHandler.handle(new JobEvent(getJob().getID(), JobEventType.INTERNAL_ERROR));
                    return;
                }
            }
        }
    };
    this.eventHandlingThread.start();
    super.serviceStart();
}
Also used : JobEvent(org.apache.hadoop.mapreduce.v2.app.job.event.JobEvent)

Example 7 with ContainerAllocatorEvent

use of org.apache.hadoop.mapreduce.v2.app.rm.ContainerAllocatorEvent in project hadoop by apache.

the class LocalContainerAllocator method handle.

@SuppressWarnings("unchecked")
@Override
public void handle(ContainerAllocatorEvent event) {
    if (event.getType() == ContainerAllocator.EventType.CONTAINER_REQ) {
        LOG.info("Processing the event " + event.toString());
        // Assign the same container ID as the AM
        ContainerId cID = ContainerId.newContainerId(getContext().getApplicationAttemptId(), this.containerId.getContainerId());
        Container container = recordFactory.newRecordInstance(Container.class);
        container.setId(cID);
        NodeId nodeId = NodeId.newInstance(this.nmHost, this.nmPort);
        container.setResource(Resource.newInstance(0, 0));
        container.setNodeId(nodeId);
        container.setContainerToken(null);
        container.setNodeHttpAddress(this.nmHost + ":" + this.nmHttpPort);
        if (event.getAttemptID().getTaskId().getTaskType() == TaskType.MAP) {
            JobCounterUpdateEvent jce = new JobCounterUpdateEvent(event.getAttemptID().getTaskId().getJobId());
            // TODO Setting OTHER_LOCAL_MAP for now.
            jce.addCounterUpdate(JobCounter.OTHER_LOCAL_MAPS, 1);
            eventHandler.handle(jce);
        }
        eventHandler.handle(new TaskAttemptContainerAssignedEvent(event.getAttemptID(), container, applicationACLs));
    }
}
Also used : Container(org.apache.hadoop.yarn.api.records.Container) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) NodeId(org.apache.hadoop.yarn.api.records.NodeId) JobCounterUpdateEvent(org.apache.hadoop.mapreduce.v2.app.job.event.JobCounterUpdateEvent) TaskAttemptContainerAssignedEvent(org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptContainerAssignedEvent)

Example 8 with ContainerAllocatorEvent

use of org.apache.hadoop.mapreduce.v2.app.rm.ContainerAllocatorEvent in project hadoop by apache.

the class TestLocalContainerAllocator method createContainerRequestEvent.

private static ContainerAllocatorEvent createContainerRequestEvent() {
    TaskAttemptId taskAttemptId = mock(TaskAttemptId.class);
    TaskId taskId = mock(TaskId.class);
    when(taskAttemptId.getTaskId()).thenReturn(taskId);
    return new ContainerAllocatorEvent(taskAttemptId, ContainerAllocator.EventType.CONTAINER_REQ);
}
Also used : TaskId(org.apache.hadoop.mapreduce.v2.api.records.TaskId) TaskAttemptId(org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId) ContainerAllocatorEvent(org.apache.hadoop.mapreduce.v2.app.rm.ContainerAllocatorEvent)

Example 9 with ContainerAllocatorEvent

use of org.apache.hadoop.mapreduce.v2.app.rm.ContainerAllocatorEvent in project hadoop by apache.

the class TestRMContainerAllocator method createDeallocateEvent.

private ContainerAllocatorEvent createDeallocateEvent(JobId jobId, int taskAttemptId, boolean reduce) {
    TaskId taskId;
    if (reduce) {
        taskId = MRBuilderUtils.newTaskId(jobId, 0, TaskType.REDUCE);
    } else {
        taskId = MRBuilderUtils.newTaskId(jobId, 0, TaskType.MAP);
    }
    TaskAttemptId attemptId = MRBuilderUtils.newTaskAttemptId(taskId, taskAttemptId);
    return new ContainerAllocatorEvent(attemptId, ContainerAllocator.EventType.CONTAINER_DEALLOCATE);
}
Also used : TaskId(org.apache.hadoop.mapreduce.v2.api.records.TaskId) TaskAttemptId(org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId)

Aggregations

Test (org.junit.Test)5 Configuration (org.apache.hadoop.conf.Configuration)4 JobId (org.apache.hadoop.mapreduce.v2.api.records.JobId)4 Job (org.apache.hadoop.mapreduce.v2.app.job.Job)4 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)4 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)4 DrainDispatcher (org.apache.hadoop.yarn.event.DrainDispatcher)4 MockNM (org.apache.hadoop.yarn.server.resourcemanager.MockNM)4 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)4 TaskAttemptContainerAssignedEvent (org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptContainerAssignedEvent)3 TaskAttemptId (org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId)2 TaskId (org.apache.hadoop.mapreduce.v2.api.records.TaskId)2 ContainerAllocatorEvent (org.apache.hadoop.mapreduce.v2.app.rm.ContainerAllocatorEvent)2 Container (org.apache.hadoop.yarn.api.records.Container)2 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)2 ResourceRequest (org.apache.hadoop.yarn.api.records.ResourceRequest)2 ControlledClock (org.apache.hadoop.yarn.util.ControlledClock)2 AppContext (org.apache.hadoop.mapreduce.v2.app.AppContext)1 ClientService (org.apache.hadoop.mapreduce.v2.app.client.ClientService)1 Task (org.apache.hadoop.mapreduce.v2.app.job.Task)1