List of usage examples for org.apache.hadoop.yarn.api.records Priority getPriority
@Public @Stable public abstract int getPriority();
From source file:com.continuuity.weave.internal.yarn.ports.AMRMClientImpl.java
License:Apache License
private void addResourceRequest(Priority priority, String resourceName, Resource capability, int containerCount) { Map<String, Map<Resource, ResourceRequest>> remoteRequests = this.remoteRequestsTable.get(priority); if (remoteRequests == null) { remoteRequests = new HashMap<String, Map<Resource, ResourceRequest>>(); this.remoteRequestsTable.put(priority, remoteRequests); if (LOG.isDebugEnabled()) { LOG.debug("Added priority=" + priority); }// w ww .j av a2s . c o m } Map<Resource, ResourceRequest> reqMap = remoteRequests.get(resourceName); if (reqMap == null) { reqMap = new HashMap<Resource, ResourceRequest>(); remoteRequests.put(resourceName, reqMap); } ResourceRequest remoteRequest = reqMap.get(capability); if (remoteRequest == null) { remoteRequest = BuilderUtils.newResourceRequest(priority, resourceName, capability, 0); reqMap.put(capability, remoteRequest); } remoteRequest.setNumContainers(remoteRequest.getNumContainers() + containerCount); // Note this down for next interaction with ResourceManager addResourceRequestToAsk(remoteRequest); if (LOG.isDebugEnabled()) { LOG.debug("addResourceRequest:" + " applicationId=" + appAttemptId + " priority=" + priority.getPriority() + " resourceName=" + resourceName + " numContainers=" + remoteRequest.getNumContainers() + " #asks=" + ask.size()); } }
From source file:com.continuuity.weave.internal.yarn.ports.AMRMClientImpl.java
License:Apache License
private void decResourceRequest(Priority priority, String resourceName, Resource capability, int containerCount) { Map<String, Map<Resource, ResourceRequest>> remoteRequests = this.remoteRequestsTable.get(priority); if (remoteRequests == null) { if (LOG.isDebugEnabled()) { LOG.debug("Not decrementing resource as priority " + priority + " is not present in request table"); }/* w ww . ja v a 2 s.c om*/ return; } Map<Resource, ResourceRequest> reqMap = remoteRequests.get(resourceName); if (reqMap == null) { if (LOG.isDebugEnabled()) { LOG.debug("Not decrementing resource as " + resourceName + " is not present in request table"); } return; } ResourceRequest remoteRequest = reqMap.get(capability); if (LOG.isDebugEnabled()) { LOG.debug("BEFORE decResourceRequest:" + " applicationId=" + appAttemptId + " priority=" + priority.getPriority() + " resourceName=" + resourceName + " numContainers=" + remoteRequest.getNumContainers() + " #asks=" + ask.size()); } remoteRequest.setNumContainers(remoteRequest.getNumContainers() - containerCount); if (remoteRequest.getNumContainers() < 0) { // guard against spurious removals remoteRequest.setNumContainers(0); } // send the ResourceRequest to RM even if is 0 because it needs to override // a previously sent value. If ResourceRequest was not sent previously then // sending 0 aught to be a no-op on RM addResourceRequestToAsk(remoteRequest); // delete entries from map if no longer needed if (remoteRequest.getNumContainers() == 0) { reqMap.remove(capability); if (reqMap.size() == 0) { remoteRequests.remove(resourceName); } if (remoteRequests.size() == 0) { remoteRequestsTable.remove(priority); } } if (LOG.isDebugEnabled()) { LOG.info("AFTER decResourceRequest:" + " applicationId=" + appAttemptId + " priority=" + priority.getPriority() + " resourceName=" + resourceName + " numContainers=" + remoteRequest.getNumContainers() + " #asks=" + ask.size()); } }
From source file:disAMS.AMRMClient.Impl.AMRMClientImpl.java
License:Apache License
private void addResourceRequest(Priority priority, String resourceName, Resource capability, T req, boolean relaxLocality, String labelExpression) { Map<String, TreeMap<Resource, ResourceRequestInfo>> remoteRequests = this.remoteRequestsTable.get(priority); if (remoteRequests == null) { remoteRequests = new HashMap<String, TreeMap<Resource, ResourceRequestInfo>>(); this.remoteRequestsTable.put(priority, remoteRequests); if (LOG.isDebugEnabled()) { LOG.debug("Added priority=" + priority); }// w w w . jav a2s . com } TreeMap<Resource, ResourceRequestInfo> reqMap = remoteRequests.get(resourceName); if (reqMap == null) { // capabilities are stored in reverse sorted order. smallest last. reqMap = new TreeMap<Resource, ResourceRequestInfo>(new ResourceReverseMemoryThenCpuComparator()); remoteRequests.put(resourceName, reqMap); } ResourceRequestInfo resourceRequestInfo = reqMap.get(capability); if (resourceRequestInfo == null) { resourceRequestInfo = new ResourceRequestInfo(priority, resourceName, capability, relaxLocality); reqMap.put(capability, resourceRequestInfo); } resourceRequestInfo.remoteRequest .setNumContainers(resourceRequestInfo.remoteRequest.getNumContainers() + 1); if (relaxLocality) { resourceRequestInfo.containerRequests.add(req); } if (ResourceRequest.ANY.equals(resourceName)) { resourceRequestInfo.remoteRequest.setNodeLabelExpression(labelExpression); } // Note this down for next interaction with ResourceManager addResourceRequestToAsk(resourceRequestInfo.remoteRequest); if (LOG.isDebugEnabled()) { LOG.debug("addResourceRequest:" + " applicationId=" + " priority=" + priority.getPriority() + " resourceName=" + resourceName + " numContainers=" + resourceRequestInfo.remoteRequest.getNumContainers() + " #asks=" + ask.size()); } }
From source file:disAMS.AMRMClient.Impl.AMRMClientImpl.java
License:Apache License
private void decResourceRequest(Priority priority, String resourceName, Resource capability, T req) { Map<String, TreeMap<Resource, ResourceRequestInfo>> remoteRequests = this.remoteRequestsTable.get(priority); if (remoteRequests == null) { if (LOG.isDebugEnabled()) { LOG.debug("Not decrementing resource as priority " + priority + " is not present in request table"); }// w ww . ja va 2 s. co m return; } Map<Resource, ResourceRequestInfo> reqMap = remoteRequests.get(resourceName); if (reqMap == null) { if (LOG.isDebugEnabled()) { LOG.debug("Not decrementing resource as " + resourceName + " is not present in request table"); } return; } ResourceRequestInfo resourceRequestInfo = reqMap.get(capability); if (LOG.isDebugEnabled()) { LOG.debug("BEFORE decResourceRequest:" + " applicationId=" + " priority=" + priority.getPriority() + " resourceName=" + resourceName + " numContainers=" + resourceRequestInfo.remoteRequest.getNumContainers() + " #asks=" + ask.size()); } resourceRequestInfo.remoteRequest .setNumContainers(resourceRequestInfo.remoteRequest.getNumContainers() - 1); resourceRequestInfo.containerRequests.remove(req); if (resourceRequestInfo.remoteRequest.getNumContainers() < 0) { // guard against spurious removals resourceRequestInfo.remoteRequest.setNumContainers(0); } // send the ResourceRequest to RM even if is 0 because it needs to override // a previously sent value. If ResourceRequest was not sent previously then // sending 0 aught to be a no-op on RM addResourceRequestToAsk(resourceRequestInfo.remoteRequest); // delete entries from map if no longer needed if (resourceRequestInfo.remoteRequest.getNumContainers() == 0) { reqMap.remove(capability); if (reqMap.size() == 0) { remoteRequests.remove(resourceName); } if (remoteRequests.size() == 0) { remoteRequestsTable.remove(priority); } } if (LOG.isDebugEnabled()) { LOG.info("AFTER decResourceRequest:" + " applicationId=" + " priority=" + priority.getPriority() + " resourceName=" + resourceName + " numContainers=" + resourceRequestInfo.remoteRequest.getNumContainers() + " #asks=" + ask.size()); } }
From source file:org.apache.hoya.yarn.appmaster.state.ContainerPriority.java
License:Apache License
/** * Map from a container to a role key by way of its priority * @param container container/* w ww.j a v a2s .com*/ * @return role key */ public static int extractRole(Container container) { Priority priority = container.getPriority(); assert priority != null; return extractRole(priority.getPriority()); }
From source file:org.apache.hoya.yarn.appmaster.state.ContainerPriority.java
License:Apache License
/** * Map from a container to a role key by way of its priority * @param container container//from w w w . java2s . c o m * @return role key */ public static int extractRole(Priority priorityRecord) { return extractRole(priorityRecord.getPriority()); }
From source file:org.apache.slider.server.appmaster.state.ContainerPriority.java
License:Apache License
/** * Priority record to role mapper/*w w w . j a v a 2s .c o m*/ * @param priorityRecord priority record * @return the role # */ public static int extractRole(Priority priorityRecord) { Preconditions.checkNotNull(priorityRecord); return extractRole(priorityRecord.getPriority()); }
From source file:org.apache.slider.server.appmaster.state.ContainerPriority.java
License:Apache License
/** * Convert a priority record to a string, extracting role and locality * @param priorityRecord priority record. May be null * @return a string value/* ww w . j a va2 s .c o m*/ */ public static String toString(Priority priorityRecord) { if (priorityRecord == null) { return "(null)"; } else { return String.format(Locale.ENGLISH, "role %d (locality=%b)", extractRole(priorityRecord), hasLocation(priorityRecord.getPriority())); } }
From source file:org.apache.tez.dag.app.rm.TaskScheduler.java
License:Apache License
private boolean isHigherPriority(Priority lhs, Priority rhs) { return lhs.getPriority() < rhs.getPriority(); }
From source file:org.apache.tez.dag.app.rm.TestContainerReuse.java
License:Apache License
private AMSchedulerEventTALaunchRequest createLaunchRequestEvent(TezTaskAttemptID taID, TaskAttempt ta, Resource capability, String[] hosts, String[] racks, Priority priority, ContainerContext containerContext) { TaskLocationHint locationHint = null; if (hosts != null || racks != null) { Set<String> hostsSet = Sets.newHashSet(hosts); Set<String> racksSet = Sets.newHashSet(racks); locationHint = TaskLocationHint.createTaskLocationHint(hostsSet, racksSet); }//ww w. ja v a 2 s. c om AMSchedulerEventTALaunchRequest lr = new AMSchedulerEventTALaunchRequest(taID, capability, new TaskSpec( taID, "dagName", "vertexName", -1, ProcessorDescriptor.create("processorClassName"), Collections.singletonList(new InputSpec("vertexName", InputDescriptor.create("inputClassName"), 1)), Collections.singletonList( new OutputSpec("vertexName", OutputDescriptor.create("outputClassName"), 1)), null), ta, locationHint, priority.getPriority(), containerContext); return lr; }