Java Code Examples for org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer#getContainer()
The following examples show how to use
org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer#getContainer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: YarnNodeCapacityManager.java From incubator-myriad with Apache License 2.0 | 6 votes |
private Protos.TaskInfo getTaskInfoForContainer(RMContainer rmContainer, ConsumedOffer consumedOffer, Node node) { Protos.Offer offer = consumedOffer.getOffers().get(0); Container container = rmContainer.getContainer(); Protos.TaskID taskId = Protos.TaskID.newBuilder().setValue( ContainerTaskStatusRequest.YARN_CONTAINER_TASK_ID_PREFIX + container.getId().toString()).build(); // TODO (sdaingade) Remove ExecutorInfo from the Node object // as this is now cached in the NodeTask object in scheduler state. Protos.ExecutorInfo executorInfo = node.getExecInfo(); if (executorInfo == null) { executorInfo = Protos.ExecutorInfo.newBuilder(state.getNodeTask(offer.getSlaveId(), NodeManagerConfiguration.DEFAULT_NM_TASK_PREFIX) .getExecutorInfo()).setFrameworkId(offer.getFrameworkId()).build(); node.setExecInfo(executorInfo); } return Protos.TaskInfo.newBuilder() .setName("task_" + taskId.getValue()).setTaskId(taskId) .setSlaveId(offer.getSlaveId()) .addAllResources(taskUtils.getScalarResource(offer, "cpus", (double) container.getResource().getVirtualCores(), 0.0)) .addAllResources(taskUtils.getScalarResource(offer, "mem", (double) container.getResource().getMemory(), 0.0)) .setExecutor(executorInfo) .build(); }
Example 2
Source File: SchedulerApplicationAttempt.java From hadoop with Apache License 2.0 | 5 votes |
public synchronized ContainersAndNMTokensAllocation pullNewlyAllocatedContainersAndNMTokens() { List<Container> returnContainerList = new ArrayList<Container>(newlyAllocatedContainers.size()); List<NMToken> nmTokens = new ArrayList<NMToken>(); for (Iterator<RMContainer> i = newlyAllocatedContainers.iterator(); i .hasNext();) { RMContainer rmContainer = i.next(); Container container = rmContainer.getContainer(); try { // create container token and NMToken altogether. container.setContainerToken(rmContext.getContainerTokenSecretManager() .createContainerToken(container.getId(), container.getNodeId(), getUser(), container.getResource(), container.getPriority(), rmContainer.getCreationTime(), this.logAggregationContext)); NMToken nmToken = rmContext.getNMTokenSecretManager().createAndGetNMToken(getUser(), getApplicationAttemptId(), container); if (nmToken != null) { nmTokens.add(nmToken); } } catch (IllegalArgumentException e) { // DNS might be down, skip returning this container. LOG.error("Error trying to assign container token and NM token to" + " an allocated container " + container.getId(), e); continue; } returnContainerList.add(container); i.remove(); rmContainer.handle(new RMContainerEvent(rmContainer.getContainerId(), RMContainerEventType.ACQUIRED)); } return new ContainersAndNMTokensAllocation(returnContainerList, nmTokens); }
Example 3
Source File: CapacityScheduler.java From big-c with Apache License 2.0 | 5 votes |
@Lock(CapacityScheduler.class) @Override protected synchronized void completedContainer(RMContainer rmContainer, ContainerStatus containerStatus, RMContainerEventType event) { if (rmContainer == null) { LOG.info("Null container completed..."); return; } Container container = rmContainer.getContainer(); // Get the application for the finished container FiCaSchedulerApp application = getCurrentAttemptForContainer(container.getId()); ApplicationId appId = container.getId().getApplicationAttemptId().getApplicationId(); if (application == null) { LOG.info("Container " + container + " of" + " unknown application " + appId + " completed or suspended with event " + event); return; } // Get the node on which the container was allocated FiCaSchedulerNode node = getNode(container.getNodeId()); // Inform the queue LeafQueue queue = (LeafQueue)application.getQueue(); queue.completedContainer(clusterResource, application, node, rmContainer, containerStatus, event, null, true); LOG.info("Application attempt " + application.getApplicationAttemptId() + " released container " + container.getId() + " on node: " + node + " with event: " + event); }
Example 4
Source File: FiCaSchedulerApp.java From big-c with Apache License 2.0 | 5 votes |
public synchronized boolean unreserve(FiCaSchedulerNode node, Priority priority) { Map<NodeId, RMContainer> reservedContainers = this.reservedContainers.get(priority); if (reservedContainers != null) { RMContainer reservedContainer = reservedContainers.remove(node.getNodeID()); // unreserve is now triggered in new scenarios (preemption) // as a consequence reservedcontainer might be null, adding NP-checks if (reservedContainer != null && reservedContainer.getContainer() != null && reservedContainer.getContainer().getResource() != null) { if (reservedContainers.isEmpty()) { this.reservedContainers.remove(priority); } // Reset the re-reservation count resetReReservations(priority); Resource resource = reservedContainer.getContainer().getResource(); Resources.subtractFrom(currentReservation, resource); LOG.info("Application " + getApplicationId() + " unreserved " + " on node " + node + ", currently has " + reservedContainers.size() + " at priority " + priority + "; currentReservation " + currentReservation); return true; } } return false; }
Example 5
Source File: FSAppAttempt.java From big-c with Apache License 2.0 | 5 votes |
synchronized public void containerCompleted(RMContainer rmContainer, ContainerStatus containerStatus, RMContainerEventType event) { Container container = rmContainer.getContainer(); ContainerId containerId = container.getId(); // Remove from the list of newly allocated containers if found newlyAllocatedContainers.remove(rmContainer); // Inform the container rmContainer.handle( new RMContainerFinishedEvent( containerId, containerStatus, event) ); LOG.info("Completed container: " + rmContainer.getContainerId() + " in state: " + rmContainer.getState() + " event:" + event); // Remove from the list of containers liveContainers.remove(rmContainer.getContainerId()); RMAuditLogger.logSuccess(getUser(), AuditConstants.RELEASE_CONTAINER, "SchedulerApp", getApplicationId(), containerId); // Update usage metrics Resource containerResource = rmContainer.getContainer().getResource(); queue.getMetrics().releaseResources(getUser(), 1, containerResource); Resources.subtractFrom(currentConsumption, containerResource); // remove from preemption map if it is completed preemptionMap.remove(rmContainer); // Clear resource utilization metrics cache. lastMemoryAggregateAllocationUpdateTime = -1; }
Example 6
Source File: LeafQueue.java From big-c with Apache License 2.0 | 5 votes |
private Container getContainer(RMContainer rmContainer, FiCaSchedulerApp application, FiCaSchedulerNode node, Resource capability, Priority priority) { //是否是reserve 的情况 return (rmContainer != null) ? rmContainer.getContainer() : createContainer(application, node, capability, priority); }
Example 7
Source File: CompositeInterceptor.java From incubator-myriad with Apache License 2.0 | 5 votes |
@Override public void beforeCompletedContainer(RMContainer rmContainer, ContainerStatus containerStatus, RMContainerEventType event) { if (rmContainer != null && rmContainer.getContainer() != null) { NodeId nodeId = rmContainer.getContainer().getNodeId(); for (YarnSchedulerInterceptor interceptor : interceptors.values()) { if (interceptor.getCallBackFilter().allowCallBacksForNode(nodeId)) { interceptor.beforeCompletedContainer(rmContainer, containerStatus, event); } } } }
Example 8
Source File: CapacityScheduler.java From hadoop with Apache License 2.0 | 5 votes |
@Lock(CapacityScheduler.class) @Override protected synchronized void completedContainer(RMContainer rmContainer, ContainerStatus containerStatus, RMContainerEventType event) { if (rmContainer == null) { LOG.info("Null container completed..."); return; } Container container = rmContainer.getContainer(); // Get the application for the finished container FiCaSchedulerApp application = getCurrentAttemptForContainer(container.getId()); ApplicationId appId = container.getId().getApplicationAttemptId().getApplicationId(); if (application == null) { LOG.info("Container " + container + " of" + " unknown application " + appId + " completed with event " + event); return; } // Get the node on which the container was allocated FiCaSchedulerNode node = getNode(container.getNodeId()); // Inform the queue LeafQueue queue = (LeafQueue)application.getQueue(); queue.completedContainer(clusterResource, application, node, rmContainer, containerStatus, event, null, true); LOG.info("Application attempt " + application.getApplicationAttemptId() + " released container " + container.getId() + " on node: " + node + " with event: " + event); }
Example 9
Source File: SchedulerNode.java From hadoop with Apache License 2.0 | 5 votes |
/** * The Scheduler has allocated containers on this node to the given * application. * * @param rmContainer * allocated container */ public synchronized void allocateContainer(RMContainer rmContainer) { Container container = rmContainer.getContainer(); deductAvailableResource(container.getResource()); ++numContainers; launchedContainers.put(container.getId(), rmContainer); LOG.info("Assigned container " + container.getId() + " of capacity " + container.getResource() + " on host " + rmNode.getNodeAddress() + ", which has " + numContainers + " containers, " + getUsedResource() + " used and " + getAvailableResource() + " available after allocation"); }
Example 10
Source File: FSAppAttempt.java From hadoop with Apache License 2.0 | 5 votes |
synchronized public void containerCompleted(RMContainer rmContainer, ContainerStatus containerStatus, RMContainerEventType event) { Container container = rmContainer.getContainer(); ContainerId containerId = container.getId(); // Remove from the list of newly allocated containers if found newlyAllocatedContainers.remove(rmContainer); // Inform the container rmContainer.handle( new RMContainerFinishedEvent( containerId, containerStatus, event) ); LOG.info("Completed container: " + rmContainer.getContainerId() + " in state: " + rmContainer.getState() + " event:" + event); // Remove from the list of containers liveContainers.remove(rmContainer.getContainerId()); RMAuditLogger.logSuccess(getUser(), AuditConstants.RELEASE_CONTAINER, "SchedulerApp", getApplicationId(), containerId); // Update usage metrics Resource containerResource = rmContainer.getContainer().getResource(); queue.getMetrics().releaseResources(getUser(), 1, containerResource); this.attemptResourceUsage.decUsed(containerResource); // remove from preemption map if it is completed preemptionMap.remove(rmContainer); // Clear resource utilization metrics cache. lastMemoryAggregateAllocationUpdateTime = -1; }
Example 11
Source File: FairScheduler.java From hadoop with Apache License 2.0 | 5 votes |
/** * Clean up a completed container. */ @Override protected synchronized void completedContainer(RMContainer rmContainer, ContainerStatus containerStatus, RMContainerEventType event) { if (rmContainer == null) { LOG.info("Null container completed..."); return; } Container container = rmContainer.getContainer(); // Get the application for the finished container FSAppAttempt application = getCurrentAttemptForContainer(container.getId()); ApplicationId appId = container.getId().getApplicationAttemptId().getApplicationId(); if (application == null) { LOG.info("Container " + container + " of" + " unknown application attempt " + appId + " completed with event " + event); return; } // Get the node on which the container was allocated FSSchedulerNode node = getFSSchedulerNode(container.getNodeId()); if (rmContainer.getState() == RMContainerState.RESERVED) { application.unreserve(rmContainer.getReservedPriority(), node); } else { application.containerCompleted(rmContainer, containerStatus, event); node.releaseContainer(container); updateRootQueueMetrics(); } LOG.info("Application attempt " + application.getApplicationAttemptId() + " released container " + container.getId() + " on node: " + node + " with event: " + event); }
Example 12
Source File: CapacityScheduler.java From hadoop with Apache License 2.0 | 4 votes |
private synchronized void allocateContainersToNode(FiCaSchedulerNode node) { if (rmContext.isWorkPreservingRecoveryEnabled() && !rmContext.isSchedulerReadyForAllocatingContainers()) { return; } // Assign new containers... // 1. Check for reserved applications // 2. Schedule if there are no reservations RMContainer reservedContainer = node.getReservedContainer(); if (reservedContainer != null) { FiCaSchedulerApp reservedApplication = getCurrentAttemptForContainer(reservedContainer.getContainerId()); // Try to fulfill the reservation LOG.info("Trying to fulfill reservation for application " + reservedApplication.getApplicationId() + " on node: " + node.getNodeID()); LeafQueue queue = ((LeafQueue)reservedApplication.getQueue()); CSAssignment assignment = queue.assignContainers( clusterResource, node, // TODO, now we only consider limits for parent for non-labeled // resources, should consider labeled resources as well. new ResourceLimits(labelManager.getResourceByLabel( RMNodeLabelsManager.NO_LABEL, clusterResource))); RMContainer excessReservation = assignment.getExcessReservation(); if (excessReservation != null) { Container container = excessReservation.getContainer(); queue.completedContainer( clusterResource, assignment.getApplication(), node, excessReservation, SchedulerUtils.createAbnormalContainerStatus( container.getId(), SchedulerUtils.UNRESERVED_CONTAINER), RMContainerEventType.RELEASED, null, true); } } // Try to schedule more if there are no reservations to fulfill if (node.getReservedContainer() == null) { if (calculator.computeAvailableContainers(node.getAvailableResource(), minimumAllocation) > 0) { if (LOG.isDebugEnabled()) { LOG.debug("Trying to schedule on node: " + node.getNodeName() + ", available: " + node.getAvailableResource()); } root.assignContainers( clusterResource, node, // TODO, now we only consider limits for parent for non-labeled // resources, should consider labeled resources as well. new ResourceLimits(labelManager.getResourceByLabel( RMNodeLabelsManager.NO_LABEL, clusterResource))); } } else { LOG.info("Skipping scheduling since node " + node.getNodeID() + " is reserved by application " + node.getReservedContainer().getContainerId().getApplicationAttemptId() ); } }
Example 13
Source File: LeafQueue.java From hadoop with Apache License 2.0 | 4 votes |
private Container getContainer(RMContainer rmContainer, FiCaSchedulerApp application, FiCaSchedulerNode node, Resource capability, Priority priority) { return (rmContainer != null) ? rmContainer.getContainer() : createContainer(application, node, capability, priority); }
Example 14
Source File: LeafQueue.java From hadoop with Apache License 2.0 | 4 votes |
@Override public void completedContainer(Resource clusterResource, FiCaSchedulerApp application, FiCaSchedulerNode node, RMContainer rmContainer, ContainerStatus containerStatus, RMContainerEventType event, CSQueue childQueue, boolean sortQueues) { if (application != null) { boolean removed = false; // Careful! Locking order is important! synchronized (this) { Container container = rmContainer.getContainer(); // Inform the application & the node // Note: It's safe to assume that all state changes to RMContainer // happen under scheduler's lock... // So, this is, in effect, a transaction across application & node if (rmContainer.getState() == RMContainerState.RESERVED) { removed = unreserve(application, rmContainer.getReservedPriority(), node, rmContainer); } else { removed = application.containerCompleted(rmContainer, containerStatus, event, node.getPartition()); node.releaseContainer(container); } // Book-keeping if (removed) { releaseResource(clusterResource, application, container.getResource(), node.getLabels()); LOG.info("completedContainer" + " container=" + container + " queue=" + this + " cluster=" + clusterResource); } } if (removed) { // Inform the parent queue _outside_ of the leaf-queue lock getParent().completedContainer(clusterResource, application, node, rmContainer, null, event, this, sortQueues); } } }
Example 15
Source File: FiCaSchedulerApp.java From hadoop with Apache License 2.0 | 4 votes |
synchronized public boolean containerCompleted(RMContainer rmContainer, ContainerStatus containerStatus, RMContainerEventType event, String partition) { // Remove from the list of containers if (null == liveContainers.remove(rmContainer.getContainerId())) { return false; } // Remove from the list of newly allocated containers if found newlyAllocatedContainers.remove(rmContainer); Container container = rmContainer.getContainer(); ContainerId containerId = container.getId(); // Inform the container rmContainer.handle( new RMContainerFinishedEvent( containerId, containerStatus, event) ); LOG.info("Completed container: " + rmContainer.getContainerId() + " in state: " + rmContainer.getState() + " event:" + event); containersToPreempt.remove(rmContainer.getContainerId()); RMAuditLogger.logSuccess(getUser(), AuditConstants.RELEASE_CONTAINER, "SchedulerApp", getApplicationId(), containerId); // Update usage metrics Resource containerResource = rmContainer.getContainer().getResource(); queue.getMetrics().releaseResources(getUser(), 1, containerResource); attemptResourceUsage.decUsed(partition, containerResource); // Clear resource utilization metrics cache. lastMemoryAggregateAllocationUpdateTime = -1; return true; }
Example 16
Source File: LeafQueue.java From big-c with Apache License 2.0 | 4 votes |
@Override public void completedContainer(Resource clusterResource, FiCaSchedulerApp application, FiCaSchedulerNode node, RMContainer rmContainer, ContainerStatus containerStatus, RMContainerEventType event, CSQueue childQueue, boolean sortQueues) { if (application != null) { boolean removed = false; // Careful! Locking order is important! synchronized (this) { Container container = rmContainer.getContainer(); Resource toRelease = null; // Inform the application & the node // Note: It's safe to assume that all state changes to RMContainer // happen under scheduler's lock... // So, this is, in effect, a transaction across application & node if (rmContainer.getState() == RMContainerState.RESERVED) { removed = unreserve(application, rmContainer.getReservedPriority(), node, rmContainer); toRelease = container.getResource(); } else { //for container suspend event if (event == RMContainerEventType.SUSPEND){ removed = application.containerSuspend(rmContainer, containerStatus, event); //suspend and resume in fifo order if(!suspendedApps.contains(application.getApplicationAttemptId())){ LOG.info(application.getApplicationAttemptId()+"into suspending list"); suspendedApps.add(application.getApplicationAttemptId()); } //we suspend the container on this node node.suspendContainer(container,rmContainer.getLastPreemptedResource()); toRelease = rmContainer.getLastPreemptedResource(); }else{ toRelease = rmContainer.getCurrentUsedResource(); removed = application.containerCompleted(rmContainer, containerStatus, event); node.releaseContainer(container,toRelease); //for container suspend event //in case of completing a suspended container } } // Book-keeping if (removed) { //更新资源试用情况 if(event == RMContainerEventType.SUSPEND){ releaseResource(clusterResource, application, toRelease, node.getLabels(),true); }else{ releaseResource(clusterResource, application, toRelease, node.getLabels(),false); } LOG.info("completedContainer" + " container=" + container + " queue=" + this + " cluster=" + clusterResource); } } if (removed) { // Inform the parent queue _outside_ of the leaf-queue lock getParent().completedContainer(clusterResource, application, node, rmContainer, null, event, this, sortQueues); } } }
Example 17
Source File: YarnNodeCapacityManager.java From incubator-myriad with Apache License 2.0 | 4 votes |
private boolean containersNotNull(RMContainer rmContainer) { return (rmContainer != null && rmContainer.getContainer() != null); }
Example 18
Source File: FiCaSchedulerApp.java From big-c with Apache License 2.0 | 4 votes |
synchronized public boolean containerSuspend(RMContainer rmContainer, ContainerStatus containerStatus, RMContainerEventType event){ //we try to find it from live container list LOG.info("app suspend "+rmContainer.getContainerId()); if (!liveContainers.keySet().contains(rmContainer.getContainerId())){ LOG.info("container not found "+rmContainer.getContainerId()); return false; } isSuspending = true; Container container = rmContainer.getContainer(); ContainerId containerId = container.getId(); if(!this.containersSuspended.contains(rmContainer.getContainerId())){ //add to suspended set if this container is first suspended containersSuspended.add(containerId); } // Inform the container rmContainer.handle( new RMContainerFinishedEvent( containerId, containerStatus, event) ); // Update usage metrics,we release resource here,to support increamental suspension Resource toPreempted = rmContainer.getLastPreemptedResource(); queue.getMetrics().releaseResources(getUser(), 1, toPreempted); Resources.subtractFrom(currentConsumption, toPreempted); LOG.info("app suspend container: " + rmContainer.getContainerId() + " in state: " + rmContainer.getState() + " resource:" + toPreempted); // Clear resource utilization metrics cache. lastMemoryAggregateAllocationUpdateTime = -1; return true; }
Example 19
Source File: FiCaSchedulerApp.java From big-c with Apache License 2.0 | 4 votes |
synchronized public boolean containerCompleted(RMContainer rmContainer, ContainerStatus containerStatus, RMContainerEventType event) { // Remove from the list of containers if (null == liveContainers.remove(rmContainer.getContainerId())) { return false; } // Remove from the list of newly allocated containers if found newlyAllocatedContainers.remove(rmContainer); Container container = rmContainer.getContainer(); ContainerId containerId = container.getId(); //we are trying to complete a suspeded container containersSuspended.remove(containerId); // Inform the container rmContainer.handle( new RMContainerFinishedEvent( containerId, containerStatus, event) ); LOG.info("Completed container: " + rmContainer.getContainerId() + " in state: " + rmContainer.getState() + " event:" + event); containersToPreempt.remove(rmContainer.getContainerId()); RMAuditLogger.logSuccess(getUser(), AuditConstants.RELEASE_CONTAINER, "SchedulerApp", getApplicationId(), containerId); Resource containerResource = rmContainer.getCurrentUsedResource(); queue.getMetrics().releaseResources(getUser(), 1, containerResource); Resources.subtractFrom(currentConsumption, containerResource); LOG.info("Completed container: after substract resource is "+containerResource); // Clear resource utilization metrics cache. lastMemoryAggregateAllocationUpdateTime = -1; return true; }
Example 20
Source File: FifoScheduler.java From hadoop with Apache License 2.0 | 4 votes |
@Lock(FifoScheduler.class) @Override protected synchronized void completedContainer(RMContainer rmContainer, ContainerStatus containerStatus, RMContainerEventType event) { if (rmContainer == null) { LOG.info("Null container completed..."); return; } // Get the application for the finished container Container container = rmContainer.getContainer(); FiCaSchedulerApp application = getCurrentAttemptForContainer(container.getId()); ApplicationId appId = container.getId().getApplicationAttemptId().getApplicationId(); // Get the node on which the container was allocated FiCaSchedulerNode node = getNode(container.getNodeId()); if (application == null) { LOG.info("Unknown application: " + appId + " released container " + container.getId() + " on node: " + node + " with event: " + event); return; } // Inform the application application.containerCompleted(rmContainer, containerStatus, event, RMNodeLabelsManager.NO_LABEL); // Inform the node node.releaseContainer(container); // Update total usage Resources.subtractFrom(usedResource, container.getResource()); LOG.info("Application attempt " + application.getApplicationAttemptId() + " released container " + container.getId() + " on node: " + node + " with event: " + event); }