Search in sources :

Example 1 with WeaveContainerLauncher

use of com.continuuity.weave.internal.WeaveContainerLauncher in project weave by continuuity.

the class ApplicationMasterService method launchRunnable.

/**
   * Launches runnables in the provisioned containers.
   */
private void launchRunnable(List<ProcessLauncher<YarnContainerInfo>> launchers, Queue<ProvisionRequest> provisioning) {
    for (ProcessLauncher<YarnContainerInfo> processLauncher : launchers) {
        LOG.info("Got container {}", processLauncher.getContainerInfo().getId());
        ProvisionRequest provisionRequest = provisioning.peek();
        if (provisionRequest == null) {
            continue;
        }
        String runnableName = provisionRequest.getRuntimeSpec().getName();
        LOG.info("Starting runnable {} with {}", runnableName, processLauncher);
        int containerCount = expectedContainers.getExpected(runnableName);
        ProcessLauncher.PrepareLaunchContext launchContext = processLauncher.prepareLaunch(ImmutableMap.<String, String>builder().put(EnvKeys.WEAVE_APP_DIR, System.getenv(EnvKeys.WEAVE_APP_DIR)).put(EnvKeys.WEAVE_FS_USER, System.getenv(EnvKeys.WEAVE_FS_USER)).put(EnvKeys.WEAVE_APP_RUN_ID, runId.getId()).put(EnvKeys.WEAVE_APP_NAME, weaveSpec.getName()).put(EnvKeys.WEAVE_ZK_CONNECT, zkClient.getConnectString()).put(EnvKeys.WEAVE_LOG_KAFKA_ZK, getKafkaZKConnect()).build(), getLocalizeFiles(), credentials);
        WeaveContainerLauncher launcher = new WeaveContainerLauncher(weaveSpec.getRunnables().get(runnableName), launchContext, ZKClients.namespace(zkClient, getZKNamespace(runnableName)), containerCount, jvmOpts, reservedMemory, getSecureStoreLocation());
        runningContainers.start(runnableName, processLauncher.getContainerInfo(), launcher);
        // Need to call complete to workaround bug in YARN AMRMClient
        if (provisionRequest.containerAcquired()) {
            amClient.completeContainerRequest(provisionRequest.getRequestId());
        }
        if (expectedContainers.getExpected(runnableName) == runningContainers.count(runnableName)) {
            LOG.info("Runnable " + runnableName + " fully provisioned with " + containerCount + " instances.");
            provisioning.poll();
        }
    }
}
Also used : YarnContainerInfo(com.continuuity.weave.internal.yarn.YarnContainerInfo) ProcessLauncher(com.continuuity.weave.internal.ProcessLauncher) WeaveContainerLauncher(com.continuuity.weave.internal.WeaveContainerLauncher)

Aggregations

ProcessLauncher (com.continuuity.weave.internal.ProcessLauncher)1 WeaveContainerLauncher (com.continuuity.weave.internal.WeaveContainerLauncher)1 YarnContainerInfo (com.continuuity.weave.internal.yarn.YarnContainerInfo)1