Java Code Examples for org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer#getState()

The following examples show how to use org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer#getState() . 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: FairScheduler.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * 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 2
Source File: FairScheduler.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * 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,container.getResource());
    updateRootQueueMetrics();
  }

  LOG.info("Application attempt " + application.getApplicationAttemptId()
      + " released container " + container.getId() + " on node: " + node
      + " with event: " + event);
}
 
Example 3
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 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);
    }
  }
}