Search in sources :

Example 1 with RunnableProcessLauncher

use of com.continuuity.weave.internal.appmaster.RunnableProcessLauncher in project weave by continuuity.

the class Hadoop20YarnAMClient method allocate.

@Override
public synchronized void allocate(float progress, AllocateHandler handler) throws Exception {
    AllocationResponse response = amrmClient.allocate(progress);
    List<ProcessLauncher<YarnContainerInfo>> launchers = Lists.newArrayListWithCapacity(response.getAllocatedContainers().size());
    for (Container container : response.getAllocatedContainers()) {
        launchers.add(new RunnableProcessLauncher(new Hadoop20YarnContainerInfo(container), nmClient));
    }
    if (!launchers.isEmpty()) {
        handler.acquired(launchers);
        // If no process has been launched through the given launcher, return the container.
        for (ProcessLauncher<YarnContainerInfo> l : launchers) {
            // This cast always works.
            RunnableProcessLauncher launcher = (RunnableProcessLauncher) l;
            if (!launcher.isLaunched()) {
                Container container = launcher.getContainerInfo().getContainer();
                LOG.info("Nothing to run in container, releasing it: {}", container);
                amrmClient.releaseAssignedContainer(container.getId());
            }
        }
    }
    List<YarnContainerStatus> completed = ImmutableList.copyOf(Iterables.transform(response.getCompletedContainersStatuses(), STATUS_TRANSFORM));
    if (!completed.isEmpty()) {
        handler.completed(completed);
    }
}
Also used : Container(org.apache.hadoop.yarn.api.records.Container) RunnableProcessLauncher(com.continuuity.weave.internal.appmaster.RunnableProcessLauncher) ProcessLauncher(com.continuuity.weave.internal.ProcessLauncher) RunnableProcessLauncher(com.continuuity.weave.internal.appmaster.RunnableProcessLauncher) AllocationResponse(com.continuuity.weave.internal.yarn.ports.AllocationResponse)

Example 2 with RunnableProcessLauncher

use of com.continuuity.weave.internal.appmaster.RunnableProcessLauncher in project weave by continuuity.

the class Hadoop21YarnAMClient method allocate.

@Override
public synchronized void allocate(float progress, AllocateHandler handler) throws Exception {
    AllocateResponse allocateResponse = amrmClient.allocate(progress);
    List<ProcessLauncher<YarnContainerInfo>> launchers = Lists.newArrayListWithCapacity(allocateResponse.getAllocatedContainers().size());
    for (Container container : allocateResponse.getAllocatedContainers()) {
        launchers.add(new RunnableProcessLauncher(new Hadoop21YarnContainerInfo(container), nmClient));
    }
    if (!launchers.isEmpty()) {
        handler.acquired(launchers);
        // If no process has been launched through the given launcher, return the container.
        for (ProcessLauncher<YarnContainerInfo> l : launchers) {
            // This cast always works.
            RunnableProcessLauncher launcher = (RunnableProcessLauncher) l;
            if (!launcher.isLaunched()) {
                Container container = launcher.getContainerInfo().getContainer();
                LOG.info("Nothing to run in container, releasing it: {}", container);
                amrmClient.releaseAssignedContainer(container.getId());
            }
        }
    }
    List<YarnContainerStatus> completed = ImmutableList.copyOf(Iterables.transform(allocateResponse.getCompletedContainersStatuses(), STATUS_TRANSFORM));
    if (!completed.isEmpty()) {
        handler.completed(completed);
    }
}
Also used : AllocateResponse(org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse) Container(org.apache.hadoop.yarn.api.records.Container) RunnableProcessLauncher(com.continuuity.weave.internal.appmaster.RunnableProcessLauncher) ProcessLauncher(com.continuuity.weave.internal.ProcessLauncher) RunnableProcessLauncher(com.continuuity.weave.internal.appmaster.RunnableProcessLauncher)

Aggregations

ProcessLauncher (com.continuuity.weave.internal.ProcessLauncher)2 RunnableProcessLauncher (com.continuuity.weave.internal.appmaster.RunnableProcessLauncher)2 Container (org.apache.hadoop.yarn.api.records.Container)2 AllocationResponse (com.continuuity.weave.internal.yarn.ports.AllocationResponse)1 AllocateResponse (org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse)1