Search in sources :

Example 1 with ResourceRequestInfo

use of org.apache.hadoop.yarn.client.api.impl.AMRMClientImpl.ResourceRequestInfo 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 2 with ResourceRequestInfo

use of org.apache.hadoop.yarn.client.api.impl.AMRMClientImpl.ResourceRequestInfo in project hadoop by apache.

the class RemoteRequestsTable method getMatchingRequests.

List<ResourceRequestInfo> getMatchingRequests(Priority priority, String resourceName, ExecutionType executionType, Resource capability) {
    List<ResourceRequestInfo> list = new LinkedList<>();
    TreeMap<Resource, ResourceRequestInfo> capabilityMap = getCapabilityMap(priority, resourceName, executionType);
    if (capabilityMap != null) {
        ResourceRequestInfo resourceRequestInfo = capabilityMap.get(capability);
        if (resourceRequestInfo != null) {
            list.add(resourceRequestInfo);
        } else {
            list.addAll(capabilityMap.tailMap(capability).values());
        }
    }
    return list;
}
Also used : ResourceRequestInfo(org.apache.hadoop.yarn.client.api.impl.AMRMClientImpl.ResourceRequestInfo) Resource(org.apache.hadoop.yarn.api.records.Resource) LinkedList(java.util.LinkedList)

Example 3 with ResourceRequestInfo

use of org.apache.hadoop.yarn.client.api.impl.AMRMClientImpl.ResourceRequestInfo in project hadoop by apache.

the class RemoteRequestsTable method decResourceRequest.

ResourceRequestInfo decResourceRequest(Priority priority, String resourceName, ExecutionTypeRequest execTypeReq, Resource capability, T req) {
    ResourceRequestInfo resourceRequestInfo = get(priority, resourceName, execTypeReq.getExecutionType(), capability);
    if (resourceRequestInfo == null) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Not decrementing resource as ResourceRequestInfo with" + "priority=" + priority + ", " + "resourceName=" + resourceName + ", " + "executionType=" + execTypeReq + ", " + "capability=" + capability + " is not present in request table");
        }
        return null;
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("BEFORE decResourceRequest:" + " applicationId=" + " priority=" + priority.getPriority() + " resourceName=" + resourceName + " numContainers=" + resourceRequestInfo.remoteRequest.getNumContainers());
    }
    resourceRequestInfo.remoteRequest.setNumContainers(resourceRequestInfo.remoteRequest.getNumContainers() - 1);
    resourceRequestInfo.containerRequests.remove(req);
    if (resourceRequestInfo.remoteRequest.getNumContainers() < 0) {
        // guard against spurious removals
        resourceRequestInfo.remoteRequest.setNumContainers(0);
    }
    return resourceRequestInfo;
}
Also used : ResourceRequestInfo(org.apache.hadoop.yarn.client.api.impl.AMRMClientImpl.ResourceRequestInfo)

Example 4 with ResourceRequestInfo

use of org.apache.hadoop.yarn.client.api.impl.AMRMClientImpl.ResourceRequestInfo in project hadoop by apache.

the class RemoteRequestsTable method addResourceRequest.

@SuppressWarnings("unchecked")
ResourceRequestInfo addResourceRequest(Long allocationRequestId, Priority priority, String resourceName, ExecutionTypeRequest execTypeReq, Resource capability, T req, boolean relaxLocality, String labelExpression) {
    ResourceRequestInfo resourceRequestInfo = get(priority, resourceName, execTypeReq.getExecutionType(), capability);
    if (resourceRequestInfo == null) {
        resourceRequestInfo = new ResourceRequestInfo(allocationRequestId, priority, resourceName, capability, relaxLocality);
        put(priority, resourceName, execTypeReq.getExecutionType(), capability, resourceRequestInfo);
    }
    resourceRequestInfo.remoteRequest.setExecutionTypeRequest(execTypeReq);
    resourceRequestInfo.remoteRequest.setNumContainers(resourceRequestInfo.remoteRequest.getNumContainers() + 1);
    if (relaxLocality) {
        resourceRequestInfo.containerRequests.add(req);
    }
    if (ResourceRequest.ANY.equals(resourceName)) {
        resourceRequestInfo.remoteRequest.setNodeLabelExpression(labelExpression);
    }
    return resourceRequestInfo;
}
Also used : ResourceRequestInfo(org.apache.hadoop.yarn.client.api.impl.AMRMClientImpl.ResourceRequestInfo)

Aggregations

ResourceRequestInfo (org.apache.hadoop.yarn.client.api.impl.AMRMClientImpl.ResourceRequestInfo)4 Resource (org.apache.hadoop.yarn.api.records.Resource)2 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 ExecutionType (org.apache.hadoop.yarn.api.records.ExecutionType)1