Search in sources :

Example 41 with ContainerStatus

use of org.apache.hadoop.yarn.api.records.ContainerStatus in project hadoop by apache.

the class NMSimulator method generateContainerStatusList.

/**
   * catch status of all containers located on current node
   */
private ArrayList<ContainerStatus> generateContainerStatusList() {
    ArrayList<ContainerStatus> csList = new ArrayList<ContainerStatus>();
    // add running containers
    for (ContainerSimulator container : runningContainers.values()) {
        csList.add(newContainerStatus(container.getId(), ContainerState.RUNNING, ContainerExitStatus.SUCCESS));
    }
    synchronized (amContainerList) {
        for (ContainerId cId : amContainerList) {
            csList.add(newContainerStatus(cId, ContainerState.RUNNING, ContainerExitStatus.SUCCESS));
        }
    }
    // add complete containers
    synchronized (completedContainerList) {
        for (ContainerId cId : completedContainerList) {
            LOG.debug(MessageFormat.format("NodeManager {0} completed" + " container ({1}).", node.getNodeID(), cId));
            csList.add(newContainerStatus(cId, ContainerState.COMPLETE, ContainerExitStatus.SUCCESS));
        }
        completedContainerList.clear();
    }
    // released containers
    synchronized (releasedContainerList) {
        for (ContainerId cId : releasedContainerList) {
            LOG.debug(MessageFormat.format("NodeManager {0} released container" + " ({1}).", node.getNodeID(), cId));
            csList.add(newContainerStatus(cId, ContainerState.COMPLETE, ContainerExitStatus.ABORTED));
        }
        releasedContainerList.clear();
    }
    return csList;
}
Also used : ContainerSimulator(org.apache.hadoop.yarn.sls.scheduler.ContainerSimulator) ContainerStatus(org.apache.hadoop.yarn.api.records.ContainerStatus) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ArrayList(java.util.ArrayList)

Example 42 with ContainerStatus

use of org.apache.hadoop.yarn.api.records.ContainerStatus in project hadoop by apache.

the class SLSCapacityScheduler method updateQueueWithNodeUpdate.

private void updateQueueWithNodeUpdate(NodeUpdateSchedulerEventWrapper eventWrapper) {
    RMNodeWrapper node = (RMNodeWrapper) eventWrapper.getRMNode();
    List<UpdatedContainerInfo> containerList = node.getContainerUpdates();
    for (UpdatedContainerInfo info : containerList) {
        for (ContainerStatus status : info.getCompletedContainers()) {
            ContainerId containerId = status.getContainerId();
            SchedulerAppReport app = super.getSchedulerAppInfo(containerId.getApplicationAttemptId());
            if (app == null) {
                // information.
                continue;
            }
            String queue = appQueueMap.get(containerId.getApplicationAttemptId());
            int releasedMemory = 0, releasedVCores = 0;
            if (status.getExitStatus() == ContainerExitStatus.SUCCESS) {
                for (RMContainer rmc : app.getLiveContainers()) {
                    if (rmc.getContainerId() == containerId) {
                        releasedMemory += rmc.getContainer().getResource().getMemorySize();
                        releasedVCores += rmc.getContainer().getResource().getVirtualCores();
                        break;
                    }
                }
            } else if (status.getExitStatus() == ContainerExitStatus.ABORTED) {
                if (preemptionContainerMap.containsKey(containerId)) {
                    Resource preResource = preemptionContainerMap.get(containerId);
                    releasedMemory += preResource.getMemorySize();
                    releasedVCores += preResource.getVirtualCores();
                    preemptionContainerMap.remove(containerId);
                }
            }
            // update queue counters
            updateQueueMetrics(queue, releasedMemory, releasedVCores);
        }
    }
}
Also used : ContainerStatus(org.apache.hadoop.yarn.api.records.ContainerStatus) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) UpdatedContainerInfo(org.apache.hadoop.yarn.server.resourcemanager.rmnode.UpdatedContainerInfo) Resource(org.apache.hadoop.yarn.api.records.Resource) RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer) SchedulerAppReport(org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerAppReport)

Example 43 with ContainerStatus

use of org.apache.hadoop.yarn.api.records.ContainerStatus in project hadoop by apache.

the class NMSimulator method newContainerStatus.

private ContainerStatus newContainerStatus(ContainerId cId, ContainerState state, int exitState) {
    ContainerStatus cs = Records.newRecord(ContainerStatus.class);
    cs.setContainerId(cId);
    cs.setState(state);
    cs.setExitStatus(exitState);
    return cs;
}
Also used : ContainerStatus(org.apache.hadoop.yarn.api.records.ContainerStatus)

Example 44 with ContainerStatus

use of org.apache.hadoop.yarn.api.records.ContainerStatus in project hadoop by apache.

the class AllocateResponsePBImpl method initLocalFinishedContainerList.

// Once this is called. containerList will never be null - until a getProto
// is called.
private synchronized void initLocalFinishedContainerList() {
    if (this.completedContainersStatuses != null) {
        return;
    }
    AllocateResponseProtoOrBuilder p = viaProto ? proto : builder;
    List<ContainerStatusProto> list = p.getCompletedContainerStatusesList();
    completedContainersStatuses = new ArrayList<ContainerStatus>();
    for (ContainerStatusProto c : list) {
        completedContainersStatuses.add(convertFromProtoFormat(c));
    }
}
Also used : ContainerStatusProto(org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto) ContainerStatus(org.apache.hadoop.yarn.api.records.ContainerStatus) AllocateResponseProtoOrBuilder(org.apache.hadoop.yarn.proto.YarnServiceProtos.AllocateResponseProtoOrBuilder)

Example 45 with ContainerStatus

use of org.apache.hadoop.yarn.api.records.ContainerStatus in project hadoop by apache.

the class GetContainerStatusesResponsePBImpl method addLocalContainerStatusesToProto.

private void addLocalContainerStatusesToProto() {
    maybeInitBuilder();
    builder.clearStatus();
    if (this.containerStatuses == null)
        return;
    List<ContainerStatusProto> protoList = new ArrayList<ContainerStatusProto>();
    for (ContainerStatus status : containerStatuses) {
        protoList.add(convertToProtoFormat(status));
    }
    builder.addAllStatus(protoList);
}
Also used : ContainerStatusProto(org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto) ContainerStatus(org.apache.hadoop.yarn.api.records.ContainerStatus) ArrayList(java.util.ArrayList)

Aggregations

ContainerStatus (org.apache.hadoop.yarn.api.records.ContainerStatus)124 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)67 Test (org.junit.Test)61 ArrayList (java.util.ArrayList)52 Container (org.apache.hadoop.yarn.api.records.Container)35 NMContainerStatus (org.apache.hadoop.yarn.server.api.protocolrecords.NMContainerStatus)28 HashMap (java.util.HashMap)24 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)23 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)22 NodeId (org.apache.hadoop.yarn.api.records.NodeId)21 GetContainerStatusesRequest (org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesRequest)20 ContainerLaunchContext (org.apache.hadoop.yarn.api.records.ContainerLaunchContext)20 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)20 StartContainerRequest (org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest)19 StartContainersRequest (org.apache.hadoop.yarn.api.protocolrecords.StartContainersRequest)18 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)18 AllocateResponse (org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse)17 Resource (org.apache.hadoop.yarn.api.records.Resource)16 Configuration (org.apache.hadoop.conf.Configuration)14 RMContainer (org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)14