Search in sources :

Example 1 with ContainerUpdateType

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

the class AMRMClientImpl method createUpdateList.

private List<UpdateContainerRequest> createUpdateList() {
    List<UpdateContainerRequest> updateList = new ArrayList<>();
    for (Map.Entry<ContainerId, SimpleEntry<Container, UpdateContainerRequest>> entry : change.entrySet()) {
        Resource targetCapability = entry.getValue().getValue().getCapability();
        ExecutionType targetExecType = entry.getValue().getValue().getExecutionType();
        ContainerUpdateType updateType = entry.getValue().getValue().getContainerUpdateType();
        int version = entry.getValue().getKey().getVersion();
        updateList.add(UpdateContainerRequest.newInstance(version, entry.getKey(), updateType, targetCapability, targetExecType));
    }
    return updateList;
}
Also used : ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) SimpleEntry(java.util.AbstractMap.SimpleEntry) ExecutionType(org.apache.hadoop.yarn.api.records.ExecutionType) ContainerUpdateType(org.apache.hadoop.yarn.api.records.ContainerUpdateType) ArrayList(java.util.ArrayList) Resource(org.apache.hadoop.yarn.api.records.Resource) UpdateContainerRequest(org.apache.hadoop.yarn.api.records.UpdateContainerRequest) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with ContainerUpdateType

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

the class RMServerUtils method validateAndSplitUpdateResourceRequests.

/**
   * Check if we have:
   * - Request for same containerId and different target resource.
   * - If targetResources violates maximum/minimumAllocation.
   * @param rmContext RM context.
   * @param request Allocate Request.
   * @param maximumAllocation Maximum Allocation.
   * @param updateErrors Container update errors.
   * @return ContainerUpdateRequests.
   */
public static ContainerUpdates validateAndSplitUpdateResourceRequests(RMContext rmContext, AllocateRequest request, Resource maximumAllocation, List<UpdateContainerError> updateErrors) {
    ContainerUpdates updateRequests = new ContainerUpdates();
    Set<ContainerId> outstandingUpdate = new HashSet<>();
    for (UpdateContainerRequest updateReq : request.getUpdateRequests()) {
        RMContainer rmContainer = rmContext.getScheduler().getRMContainer(updateReq.getContainerId());
        String msg = validateContainerIdAndVersion(outstandingUpdate, updateReq, rmContainer);
        ContainerUpdateType updateType = updateReq.getContainerUpdateType();
        if (msg == null) {
            if ((updateType != ContainerUpdateType.PROMOTE_EXECUTION_TYPE) && (updateType != ContainerUpdateType.DEMOTE_EXECUTION_TYPE)) {
                if (validateIncreaseDecreaseRequest(rmContext, updateReq, maximumAllocation)) {
                    if (ContainerUpdateType.INCREASE_RESOURCE == updateType) {
                        updateRequests.getIncreaseRequests().add(updateReq);
                    } else {
                        updateRequests.getDecreaseRequests().add(updateReq);
                    }
                    outstandingUpdate.add(updateReq.getContainerId());
                } else {
                    msg = RESOURCE_OUTSIDE_ALLOWED_RANGE;
                }
            } else {
                ExecutionType original = rmContainer.getExecutionType();
                ExecutionType target = updateReq.getExecutionType();
                if (target != original) {
                    if (target == ExecutionType.GUARANTEED && original == ExecutionType.OPPORTUNISTIC) {
                        updateRequests.getPromotionRequests().add(updateReq);
                        outstandingUpdate.add(updateReq.getContainerId());
                    } else if (target == ExecutionType.OPPORTUNISTIC && original == ExecutionType.GUARANTEED) {
                        updateRequests.getDemotionRequests().add(updateReq);
                        outstandingUpdate.add(updateReq.getContainerId());
                    }
                }
            }
        }
        checkAndcreateUpdateError(updateErrors, updateReq, rmContainer, msg);
    }
    return updateRequests;
}
Also used : ContainerUpdates(org.apache.hadoop.yarn.server.resourcemanager.scheduler.ContainerUpdates) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ContainerUpdateType(org.apache.hadoop.yarn.api.records.ContainerUpdateType) ExecutionType(org.apache.hadoop.yarn.api.records.ExecutionType) UpdateContainerRequest(org.apache.hadoop.yarn.api.records.UpdateContainerRequest) RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer) HashSet(java.util.HashSet)

Aggregations

ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)2 ContainerUpdateType (org.apache.hadoop.yarn.api.records.ContainerUpdateType)2 ExecutionType (org.apache.hadoop.yarn.api.records.ExecutionType)2 UpdateContainerRequest (org.apache.hadoop.yarn.api.records.UpdateContainerRequest)2 SimpleEntry (java.util.AbstractMap.SimpleEntry)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Resource (org.apache.hadoop.yarn.api.records.Resource)1 RMContainer (org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)1 ContainerUpdates (org.apache.hadoop.yarn.server.resourcemanager.scheduler.ContainerUpdates)1