Search in sources :

Example 1 with RMNodeDecreaseContainerEvent

use of org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeDecreaseContainerEvent in project hadoop by apache.

the class SchedulerApplicationAttempt method updateContainerAndNMToken.

private Container updateContainerAndNMToken(RMContainer rmContainer, ContainerUpdateType updateType) {
    Container container = rmContainer.getContainer();
    ContainerType containerType = ContainerType.TASK;
    if (updateType != null) {
        container.setVersion(container.getVersion() + 1);
    }
    // itself is the master container.
    if (isWaitingForAMContainer()) {
        containerType = ContainerType.APPLICATION_MASTER;
    }
    try {
        // create container token and NMToken altogether.
        container.setContainerToken(rmContext.getContainerTokenSecretManager().createContainerToken(container.getId(), container.getVersion(), container.getNodeId(), getUser(), container.getResource(), container.getPriority(), rmContainer.getCreationTime(), this.logAggregationContext, rmContainer.getNodeLabelExpression(), containerType));
        updateNMToken(container);
    } catch (IllegalArgumentException e) {
        // DNS might be down, skip returning this container.
        LOG.error("Error trying to assign container token and NM token to" + " an updated container " + container.getId(), e);
        return null;
    }
    if (updateType == null || ContainerUpdateType.PROMOTE_EXECUTION_TYPE == updateType || ContainerUpdateType.DEMOTE_EXECUTION_TYPE == updateType) {
        rmContainer.handle(new RMContainerEvent(rmContainer.getContainerId(), RMContainerEventType.ACQUIRED));
    } else {
        rmContainer.handle(new RMContainerUpdatesAcquiredEvent(rmContainer.getContainerId(), ContainerUpdateType.INCREASE_RESOURCE == updateType));
        if (ContainerUpdateType.DECREASE_RESOURCE == updateType) {
            this.rmContext.getDispatcher().getEventHandler().handle(new RMNodeDecreaseContainerEvent(rmContainer.getNodeId(), Collections.singletonList(rmContainer.getContainer())));
        }
    }
    return container;
}
Also used : RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer) Container(org.apache.hadoop.yarn.api.records.Container) RMContainerEvent(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerEvent) ContainerType(org.apache.hadoop.yarn.server.api.ContainerType) RMNodeDecreaseContainerEvent(org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeDecreaseContainerEvent) RMContainerUpdatesAcquiredEvent(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerUpdatesAcquiredEvent)

Aggregations

Container (org.apache.hadoop.yarn.api.records.Container)1 ContainerType (org.apache.hadoop.yarn.server.api.ContainerType)1 RMContainer (org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)1 RMContainerEvent (org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerEvent)1 RMContainerUpdatesAcquiredEvent (org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerUpdatesAcquiredEvent)1 RMNodeDecreaseContainerEvent (org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeDecreaseContainerEvent)1