Search in sources :

Example 1 with TezTaskCommunicatorImpl

use of org.apache.tez.dag.app.TezTaskCommunicatorImpl in project tez by apache.

the class LocalContainerLauncher method launch.

// launch tasks
private void launch(ContainerLaunchRequest event) {
    String tokenIdentifier = context.getApplicationID().toString();
    try {
        TezChild tezChild;
        try {
            int taskCommId = context.getTaskCommunicatorIdentifier(event.getTaskCommunicatorName());
            Configuration conf = context.getAMConf();
            if (isLocalMode) {
                TezLocalCacheManager cacheManager = new TezLocalCacheManager(event.getContainerLaunchContext().getLocalResources(), conf);
                cacheManagers.put(event.getContainerId(), cacheManager);
                cacheManager.localize();
            }
            tezChild = createTezChild(conf, event.getContainerId(), tokenIdentifier, context.getApplicationAttemptId().getAttemptId(), context.getLocalDirs(), ((TezTaskCommunicatorImpl) tal.getTaskCommunicator(taskCommId).getTaskCommunicator()).getUmbilical(), TezCommonUtils.parseCredentialsBytes(event.getContainerLaunchContext().getTokens().array()));
        } catch (InterruptedException e) {
            handleLaunchFailed(e, event.getContainerId());
            return;
        } catch (TezException e) {
            handleLaunchFailed(e, event.getContainerId());
            return;
        } catch (IOException e) {
            handleLaunchFailed(e, event.getContainerId());
            return;
        }
        ListenableFuture<TezChild.ContainerExecutionResult> runningTaskFuture = taskExecutorService.submit(createSubTask(tezChild, event.getContainerId()));
        RunningTaskCallback callback = new RunningTaskCallback(event.getContainerId());
        runningContainers.put(event.getContainerId(), runningTaskFuture);
        Futures.addCallback(runningTaskFuture, callback, callbackExecutor);
        if (deletionTracker != null) {
            deletionTracker.addNodeShufflePort(event.getNodeId(), shufflePort);
        }
    } catch (RejectedExecutionException e) {
        handleLaunchFailed(e, event.getContainerId());
    }
}
Also used : TezException(org.apache.tez.dag.api.TezException) Configuration(org.apache.hadoop.conf.Configuration) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) IOException(java.io.IOException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) TezTaskCommunicatorImpl(org.apache.tez.dag.app.TezTaskCommunicatorImpl) TezChild(org.apache.tez.runtime.task.TezChild)

Example 2 with TezTaskCommunicatorImpl

use of org.apache.tez.dag.app.TezTaskCommunicatorImpl in project tez by apache.

the class TestTezTaskCommunicatorManager method testContainerAliveOnGetTask.

@Test(timeout = 5000)
public void testContainerAliveOnGetTask() throws IOException {
    TaskCommunicatorContext context = mock(TaskCommunicatorContext.class);
    Configuration conf = new Configuration(false);
    UserPayload userPayload = TezUtils.createUserPayloadFromConf(conf);
    ApplicationId appId = ApplicationId.newInstance(1000, 1);
    ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1);
    ContainerId containerId = createContainerId(appId, 1);
    doReturn(appAttemptId).when(context).getApplicationAttemptId();
    doReturn(userPayload).when(context).getInitialUserPayload();
    doReturn(new Credentials()).when(context).getAMCredentials();
    TezTaskCommunicatorImpl taskComm = new TezTaskCommunicatorImpl(context);
    ContainerContext containerContext = new ContainerContext(containerId.toString());
    taskComm.registerRunningContainer(containerId, "fakehost", 0);
    ContainerTask containerTask = taskComm.getUmbilical().getTask(containerContext);
    assertNull(containerTask);
    verify(context).containerAlive(containerId);
}
Also used : ContainerContext(org.apache.tez.common.ContainerContext) Configuration(org.apache.hadoop.conf.Configuration) UserPayload(org.apache.tez.dag.api.UserPayload) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) ContainerTask(org.apache.tez.common.ContainerTask) Credentials(org.apache.hadoop.security.Credentials) TaskCommunicatorContext(org.apache.tez.serviceplugins.api.TaskCommunicatorContext) TezTaskCommunicatorImpl(org.apache.tez.dag.app.TezTaskCommunicatorImpl) Test(org.junit.Test)

Aggregations

Configuration (org.apache.hadoop.conf.Configuration)2 TezTaskCommunicatorImpl (org.apache.tez.dag.app.TezTaskCommunicatorImpl)2 IOException (java.io.IOException)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 Credentials (org.apache.hadoop.security.Credentials)1 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)1 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)1 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)1 ContainerContext (org.apache.tez.common.ContainerContext)1 ContainerTask (org.apache.tez.common.ContainerTask)1 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)1 TezException (org.apache.tez.dag.api.TezException)1 UserPayload (org.apache.tez.dag.api.UserPayload)1 TezChild (org.apache.tez.runtime.task.TezChild)1 TaskCommunicatorContext (org.apache.tez.serviceplugins.api.TaskCommunicatorContext)1 Test (org.junit.Test)1