Java Code Examples for org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp#containerCompleted()

The following examples show how to use org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp#containerCompleted() . 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: FifoScheduler.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@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);
   
}
 
Example 2
Source File: LeafQueue.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@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 3
Source File: FifoScheduler.java    From big-c with Apache License 2.0 4 votes vote down vote up
@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);

  // Inform the node
  node.releaseContainer(container,container.getResource());
  
  // Update total usage
  Resources.subtractFrom(usedResource, container.getResource());

  LOG.info("Application attempt " + application.getApplicationAttemptId() + 
      " released container " + container.getId() +
      " on node: " + node + 
      " with event: " + event);
   
}
 
Example 4
Source File: LeafQueue.java    From big-c with Apache License 2.0 4 votes vote down vote up
@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);
    }
  }
}