List of usage examples for org.apache.hadoop.yarn.api.records Container getPriority
@Public @Stable public abstract Priority getPriority();
Priority
at which the Container
was allocated. From source file:org.apache.tez.dag.app.rm.YarnTaskSchedulerService.java
License:Apache License
private CookieContainerRequest getMatchingRequestWithPriority(Container container, String location) { Priority priority = container.getPriority(); Resource capability = container.getResource(); List<? extends Collection<CookieContainerRequest>> requestsList = amRmClient.getMatchingRequests(priority, location, capability);/* w w w . ja va2 s . c o m*/ if (!requestsList.isEmpty()) { // pick first one for (Collection<CookieContainerRequest> requests : requestsList) { for (CookieContainerRequest cookieContainerRequest : requests) { if (canAssignTaskToContainer(cookieContainerRequest, container)) { return cookieContainerRequest; } } } } return null; }
From source file:org.apache.tez.dag.app.rm.YarnTaskSchedulerService.java
License:Apache License
private synchronized boolean assignReUsedContainerWithLocation(Container container, ContainerAssigner assigner, Map<CookieContainerRequest, Container> assignedContainers, boolean honorLocality) { Priority containerPriority = container.getPriority(); Priority topPendingTaskPriority = amRmClient.getTopPriority(); if (topPendingTaskPriority == null) { // nothing left to assign return false; }/*from w ww. java 2s. com*/ if (topPendingTaskPriority.compareTo(containerPriority) > 0 && heldContainers.get(container.getId()).isNew()) { // if the next task to assign is higher priority than the container then // dont assign this container to that task. // if task and container are equal priority - then its first use or reuse // within the same priority - safe to use // if task is lower priority than container then if we use a container that // is no longer needed by higher priority tasks All those higher pri tasks // has been assigned resources - safe to use (first use or reuse) // if task is higher priority than container then we may end up using a // container that was assigned by the RM for a lower priority pending task // that will be assigned after this higher priority task is assigned. If we // use that task's container now then we may not be able to match this // container to that task later on. However the RM has already assigned us // all containers and is not going to give us new containers. We will get // stuck for resources. // the above applies for new containers. If a container has already been // re-used then this is not relevant return false; } CookieContainerRequest assigned = assigner.assignReUsedContainer(container, honorLocality); if (assigned != null) { assignedContainers.put(assigned, container); return true; } return false; }
From source file:org.springframework.yarn.am.monitor.DefaultContainerMonitorTests.java
License:Apache License
/** * Mock {@link Container}// w w w . j a v a2 s . com * * @param containerId the {@link ContainerId} * @param nodeId the {@link NodeId} * @param resource the {@link Resource} * @param priority the {@link Priority} * @param state the {@link ContainerState} * @return mocked {@link Container} */ public static Container getMockContainer(ContainerId containerId, NodeId nodeId, Resource resource, Priority priority) { Container container = mock(Container.class); when(container.getId()).thenReturn(containerId); when(container.getNodeId()).thenReturn(nodeId); when(container.getResource()).thenReturn(resource); when(container.getPriority()).thenReturn(priority); return container; }
From source file:org.springframework.yarn.boot.MockUtils.java
License:Apache License
public static Container getMockContainer(ContainerId containerId, NodeId nodeId, Resource resource, Priority priority) {/*from www . j av a2s . c o m*/ Container container = mock(Container.class); when(container.getId()).thenReturn(containerId); when(container.getNodeId()).thenReturn(nodeId); when(container.getResource()).thenReturn(resource); when(container.getPriority()).thenReturn(priority); return container; }