Example usage for org.apache.hadoop.yarn.api.records ContainerStatus getContainerId

List of usage examples for org.apache.hadoop.yarn.api.records ContainerStatus getContainerId

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.api.records ContainerStatus getContainerId.

Prototype

@Public
@Stable
public abstract ContainerId getContainerId();

Source Link

Document

Get the ContainerId of the container.

Usage

From source file:com.hazelcast.yarn.ApplicationMaster.java

License:Open Source License

@Override
public void onContainersCompleted(List<ContainerStatus> statuses) {
    for (ContainerStatus status : statuses) {
        this.containers.remove(status.getContainerId());

        LOG.log(Level.INFO, "Container completed. Container id: {0}. State: {1}.",
                new Object[] { status.getContainerId(), status.getState() });
    }/*from   w  ww  . ja  v a  2  s .c  o  m*/
}

From source file:com.inforefiner.hdata.ApplicationMaster.java

License:Apache License

private static void publishContainerEndEvent(final TimelineClient timelineClient, ContainerStatus container,
        String domainId, UserGroupInformation ugi) {
    final TimelineEntity entity = new TimelineEntity();
    entity.setEntityId(container.getContainerId().toString());
    entity.setEntityType(DSEntity.DS_CONTAINER.toString());
    entity.setDomainId(domainId);//from   w  ww  .j a v  a  2s  . c  om
    entity.addPrimaryFilter("user", ugi.getShortUserName());
    TimelineEvent event = new TimelineEvent();
    event.setTimestamp(System.currentTimeMillis());
    event.setEventType(DSEvent.DS_CONTAINER_END.toString());
    event.addEventInfo("State", container.getState().name());
    event.addEventInfo("Exit Status", container.getExitStatus());
    entity.addEvent(event);
    try {
        timelineClient.putEntities(entity);
    } catch (YarnException | IOException e) {
        LOG.error("Container end event could not be published for " + container.getContainerId().toString(), e);
    }
}

From source file:com.scistor.dshell.ScistorApplicationMaster.java

License:Apache License

private static void publishContainerEndEvent(TimelineClient timelineClient, ContainerStatus container)
        throws IOException, YarnException {
    TimelineEntity entity = new TimelineEntity();
    entity.setEntityId(container.getContainerId().toString());
    entity.setEntityType(DSEntity.DS_CONTAINER.toString());
    entity.addPrimaryFilter("user", UserGroupInformation.getCurrentUser().toString());
    TimelineEvent event = new TimelineEvent();
    event.setTimestamp(System.currentTimeMillis());
    event.setEventType(DSEvent.DS_CONTAINER_END.toString());
    event.addEventInfo("State", container.getState().name());
    event.addEventInfo("Exit Status", container.getExitStatus());
    entity.addEvent(event);/*  www . ja  v  a2s .  co  m*/

    timelineClient.putEntities(entity);
}

From source file:de.huberlin.wbi.hiway.scheduler.c3po.C3PO.java

License:Apache License

@Override
public Collection<ContainerId> taskCompleted(TaskInstance task, ContainerStatus containerStatus,
        long runtimeInMs) {
    super.taskCompleted(task, containerStatus, runtimeInMs);
    provenanceManager.updateRuntimeEstimates(task.getWorkflowId().toString());
    Collection<ContainerId> toBeReleasedContainers = new ArrayList<>();

    // kill speculative copies
    for (Container container : taskToContainers.get(task)) {
        if (!container.getId().equals(containerStatus.getContainerId())) {
            toBeReleasedContainers.add(container.getId());
            unissuedContainerRequests.add(setupContainerAskForRM(new String[0], containerMemoryMegaBytes));
        }//from w w w.  j a v a 2 s  .c  om
    }
    taskToContainers.remove(task);
    runningTasks.get(task.getTaskId()).remove(task);

    return toBeReleasedContainers;
}

From source file:de.huberlin.wbi.hiway.scheduler.c3po.C3PO.java

License:Apache License

@Override
public Collection<ContainerId> taskFailed(TaskInstance task, ContainerStatus containerStatus) {
    super.taskFailed(task, containerStatus);

    Collection<ContainerId> toBeReleasedContainers = new ArrayList<>();
    if (!task.retry(maxRetries)) {
        for (Container container : taskToContainers.get(task)) {
            if (!container.getId().equals(containerStatus.getContainerId())) {
                toBeReleasedContainers.add(container.getId());
            }//from   w ww.  j  a  v  a  2  s .c o  m
        }
        taskToContainers.remove(task);

        return toBeReleasedContainers;
    }

    return new ArrayList<>();
}

From source file:de.huberlin.wbi.hiway.scheduler.Scheduler.java

License:Apache License

public Collection<ContainerId> taskCompleted(TaskInstance task, ContainerStatus containerStatus,
        long runtimeInMs) {

    numberOfRunningTasks--;//from   ww w. j  a v  a2s. c  om
    numberOfFinishedTasks++;

    System.out.println("Task " + task + " in container " + containerStatus.getContainerId().getContainerId()
            + " finished after " + runtimeInMs + " ms");

    return new ArrayList<>();
}

From source file:de.huberlin.wbi.hiway.scheduler.Scheduler.java

License:Apache License

public Collection<ContainerId> taskFailed(TaskInstance task, ContainerStatus containerStatus) {
    numberOfRunningTasks--;/*from ww  w. j  a  v a  2s . c  om*/

    System.out.println(
            "Task " + task + " on container " + containerStatus.getContainerId().getContainerId() + " failed");
    if (task.retry(maxRetries)) {
        System.out.println("Retrying task " + task + ".");
        addTask(task);
    } else {
        System.out.println(
                "Task " + task + " has exceeded maximum number of allowed retries. Aborting workflow.");
        throw new RuntimeException();
    }

    return new ArrayList<>();
}

From source file:de.huberlin.wbi.hiway.scheduler.WorkflowScheduler.java

License:Apache License

/** Informs the scheduler about a successfully completed task. The logic on whether more tasks are now ready happens elsewhere.
 * @return a collection of to be released containers, used by {@link de.huberlin.wbi.hiway.scheduler.c3po.C3PO} for killing speculative task replicas.
 *//*  ww w .  j  a v a 2 s .c o  m*/
public Collection<ContainerId> taskCompleted(TaskInstance task, ContainerStatus containerStatus,
        long runtimeInMs) {

    numberOfRunningTasks--;
    numberOfFinishedTasks++;

    /* log */
    WorkflowDriver.Logger.writeToStdout("Task " + task + " on container " + containerStatus.getContainerId()
            + " completed successfully after " + runtimeInMs + " ms");

    return new ArrayList<>();
}

From source file:de.huberlin.wbi.hiway.scheduler.WorkflowScheduler.java

License:Apache License

/** Inform the scheduler about a task failure. Causes task retry, if the number of maximum retries has not been reached.
 * @return a collection of to be released containers, used by {@link de.huberlin.wbi.hiway.scheduler.c3po.C3PO} for killing speculative task replicas.
 *///  w w w. j a v  a 2s. c om
public Collection<ContainerId> taskFailed(TaskInstance task, ContainerStatus containerStatus) {
    numberOfRunningTasks--;

    /* log */
    WorkflowDriver.Logger
            .writeToStdout("Task " + task + " on container " + containerStatus.getContainerId() + " failed");
    if (task.retry(maxRetries)) {
        /* log */
        WorkflowDriver.Logger.writeToStdout("Retrying task " + task + ".");
        addTask(task);
    } else {
        /* log */
        WorkflowDriver.Logger.writeToStdout(
                "Task " + task + " has exceeded maximum number of allowed retries. Aborting workflow.");
        System.exit(-1);
    }

    return new ArrayList<>();
}

From source file:disAMS.AMRMClient.Impl.AMRMClientImpl.java

License:Apache License

protected void removePendingReleaseRequests(List<ContainerStatus> completedContainersStatuses) {
    for (ContainerStatus containerStatus : completedContainersStatuses) {
        pendingRelease.remove(containerStatus.getContainerId());
    }/*from w w w.  j  a v a  2  s. c om*/
}