use of org.apache.tez.dag.app.rm.container.AMContainerEventAssignTA in project tez by apache.
the class TestContainerReuse method testReuseLocalResourcesChanged.
@Test(timeout = 30000l)
public void testReuseLocalResourcesChanged() throws IOException, InterruptedException, ExecutionException {
LOG.info("Test testReuseLocalResourcesChanged");
Configuration tezConf = new Configuration(new YarnConfiguration());
tezConf.setBoolean(TezConfiguration.TEZ_AM_CONTAINER_REUSE_ENABLED, true);
tezConf.setBoolean(TezConfiguration.TEZ_AM_CONTAINER_REUSE_RACK_FALLBACK_ENABLED, true);
tezConf.setBoolean(TezConfiguration.TEZ_AM_CONTAINER_REUSE_NON_LOCAL_FALLBACK_ENABLED, true);
tezConf.setLong(TezConfiguration.TEZ_AM_CONTAINER_REUSE_LOCALITY_DELAY_ALLOCATION_MILLIS, 0);
tezConf.setLong(TezConfiguration.TEZ_AM_CONTAINER_IDLE_RELEASE_TIMEOUT_MIN_MILLIS, -1);
CapturingEventHandler eventHandler = new CapturingEventHandler();
TezDAGID dagID1 = TezDAGID.getInstance("0", 1, 0);
AMRMClient<CookieContainerRequest> rmClientCore = new AMRMClientForTest();
TezAMRMClientAsync<CookieContainerRequest> rmClient = spy(new AMRMClientAsyncForTest(rmClientCore, 100));
AppContext appContext = mock(AppContext.class);
doReturn(new Configuration(false)).when(appContext).getAMConf();
ChangingDAGIDAnswer dagIDAnswer = new ChangingDAGIDAnswer(dagID1);
AMContainerMap amContainerMap = new AMContainerMap(mock(ContainerHeartbeatHandler.class), mock(TaskCommunicatorManagerInterface.class), new ContainerContextMatcher(), appContext);
AMNodeTracker amNodeTracker = new AMNodeTracker(eventHandler, appContext);
doReturn(amContainerMap).when(appContext).getAllContainers();
doReturn(amNodeTracker).when(appContext).getNodeTracker();
doReturn(DAGAppMasterState.RUNNING).when(appContext).getAMState();
doReturn(true).when(appContext).isSession();
doAnswer(dagIDAnswer).when(appContext).getCurrentDAGID();
doReturn(mock(ClusterInfo.class)).when(appContext).getClusterInfo();
TaskSchedulerManager taskSchedulerManagerReal = new TaskSchedulerManagerForTest(appContext, eventHandler, rmClient, new AlwaysMatchesContainerMatcher(), TezUtils.createUserPayloadFromConf(tezConf));
TaskSchedulerManager taskSchedulerManager = spy(taskSchedulerManagerReal);
taskSchedulerManager.init(tezConf);
taskSchedulerManager.start();
TaskSchedulerWithDrainableContext taskScheduler = (TaskSchedulerWithDrainableContext) ((TaskSchedulerManagerForTest) taskSchedulerManager).getSpyTaskScheduler();
TaskSchedulerContextDrainable drainableAppCallback = taskScheduler.getDrainableAppCallback();
AtomicBoolean drainNotifier = new AtomicBoolean(false);
taskScheduler.delayedContainerManager.drainedDelayedContainersForTest = drainNotifier;
Resource resource1 = Resource.newInstance(1024, 1);
String[] host1 = { "host1" };
String[] racks = { "/default-rack" };
Priority priority1 = Priority.newInstance(1);
String rsrc1 = "rsrc1";
String rsrc2 = "rsrc2";
String rsrc3 = "rsrc3";
LocalResource lr1 = mock(LocalResource.class);
LocalResource lr2 = mock(LocalResource.class);
LocalResource lr3 = mock(LocalResource.class);
AMContainerEventAssignTA assignEvent = null;
Map<String, LocalResource> dag1LRs = Maps.newHashMap();
dag1LRs.put(rsrc1, lr1);
TezVertexID vertexID11 = TezVertexID.getInstance(dagID1, 1);
// Vertex 1, Task 1, Attempt 1, host1, lr1
TezTaskAttemptID taID111 = TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexID11, 1), 1);
TaskAttempt ta111 = mock(TaskAttempt.class);
AMSchedulerEventTALaunchRequest lrEvent11 = createLaunchRequestEvent(taID111, ta111, resource1, host1, racks, priority1, dag1LRs);
// Vertex 1, Task 2, Attempt 1, host1, lr1
TezTaskAttemptID taID112 = TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexID11, 2), 1);
TaskAttempt ta112 = mock(TaskAttempt.class);
AMSchedulerEventTALaunchRequest lrEvent12 = createLaunchRequestEvent(taID112, ta112, resource1, host1, racks, priority1, dag1LRs);
taskSchedulerManager.handleEvent(lrEvent11);
taskSchedulerManager.handleEvent(lrEvent12);
Container container1 = createContainer(1, "host1", resource1, priority1);
// One container allocated.
taskScheduler.onContainersAllocated(Collections.singletonList(container1));
TestTaskSchedulerHelpers.waitForDelayedDrainNotify(drainNotifier);
drainableAppCallback.drain();
verify(taskSchedulerManager).taskAllocated(eq(0), eq(ta111), any(Object.class), eq(container1));
assignEvent = (AMContainerEventAssignTA) eventHandler.verifyInvocation(AMContainerEventAssignTA.class);
assertEquals(1, assignEvent.getRemoteTaskLocalResources().size());
// Task assigned to container completed successfully. Container should be re-used.
taskSchedulerManager.handleEvent(new AMSchedulerEventTAEnded(ta111, container1.getId(), TaskAttemptState.SUCCEEDED, null, null, 0));
drainableAppCallback.drain();
verifyDeAllocateTask(taskScheduler, ta111, true, null, null);
verify(taskSchedulerManager).taskAllocated(eq(0), eq(ta112), any(Object.class), eq(container1));
verify(rmClient, times(0)).releaseAssignedContainer(eq(container1.getId()));
eventHandler.verifyNoInvocations(AMContainerEventStopRequest.class);
assignEvent = (AMContainerEventAssignTA) eventHandler.verifyInvocation(AMContainerEventAssignTA.class);
assertEquals(1, assignEvent.getRemoteTaskLocalResources().size());
eventHandler.reset();
// Task assigned to container completed successfully.
// Verify reuse across hosts.
taskSchedulerManager.handleEvent(new AMSchedulerEventTAEnded(ta112, container1.getId(), TaskAttemptState.SUCCEEDED, null, null, 0));
drainableAppCallback.drain();
verifyDeAllocateTask(taskScheduler, ta112, true, null, null);
verify(rmClient, times(0)).releaseAssignedContainer(eq(container1.getId()));
eventHandler.verifyNoInvocations(AMContainerEventStopRequest.class);
eventHandler.reset();
// Setup DAG2 with additional resources. Make sure the container, even without all resources, is reused.
TezDAGID dagID2 = TezDAGID.getInstance("0", 2, 0);
dagIDAnswer.setDAGID(dagID2);
Map<String, LocalResource> dag2LRs = Maps.newHashMap();
dag2LRs.put(rsrc2, lr2);
dag2LRs.put(rsrc3, lr3);
TezVertexID vertexID21 = TezVertexID.getInstance(dagID2, 1);
// Vertex 2, Task 1, Attempt 1, host1, lr2
TezTaskAttemptID taID211 = TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexID21, 1), 1);
TaskAttempt ta211 = mock(TaskAttempt.class);
AMSchedulerEventTALaunchRequest lrEvent21 = createLaunchRequestEvent(taID211, ta211, resource1, host1, racks, priority1, dag2LRs);
// Vertex 2, Task 2, Attempt 1, host1, lr2
TezTaskAttemptID taID212 = TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexID21, 2), 1);
TaskAttempt ta212 = mock(TaskAttempt.class);
AMSchedulerEventTALaunchRequest lrEvent22 = createLaunchRequestEvent(taID212, ta212, resource1, host1, racks, priority1, dag2LRs);
taskSchedulerManager.handleEvent(lrEvent21);
taskSchedulerManager.handleEvent(lrEvent22);
TestTaskSchedulerHelpers.waitForDelayedDrainNotify(drainNotifier);
drainableAppCallback.drain();
verify(taskSchedulerManager).taskAllocated(eq(0), eq(ta211), any(Object.class), eq(container1));
verify(rmClient, times(0)).releaseAssignedContainer(eq(container1.getId()));
eventHandler.verifyNoInvocations(AMContainerEventStopRequest.class);
assignEvent = (AMContainerEventAssignTA) eventHandler.verifyInvocation(AMContainerEventAssignTA.class);
assertEquals(2, assignEvent.getRemoteTaskLocalResources().size());
eventHandler.reset();
taskSchedulerManager.handleEvent(new AMSchedulerEventTAEnded(ta211, container1.getId(), TaskAttemptState.SUCCEEDED, null, null, 0));
drainableAppCallback.drain();
verifyDeAllocateTask(taskScheduler, ta211, true, null, null);
verify(taskSchedulerManager).taskAllocated(eq(0), eq(ta212), any(Object.class), eq(container1));
verify(rmClient, times(0)).releaseAssignedContainer(eq(container1.getId()));
eventHandler.verifyNoInvocations(AMContainerEventStopRequest.class);
assignEvent = (AMContainerEventAssignTA) eventHandler.verifyInvocation(AMContainerEventAssignTA.class);
assertEquals(2, assignEvent.getRemoteTaskLocalResources().size());
eventHandler.reset();
taskScheduler.shutdown();
taskSchedulerManager.close();
}
use of org.apache.tez.dag.app.rm.container.AMContainerEventAssignTA in project tez by apache.
the class TestTaskSchedulerManager method testSimpleAllocate.
@Test(timeout = 5000)
public void testSimpleAllocate() 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);
when(mockAMContainerMap.get(mockCId)).thenReturn(mockAMContainer);
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());
}
use of org.apache.tez.dag.app.rm.container.AMContainerEventAssignTA in project tez by apache.
the class TestContainerReuse method testReuseConflictLocalResources.
@Test(timeout = 30000l)
public void testReuseConflictLocalResources() throws IOException, InterruptedException, ExecutionException {
LOG.info("Test testReuseLocalResourcesChanged");
Configuration tezConf = new Configuration(new YarnConfiguration());
tezConf.setBoolean(TezConfiguration.TEZ_AM_CONTAINER_REUSE_ENABLED, true);
tezConf.setBoolean(TezConfiguration.TEZ_AM_CONTAINER_REUSE_RACK_FALLBACK_ENABLED, true);
tezConf.setBoolean(TezConfiguration.TEZ_AM_CONTAINER_REUSE_NON_LOCAL_FALLBACK_ENABLED, true);
tezConf.setLong(TezConfiguration.TEZ_AM_CONTAINER_REUSE_LOCALITY_DELAY_ALLOCATION_MILLIS, 0);
tezConf.setLong(TezConfiguration.TEZ_AM_CONTAINER_IDLE_RELEASE_TIMEOUT_MIN_MILLIS, -1);
CapturingEventHandler eventHandler = new CapturingEventHandler();
TezDAGID dagID1 = TezDAGID.getInstance("0", 1, 0);
AMRMClient<CookieContainerRequest> rmClientCore = new AMRMClientForTest();
TezAMRMClientAsync<CookieContainerRequest> rmClient = spy(new AMRMClientAsyncForTest(rmClientCore, 100));
AppContext appContext = mock(AppContext.class);
doReturn(new Configuration(false)).when(appContext).getAMConf();
ChangingDAGIDAnswer dagIDAnswer = new ChangingDAGIDAnswer(dagID1);
AMContainerMap amContainerMap = new AMContainerMap(mock(ContainerHeartbeatHandler.class), mock(TaskCommunicatorManagerInterface.class), new ContainerContextMatcher(), appContext);
AMNodeTracker amNodeTracker = new AMNodeTracker(eventHandler, appContext);
doReturn(amContainerMap).when(appContext).getAllContainers();
doReturn(amNodeTracker).when(appContext).getNodeTracker();
doReturn(DAGAppMasterState.RUNNING).when(appContext).getAMState();
doReturn(true).when(appContext).isSession();
doAnswer(dagIDAnswer).when(appContext).getCurrentDAGID();
doReturn(mock(ClusterInfo.class)).when(appContext).getClusterInfo();
TaskSchedulerManager taskSchedulerManagerReal = new TaskSchedulerManagerForTest(appContext, eventHandler, rmClient, new ContainerContextMatcher(), TezUtils.createUserPayloadFromConf(tezConf));
TaskSchedulerManager taskSchedulerManager = spy(taskSchedulerManagerReal);
taskSchedulerManager.init(tezConf);
taskSchedulerManager.start();
TaskSchedulerWithDrainableContext taskScheduler = (TaskSchedulerWithDrainableContext) ((TaskSchedulerManagerForTest) taskSchedulerManager).getSpyTaskScheduler();
TaskSchedulerContextDrainable drainableAppCallback = taskScheduler.getDrainableAppCallback();
AtomicBoolean drainNotifier = new AtomicBoolean(false);
taskScheduler.delayedContainerManager.drainedDelayedContainersForTest = drainNotifier;
Resource resource1 = Resource.newInstance(1024, 1);
String[] host1 = { "host1" };
String[] racks = { "/default-rack" };
Priority priority1 = Priority.newInstance(1);
String rsrc1 = "rsrc1";
String rsrc2 = "rsrc2";
LocalResource lr1 = mock(LocalResource.class);
doReturn(LocalResourceType.FILE).when(lr1).getType();
LocalResource lr2 = mock(LocalResource.class);
doReturn(LocalResourceType.FILE).when(lr2).getType();
LocalResource lr3 = mock(LocalResource.class);
doReturn(LocalResourceType.FILE).when(lr3).getType();
AMContainerEventAssignTA assignEvent = null;
Map<String, LocalResource> v11LR = Maps.newHashMap();
v11LR.put(rsrc1, lr1);
TezVertexID vertexID11 = TezVertexID.getInstance(dagID1, 1);
// Vertex 1, Task 1, Attempt 1, host1, lr1
TezTaskAttemptID taID111 = TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexID11, 1), 1);
TaskAttempt ta111 = mock(TaskAttempt.class);
doReturn(taID111).when(ta111).getID();
doReturn("Mock for TA " + taID111.toString()).when(ta111).toString();
AMSchedulerEventTALaunchRequest lrEvent11 = createLaunchRequestEvent(taID111, ta111, resource1, host1, racks, priority1, v11LR);
Map<String, LocalResource> v12LR = Maps.newHashMap();
v12LR.put(rsrc1, lr1);
v12LR.put(rsrc2, lr2);
// Vertex 1, Task 2, Attempt 1, host1, lr1
TezTaskAttemptID taID112 = TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexID11, 2), 1);
TaskAttempt ta112 = mock(TaskAttempt.class);
doReturn(taID112).when(ta112).getID();
doReturn("Mock for TA " + taID112.toString()).when(ta112).toString();
AMSchedulerEventTALaunchRequest lrEvent12 = createLaunchRequestEvent(taID112, ta112, resource1, host1, racks, priority1, v12LR);
// Vertex 1, Task 3, Attempt 1, host1
TezTaskAttemptID taID113 = TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexID11, 3), 1);
TaskAttempt ta113 = mock(TaskAttempt.class);
doReturn(taID113).when(ta113).getID();
doReturn("Mock for TA " + taID113.toString()).when(ta113).toString();
AMSchedulerEventTALaunchRequest lrEvent13 = createLaunchRequestEvent(taID113, ta113, resource1, host1, racks, priority1, new HashMap<String, LocalResource>());
// Vertex 1, Task 4, Attempt 1, host1
TezTaskAttemptID taID114 = TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexID11, 4), 1);
TaskAttempt ta114 = mock(TaskAttempt.class);
doReturn(taID114).when(ta114).getID();
doReturn("Mock for TA " + taID114.toString()).when(ta114).toString();
AMSchedulerEventTALaunchRequest lrEvent14 = createLaunchRequestEvent(taID114, ta114, resource1, host1, racks, priority1, new HashMap<String, LocalResource>());
taskSchedulerManager.handleEvent(lrEvent11);
taskSchedulerManager.handleEvent(lrEvent12);
Container container1 = createContainer(1, "host1", resource1, priority1);
Container container2 = createContainer(2, "host1", resource1, priority1);
// One container allocated.
taskScheduler.onContainersAllocated(Collections.singletonList(container1));
TestTaskSchedulerHelpers.waitForDelayedDrainNotify(drainNotifier);
drainableAppCallback.drain();
verify(taskSchedulerManager).taskAllocated(eq(0), eq(ta111), any(Object.class), eq(container1));
assignEvent = (AMContainerEventAssignTA) eventHandler.verifyInvocation(AMContainerEventAssignTA.class);
assertEquals(1, assignEvent.getRemoteTaskLocalResources().size());
// Task assigned to container completed successfully. Container should be re-used.
taskSchedulerManager.handleEvent(new AMSchedulerEventTAEnded(ta111, container1.getId(), TaskAttemptState.SUCCEEDED, null, null, 0));
drainableAppCallback.drain();
verifyDeAllocateTask(taskScheduler, ta111, true, null, null);
verify(taskSchedulerManager).taskAllocated(eq(0), eq(ta112), any(Object.class), eq(container1));
verify(rmClient, times(0)).releaseAssignedContainer(eq(container1.getId()));
eventHandler.verifyNoInvocations(AMContainerEventStopRequest.class);
assignEvent = (AMContainerEventAssignTA) eventHandler.verifyInvocation(AMContainerEventAssignTA.class);
assertEquals(1, assignEvent.getRemoteTaskLocalResources().size());
eventHandler.reset();
// Task assigned to container completed successfully.
// Verify reuse across hosts.
taskSchedulerManager.handleEvent(new AMSchedulerEventTAEnded(ta112, container1.getId(), TaskAttemptState.SUCCEEDED, null, null, 0));
drainableAppCallback.drain();
verifyDeAllocateTask(taskScheduler, ta112, true, null, null);
verify(rmClient, times(0)).releaseAssignedContainer(eq(container1.getId()));
eventHandler.verifyNoInvocations(AMContainerEventStopRequest.class);
eventHandler.reset();
// Task 3
taskSchedulerManager.handleEvent(lrEvent13);
TestTaskSchedulerHelpers.waitForDelayedDrainNotify(drainNotifier);
drainableAppCallback.drain();
verify(taskSchedulerManager).taskAllocated(eq(0), eq(ta113), any(Object.class), eq(container1));
verify(rmClient, times(0)).releaseAssignedContainer(eq(container1.getId()));
eventHandler.verifyNoInvocations(AMContainerEventStopRequest.class);
eventHandler.reset();
taskSchedulerManager.handleEvent(new AMSchedulerEventTAEnded(ta113, container1.getId(), TaskAttemptState.SUCCEEDED, null, null, 0));
drainableAppCallback.drain();
verifyDeAllocateTask(taskScheduler, ta113, true, null, null);
verify(rmClient, times(0)).releaseAssignedContainer(eq(container1.getId()));
eventHandler.verifyNoInvocations(AMContainerEventStopRequest.class);
eventHandler.reset();
// Task 4
taskSchedulerManager.handleEvent(lrEvent14);
TestTaskSchedulerHelpers.waitForDelayedDrainNotify(drainNotifier);
drainableAppCallback.drain();
verify(taskSchedulerManager).taskAllocated(eq(0), eq(ta114), any(Object.class), eq(container1));
verify(rmClient, times(0)).releaseAssignedContainer(eq(container1.getId()));
eventHandler.verifyNoInvocations(AMContainerEventStopRequest.class);
eventHandler.reset();
taskSchedulerManager.handleEvent(new AMSchedulerEventTAEnded(ta114, container1.getId(), TaskAttemptState.SUCCEEDED, null, null, 0));
drainableAppCallback.drain();
verifyDeAllocateTask(taskScheduler, ta114, true, null, null);
verify(rmClient, times(0)).releaseAssignedContainer(eq(container1.getId()));
eventHandler.verifyNoInvocations(AMContainerEventStopRequest.class);
eventHandler.reset();
// Setup DAG2 with different resources.
TezDAGID dagID2 = TezDAGID.getInstance("0", 2, 0);
dagIDAnswer.setDAGID(dagID2);
Map<String, LocalResource> v21LR = Maps.newHashMap();
v21LR.put(rsrc1, lr1);
v21LR.put(rsrc2, lr3);
TezVertexID vertexID21 = TezVertexID.getInstance(dagID2, 1);
// Vertex 2, Task 1, Attempt 1, host1, lr2
TezTaskAttemptID taID211 = TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexID21, 1), 1);
TaskAttempt ta211 = mock(TaskAttempt.class);
doReturn(taID211).when(ta211).getID();
doReturn("Mock for TA " + taID211.toString()).when(ta211).toString();
AMSchedulerEventTALaunchRequest lrEvent21 = createLaunchRequestEvent(taID211, ta211, resource1, host1, racks, priority1, v21LR);
taskSchedulerManager.handleEvent(lrEvent21);
TestTaskSchedulerHelpers.waitForDelayedDrainNotify(drainNotifier);
drainableAppCallback.drain();
verify(rmClient, times(1)).releaseAssignedContainer(eq(container1.getId()));
taskScheduler.onContainersAllocated(Collections.singletonList(container2));
TestTaskSchedulerHelpers.waitForDelayedDrainNotify(drainNotifier);
drainableAppCallback.drain();
verify(taskSchedulerManager).taskAllocated(eq(0), eq(ta211), any(Object.class), eq(container2));
eventHandler.reset();
taskSchedulerManager.handleEvent(new AMSchedulerEventTAEnded(ta211, container2.getId(), TaskAttemptState.SUCCEEDED, null, null, 0));
drainableAppCallback.drain();
verifyDeAllocateTask(taskScheduler, ta211, true, null, null);
verify(rmClient, times(0)).releaseAssignedContainer(eq(container2.getId()));
eventHandler.reset();
// Setup DAG3 with a subset of resources from DAG2 (container should be reused).
TezDAGID dagID3 = TezDAGID.getInstance("0", 3, 0);
dagIDAnswer.setDAGID(dagID3);
Map<String, LocalResource> v31LR = Collections.singletonMap(rsrc1, lr1);
// dag3, vertex1, task1, ta1
TezTaskAttemptID taID311 = TezTaskAttemptID.getInstance(TezTaskID.getInstance(TezVertexID.getInstance(dagID3, 1), 1), 1);
TaskAttempt ta311 = mock(TaskAttempt.class);
doReturn(taID311).when(ta311).getID();
doReturn("Mock for TA " + taID311).when(ta311).toString();
AMSchedulerEventTALaunchRequest lrEvent31 = createLaunchRequestEvent(taID311, ta311, resource1, host1, racks, priority1, v31LR);
taskSchedulerManager.handleEvent(lrEvent31);
TestTaskSchedulerHelpers.waitForDelayedDrainNotify(drainNotifier);
drainableAppCallback.drain();
verify(taskSchedulerManager).taskAllocated(eq(0), eq(ta311), any(Object.class), eq(container2));
eventHandler.reset();
taskScheduler.shutdown();
taskSchedulerManager.close();
}
use of org.apache.tez.dag.app.rm.container.AMContainerEventAssignTA in project tez by apache.
the class TaskSchedulerManager method taskAllocated.
// TaskSchedulerAppCallback methods with schedulerId, where relevant
public synchronized void taskAllocated(int schedulerId, Object task, Object appCookie, Container container) {
AMSchedulerEventTALaunchRequest event = (AMSchedulerEventTALaunchRequest) appCookie;
ContainerId containerId = container.getId();
if (appContext.getAllContainers().addContainerIfNew(container, schedulerId, event.getLauncherId(), event.getTaskCommId())) {
appContext.getNodeTracker().nodeSeen(container.getNodeId(), schedulerId);
sendEvent(new AMNodeEventContainerAllocated(container.getNodeId(), schedulerId, container.getId()));
}
TaskAttempt taskAttempt = event.getTaskAttempt();
// taskAllocated() upcall
assert task.equals(taskAttempt);
if (appContext.getAllContainers().get(containerId).getState() == AMContainerState.ALLOCATED) {
sendEvent(new AMContainerEventLaunchRequest(containerId, taskAttempt.getVertexID(), event.getContainerContext(), event.getLauncherId(), event.getTaskCommId()));
}
sendEvent(new AMContainerEventAssignTA(containerId, taskAttempt.getID(), event.getRemoteTaskSpec(), event.getContainerContext().getLocalResources(), event.getContainerContext().getCredentials(), event.getPriority()));
}
Aggregations