hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vino...@apache.org
Subject svn commit: r1153445 [1/2] - in /hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager: ./ recovery/ rmapp/attempt/ rmcontainer/ rmnode/ scheduler/ scheduler/cap...
Date Wed, 03 Aug 2011 11:46:49 GMT
Author: vinodkv
Date: Wed Aug  3 11:46:46 2011
New Revision: 1153445

URL: http://svn.apache.org/viewvc?rev=1153445&view=rev
Log:
Moving RmContainer into the scheduler.

Added:
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/NodeReport.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerNodeReport.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/event/ContainerExpiredSchedulerEvent.java
Modified:
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ApplicationMasterService.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContext.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContextImpl.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/ZKStore.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttempt.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/ContainerAllocationExpirer.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainerImpl.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNode.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApp.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerNode.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/YarnScheduler.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/event/ContainerFinishedSchedulerEvent.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/event/SchedulerEventType.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/FifoScheduler.java
    hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/NodesPage.java

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ApplicationMasterService.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ApplicationMasterService.java?rev=1153445&r1=1153444&r2=1153445&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ApplicationMasterService.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ApplicationMasterService.java Wed Aug  3 11:46:46 2011
@@ -56,8 +56,7 @@ import org.apache.hadoop.yarn.server.res
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptRegistrationEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptStatusupdateEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptUnregistrationEvent;
-import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerEvent;
-import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerEventType;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler;
 import org.apache.hadoop.yarn.service.AbstractService;
 
@@ -217,26 +216,18 @@ public class ApplicationMasterService ex
       List<Container> release = request.getReleaseList();
 
       // Send new requests to appAttempt.
-      if (!ask.isEmpty()) {        this.rScheduler.allocate(appAttemptId, ask);
-      }
-
-      // Send events to the containers being released.
-      for (Container releasedContainer : release) {
-        this.rmContext.getDispatcher().getEventHandler().handle(
-            new RMContainerEvent(releasedContainer.getId(),
-                RMContainerEventType.RELEASED));
-      }
+      Allocation allocation = 
+          this.rScheduler.allocate(appAttemptId, ask, release);
 
       RMApp app = this.rmContext.getRMApps().get(appAttemptId.getApplicationId());
       RMAppAttempt appAttempt = app.getRMAppAttempt(appAttemptId);
 
       AMResponse response = recordFactory.newRecordInstance(AMResponse.class);
-      response.addAllNewContainers(appAttempt.pullNewlyAllocatedContainers());
+      response.addAllNewContainers(allocation.getContainers());
       response.addAllFinishedContainers(appAttempt
           .pullJustFinishedContainers());
       response.setResponseId(lastResponse.getResponseId() + 1);
-      response.setAvailableResources(rScheduler
-          .getResourceLimit(appAttemptId));
+      response.setAvailableResources(allocation.getResourceLimit());
       responseMap.put(appAttemptId, response);
       allocateResponse.setAMResponse(response);
       return allocateResponse;

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java?rev=1153445&r1=1153444&r2=1153445&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java Wed Aug  3 11:46:46 2011
@@ -354,21 +354,15 @@ public class ClientRMService extends Abs
   }
 
   private NodeReport createNodeReports(RMNode rmNode) {
-    NodeReport report = 
-      recordFactory.newRecordInstance(NodeReport.class);
+    NodeReport report = recordFactory.newRecordInstance(NodeReport.class);
     report.setNodeId(rmNode.getNodeID());
     report.setRackName(rmNode.getRackName());
     report.setCapability(rmNode.getTotalCapability());
     report.setNodeHealthStatus(rmNode.getNodeHealthStatus());
-    List<Container> containers = rmNode.getRunningContainers();
-    int userdResource = 0;
-    for (Container c : containers) {
-      userdResource += c.getResource().getMemory();
-    }
-    Resource usedRsrc = recordFactory.newRecordInstance(Resource.class);
-    usedRsrc.setMemory(userdResource);
-    report.setUsed(usedRsrc);
-    report.setNumContainers(rmNode.getNumContainers());
+    org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNodeReport schedulerNodeReport = scheduler
+        .getNodeReport(rmNode.getNodeID());
+    report.setUsed(schedulerNodeReport.getUsedResources());
+    report.setNumContainers(schedulerNodeReport.getNumContainers());
     return report;
   }
 

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContext.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContext.java?rev=1153445&r1=1153444&r2=1153445&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContext.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContext.java Wed Aug  3 11:46:46 2011
@@ -3,7 +3,6 @@ package org.apache.hadoop.yarn.server.re
 import java.util.concurrent.ConcurrentMap;
 
 import org.apache.hadoop.yarn.api.records.ApplicationId;
-import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.NodeId;
 import org.apache.hadoop.yarn.event.Dispatcher;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.ApplicationsStore;
@@ -11,7 +10,6 @@ import org.apache.hadoop.yarn.server.res
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.AMLivelinessMonitor;
 import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.ContainerAllocationExpirer;
-import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
 import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
 
 public interface RMContext {
@@ -24,8 +22,6 @@ public interface RMContext {
 
   ConcurrentMap<ApplicationId, RMApp> getRMApps();
 
-  ConcurrentMap<ContainerId, RMContainer> getRMContainers();
-
   ConcurrentMap<NodeId, RMNode> getRMNodes();
 
   AMLivelinessMonitor getAMLivelinessMonitor();

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContextImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContextImpl.java?rev=1153445&r1=1153444&r2=1153445&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContextImpl.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContextImpl.java Wed Aug  3 11:46:46 2011
@@ -24,9 +24,6 @@ public class RMContextImpl implements RM
   private final ConcurrentMap<ApplicationId, RMApp> applications
     = new ConcurrentHashMap<ApplicationId, RMApp>();
 
-  private final ConcurrentMap<ContainerId, RMContainer> containers
-    = new ConcurrentHashMap<ContainerId, RMContainer>();
-
   private final ConcurrentMap<NodeId, RMNode> nodes
     = new ConcurrentHashMap<NodeId, RMNode>();
 
@@ -63,11 +60,6 @@ public class RMContextImpl implements RM
   }
 
   @Override
-  public ConcurrentMap<ContainerId, RMContainer> getRMContainers() {
-    return this.containers;
-  }
-
-  @Override
   public ConcurrentMap<NodeId, RMNode> getRMNodes() {
     return this.nodes;
   }

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java?rev=1153445&r1=1153444&r2=1153445&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java Wed Aug  3 11:46:46 2011
@@ -150,10 +150,6 @@ public class ResourceManager extends Com
     this.rmDispatcher.register(RMNodeEventType.class,
         new NodeEventDispatcher(this.rmContext));
 
-    // Register event handler for RMContainer
-    this.rmDispatcher.register(RMContainerEventType.class,
-        new ContainerEventDispatcher(this.rmContext));
-
     //TODO change this to be random
     this.appTokenSecretManager.setMasterKey(ApplicationTokenSecretManager
         .createSecretKey("Dummy".getBytes()));
@@ -294,30 +290,6 @@ public class ResourceManager extends Com
     }
   }
 
-  private static final class ContainerEventDispatcher implements
-      EventHandler<RMContainerEvent> {
-
-    private final RMContext rmContext;
-
-    public ContainerEventDispatcher(RMContext rmContext) {
-      this.rmContext = rmContext;
-    }
-
-    @Override
-    public void handle(RMContainerEvent event) {
-      ContainerId containerId = event.getContainerId();
-      RMContainer container = this.rmContext.getRMContainers().get(containerId);
-      if (container != null) {
-        try {
-          ((EventHandler<RMContainerEvent>) container).handle(event);
-        } catch (Throwable t) {
-          LOG.error("Error in handling event type " + event.getType()
-              + " for container " + containerId, t);
-        }
-      }
-    }
-  }
-
   protected void startWepApp() {
     webApp = WebApps.$for("yarn", masterService).at(
         conf.get(YarnConfiguration.RM_WEBAPP_BIND_ADDRESS,

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/ZKStore.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/ZKStore.java?rev=1153445&r1=1153444&r2=1153445&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/ZKStore.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/ZKStore.java Wed Aug  3 11:46:46 2011
@@ -114,7 +114,8 @@ public class ZKStore implements Store {
     node.setCapability(rmNode.getTotalCapability());
     // TODO: FIXME
 //    node.setUsed(nodeInfo.getUsedResource());
-    node.setNumContainers(rmNode.getNumContainers());
+    // TODO: acm: refactor2 FIXME
+//  node.setNumContainers(rmNode.getNumContainers());
     return (NodeReportPBImpl)node;
   }
 

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttempt.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttempt.java?rev=1153445&r1=1153444&r2=1153445&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttempt.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttempt.java Wed Aug  3 11:46:46 2011
@@ -31,12 +31,8 @@ public interface RMAppAttempt extends Ev
 
   List<Container> pullJustFinishedContainers();
 
-  List<Container> pullNewlyAllocatedContainers();
-
   List<Container> getJustFinishedContainers();
 
-  List<Container> getNewlyAllocatedContainers();
-
   Container getMasterContainer();
 
   ApplicationSubmissionContext getSubmissionContext();

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java?rev=1153445&r1=1153444&r2=1153445&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptImpl.java Wed Aug  3 11:46:46 2011
@@ -79,14 +79,9 @@ public class RMAppAttemptImpl implements
   private final String clientToken;
   private final ApplicationSubmissionContext submissionContext;
 
-  private Map<ContainerId, ContainerId> liveContainers
-    = new HashMap<ContainerId, ContainerId>();
-
   //nodes on while this attempt's containers ran
   private final Set<NodeId> ranNodes = 
     new HashSet<NodeId>();
-  private final List<Container> newlyAllocatedContainers = 
-    new ArrayList<Container>();
   private final List<Container> justFinishedContainers = 
     new ArrayList<Container>();
   private Container masterContainer;
@@ -162,8 +157,7 @@ public class RMAppAttemptImpl implements
       .addTransition(RMAppAttemptState.RUNNING, RMAppAttemptState.RUNNING,
           RMAppAttemptEventType.STATUS_UPDATE, new StatusUpdateTransition())
       .addTransition(RMAppAttemptState.RUNNING, RMAppAttemptState.RUNNING,
-          RMAppAttemptEventType.CONTAINER_ALLOCATED,
-          new NormalContainerAllocatedTransition())
+          RMAppAttemptEventType.CONTAINER_ALLOCATED)
       .addTransition(
           RMAppAttemptState.RUNNING,
           EnumSet.of(RMAppAttemptState.RUNNING, RMAppAttemptState.FAILED),
@@ -333,16 +327,6 @@ public class RMAppAttemptImpl implements
   }
 
   @Override
-  public List<Container> getNewlyAllocatedContainers() {
-    this.readLock.lock();
-    try {
-      return this.newlyAllocatedContainers;
-    } finally {
-      this.readLock.unlock();
-    }
-  }
-
-  @Override
   public List<Container> pullJustFinishedContainers() {
     this.writeLock.lock();
 
@@ -363,27 +347,6 @@ public class RMAppAttemptImpl implements
   }
 
   @Override
-  public List<Container> pullNewlyAllocatedContainers() {
-    this.writeLock.lock();
-
-    try {
-      List<Container> returnList = new ArrayList<Container>(
-          this.newlyAllocatedContainers.size());
-      returnList.addAll(this.newlyAllocatedContainers);
-      for (Container cont : newlyAllocatedContainers) {
-        ranNodes.add(cont.getNodeId());//add to the nodes set when these containers
-        //are pulled by AM
-        eventHandler.handle(
-            new RMContainerEvent(cont.getId(), RMContainerEventType.ACQUIRED));
-      }
-      this.newlyAllocatedContainers.clear();
-      return returnList;
-    } finally {
-      this.writeLock.unlock();
-    }
-  }
-
-  @Override
   public Container getMasterContainer() {
     this.readLock.lock();
 
@@ -461,6 +424,8 @@ public class RMAppAttemptImpl implements
     }
   }
 
+  private static final List<Container> EMPTY_CONTAINER_LIST = 
+      new ArrayList<Container>();
   private static final class ScheduleTransition extends BaseTransition {
     @Override
     public void transition(RMAppAttemptImpl appAttempt,
@@ -479,7 +444,7 @@ public class RMAppAttemptImpl implements
           + appAttempt.applicationAttemptId + " required " + request);
 
       appAttempt.scheduler.allocate(appAttempt.applicationAttemptId,
-          Collections.singletonList(request));
+          Collections.singletonList(request), EMPTY_CONTAINER_LIST);
     }
   }
 
@@ -657,29 +622,6 @@ public class RMAppAttemptImpl implements
       // Tell the launcher to cleanup.
       appAttempt.eventHandler.handle(new AMLauncherEvent(
           AMLauncherEventType.CLEANUP, appAttempt));
-
-      // Kill all the allocated containers.
-      for (ContainerId containerid : appAttempt.liveContainers.keySet()) {
-        appAttempt.eventHandler.handle(new RMContainerEvent(containerid,
-            RMContainerEventType.KILL));
-      }
-    }
-  }
-
-  private static final class NormalContainerAllocatedTransition extends
-      BaseTransition {
-    @Override
-    public void transition(RMAppAttemptImpl appAttempt,
-        RMAppAttemptEvent event) {
-      RMAppAttemptContainerAllocatedEvent allocatedEvent
-          = (RMAppAttemptContainerAllocatedEvent) event;
-
-      // Store the container for pulling
-      Container container = allocatedEvent.getContainer();
-      appAttempt.newlyAllocatedContainers.add(container);
-
-      // Add it to allContainers list.
-      appAttempt.liveContainers.put(container.getId(), container.getId());
     }
   }
 
@@ -745,9 +687,6 @@ public class RMAppAttemptImpl implements
 
       // Normal container.
 
-      // Remove it from allContainers list.
-      appAttempt.liveContainers.remove(container.getId());
-
       // Put it in completedcontainers list
       appAttempt.justFinishedContainers.add(container);
       return RMAppAttemptState.RUNNING;

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/ContainerAllocationExpirer.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/ContainerAllocationExpirer.java?rev=1153445&r1=1153444&r2=1153445&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/ContainerAllocationExpirer.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/ContainerAllocationExpirer.java Wed Aug  3 11:46:46 2011
@@ -20,14 +20,16 @@ package org.apache.hadoop.yarn.server.re
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.SystemClock;
+import org.apache.hadoop.yarn.api.records.Container;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.event.Dispatcher;
 import org.apache.hadoop.yarn.event.EventHandler;
 import org.apache.hadoop.yarn.server.resourcemanager.RMConfig;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.ContainerExpiredSchedulerEvent;
 import org.apache.hadoop.yarn.util.AbstractLivelinessMonitor;
 
 public class ContainerAllocationExpirer extends
-    AbstractLivelinessMonitor<ContainerId> {
+    AbstractLivelinessMonitor<Container> {
 
   private EventHandler dispatcher;
 
@@ -46,7 +48,7 @@ public class ContainerAllocationExpirer 
   }
 
   @Override
-  protected void expire(ContainerId id) {
-    dispatcher.handle(new RMContainerEvent(id, RMContainerEventType.EXPIRE));
+  protected void expire(Container container) {
+    dispatcher.handle(new ContainerExpiredSchedulerEvent(container));
   }
 }
\ No newline at end of file

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainerImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainerImpl.java?rev=1153445&r1=1153444&r2=1153445&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainerImpl.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainerImpl.java Wed Aug  3 11:46:46 2011
@@ -15,7 +15,6 @@ import org.apache.hadoop.yarn.event.Even
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptContainerAllocatedEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptContainerFinishedEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeCleanContainerEvent;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.ContainerFinishedSchedulerEvent;
 import org.apache.hadoop.yarn.state.InvalidStateTransitonException;
 import org.apache.hadoop.yarn.state.SingleArcTransition;
 import org.apache.hadoop.yarn.state.StateMachine;
@@ -91,12 +90,12 @@ public class RMContainerImpl implements 
   private final EventHandler eventHandler;
   private final ContainerAllocationExpirer containerAllocationExpirer;
 
-  public RMContainerImpl(ContainerId containerId,
-      ApplicationAttemptId appAttemptId, NodeId nodeId, Container container,
+  public RMContainerImpl(Container container,
+      ApplicationAttemptId appAttemptId, NodeId nodeId,
       EventHandler handler,
       ContainerAllocationExpirer containerAllocationExpirer) {
     this.stateMachine = stateMachineFactory.make(this);
-    this.containerId = containerId;
+    this.containerId = container.getId();
     this.nodeId = nodeId;
     this.container = container;
     this.appAttemptId = appAttemptId;
@@ -182,7 +181,7 @@ public class RMContainerImpl implements 
     @Override
     public void transition(RMContainerImpl container, RMContainerEvent event) {
       // Register with containerAllocationExpirer.
-      container.containerAllocationExpirer.register(container.containerId);
+      container.containerAllocationExpirer.register(container.getContainer());
     }
   }
 
@@ -191,7 +190,7 @@ public class RMContainerImpl implements 
     @Override
     public void transition(RMContainerImpl container, RMContainerEvent event) {
       // Unregister from containerAllocationExpirer.
-      container.containerAllocationExpirer.unregister(container.containerId);
+      container.containerAllocationExpirer.unregister(container.getContainer());
     }
   }
 
@@ -211,10 +210,6 @@ public class RMContainerImpl implements 
       // Inform AppAttempt
       container.eventHandler.handle(new RMAppAttemptContainerFinishedEvent(
           container.appAttemptId, container.container));
-
-      // Inform Scheduler
-      container.eventHandler.handle(new ContainerFinishedSchedulerEvent(
-          container.container));
     }
   }
 
@@ -224,7 +219,7 @@ public class RMContainerImpl implements 
     public void transition(RMContainerImpl container, RMContainerEvent event) {
 
       // Unregister from containerAllocationExpirer.
-      container.containerAllocationExpirer.unregister(container.containerId);
+      container.containerAllocationExpirer.unregister(container.getContainer());
 
       // Inform AppAttempt, scheduler etc.
       super.transition(container, event);
@@ -237,7 +232,7 @@ public class RMContainerImpl implements 
     public void transition(RMContainerImpl container, RMContainerEvent event) {
 
       // Unregister from containerAllocationExpirer.
-      container.containerAllocationExpirer.unregister(container.containerId);
+      container.containerAllocationExpirer.unregister(container.getContainer());
 
       // Inform node
       container.eventHandler.handle(new RMNodeCleanContainerEvent(

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNode.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNode.java?rev=1153445&r1=1153444&r2=1153445&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNode.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNode.java Wed Aug  3 11:46:46 2011
@@ -99,20 +99,8 @@ public interface RMNode {
    */
   public Node getNode();
   
-  /**
-   * The current number of containers for this node
-   * @return the number of containers
-   */
-  public int getNumContainers();
-
   public RMNodeState getState();
 
-  /**
-   * Get running containers on this node.
-   * @return running containers
-   */
-  public List<Container> getRunningContainers();
-
   public List<ContainerId> pullContainersToCleanUp();
 
   public List<ApplicationId> pullAppsToCleanup();

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java?rev=1153445&r1=1153444&r2=1153445&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java Wed Aug  3 11:46:46 2011
@@ -21,9 +21,7 @@ package org.apache.hadoop.yarn.server.re
 import java.util.ArrayList;
 import java.util.EnumSet;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
-import java.util.TreeMap;
 import java.util.TreeSet;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
@@ -35,9 +33,7 @@ import org.apache.hadoop.classification.
 import org.apache.hadoop.classification.InterfaceStability.Unstable;
 import org.apache.hadoop.net.Node;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
-import org.apache.hadoop.yarn.api.records.Container;
 import org.apache.hadoop.yarn.api.records.ContainerId;
-import org.apache.hadoop.yarn.api.records.ContainerState;
 import org.apache.hadoop.yarn.api.records.NodeHealthStatus;
 import org.apache.hadoop.yarn.api.records.NodeId;
 import org.apache.hadoop.yarn.api.records.Resource;
@@ -46,9 +42,6 @@ import org.apache.hadoop.yarn.factories.
 import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
 import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse;
 import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
-import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerEvent;
-import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerEventType;
-import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerFinishedEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeAddedSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeRemovedSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent;
@@ -88,10 +81,6 @@ public class RMNodeImpl implements RMNod
   private final NodeHealthStatus nodeHealthStatus = recordFactory
       .newRecordInstance(NodeHealthStatus.class);
   
-  /* set of containers that are allocated containers */
-  private final Map<ContainerId, Container> launchedContainers = 
-    new TreeMap<ContainerId, Container>();
-  
   /* set of containers that need to be cleaned */
   private final Set<ContainerId> containersToClean = new TreeSet<ContainerId>(
       new ContainerIdComparator());
@@ -209,30 +198,6 @@ public class RMNodeImpl implements RMNod
   }
   
   @Override
-  public List<Container> getRunningContainers() {
-    this.readLock.lock();
-
-    try {
-      List<Container> containers = new ArrayList<Container>();
-      containers.addAll(this.launchedContainers.values());
-      return containers;
-    } finally {
-      this.readLock.unlock();
-    }
-  }
-
-  @Override
-  public int getNumContainers() {
-    this.readLock.lock();
-
-    try {
-      return this.launchedContainers.size();
-    } finally {
-      this.readLock.unlock();
-    }
-  }
-
-  @Override
   public NodeHealthStatus getNodeHealthStatus() {
     this.readLock.lock();
 
@@ -319,13 +284,6 @@ public class RMNodeImpl implements RMNod
     }
   }
   
-  private void killAllContainers() {
-    for (ContainerId contId : launchedContainers.keySet()) {
-      context.getDispatcher().getEventHandler().handle(
-          new RMContainerEvent(contId, RMContainerEventType.KILL));
-    }
-  }
-
   public static class CleanUpAppTransition
     implements SingleArcTransition<RMNodeImpl, RMNodeEvent> {
 
@@ -352,7 +310,7 @@ public class RMNodeImpl implements RMNod
 
     @Override
     public void transition(RMNodeImpl rmNode, RMNodeEvent event) {
-      rmNode.killAllContainers();
+      // Inform the scheduler
       rmNode.context.getDispatcher().getEventHandler().handle(
           new NodeRemovedSchedulerEvent(rmNode));
 
@@ -374,39 +332,12 @@ public class RMNodeImpl implements RMNod
       rmNode.latestHeartBeatResponse = statusEvent.getLatestResponse();
 
       if (!statusEvent.getNodeHealthStatus().getIsNodeHealthy()) {
-        rmNode.killAllContainers();
+        // Inform the scheduler
         rmNode.context.getDispatcher().getEventHandler().handle(
             new NodeRemovedSchedulerEvent(rmNode));
         return RMNodeState.UNHEALTHY;
       }
 
-      Map<ApplicationId, List<Container>> remoteAppContainersMap = statusEvent
-          .getContainersCollection();
-      for (List<Container> remoteContainerList : remoteAppContainersMap
-          .values()) {
-        for (Container remoteContainer : remoteContainerList) {
-
-          // Process running containers
-          ContainerId containerId = remoteContainer.getId();
-          if (remoteContainer.getState() == ContainerState.RUNNING
-              || remoteContainer.getState() == ContainerState.INITIALIZING) {
-            if (!rmNode.launchedContainers.containsKey(containerId)) {
-              // Just launched container. RM knows about it the first time.
-              rmNode.launchedContainers.put(containerId, remoteContainer);
-              rmNode.context.getDispatcher().getEventHandler().handle(
-                  new RMContainerEvent(containerId,
-                      RMContainerEventType.LAUNCHED));
-            }
-          } else {
-            // A finished container
-            // Send event to the finished container
-            rmNode.context.getDispatcher().getEventHandler().handle(
-                new RMContainerFinishedEvent(containerId, remoteContainer
-                    .getContainerStatus()));
-          }
-        }
-      }
-
       rmNode.context.getDispatcher().getEventHandler().handle(
           new NodeUpdateSchedulerEvent(rmNode, statusEvent
               .getContainersCollection()));

Added: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/NodeReport.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/NodeReport.java?rev=1153445&view=auto
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/NodeReport.java (added)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/NodeReport.java Wed Aug  3 11:46:46 2011
@@ -0,0 +1,28 @@
+package org.apache.hadoop.yarn.server.resourcemanager.scheduler;
+
+import org.apache.hadoop.classification.InterfaceAudience.Private;
+import org.apache.hadoop.classification.InterfaceStability.Stable;
+import org.apache.hadoop.yarn.api.records.Resource;
+
+/**
+ * Node usage report.
+ */
+@Private
+@Stable
+public class NodeReport {
+  private final Resource usedResources;
+  private final int numContainers;
+  
+  public NodeReport(Resource used, int numContainers) {
+    this.usedResources = used;
+    this.numContainers = numContainers;
+  }
+
+  public Resource getUsedResources() {
+    return usedResources;
+  }
+
+  public int getNumContainers() {
+    return numContainers;
+  }
+}

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApp.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApp.java?rev=1153445&r1=1153444&r2=1153445&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApp.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApp.java Wed Aug  3 11:46:46 2011
@@ -1,6 +1,8 @@
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -9,6 +11,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.Container;
+import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.Priority;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.api.records.ResourceRequest;
@@ -16,6 +19,10 @@ import org.apache.hadoop.yarn.factories.
 import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
 import org.apache.hadoop.yarn.server.resourcemanager.resource.Resources;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState;
+import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
+import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerEvent;
+import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerEventType;
+import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerFinishedEvent;
 
 public class SchedulerApp {
 
@@ -32,6 +39,11 @@ public class SchedulerApp {
   private Resource resourceLimit = recordFactory
       .newRecordInstance(Resource.class);
 
+  private Map<ContainerId, RMContainer> liveContainers
+  = new HashMap<ContainerId, RMContainer>();
+  private List<Container> newlyAllocatedContainers = 
+      new ArrayList<Container>();
+
   public SchedulerApp(AppSchedulingInfo application, Queue queue) {
     this.appSchedulingInfo = application;
     this.queue = queue;
@@ -62,10 +74,15 @@ public class SchedulerApp {
     return this.appSchedulingInfo.getNewContainerId();
   }
   
+  @Deprecated
   public List<Container> getCurrentContainers() {
     return this.appSchedulingInfo.getCurrentContainers();
   }
 
+  public synchronized Collection<RMContainer> getLiveContainers() {
+    return liveContainers.values();
+  }
+  
   public Collection<Priority> getPriorities() {
     return this.appSchedulingInfo.getPriorities();
   }
@@ -90,30 +107,85 @@ public class SchedulerApp {
     return this.queue;
   }
 
-  public void stop(RMAppAttemptState rmAppAttemptFinalState) {
+  public synchronized void stop(RMAppAttemptState rmAppAttemptFinalState) {
+    // Kill all 'live' containers
+    for (RMContainer container : getLiveContainers()) {
+      completedContainer(container.getContainer(), 
+          RMContainerEventType.KILL); 
+    }
+    
+    // Cleanup all scheduling information
     this.appSchedulingInfo.stop(rmAppAttemptFinalState);
   }
 
-  synchronized public void completedContainer(Container container, 
-      Resource containerResource) {
-    if (container != null) {
-      LOG.info("Completed container: " + container);
+  synchronized public void launchContainer(ContainerId containerId) {
+    // Inform the container
+    RMContainer rmContainer = 
+        getRMContainer(containerId);
+    rmContainer.handle(
+        new RMContainerEvent(containerId, 
+            RMContainerEventType.LAUNCHED));
+  }
+
+  public synchronized void killContainers(
+      SchedulerApp application) {
+  }
+
+  synchronized public void completedContainer(Container cont,
+      RMContainerEventType event) {
+    ContainerId containerId = cont.getId();
+    // Inform the container
+    RMContainer container = getRMContainer(containerId);
+    if (event.equals(RMContainerEventType.FINISHED)) {
+      // Have to send diagnostics for finished containers.
+      container.handle(new RMContainerFinishedEvent(containerId,
+          cont.getContainerStatus()));
+    } else {
+      container.handle(new RMContainerEvent(containerId, event));
     }
-    queue.getMetrics().releaseResources(getUser(), 1,
-        containerResource);
+    LOG.info("Completed container: " + container + 
+        " in state: " + container.getState());
+    
+    // Remove from the list of containers
+    liveContainers.remove(container.getContainer());
+    
+    // Update usage metrics 
+    Resource containerResource = container.getContainer().getResource();
+    queue.getMetrics().releaseResources(getUser(), 1, containerResource);
     Resources.subtractFrom(currentConsumption, containerResource);
   }
 
   synchronized public void allocate(NodeType type, SchedulerNode node,
-      Priority priority, ResourceRequest request, List<Container> containers) {
+      Priority priority, ResourceRequest request, 
+      List<RMContainer> containers) {
     // Update consumption and track allocations
-    for (Container container : containers) {
-      Resources.addTo(currentConsumption, container.getResource());
-      LOG.debug("allocate: applicationId=" + container.getId().getAppId()
-          + " container=" + container.getId() + " host="
-          + container.getNodeId().toString());
+    List<Container> allocatedContainers = 
+        new ArrayList<Container>();
+    for (RMContainer container : containers) {
+      Container c = container.getContainer();
+      // Inform the container
+      container.handle(
+          new RMContainerEvent(c.getId(), RMContainerEventType.START));
+      allocatedContainers.add(c);
+      
+      Resources.addTo(currentConsumption, c.getResource());
+      LOG.debug("allocate: applicationId=" + c.getId().getAppId()
+          + " container=" + c.getId() + " host="
+          + c.getNodeId().toString());
+      
+      // Add it to allContainers list.
+      newlyAllocatedContainers.add(c);
+      liveContainers.put(c.getId(), container);
     }
-    appSchedulingInfo.allocate(type, node, priority, request, containers);
+    
+    appSchedulingInfo.allocate(type, node, priority, 
+        request, allocatedContainers);
+  }
+  
+  synchronized public List<Container> pullNewlyAllocatedContainers() {
+    List<Container> allocatedContainers = newlyAllocatedContainers;
+    newlyAllocatedContainers = new ArrayList<Container>();
+    return allocatedContainers;
   }
 
   public Resource getCurrentConsumption() {
@@ -155,4 +227,8 @@ public class SchedulerApp {
     
     return limit;
   }
+
+  public synchronized RMContainer getRMContainer(ContainerId id) {
+    return liveContainers.get(id);
+  }
 }

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerNode.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerNode.java?rev=1153445&r1=1153444&r2=1153445&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerNode.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerNode.java Wed Aug  3 11:46:46 2011
@@ -1,6 +1,7 @@
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
@@ -31,9 +32,9 @@ public class SchedulerNode {
   private volatile int numContainers;
 
   /* set of containers that are allocated containers */
-  private final Map<ContainerId, Container> runningContainers = 
+  private final Map<ContainerId, Container> launchedContainers = 
     new TreeMap<ContainerId, Container>();
-
+  
   private final RMNode rmNode;
 
   public static final String ANY = "*";
@@ -71,70 +72,11 @@ public class SchedulerNode {
    * @param containers allocated containers
    */
   public synchronized void allocateContainer(ApplicationId applicationId, 
-      List<Container> containers) {
-    if (containers == null) {
-      LOG.error("Adding null containers for application " + applicationId);
-      return;
-    }   
-    for (Container container : containers) {
-      allocateContainer(container);
-    }
-
-    LOG.info("addContainers:" +
-        " node=" + rmNode.getNodeAddress() + 
-        " #containers=" + containers.size() + 
-        " available=" + getAvailableResource().getMemory() + 
-        " used=" + getUsedResource().getMemory());
-  }
-
-  /**
-   * Status update from the NodeManager
-   * @param nodeStatus node status
-   * @return the set of containers no longer should be used by the
-   * node manager.
-   */
-  public synchronized void 
-    statusUpdate(Map<String,List<Container>> allContainers) {
-
-    if (allContainers == null) {
-      return;
-    }
-       
-    List<Container> listContainers = new ArrayList<Container>();
-    // Iterate through the running containers and update their status
-    for (Map.Entry<String, List<Container>> e : 
-      allContainers.entrySet()) {
-      listContainers.addAll(e.getValue());
-    }
-    update(listContainers);
-  }
-  
-  /**
-   * Status update for an application running on a given node
-   * @param node node
-   * @param containers containers update.
-   * @return containers that are completed or need to be preempted.
-   */
-  private synchronized void update(List<Container> containers) {
-    
-    for (Container container : containers) {
-    
-      if (container.getState() == ContainerState.COMPLETE) {
-        if (runningContainers.remove(container.getId()) != null) {
-          updateResource(container);
-          LOG.info("Completed container " + container);
-        }
-        LOG.info("Removed completed container " + container.getId() + " on node " + 
-            rmNode.getNodeAddress());
-      }
-    }
-  }
-  
-  private synchronized void allocateContainer(Container container) {
+      Container container) {
     deductAvailableResource(container.getResource());
     ++numContainers;
     
-    runningContainers.put(container.getId(), container);
+    launchedContainers.put(container.getId(), container);
     LOG.info("Allocated container " + container.getId() + 
         " to node " + rmNode.getNodeAddress());
     
@@ -154,7 +96,7 @@ public class SchedulerNode {
   }
 
   private synchronized boolean isValidContainer(Container c) {    
-    if (runningContainers.containsKey(c.getId()))
+    if (launchedContainers.containsKey(c.getId()))
       return true;
     return false;
   }
@@ -178,7 +120,7 @@ public class SchedulerNode {
     
     /* remove the containers from the nodemanger */
     
-    runningContainers.remove(container.getId());
+    launchedContainers.remove(container.getId());
     updateResource(container);
 
     LOG.info("Released container " + container.getId() + 
@@ -211,8 +153,16 @@ public class SchedulerNode {
 
   @Override
   public String toString() {
-    return "host: " + rmNode.getNodeAddress() + " #containers=" + rmNode.getNumContainers() +  
+    return "host: " + rmNode.getNodeAddress() + " #containers=" + getNumContainers() +  
       " available=" + getAvailableResource().getMemory() + 
       " used=" + getUsedResource().getMemory();
   }
+
+  public int getNumContainers() {
+    return numContainers;
+  }
+
+  public synchronized List<Container> getRunningContainers() {
+    return new ArrayList<Container>(launchedContainers.values());
+  }
 }

Added: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerNodeReport.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerNodeReport.java?rev=1153445&view=auto
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerNodeReport.java (added)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerNodeReport.java Wed Aug  3 11:46:46 2011
@@ -0,0 +1,28 @@
+package org.apache.hadoop.yarn.server.resourcemanager.scheduler;
+
+import org.apache.hadoop.classification.InterfaceAudience.Private;
+import org.apache.hadoop.classification.InterfaceStability.Stable;
+import org.apache.hadoop.yarn.api.records.Resource;
+
+/**
+ * Node usage report.
+ */
+@Private
+@Stable
+public class SchedulerNodeReport {
+  private final Resource usedResources;
+  private final int numContainers;
+  
+  public SchedulerNodeReport(Resource used, int numContainers) {
+    this.usedResources = used;
+    this.numContainers = numContainers;
+  }
+
+  public Resource getUsedResources() {
+    return usedResources;
+  }
+
+  public int getNumContainers() {
+    return numContainers;
+  }
+}

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/YarnScheduler.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/YarnScheduler.java?rev=1153445&r1=1153444&r2=1153445&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/YarnScheduler.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/YarnScheduler.java Wed Aug  3 11:46:46 2011
@@ -21,7 +21,11 @@ package org.apache.hadoop.yarn.server.re
 import java.io.IOException;
 import java.util.List;
 
+import org.apache.hadoop.classification.InterfaceAudience.Private;
+import org.apache.hadoop.classification.InterfaceAudience.Public;
+import org.apache.hadoop.classification.InterfaceStability.Stable;
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.Container;
 import org.apache.hadoop.yarn.api.records.NodeId;
 import org.apache.hadoop.yarn.api.records.QueueInfo;
 import org.apache.hadoop.yarn.api.records.QueueUserACLInfo;
@@ -45,6 +49,8 @@ public interface YarnScheduler extends E
    * @return queue information
    * @throws IOException
    */
+  @Public
+  @Stable
   public QueueInfo getQueueInfo(String queueName, boolean includeChildQueues,
       boolean recursive) throws IOException;
 
@@ -53,26 +59,68 @@ public interface YarnScheduler extends E
    * @return acls for queues for current user
    * @throws IOException
    */
+  @Public
+  @Stable
   public List<QueueUserACLInfo> getQueueUserAclInfo();
   
   /**
    * Get minimum allocatable {@link Resource}.
    * @return minimum allocatable resource
    */
+  @Public
+  @Stable
   public Resource getMinimumResourceCapability();
   
   /**
    * Get maximum allocatable {@link Resource}.
    * @return maximum allocatable resource
    */
+  @Public
+  @Stable
   public Resource getMaximumResourceCapability();
 
-  public Resource getResourceLimit(ApplicationAttemptId appAttemptId);
-
-  void allocate(ApplicationAttemptId appAttemptId, List<ResourceRequest> ask);
+  /**
+   * The main api between the ApplicationMaster and the Scheduler.
+   * The ApplicationMaster is updating his future resource requirements
+   * and may release containers he doens't need.
+   * 
+   * @param appAttemptId
+   * @param ask
+   * @param release
+   * @return the {@link Allocation} for the application
+   */
+  @Public
+  @Stable
+  Allocation 
+  allocate(ApplicationAttemptId appAttemptId, 
+      List<ResourceRequest> ask,
+      List<Container> release);
 
+  /**
+   * Get node resource usage report.
+   * @param nodeId
+   * @return the {@link SchedulerNodeReport} for the node
+   */
+  @Private
+  @Stable
+  public SchedulerNodeReport getNodeReport(NodeId nodeId);
+  
+  /**
+   * Get used resources on the node
+   * @param nodeId node
+   * @return used resources on the node
+   */
+  @Private
+  @Stable
   Resource getUsedResource(NodeId nodeId);
 
+  /**
+   * Get available resources on the node
+   * @param nodeId node
+   * @return available resources on the node
+   */
+  @Private
+  @Stable
   Resource getAvailableResource(NodeId nodeId);
-
+  
 }

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java?rev=1153445&r1=1153444&r2=1153445&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java Wed Aug  3 11:46:46 2011
@@ -52,27 +52,25 @@ import org.apache.hadoop.yarn.api.record
 import org.apache.hadoop.yarn.api.records.ResourceRequest;
 import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
 import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
-import org.apache.hadoop.yarn.server.resourcemanager.recovery.Store.ApplicationInfo;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.Store.RMState;
 import org.apache.hadoop.yarn.server.resourcemanager.resource.Resources;
-import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppRejectedEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptEventType;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptRejectedEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.AppSchedulingInfo;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNodeReport;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAddedSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppRemovedSchedulerEvent;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.ContainerFinishedSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeAddedSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeRemovedSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.SchedulerEvent;
 import org.apache.hadoop.yarn.server.security.ContainerTokenSecretManager;
-import org.apache.hadoop.yarn.util.BuilderUtils;
 
 @LimitedPrivate("yarn")
 @Evolving
@@ -380,36 +378,46 @@ implements ResourceScheduler, CapacitySc
     applications.remove(applicationAttemptId);
   }
 
+  private static final Allocation EMPTY_ALLOCATION = 
+      new Allocation(EMPTY_CONTAINER_LIST, Resources.createResource(0));
+
   @Override
   @Lock(Lock.NoLock.class)
-  public void allocate(ApplicationAttemptId applicationAttemptId,
-      List<ResourceRequest> ask) {
+  public Allocation allocate(ApplicationAttemptId applicationAttemptId,
+      List<ResourceRequest> ask, List<Container> release) {
 
     CSApp application = getApplication(applicationAttemptId);
     if (application == null) {
       LOG.info("Calling allocate on removed " +
           "or non existant application " + applicationAttemptId);
-      return;
+      return EMPTY_ALLOCATION;
     }
     
     // Sanity check
     normalizeRequests(ask);
 
-    LOG.info("DEBUG --- allocate: pre-update" +
-        " applicationId=" + applicationAttemptId + 
-        " application=" + application);
-    application.showRequests();
-
-    // Update application requests
-    application.updateResourceRequests(ask);
-
-    LOG.info("DEBUG --- allocate: post-update");
-    application.showRequests();
-    
-    LOG.info("DEBUG --- allocate:" +
-        " applicationId=" + applicationAttemptId + 
-        " #ask=" + ask.size());
-   }
+    synchronized (application) {
+
+      LOG.info("DEBUG --- allocate: pre-update" +
+          " applicationId=" + applicationAttemptId + 
+          " application=" + application);
+      application.showRequests();
+
+      // Update application requests
+      application.updateResourceRequests(ask);
+
+      LOG.info("DEBUG --- allocate: post-update");
+      application.showRequests();
+
+      LOG.info("DEBUG --- allocate:" +
+          " applicationId=" + applicationAttemptId + 
+          " #ask=" + ask.size());
+      
+      return new Allocation(
+          application.pullNewlyAllocatedContainers(), 
+          application.getHeadroom());
+    }
+  }
 
   @Override
   @Lock(Lock.NoLock.class)
@@ -480,7 +488,7 @@ implements ResourceScheduler, CapacitySc
       Map<String,List<Container>> containers ) {
     LOG.info("nodeUpdate: " + nm + " clusterResources: " + clusterResource);
     SchedulerNode node = this.csNodes.get(nm.getNodeID());
-    node.statusUpdate(containers);
+    //TODO node.statusUpdate(containers);
 
     // Completed containers
     processCompletedContainers(getCompletedContainers(containers));
@@ -594,11 +602,6 @@ implements ResourceScheduler, CapacitySc
   }
 
   @Override
-  public Resource getResourceLimit(ApplicationAttemptId applicationAttemptId) {
-    return applications.get(applicationAttemptId).getHeadroom();
-  }
-
-  @Override
   public synchronized void handle(SchedulerEvent event) {
     switch(event.getType()) {
     case NODE_ADDED:
@@ -628,13 +631,6 @@ implements ResourceScheduler, CapacitySc
       doneApplication(appRemovedEvent.getApplicationAttemptID(),
           appRemovedEvent.getFinalAttemptState());
       break;
-    case CONTAINER_FINISHED:
-      ContainerFinishedSchedulerEvent containerFinishedEvent = (ContainerFinishedSchedulerEvent) event;
-      Container container = containerFinishedEvent.getContainer();
-      this.rmContext.getRMContainers().remove(container.getId());
-      processSingleCompletedContainer(container);
-      releaseContainer(container.getId().getAppId(), container);
-      break;
     default:
       LOG.error("Invalid eventtype " + event.getType() + ". Ignoring!");
     }
@@ -654,7 +650,7 @@ implements ResourceScheduler, CapacitySc
     --numNodeManagers;
 
     // Remove running containers
-    List<Container> runningContainers = nodeInfo.getRunningContainers();
+    List<Container> runningContainers = null;//TODO = nodeInfo.getRunningContainers();
     killRunningContainers(runningContainers);
     
     // Remove reservations, if any
@@ -693,4 +689,10 @@ implements ResourceScheduler, CapacitySc
 //      }
 //    }
   }
+
+  @Override
+  public SchedulerNodeReport getNodeReport(NodeId nodeId) {
+    // TODO Auto-generated method stub
+    return null;
+  }
 }

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java?rev=1153445&r1=1153444&r2=1153445&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java Wed Aug  3 11:46:46 2011
@@ -919,28 +919,31 @@ public class LeafQueue implements Queue 
       Priority priority, ResourceRequest request, 
       CSNode node, List<Container> containers) {
     // Allocate container to the application
-    application.allocate(type, node, priority, request, containers);
+    // TODO: acm: refactor2 FIXME
+    application.allocate(type, node, priority, request, null);
 
     for (Container container : containers) {
       // Create the container and 'start' it.
       ContainerId containerId = container.getId();
       RMContext rmContext = this.scheduler.getRMContext();
       EventHandler eventHandler = rmContext.getDispatcher().getEventHandler();
-      RMContainer rmContainer = new RMContainerImpl(containerId, application
-          .getApplicationAttemptId(), node.getNodeID(), container,
+      RMContainer rmContainer = new RMContainerImpl(container, application
+          .getApplicationAttemptId(), node.getNodeID(),
           eventHandler, rmContext.getContainerAllocationExpirer());
-      if (rmContext.getRMContainers().putIfAbsent(containerId, rmContainer) != null) {
-        LOG.error("Duplicate container addition! ContainerID :  "
-            + containerId);
-      } else {
-        eventHandler.handle(new RMContainerEvent(containerId,
-            RMContainerEventType.START));
-      }
+      // TODO: FIX
+//      if (rmContext.getRMContainers().putIfAbsent(containerId, rmContainer) != null) {
+//        LOG.error("Duplicate container addition! ContainerID :  "
+//            + containerId);
+//      } else {
+//        eventHandler.handle(new RMContainerEvent(containerId,
+//            RMContainerEventType.START));
+//      }
     }
 
     // Inform the NodeManager about the allocation
-    node.allocateContainer(application.getApplicationId(),
-        containers);
+    // TODO: acm: refactor2 FIXME
+//    node.allocateContainer(application.getApplicationId(),
+//        containers);
   }
 
   private void reserve(CSApp application, Priority priority, 
@@ -968,7 +971,8 @@ public class LeafQueue implements Queue 
         
         // Inform the application - this might be an allocated container or
         // an unfulfilled reservation
-        application.completedContainer(container, containerResource);
+        // TODO: acm: refactor2 FIXME
+        //application.completedContainer(container, containerResource);
         
         // Book-keeping
         releaseResource(clusterResource, 

Added: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/event/ContainerExpiredSchedulerEvent.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/event/ContainerExpiredSchedulerEvent.java?rev=1153445&view=auto
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/event/ContainerExpiredSchedulerEvent.java (added)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/event/ContainerExpiredSchedulerEvent.java Wed Aug  3 11:46:46 2011
@@ -0,0 +1,24 @@
+package org.apache.hadoop.yarn.server.resourcemanager.scheduler.event;
+
+import org.apache.hadoop.yarn.api.records.Container;
+import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.ContainerAllocationExpirer;
+
+/**
+ * The {@link SchedulerEvent} which notifies that a {@link Container}
+ * has expired, sent by {@link ContainerAllocationExpirer} 
+ *
+ */
+public class ContainerExpiredSchedulerEvent extends SchedulerEvent {
+
+  private final Container container;
+  
+  public ContainerExpiredSchedulerEvent(Container container) {
+    super(SchedulerEventType.CONTAINER_EXPIRED);
+    this.container = container;
+  }
+
+  public Container getContainer() {
+    return container;
+  }
+
+}

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/event/ContainerFinishedSchedulerEvent.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/event/ContainerFinishedSchedulerEvent.java?rev=1153445&r1=1153444&r2=1153445&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/event/ContainerFinishedSchedulerEvent.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/event/ContainerFinishedSchedulerEvent.java Wed Aug  3 11:46:46 2011
@@ -1,18 +1,25 @@
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.event;
 
 import org.apache.hadoop.yarn.api.records.Container;
+import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerEventType;
 
 public class ContainerFinishedSchedulerEvent extends SchedulerEvent {
 
   private final Container container;
+  private final RMContainerEventType cause;
 
-  public ContainerFinishedSchedulerEvent(Container container) {
+  public ContainerFinishedSchedulerEvent(Container container, RMContainerEventType cause) {
     super(SchedulerEventType.CONTAINER_FINISHED);
     this.container = container;
+    this.cause = cause;
   }
 
   public Container getContainer() {
     return container;
   }
 
+  public RMContainerEventType getCause() {
+    return cause;
+  }
+
 }

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/event/SchedulerEventType.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/event/SchedulerEventType.java?rev=1153445&r1=1153444&r2=1153445&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/event/SchedulerEventType.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/event/SchedulerEventType.java Wed Aug  3 11:46:46 2011
@@ -6,12 +6,11 @@ public enum SchedulerEventType {
   NODE_ADDED,
   NODE_REMOVED,
   NODE_UPDATE,
-
-  // Source: Container
-  CONTAINER_FINISHED,
   
   // Source: App
   APP_ADDED,
   APP_REMOVED,
 
+  // Source: ContainerAllocationExpirer
+  CONTAINER_EXPIRED
 }



Mime
View raw message