Search in sources :

Example 1 with TezChild

use of org.apache.tez.runtime.task.TezChild 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 TezChild

use of org.apache.tez.runtime.task.TezChild in project tez by apache.

the class LocalContainerLauncher method createTezChild.

private TezChild createTezChild(Configuration defaultConf, ContainerId containerId, String tokenIdentifier, int attemptNumber, String[] localDirs, TezTaskUmbilicalProtocol tezTaskUmbilicalProtocol, Credentials credentials) throws InterruptedException, TezException, IOException {
    Map<String, String> containerEnv = new HashMap<String, String>();
    containerEnv.putAll(localEnv);
    // Use the user from env if it's available.
    String user = isLocalMode ? System.getenv(Environment.USER.name()) : context.getUser();
    containerEnv.put(Environment.USER.name(), user);
    long memAvailable;
    synchronized (this) {
        // needed to fix findbugs Inconsistent synchronization warning
        memAvailable = Runtime.getRuntime().maxMemory() / numExecutors;
    }
    TezChild tezChild = TezChild.newTezChild(defaultConf, null, 0, containerId.toString(), tokenIdentifier, attemptNumber, localDirs, workingDirectory, containerEnv, "", executionContext, credentials, memAvailable, context.getUser(), tezTaskUmbilicalProtocol, false, context.getHadoopShim());
    return tezChild;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) TezChild(org.apache.tez.runtime.task.TezChild)

Aggregations

TezChild (org.apache.tez.runtime.task.TezChild)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 Configuration (org.apache.hadoop.conf.Configuration)1 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)1 TezException (org.apache.tez.dag.api.TezException)1 TezTaskCommunicatorImpl (org.apache.tez.dag.app.TezTaskCommunicatorImpl)1