Search in sources :

Example 1 with ExecutionType

use of org.apache.hadoop.yarn.api.records.ExecutionType 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 ExecutionType

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

the class RemoteRequestsTable method remove.

ResourceRequestInfo remove(Priority priority, String resourceName, ExecutionType execType, Resource capability) {
    ResourceRequestInfo retVal = null;
    Map<String, Map<ExecutionType, TreeMap<Resource, ResourceRequestInfo>>> locationMap = remoteRequestsTable.get(priority);
    if (locationMap == null) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("No such priority=" + priority);
        }
        return null;
    }
    Map<ExecutionType, TreeMap<Resource, ResourceRequestInfo>> execTypeMap = locationMap.get(resourceName);
    if (execTypeMap == null) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("No such resourceName=" + resourceName);
        }
        return null;
    }
    TreeMap<Resource, ResourceRequestInfo> capabilityMap = execTypeMap.get(execType);
    if (capabilityMap == null) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("No such Execution Type=" + execType);
        }
        return null;
    }
    retVal = capabilityMap.remove(capability);
    if (capabilityMap.size() == 0) {
        execTypeMap.remove(execType);
        if (execTypeMap.size() == 0) {
            locationMap.remove(resourceName);
            if (locationMap.size() == 0) {
                this.remoteRequestsTable.remove(priority);
            }
        }
    }
    return retVal;
}
Also used : ResourceRequestInfo(org.apache.hadoop.yarn.client.api.impl.AMRMClientImpl.ResourceRequestInfo) ExecutionType(org.apache.hadoop.yarn.api.records.ExecutionType) Resource(org.apache.hadoop.yarn.api.records.Resource) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 3 with ExecutionType

use of org.apache.hadoop.yarn.api.records.ExecutionType 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

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