Example usage for org.apache.hadoop.yarn.server.resourcemanager.rmcontainer RMContainer getContainer

List of usage examples for org.apache.hadoop.yarn.server.resourcemanager.rmcontainer RMContainer getContainer

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.server.resourcemanager.rmcontainer RMContainer getContainer.

Prototype

Container getContainer();

Source Link

Usage

From source file:org.apache.myriad.scheduler.fgs.YarnNodeCapacityManager.java

License:Apache License

private void removeYarnTask(RMContainer rmContainer) {
    if (containersNotNull(rmContainer)) {
        Protos.TaskID taskId = containerToTaskId(rmContainer);
        /*/*from w  w w  .j a v  a  2 s  .  co  m*/
         * Mark the task as killable within the ServerState object to flag the task 
         * for the TaskTerminator daemon to kill the task
         */
        state.makeTaskKillable(taskId);

        Node node = retrieveNode(rmContainer);
        if (node != null) {
            RMNode rmNode = node.getNode().getRMNode();
            Resource resource = rmContainer.getContainer().getResource();
            decrementNodeCapacity(rmNode, resource);
            LOGGER.info("Removed task yarn_{} with exit status freeing {} cpu and {} mem.",
                    rmContainer.getContainer().toString(), rmContainer.getContainerExitStatus(),
                    resource.getVirtualCores(), resource.getMemory());
        } else {
            LOGGER.warn("The Node for the {} host was not found",
                    rmContainer.getContainer().getNodeId().getHost());
        }
    }
}

From source file:org.apache.myriad.scheduler.fgs.YarnNodeCapacityManager.java

License:Apache License

private Node retrieveNode(RMContainer container) {
    String hostname = container.getContainer().getNodeId().getHost();
    return nodeStore.getNode(hostname);
}

From source file:org.apache.myriad.scheduler.fgs.YarnNodeCapacityManager.java

License:Apache License

private boolean containersNotNull(RMContainer rmContainer) {
    return (rmContainer != null && rmContainer.getContainer() != null);
}

From source file:org.apache.myriad.scheduler.fgs.YarnNodeCapacityManager.java

License:Apache License

private Protos.TaskInfo getTaskInfoForContainer(RMContainer rmContainer, ConsumedOffer consumedOffer,
        Node node) {//  w  ww. ja  va2  s . co  m

    Protos.Offer offer = consumedOffer.getOffers().get(0);
    Container container = rmContainer.getContainer();
    Protos.TaskID taskId = Protos.TaskID.newBuilder()
            .setValue(ContainerTaskStatusRequest.YARN_CONTAINER_TASK_ID_PREFIX + container.getId().toString())
            .build();

    // TODO (sdaingade) Remove ExecutorInfo from the Node object
    // as this is now cached in the NodeTask object in scheduler state.
    Protos.ExecutorInfo executorInfo = node.getExecInfo();
    if (executorInfo == null) {
        executorInfo = Protos.ExecutorInfo.newBuilder(
                state.getNodeTask(offer.getSlaveId(), NodeManagerConfiguration.DEFAULT_NM_TASK_PREFIX)
                        .getExecutorInfo())
                .setFrameworkId(offer.getFrameworkId()).build();
        node.setExecInfo(executorInfo);
    }

    return Protos.TaskInfo.newBuilder().setName("task_" + taskId.getValue()).setTaskId(taskId)
            .setSlaveId(offer.getSlaveId())
            .addAllResources(taskUtils.getScalarResource(offer, "cpus",
                    (double) container.getResource().getVirtualCores(), 0.0))
            .addAllResources(taskUtils.getScalarResource(offer, "mem",
                    (double) container.getResource().getMemory(), 0.0))
            .setExecutor(executorInfo).build();
}

From source file:org.apache.myriad.scheduler.yarn.interceptor.CompositeInterceptor.java

License:Apache License

@Override
public void beforeCompletedContainer(RMContainer rmContainer, ContainerStatus containerStatus,
        RMContainerEventType event) {//  www.ja  v  a2s .c o m
    if (rmContainer != null && rmContainer.getContainer() != null) {
        NodeId nodeId = rmContainer.getContainer().getNodeId();
        for (YarnSchedulerInterceptor interceptor : interceptors.values()) {
            if (interceptor.getCallBackFilter().allowCallBacksForNode(nodeId)) {
                interceptor.beforeCompletedContainer(rmContainer, containerStatus, event);
            }
        }
    }
}