hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vino...@apache.org
Subject svn commit: r1143250 [3/4] - in /hadoop/common/branches/MR-279/mapreduce: ./ mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/launcher/ mr-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapre...
Date Wed, 06 Jul 2011 04:51:48 GMT
Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/ApplicationsManagerImpl.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/applicationsmanager/ApplicationsManagerImpl.java?rev=1143250&r1=1143249&r2=1143250&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/ApplicationsManagerImpl.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/ApplicationsManagerImpl.java Wed Jul  6 04:51:46 2011
@@ -19,38 +19,26 @@
 package org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager;
 
 import java.io.IOException;
-import java.security.AccessControlException;
-import java.util.ArrayList;
-import java.util.List;
 import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.hadoop.security.authorize.AccessControlList;
-import org.apache.hadoop.security.token.Token;
-import org.apache.hadoop.yarn.api.records.Application;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationMaster;
-import org.apache.hadoop.yarn.api.records.ApplicationStatus;
-import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
-import org.apache.hadoop.yarn.api.records.Container;
 import org.apache.hadoop.yarn.event.EventHandler;
 import org.apache.hadoop.yarn.factories.RecordFactory;
 import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
-import org.apache.hadoop.yarn.ipc.RPCUtil;
-import org.apache.hadoop.yarn.security.ApplicationTokenIdentifier;
 import org.apache.hadoop.yarn.security.ApplicationTokenSecretManager;
 import org.apache.hadoop.yarn.security.client.ClientToAMSecretManager;
-import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
+import org.apache.hadoop.yarn.server.resourcemanager.ApplicationsManager;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager.RMContext;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.application.ApplicationACL;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.application.ApplicationACLsManager;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.AMLauncherEventType;
 import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ASMEvent;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationMasterEvents.AMLauncherEventType;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationMasterEvents.SNEventType;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationEvent;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationEventType;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.SNEventType;
+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.scheduler.YarnScheduler;
 import org.apache.hadoop.yarn.service.CompositeService;
@@ -66,19 +54,16 @@ import org.apache.hadoop.yarn.service.Se
  * AM's use to talk to the ASM via the RPC.
  */
 public class ApplicationsManagerImpl extends CompositeService
-  implements ApplicationsManager, ApplicationMasterHandler  {
+  implements ApplicationsManager  {
   private static final Log LOG = LogFactory.getLog(ApplicationsManagerImpl.class);
 
-  final private AtomicInteger applicationCounter = new AtomicInteger(0);
   final private YarnScheduler scheduler;
-  private AMTracker amTracker;
   private ClientToAMSecretManager clientToAMSecretManager =
     new ClientToAMSecretManager();
   private final EventHandler eventHandler;
   private final ApplicationTokenSecretManager applicationTokenSecretManager;
+  private AMLivelinessMonitor amLivelinessMonitor;
   private final RMContext rmContext; 
-  private  ApplicationACLsManager aclsManager;
-  private Map<ApplicationACL, AccessControlList> applicationACLs;
   private final RecordFactory recordFactory = 
     RecordFactoryProvider.getRecordFactory(null);
   
@@ -89,15 +74,17 @@ public class ApplicationsManagerImpl ext
     this.rmContext = rmContext;
     this.eventHandler = this.rmContext.getDispatcher().getEventHandler();
     this.applicationTokenSecretManager = applicationTokenSecretManager;
+    this.amLivelinessMonitor = new AMLivelinessMonitor(this.eventHandler);
    }
-  
 
-  /**
-   * create a new am heart beat handler.
-   * @return create a new am heart beat handler.
-   */
-  protected AMTracker createNewAMTracker() {
-    return new AMTracker(this.rmContext);
+  @Override
+  public AMLivelinessMonitor getAmLivelinessMonitor() {
+    return this.amLivelinessMonitor;
+  }
+
+  @Override
+  public ClientToAMSecretManager getClientToAMSecretManager() {
+    return this.clientToAMSecretManager;
   }
 
   /**
@@ -135,10 +122,7 @@ public class ApplicationsManagerImpl ext
   public  void init(Configuration conf) {
     addIfService(createNewApplicationMasterLauncher(applicationTokenSecretManager));
     addIfService(createNewSchedulerNegotiator(scheduler));
-    this.amTracker = createNewAMTracker();
-    addIfService(amTracker);
-    this.aclsManager = new ApplicationACLsManager(conf);
-    this.applicationACLs = aclsManager.constructApplicationACLs(conf);
+    addService(this.amLivelinessMonitor);
     super.init(conf);
   }
 
@@ -147,167 +131,51 @@ public class ApplicationsManagerImpl ext
     super.start();
   }
 
-  @Override
-  public ApplicationMaster getApplicationMaster(ApplicationId applicationId) {
-    ApplicationMaster appMaster =
-      amTracker.get(applicationId).getMaster();
-    //TODO NPE (When the RM is restarted - it doesn't know about previous AMs)
-    return appMaster;
-  }
-  
-  @Override
-  public ApplicationId getNewApplicationID() {
-    ApplicationId applicationId =
-      org.apache.hadoop.yarn.util.BuilderUtils.newApplicationId(recordFactory,
-          ResourceManager.clusterTimeStamp, applicationCounter.incrementAndGet());
-    LOG.info("Allocated new applicationId: " + applicationId.getId());
-    return applicationId;
-  }
-
-  @Override
-  public  void submitApplication(ApplicationSubmissionContext context)
-  throws IOException {
-    String user;
-    ApplicationId applicationId = context.getApplicationId();
-    String clientTokenStr = null;
-    try {
-      user = UserGroupInformation.getCurrentUser().getShortUserName();
-      if (UserGroupInformation.isSecurityEnabled()) {
-        Token<ApplicationTokenIdentifier> clientToken =
-          new Token<ApplicationTokenIdentifier>(
-              new ApplicationTokenIdentifier(applicationId),
-              this.clientToAMSecretManager);
-        clientTokenStr = clientToken.encodeToUrlString();
-        LOG.debug("Sending client token as " + clientTokenStr);
-      }
-    } catch (IOException e) {
-      LOG.info("Error in submitting application", e);
-      throw e;
-    } 
-
-    context.setQueue(context.getQueue() == null ? "default" : context.getQueue());
-    context.setApplicationName(context.getApplicationName() == null ? "N/A" : context.getApplicationName());
-    amTracker.addMaster(user, context, clientTokenStr);
-    ApplicationMasterInfo masterInfo = amTracker.get(applicationId);
-    /** this can throw so we need to call it synchronously to let the client
-     * know as soon as it submits. For backwards compatibility we cannot make 
-     * it asynchronous
-     */
-    try {
-      scheduler.addApplication(applicationId, masterInfo.getMaster(), user, masterInfo.getQueue(),
-          context.getPriority(), masterInfo.getStore());
-    } catch(IOException io) {
-      LOG.info("Failed to submit application " + applicationId, io);
-      amTracker.finishNonRunnableApplication(applicationId);
-      throw io;
+  /* As of now we dont remove applications from the RM */
+  /* TODO we need to decide on a strategy for expiring done applications */
+  public void remove(ApplicationId applicationId) {
+    synchronized (rmContext.getApplications()) {
+      //applications.remove(applicationId);
+      this.amLivelinessMonitor.unRegister(applicationId);
     }
-    amTracker.runApplication(applicationId);
-    // TODO this should happen via dispatcher. should move it out to scheudler
-    // negotiator.
-    LOG.info("Application with id " + applicationId.getId() + " submitted by user " + 
-        user + " with " + context);
   }
 
   @Override
-  public void finishApplicationMaster(ApplicationMaster applicationMaster)
-  throws IOException {
-    amTracker.finish(applicationMaster);
-  }
+  public void recover(RMState state) {
 
-  /**
-   * check if the calling user has the access to application information.
-   * @param applicationId
-   * @param callerUGI
-   * @param owner
-   * @param appACL
-   * @return
-   */
-  private boolean checkAccess(UserGroupInformation callerUGI, String owner, ApplicationACL appACL) {
-      if (!UserGroupInformation.isSecurityEnabled()) {
-        return true;
+    for (Map.Entry<ApplicationId, ApplicationInfo> entry : state
+        .getStoredApplications().entrySet()) {
+      ApplicationId appId = entry.getKey();
+      ApplicationInfo appInfo = entry.getValue();
+      Application application = null;
+      try {
+        application = new ApplicationImpl(this.rmContext, getConfig(), appInfo
+            .getApplicationSubmissionContext().getUser(), appInfo
+            .getApplicationSubmissionContext(), appInfo
+            .getApplicationMaster().getClientToken(), this.rmContext
+            .getApplicationsStore().createApplicationStore(appId,
+                appInfo.getApplicationSubmissionContext()),
+            this.amLivelinessMonitor);
+      } catch (IOException ie) {
+        // ignore
       }
-      AccessControlList applicationACL = applicationACLs.get(appACL);
-      return aclsManager.checkAccess(callerUGI, appACL, owner, applicationACL);
-  }
-  
-  @Override
-  public synchronized void finishApplication(ApplicationId applicationId,
-      UserGroupInformation callerUGI) 
-  throws IOException {
-    ApplicationMasterInfo masterInfo = amTracker.get(applicationId);
-    if (!checkAccess(callerUGI, masterInfo.getUser(),  ApplicationACL.MODIFY_APP)) {
-      RPCUtil.getRemoteException(new AccessControlException("User "
-          + callerUGI.getShortUserName() + " cannot perform operation "
-          + ApplicationACL.MODIFY_APP.name() + " on " + applicationId));
-    }
-    amTracker.kill(applicationId);
-  }
-
-  @Override
-  public  void applicationHeartbeat(ApplicationStatus status) 
-  throws IOException {
-    amTracker.heartBeat(status);
-  }
-
-  @Override
-  public  void registerApplicationMaster(ApplicationMaster applicationMaster)
-  throws IOException {
-    amTracker.registerMaster(applicationMaster);
- }
-
-  @Override
-  public  List<AppContext> getAllAppContexts() {
-    return amTracker.getAllApplications();
-  }
-
-  public  ApplicationMasterInfo getApplicationMasterInfo(ApplicationId
-      applicationId) {
-    return amTracker.get(applicationId);
-  }
-
-  @Override
-  public AppContext getAppContext(ApplicationId appId) {
-    return getApplicationMasterInfo(appId);
-  }
-  
-  private Application createApplication(AppContext context, String user,
-      String queue, String name, Container masterContainer) {
-    ApplicationMaster am = context.getMaster();
-    Application application = 
-      recordFactory.newRecordInstance(Application.class);
-    application.setApplicationId(am.getApplicationId());
-    application.setMasterContainer(masterContainer);
-    application.setTrackingUrl(am.getTrackingUrl());
-    application.setDiagnostics(am.getDiagnostics());
-    application.setName(name);
-    application.setQueue(queue);
-    application.setState(am.getState());
-    application.setStatus(am.getStatus());
-    application.setUser(user);
-    return application;
-  }
-  
-  @Override
-  public List<Application> getApplications() {
-    List<Application> apps = new ArrayList<Application>();
-    for (AppContext am: getAllAppContexts()) {
-      apps.add(createApplication(am, 
-          am.getUser(), am.getQueue(), am.getName(), am.getMasterContainer()));
+      ApplicationMaster master = application.getMaster();
+      ApplicationMaster storedAppMaster = appInfo.getApplicationMaster();
+      master.setAMFailCount(storedAppMaster.getAMFailCount());
+      master.setApplicationId(storedAppMaster.getApplicationId());
+      master.setClientToken(storedAppMaster.getClientToken());
+      master.setContainerCount(storedAppMaster.getContainerCount());
+      master.setTrackingUrl(storedAppMaster.getTrackingUrl());
+      master.setDiagnostics(storedAppMaster.getDiagnostics());
+      master.setHost(storedAppMaster.getHost());
+      master.setRpcPort(storedAppMaster.getRpcPort());
+      master.setStatus(storedAppMaster.getStatus());
+      master.setState(storedAppMaster.getState());
+      // TODO: Synchro? PutIfAbset?
+      this.rmContext.getApplications().put(appId, application);
+      this.rmContext.getDispatcher().getEventHandler().handle(
+          new ApplicationEvent(ApplicationEventType.RECOVER, appId));
     }
-    return apps;
-  }
 
-  @Override
-  public Application getApplication(ApplicationId appID) {
-    ApplicationMasterInfo master = amTracker.get(appID);
-    return (master == null) ? null : createApplication(master,
-        master.getUser(), master.getQueue(), master.getName(),
-        master.getMasterContainer());
-  }
-
-
-  @Override
-  public void recover(RMState state) {
-    amTracker.recover(state);
   }
 }

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/SchedulerNegotiator.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/applicationsmanager/SchedulerNegotiator.java?rev=1143250&r1=1143249&r2=1143250&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/SchedulerNegotiator.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/SchedulerNegotiator.java Wed Jul  6 04:51:46 2011
@@ -31,21 +31,18 @@ import java.util.Map;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
-import org.apache.hadoop.yarn.api.records.ApplicationMaster;
-import org.apache.hadoop.yarn.api.records.ApplicationStatus;
-import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
 import org.apache.hadoop.yarn.api.records.Container;
 import org.apache.hadoop.yarn.api.records.Priority;
-import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.api.records.ResourceRequest;
 import org.apache.hadoop.yarn.event.EventHandler;
 import org.apache.hadoop.yarn.factories.RecordFactory;
 import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager.RMContext;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.AMAllocatedEvent;
 import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ASMEvent;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationMasterEvents.ApplicationEventType;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationMasterEvents.SNEventType;
-import org.apache.hadoop.yarn.server.resourcemanager.recovery.ApplicationsStore.ApplicationStore;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationEvent;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationEventType;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.SNEventType;
 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;
@@ -54,7 +51,7 @@ import org.apache.hadoop.yarn.service.Ab
  * Negotiates with the scheduler for allocation of application master container.
  *
  */
-class SchedulerNegotiator extends AbstractService implements EventHandler<ASMEvent<SNEventType>> {
+public class SchedulerNegotiator extends AbstractService implements EventHandler<ASMEvent<SNEventType>> {
 
   private static final Log LOG = LogFactory.getLog(SchedulerNegotiator.class);
   private static final RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
@@ -72,8 +69,8 @@ class SchedulerNegotiator extends Abstra
 
   private final SchedulerThread schedulerThread;
   private final YarnScheduler scheduler;
-  private final List<AppContext> pendingApplications = 
-    new ArrayList<AppContext>();
+  private final List<Application> pendingApplications = 
+    new ArrayList<Application>();
 
   @SuppressWarnings("unchecked")
   public SchedulerNegotiator(RMContext context, 
@@ -114,11 +111,10 @@ class SchedulerNegotiator extends Abstra
     
       @Override
     public void run() {
-      List<AppContext> toSubmit = 
-        new ArrayList<AppContext>();
-      List<AppContext> submittedApplications =
-        new ArrayList<AppContext>();
-      Map<ApplicationId, List<Container>> firstAllocate = new HashMap<ApplicationId, List<Container>>();
+      List<Application> toSubmit = new ArrayList<Application>();
+      List<Application> submittedApplications = new ArrayList<Application>();
+      Map<ApplicationId, List<Container>> firstAllocate 
+              = new HashMap<ApplicationId, List<Container>>();
       while (!shutdown && !isInterrupted()) {
         try {
           toSubmit.addAll(getPendingApplications());
@@ -127,7 +123,7 @@ class SchedulerNegotiator extends Abstra
 
             submittedApplications.addAll(toSubmit);
 
-            for (AppContext masterInfo: toSubmit) {
+            for (Application masterInfo: toSubmit) {
               // Register request for the ApplicationMaster container
               ResourceRequest request = 
                 org.apache.hadoop.yarn.server.resourcemanager.resource.ResourceRequest.create(
@@ -150,10 +146,10 @@ class SchedulerNegotiator extends Abstra
 
           List<Container> containers = null;
 
-          for (Iterator<AppContext> it=submittedApplications.iterator(); 
+          for (Iterator<Application> it=submittedApplications.iterator(); 
           it.hasNext();) {
-            AppContext masterInfo = it.next();
-            ApplicationId appId = masterInfo.getMaster().getApplicationId();
+            Application application = it.next();
+            ApplicationId appId = application.getMaster().getApplicationId();
             containers = scheduler.allocate(appId, 
                 EMPTY_ASK, EMPTY_RELEASE).getContainers();
             if (firstAllocate.containsKey(appId)) {
@@ -167,12 +163,13 @@ class SchedulerNegotiator extends Abstra
               Container container = containers.get(0);
               
               LOG.info("Found container " + container + " for AM of "
-                  + masterInfo.getMaster());
-              handler.handle(new ApplicationMasterAllocatedEvent(masterInfo
+                  + application.getMaster());
+              handler.handle(new AMAllocatedEvent(application
                   .getApplicationID(), container));
             }
           }
 
+          // TODO: This can be detrimental. Use wait/notify.
           Thread.sleep(1000);
         } catch(Exception e) {
           LOG.info("Exception in submitting applications ", e);
@@ -189,8 +186,8 @@ class SchedulerNegotiator extends Abstra
     }
   }
 
-  private Collection<? extends AppContext> getPendingApplications() {
-    List<AppContext> pending = new ArrayList<AppContext>();
+  private Collection<? extends Application> getPendingApplications() {
+    List<Application> pending = new ArrayList<Application>();
     synchronized (pendingApplications) {
       pending.addAll(pendingApplications);
       pendingApplications.clear();
@@ -198,52 +195,45 @@ class SchedulerNegotiator extends Abstra
     return pending;
   }
 
-  private void addPending(AppContext masterInfo) {
-    LOG.info("Adding to pending " + masterInfo.getMaster());
+  private void addPending(Application application) {
+    LOG.info("Adding to pending " + application.getApplicationID());
     synchronized(pendingApplications) {
-      pendingApplications.add(masterInfo);
+      pendingApplications.add(application);
     }
   }
 
+  private void finishApplication(Application application)  
+  throws IOException {
+    LOG.info("Finishing application: cleaning up container " +
+        application.getMasterContainer());
+    //TODO we should release the container but looks like we just 
+    // wait for update from NodeManager
+    Container[] containers = new Container[] {application.getMasterContainer()};
+    scheduler.allocate(application.getApplicationID(), 
+        EMPTY_ASK, Arrays.asList(containers));
+  }
+
   @Override
   public void handle(ASMEvent<SNEventType> appEvent)  {
-    SNEventType event = appEvent.getType();
-    AppContext appContext = appEvent.getAppContext();
-    switch (event) {
+    SNEventType eventType = appEvent.getType();
+    Application application = appEvent.getApplication();
+    switch (eventType) {
     case SCHEDULE:
-      addPending(appContext);
+      addPending(application);
       break;
     case RELEASE:
       try {
-      scheduler.allocate(appContext.getApplicationID(), 
-          EMPTY_ASK, Collections.singletonList(appContext.getMasterContainer()));
+        finishApplication(application);
       } catch(IOException ie) {
         //TODO remove IOException from the scheduler.
-        LOG.error("Error while releasing container for AM " + appContext.getApplicationID());
-      }
-      handler.handle(new ApplicationMasterInfoEvent(
-          ApplicationEventType.RELEASED, appContext.getApplicationID()));
-      break;
-    case CLEANUP:
-      try {
-        finishApplication(appContext);
-      } catch (IOException ie) {
-        LOG.info("Error finishing application", ie);
+        LOG.error("Error while releasing container for AM " + application.getApplicationID());
       }
+      handler.handle(new ApplicationEvent(
+          ApplicationEventType.RELEASED, application.getApplicationID()));
       break;
     default:
+      LOG.warn("Unknown event " + eventType + " received. Ignoring.");
       break;
     }
   }
-  
-  private void finishApplication(AppContext masterInfo)  
-  throws IOException {
-    LOG.info("Finishing application: cleaning up container " +
-        masterInfo.getMasterContainer());
-    //TODO we should release the container but looks like we just 
-    // wait for update from NodeManager
-    Container[] containers = new Container[] {masterInfo.getMasterContainer()};
-    scheduler.allocate(masterInfo.getMaster().getApplicationId(), 
-        EMPTY_ASK, Arrays.asList(containers));
-  }  
 }
\ No newline at end of file

Added: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/AMAllocatedEvent.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/applicationsmanager/events/AMAllocatedEvent.java?rev=1143250&view=auto
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/AMAllocatedEvent.java (added)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/AMAllocatedEvent.java Wed Jul  6 04:51:46 2011
@@ -0,0 +1,38 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events;
+
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.Container;
+
+public class AMAllocatedEvent extends
+    ApplicationEvent {
+
+  private final Container masterContainer;
+
+  public AMAllocatedEvent(ApplicationId applicationId,
+      Container masterContainer) {
+    super(ApplicationEventType.ALLOCATED, applicationId);
+    this.masterContainer = masterContainer;
+  }
+
+  public Container getMasterContainer() {
+    return this.masterContainer;
+  }
+}

Added: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/AMFinishEvent.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/applicationsmanager/events/AMFinishEvent.java?rev=1143250&view=auto
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/AMFinishEvent.java (added)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/AMFinishEvent.java Wed Jul  6 04:51:46 2011
@@ -0,0 +1,48 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events;
+
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationState;
+
+public class AMFinishEvent extends ApplicationEvent {
+  private final ApplicationState finalState;
+  private final String trackingUrl;
+  private final String diagnostics;
+
+  public AMFinishEvent(ApplicationId applicationId,
+      ApplicationState finalState, String trackingUrl, String diagnostics) {
+    super(ApplicationEventType.FINISH, applicationId);
+    this.finalState = finalState;
+    this.trackingUrl = trackingUrl;
+    this.diagnostics = diagnostics;
+  }
+
+  public ApplicationState getFinalApplicationState() {
+    return this.finalState;
+  }
+
+  public String getTrackingUrl() {
+    return this.trackingUrl;
+  }
+
+  public String getDiagnostics() {
+    return this.diagnostics;
+  }
+}
\ No newline at end of file

Added: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/AMLauncherEventType.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/applicationsmanager/events/AMLauncherEventType.java?rev=1143250&view=auto
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/AMLauncherEventType.java (added)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/AMLauncherEventType.java Wed Jul  6 04:51:46 2011
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events;
+
+public enum AMLauncherEventType {
+  LAUNCH,
+  CLEANUP
+}
\ No newline at end of file

Added: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/AMRegistrationEvent.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/applicationsmanager/events/AMRegistrationEvent.java?rev=1143250&view=auto
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/AMRegistrationEvent.java (added)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/AMRegistrationEvent.java Wed Jul  6 04:51:46 2011
@@ -0,0 +1,37 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events;
+
+import org.apache.hadoop.yarn.api.records.ApplicationMaster;
+
+public class AMRegistrationEvent extends
+    ApplicationEvent {
+
+  private final ApplicationMaster applicationMaster;
+
+  public AMRegistrationEvent(ApplicationMaster applicationMaster) {
+    super(ApplicationEventType.REGISTERED, applicationMaster
+        .getApplicationId());
+    this.applicationMaster = applicationMaster;
+  }
+
+  public ApplicationMaster getApplicationMaster() {
+    return this.applicationMaster;
+  }
+}

Added: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/AMStatusUpdateEvent.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/applicationsmanager/events/AMStatusUpdateEvent.java?rev=1143250&view=auto
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/AMStatusUpdateEvent.java (added)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/AMStatusUpdateEvent.java Wed Jul  6 04:51:46 2011
@@ -0,0 +1,37 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events;
+
+import org.apache.hadoop.yarn.api.records.ApplicationStatus;
+
+public class AMStatusUpdateEvent extends
+    ApplicationEvent {
+
+  private final ApplicationStatus applicationStatus;
+
+  public AMStatusUpdateEvent(ApplicationStatus applicationStatus) {
+    super(ApplicationEventType.STATUSUPDATE, applicationStatus
+        .getApplicationId());
+    this.applicationStatus = applicationStatus;
+  }
+
+  public ApplicationStatus getApplicationStatus() {
+    return this.applicationStatus;
+  }
+}

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/ASMEvent.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/applicationsmanager/events/ASMEvent.java?rev=1143250&r1=1143249&r2=1143250&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/ASMEvent.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/ASMEvent.java Wed Jul  6 04:51:46 2011
@@ -19,21 +19,21 @@
 package org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events;
 
 import org.apache.hadoop.yarn.event.AbstractEvent;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.AppContext;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.Application;
 
 public class ASMEvent<T extends Enum<T>> extends AbstractEvent<T> {
-  private final AppContext context;
+  private final Application application;
   
-  public ASMEvent(T type, AppContext context) {
+  public ASMEvent(T type, Application app) {
     super(type);
-    this.context = context;
+    this.application = app;
   }
   
   /** 
    * return the application context.
    * @return the application context for this event.
    */
-  public AppContext getAppContext() {
-    return this.context;
+  public Application getApplication() {
+    return this.application;
   }
 }
\ No newline at end of file

Added: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/ApplicationEvent.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/applicationsmanager/events/ApplicationEvent.java?rev=1143250&view=auto
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/ApplicationEvent.java (added)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/ApplicationEvent.java Wed Jul  6 04:51:46 2011
@@ -0,0 +1,38 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events;
+
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.event.AbstractEvent;
+
+public class ApplicationEvent extends
+    AbstractEvent<ApplicationEventType> {
+
+  private final ApplicationId applicationId;
+
+  public ApplicationEvent(ApplicationEventType type,
+      ApplicationId applicationId) {
+    super(type);
+    this.applicationId = applicationId;
+  }
+
+  public ApplicationId getApplicationId() {
+    return this.applicationId;
+  }
+}

Added: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/ApplicationEventType.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/applicationsmanager/events/ApplicationEventType.java?rev=1143250&view=auto
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/ApplicationEventType.java (added)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/ApplicationEventType.java Wed Jul  6 04:51:46 2011
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events;
+
+public enum ApplicationEventType {
+
+  // Source: ApplicationMasterService -> ASM -> AMTracker-self
+  REGISTERED,
+  STATUSUPDATE,
+  FINISH, // Also by AMLauncher
+
+  // Source: SchedulerNegotiator.
+  ALLOCATED,
+  RELEASED,
+
+  // Source: ASM -> AMTracker
+  ALLOCATE, // Also AMTracker->Self
+  FAILED,
+  RECOVER,
+
+  // TODO: Nobody Uses!
+  REMOVE,
+  CLEANUP,
+
+  // Source: AMLauncher
+  LAUNCHED,
+  LAUNCH_FAILED,
+
+  // Source: AMTracker: Self-event
+  LAUNCH,
+  FAILED_MAX_RETRIES,
+
+  // Source: AMLivelinessMonitor -> AMTracker
+  EXPIRE,
+
+  // Source: ClientRMService -> ASM -> AMTracker
+  KILL
+}
\ No newline at end of file

Added: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/ApplicationTrackerEventType.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/applicationsmanager/events/ApplicationTrackerEventType.java?rev=1143250&view=auto
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/ApplicationTrackerEventType.java (added)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/ApplicationTrackerEventType.java Wed Jul  6 04:51:46 2011
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events;
+
+public enum ApplicationTrackerEventType {
+  ADD,
+  REMOVE,
+  EXPIRE
+}
\ No newline at end of file

Added: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/SNEventType.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/applicationsmanager/events/SNEventType.java?rev=1143250&view=auto
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/SNEventType.java (added)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/events/SNEventType.java Wed Jul  6 04:51:46 2011
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events;
+
+public enum SNEventType {
+  SCHEDULE,
+  RELEASE,
+}
\ 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/scheduler/Application.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/Application.java?rev=1143250&r1=1143249&r2=1143250&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/Application.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/Application.java Wed Jul  6 04:51:46 2011
@@ -470,9 +470,9 @@ public class Application {
     return new ArrayList<NodeInfo>(applicationOnNodes);
   }
 
-  synchronized public org.apache.hadoop.yarn.api.records.Application getApplicationInfo() {
-    org.apache.hadoop.yarn.api.records.Application application = recordFactory
-        .newRecordInstance(org.apache.hadoop.yarn.api.records.Application.class);
+  synchronized public org.apache.hadoop.yarn.api.records.ApplicationReport getApplicationInfo() {
+    org.apache.hadoop.yarn.api.records.ApplicationReport application = recordFactory
+        .newRecordInstance(org.apache.hadoop.yarn.api.records.ApplicationReport.class);
     application.setApplicationId(applicationId);
     application.setName("");
     application.setQueue(queue.getQueueName());

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/ResourceScheduler.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/ResourceScheduler.java?rev=1143250&r1=1143249&r2=1143250&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/ResourceScheduler.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/ResourceScheduler.java Wed Jul  6 04:51:46 2011
@@ -25,7 +25,7 @@ import org.apache.hadoop.classification.
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.event.EventHandler;
 import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ASMEvent;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationMasterEvents.ApplicationTrackerEventType;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationTrackerEventType;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.Recoverable;
 import org.apache.hadoop.yarn.server.resourcemanager.resourcetracker.ClusterTracker;
 import org.apache.hadoop.yarn.server.security.ContainerTokenSecretManager;

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=1143250&r1=1143249&r2=1143250&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 Jul  6 04:51:46 2011
@@ -51,7 +51,7 @@ 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.applicationsmanager.events.ASMEvent;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationMasterEvents.ApplicationTrackerEventType;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationTrackerEventType;
 import org.apache.hadoop.yarn.server.resourcemanager.resource.Resources;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.ApplicationsStore.ApplicationStore;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.Store.ApplicationInfo;
@@ -586,7 +586,7 @@ implements ResourceScheduler, CapacitySc
       break;
     case REMOVE:
       try {
-        doneApplication(event.getAppContext().getApplicationID(), true);
+        doneApplication(event.getApplication().getApplicationID(), true);
       } catch(IOException ie) {
         LOG.error("Error in removing 'done' application", ie);
         //TODO have to be shutdown the RM in case of this.
@@ -598,7 +598,7 @@ implements ResourceScheduler, CapacitySc
         /** do not remove the application. Just do everything else exception 
          * removing the application
          */
-        doneApplication(event.getAppContext().getApplicationID(), false);
+        doneApplication(event.getApplication().getApplicationID(), false);
       } catch(IOException ie) {
         LOG.error("Error in removing 'expired' application", ie);
         //TODO have to be shutdown the RM in case of this.

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=1143250&r1=1143249&r2=1143250&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 Jul  6 04:51:46 2011
@@ -90,7 +90,7 @@ public class LeafQueue implements Queue 
   private final QueueMetrics metrics;
 
   private QueueInfo queueInfo; 
-  private Map<ApplicationId, org.apache.hadoop.yarn.api.records.Application> 
+  private Map<ApplicationId, org.apache.hadoop.yarn.api.records.ApplicationReport> 
   applicationInfos;
 
   private QueueState state;
@@ -141,7 +141,7 @@ public class LeafQueue implements Queue 
 
     this.applicationInfos = 
       new HashMap<ApplicationId, 
-      org.apache.hadoop.yarn.api.records.Application>();
+      org.apache.hadoop.yarn.api.records.ApplicationReport>();
 
     QueueState state = cs.getConfiguration().getState(getQueuePath());
 
@@ -298,11 +298,11 @@ public class LeafQueue implements Queue 
 
     if (includeApplications) {
       queueInfo.setApplications( 
-          new ArrayList<org.apache.hadoop.yarn.api.records.Application>(
+          new ArrayList<org.apache.hadoop.yarn.api.records.ApplicationReport>(
               applicationInfos.values()));
     } else {
       queueInfo.setApplications(
-          new ArrayList<org.apache.hadoop.yarn.api.records.Application>());
+          new ArrayList<org.apache.hadoop.yarn.api.records.ApplicationReport>());
     }
 
     return queueInfo;

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/ParentQueue.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/ParentQueue.java?rev=1143250&r1=1143249&r2=1143250&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/ParentQueue.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/ParentQueue.java Wed Jul  6 04:51:46 2011
@@ -86,7 +86,7 @@ public class ParentQueue implements Queu
   private final QueueMetrics metrics;
 
   private QueueInfo queueInfo; 
-  private Map<ApplicationId, org.apache.hadoop.yarn.api.records.Application> 
+  private Map<ApplicationId, org.apache.hadoop.yarn.api.records.ApplicationReport> 
   applicationInfos;
 
   private Map<QueueACL, AccessControlList> acls = 
@@ -146,7 +146,7 @@ public class ParentQueue implements Queu
 
     this.applicationInfos = 
       new HashMap<ApplicationId, 
-      org.apache.hadoop.yarn.api.records.Application>();
+      org.apache.hadoop.yarn.api.records.ApplicationReport>();
 
 
     LOG.info("Initialized parent-queue " + queueName + 
@@ -292,11 +292,11 @@ public class ParentQueue implements Queu
 
     if (includeApplications) {
       queueInfo.setApplications( 
-        new ArrayList<org.apache.hadoop.yarn.api.records.Application>(
+        new ArrayList<org.apache.hadoop.yarn.api.records.ApplicationReport>(
             applicationInfos.values()));
     } else {
       queueInfo.setApplications(
-          new ArrayList<org.apache.hadoop.yarn.api.records.Application>());
+          new ArrayList<org.apache.hadoop.yarn.api.records.ApplicationReport>());
     }
 
     List<QueueInfo> childQueuesInfo = new ArrayList<QueueInfo>();

Modified: 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
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/fifo/FifoScheduler.java?rev=1143250&r1=1143249&r2=1143250&view=diff
==============================================================================
--- 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 (original)
+++ 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 Wed Jul  6 04:51:46 2011
@@ -53,7 +53,7 @@ import org.apache.hadoop.yarn.factory.pr
 import org.apache.hadoop.yarn.security.ContainerTokenIdentifier;
 import org.apache.hadoop.yarn.server.resourcemanager.RMConfig;
 import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ASMEvent;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationMasterEvents.ApplicationTrackerEventType;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationTrackerEventType;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.ApplicationsStore.ApplicationStore;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.Store.ApplicationInfo;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.Store.RMState;
@@ -135,7 +135,7 @@ public class FifoScheduler implements Re
         queueInfo.setApplications(getApplications());
       } else {
         queueInfo.setApplications(
-            new ArrayList<org.apache.hadoop.yarn.api.records.Application>());
+            new ArrayList<org.apache.hadoop.yarn.api.records.ApplicationReport>());
       }
       return queueInfo;
     }
@@ -577,16 +577,16 @@ public class FifoScheduler implements Re
       break;
     case REMOVE:
       try {
-        doneApplication(event.getAppContext().getApplicationID(), true);
+        doneApplication(event.getApplication().getApplicationID(), true);
       } catch(IOException ie) {
-        LOG.error("Unable to remove application " + event.getAppContext().getApplicationID(), ie);
+        LOG.error("Unable to remove application " + event.getApplication().getApplicationID(), ie);
       }
       break;  
     case EXPIRE:
       try {
-        doneApplication(event.getAppContext().getApplicationID(), false);
+        doneApplication(event.getApplication().getApplicationID(), false);
       } catch(IOException ie) {
-        LOG.error("Unable to remove application " + event.getAppContext().getApplicationID(), ie);
+        LOG.error("Unable to remove application " + event.getApplication().getApplicationID(), ie);
       }
       break;
     }
@@ -618,10 +618,10 @@ public class FifoScheduler implements Re
     return DEFAULT_QUEUE.getQueueUserAclInfo(null); 
   }
 
-  private synchronized List<org.apache.hadoop.yarn.api.records.Application> 
+  private synchronized List<org.apache.hadoop.yarn.api.records.ApplicationReport> 
   getApplications() {
-    List<org.apache.hadoop.yarn.api.records.Application> applications = 
-      new ArrayList<org.apache.hadoop.yarn.api.records.Application>();
+    List<org.apache.hadoop.yarn.api.records.ApplicationReport> applications = 
+      new ArrayList<org.apache.hadoop.yarn.api.records.ApplicationReport>();
     for (Application application : this.applications.values()) {
       applications.add(application.getApplicationInfo());
     }

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsBlock.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/webapp/AppsBlock.java?rev=1143250&r1=1143249&r2=1143250&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsBlock.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsBlock.java Wed Jul  6 04:51:46 2011
@@ -20,7 +20,7 @@ package org.apache.hadoop.yarn.server.re
 
 import com.google.inject.Inject;
 
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.AppContext;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.Application;
 import org.apache.hadoop.yarn.util.Apps;
 import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
 import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.*;
@@ -52,7 +52,7 @@ class AppsBlock extends HtmlBlock {
             th(".note", "Note")._()._().
         tbody();
     int i = 0;
-    for (AppContext app : list.apps) {
+    for (Application app : list.apps.values()) {
       String appId = Apps.toString(app.getApplicationID());
       String trackingUrl = app.getMaster().getTrackingUrl();
       String ui = trackingUrl == null || trackingUrl.isEmpty() ? "UNASSIGNED" :

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsList.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/webapp/AppsList.java?rev=1143250&r1=1143249&r2=1143250&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsList.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsList.java Wed Jul  6 04:51:46 2011
@@ -18,38 +18,43 @@
 
 package org.apache.hadoop.yarn.server.resourcemanager.webapp;
 
-import com.google.inject.Inject;
-import com.google.inject.servlet.RequestScoped;
+import static org.apache.commons.lang.StringEscapeUtils.escapeHtml;
+import static org.apache.commons.lang.StringEscapeUtils.escapeJavaScript;
+import static org.apache.hadoop.yarn.webapp.view.Jsons._SEP;
+import static org.apache.hadoop.yarn.webapp.view.Jsons.appendLink;
+import static org.apache.hadoop.yarn.webapp.view.Jsons.appendProgressBar;
+import static org.apache.hadoop.yarn.webapp.view.Jsons.appendSortable;
 
 import java.io.PrintWriter;
-import java.util.List;
+import java.util.concurrent.ConcurrentMap;
 
-import static org.apache.commons.lang.StringEscapeUtils.*;
-import static org.apache.hadoop.yarn.webapp.view.JQueryUI.*;
-import static org.apache.hadoop.yarn.webapp.view.Jsons.*;
-
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.AppContext;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.ApplicationsManager;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager.RMContext;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.Application;
 import org.apache.hadoop.yarn.util.Apps;
-import org.apache.hadoop.yarn.webapp.ToJSON;
 import org.apache.hadoop.yarn.webapp.Controller.RequestContext;
+import org.apache.hadoop.yarn.webapp.ToJSON;
+import org.apache.hadoop.yarn.webapp.view.JQueryUI.Render;
+
+import com.google.inject.Inject;
+import com.google.inject.servlet.RequestScoped;
 
 // So we only need to do asm.getApplications once in a request
 @RequestScoped
 class AppsList implements ToJSON {
   final RequestContext rc;
-  final List<AppContext> apps;
+  final ConcurrentMap<ApplicationId, Application> apps;
   Render rendering;
 
-  @Inject AppsList(RequestContext ctx, ApplicationsManager asm) {
+  @Inject AppsList(RequestContext ctx, RMContext rmContext) {
     rc = ctx;
-    apps = asm.getAllAppContexts();
+    apps = rmContext.getApplications();
   }
 
   void toDataTableArrays(PrintWriter out) {
     out.append('[');
     boolean first = true;
-    for (AppContext app : apps) {
+    for (Application app : apps.values()) {
       if (first) {
         first = false;
       } else {

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebApp.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/webapp/RMWebApp.java?rev=1143250&r1=1143249&r2=1143250&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebApp.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebApp.java Wed Jul  6 04:51:46 2011
@@ -18,8 +18,9 @@
 
 package org.apache.hadoop.yarn.server.resourcemanager.webapp;
 
+import org.apache.hadoop.yarn.server.resourcemanager.ApplicationsManager;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.ApplicationsManager;
+import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager.RMContext;
 import org.apache.hadoop.yarn.server.resourcemanager.resourcetracker.ClusterTracker;
 import org.apache.hadoop.yarn.webapp.WebApp;
 
@@ -42,6 +43,7 @@ public class RMWebApp extends WebApp {
   public void setup() {
     if (rm != null) {
       bind(ResourceManager.class).toInstance(rm);
+      bind(RMContext.class).toInstance(rm.getRMContext());
       bind(ApplicationsManager.class).toInstance(rm.getApplicationsManager());
       bind(ClusterTracker.class).toInstance(rm.getResourceTracker());
     }

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmController.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/webapp/RmController.java?rev=1143250&r1=1143249&r2=1143250&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmController.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmController.java Wed Jul  6 04:51:46 2011
@@ -22,23 +22,23 @@ import static org.apache.hadoop.yarn.ser
 import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWebApp.QUEUE_NAME;
 import static org.apache.hadoop.yarn.util.StringHelper.join;
 
+import org.apache.hadoop.util.StringUtils;
 import org.apache.hadoop.util.VersionInfo;
-import org.apache.hadoop.yarn.util.YarnVersionInfo;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.Container;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.ApplicationsManager;
+import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager.RMContext;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.Application;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
 import org.apache.hadoop.yarn.util.Apps;
 import org.apache.hadoop.yarn.util.ConverterUtils;
 import org.apache.hadoop.yarn.util.Times;
+import org.apache.hadoop.yarn.util.YarnVersionInfo;
 import org.apache.hadoop.yarn.webapp.Controller;
 import org.apache.hadoop.yarn.webapp.ResponseInfo;
 
 import com.google.inject.Inject;
-import org.apache.hadoop.util.StringUtils;
-import org.apache.hadoop.yarn.api.records.Container;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.AppContext;
 
 // Do NOT rename/refactor this to RMView as it will wreak havoc
 // on Mac OS HFS as its case-insensitive!
@@ -70,8 +70,8 @@ public class RmController extends Contro
       return;
     }
     ApplicationId appID = Apps.toAppID(aid);
-    ApplicationsManager asm = getInstance(ApplicationsManager.class);
-    AppContext app = asm.getAppContext(appID);
+    RMContext context = getInstance(RMContext.class);
+    Application app = context.getApplications().get(appID);
     if (app == null) {
       // TODO: handle redirect to jobhistory server
       setStatus(response().SC_NOT_FOUND);

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/Application.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/Application.java?rev=1143250&r1=1143249&r2=1143250&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/Application.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/Application.java Wed Jul  6 04:51:46 2011
@@ -36,6 +36,7 @@ import org.apache.hadoop.classification.
 import org.apache.hadoop.net.NetworkTopology;
 import org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest;
 import org.apache.hadoop.yarn.api.protocolrecords.StopContainerRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
 import org.apache.hadoop.yarn.api.records.Container;
@@ -99,7 +100,7 @@ public class Application {
     this.queue = queue;
     this.resourceManager = resourceManager;
     this.applicationId =
-      this.resourceManager.getApplicationsManager().getNewApplicationID();
+      this.resourceManager.getClientRMService().getNewApplicationId();
   }
 
   public String getUser() {
@@ -131,7 +132,10 @@ public class Application {
     context.setApplicationId(this.applicationId);
     context.setUser(this.user);
     context.setQueue(this.queue);
-    resourceManager.getApplicationsManager().submitApplication(context);
+    SubmitApplicationRequest request = recordFactory
+        .newRecordInstance(SubmitApplicationRequest.class);
+    request.setApplicationSubmissionContext(context);
+    resourceManager.getClientRMService().submitApplication(request);
   }
   
   public synchronized void addResourceRequestSpec(

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java?rev=1143250&r1=1143249&r2=1143250&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java Wed Jul  6 04:51:46 2011
@@ -24,7 +24,7 @@ import java.util.List;
 import java.util.Map;
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.hadoop.yarn.api.records.Application;
+import org.apache.hadoop.yarn.api.records.ApplicationReport;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.MockApps;
 import org.apache.hadoop.yarn.api.records.ApplicationMaster;
@@ -34,8 +34,11 @@ import org.apache.hadoop.yarn.api.record
 import org.apache.hadoop.yarn.api.records.Container;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.hadoop.yarn.security.client.ClientToAMSecretManager;
+import org.apache.hadoop.yarn.server.resourcemanager.ApplicationsManager;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.ApplicationsStore.ApplicationStore;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.Store.RMState;
+import org.apache.hadoop.yarn.service.AbstractService;
 import org.apache.hadoop.yarn.util.Records;
 
 @InterfaceAudience.Private
@@ -144,55 +147,29 @@ public abstract class MockAsm extends Mo
     }
   }
 
-  public static class AsmBase implements ApplicationsManager {
-    @Override
-    public ApplicationId getNewApplicationID() {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public ApplicationMaster getApplicationMaster(ApplicationId applicationId) {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public Application getApplication(ApplicationId applicationID) {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public AppContext getAppContext(ApplicationId appId) {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void submitApplication(ApplicationSubmissionContext context) throws IOException {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void finishApplication(ApplicationId applicationId,
-                                  UserGroupInformation callerUGI) throws IOException {
-      throw new UnsupportedOperationException("Not supported yet.");
+  public static class AsmBase extends AbstractService implements
+      ApplicationsManager {
+    public AsmBase() {
+      super(AsmBase.class.getName());
     }
 
     @Override
-    public List<AppContext> getAllAppContexts() {
+    public void recover(RMState state) throws Exception {
       throw new UnsupportedOperationException("Not supported yet.");
     }
 
     @Override
-    public List<Application> getApplications() {
-      throw new UnsupportedOperationException("Not supported yet.");
+    public AMLivelinessMonitor getAmLivelinessMonitor() {
+      return null;
     }
 
     @Override
-    public void recover(RMState state) throws Exception {
-      throw new UnsupportedOperationException("Not supported yet.");
+    public ClientToAMSecretManager getClientToAMSecretManager() {
+      return null;
     }
   }
 
-  public static class AppContextBase implements AppContext {
+  public static class ApplicationBase implements Application {
     @Override
     public ApplicationSubmissionContext getSubmissionContext() {
       throw new UnsupportedOperationException("Not supported yet.");
@@ -257,6 +234,11 @@ public abstract class MockAsm extends Mo
     public long getFinishTime() {
       throw new UnsupportedOperationException("Not supported yet.");
     }
+
+    @Override
+    public ApplicationState getState() {
+      throw new UnsupportedOperationException("Not supported yet.");
+    }
   }
 
   public static ApplicationMaster newAppMaster(final ApplicationId id) {
@@ -288,7 +270,7 @@ public abstract class MockAsm extends Mo
     };
   }
 
-  public static AppContext newAppContext(int i) {
+  public static Application newApplication(int i) {
     final ApplicationId id = newAppID(i);
     final ApplicationMaster master = newAppMaster(id);
     final Container masterContainer = Records.newRecord(Container.class);
@@ -303,7 +285,7 @@ public abstract class MockAsm extends Mo
     final long start = System.currentTimeMillis() - (int)(Math.random()*DT);
     final long finish = Math.random() < 0.5 ? 0 :
         System.currentTimeMillis() + (int)(Math.random()*DT);
-    return new AppContextBase() {
+    return new ApplicationBase() {
       @Override
       public ApplicationId getApplicationID() {
         return id;
@@ -351,30 +333,15 @@ public abstract class MockAsm extends Mo
     };
   }
   
-  public static List<AppContext> newAppContexts(int n) {
-    List<AppContext> list = Lists.newArrayList();
+  public static List<Application> newApplications(int n) {
+    List<Application> list = Lists.newArrayList();
     for (int i = 0; i < n; ++i) {
-      list.add(newAppContext(i));
+      list.add(newApplication(i));
     }
     return list;
   }
 
-  public static ApplicationsManager create(int n) {
-    final List<AppContext> apps = newAppContexts(n);
-    final Map<ApplicationId, AppContext> map = Maps.newHashMap();
-    for (AppContext app : apps) {
-      map.put(app.getApplicationID(), app);
-    }
-    return new AsmBase() {
-      @Override
-      public List<AppContext> getAllAppContexts() {
-        return apps;
-      }
-
-      @Override
-      public AppContext getAppContext(ApplicationId id) {
-        return map.get(id);
-      }
-    };
+  public static ApplicationsManager create() {
+    return new AsmBase();
   }
 }

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMLaunchFailure.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMLaunchFailure.java?rev=1143250&r1=1143249&r2=1143250&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMLaunchFailure.java (original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMLaunchFailure.java Wed Jul  6 04:51:46 2011
@@ -28,8 +28,10 @@ import junit.framework.Assert;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationMaster;
+import org.apache.hadoop.yarn.api.records.ApplicationReport;
 import org.apache.hadoop.yarn.api.records.ApplicationState;
 import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
 import org.apache.hadoop.yarn.api.records.Container;
@@ -43,13 +45,15 @@ import org.apache.hadoop.yarn.event.Even
 import org.apache.hadoop.yarn.factories.RecordFactory;
 import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
 import org.apache.hadoop.yarn.security.ApplicationTokenSecretManager;
+import org.apache.hadoop.yarn.server.resourcemanager.ClientRMService;
 import org.apache.hadoop.yarn.server.resourcemanager.RMConfig;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager.RMContext;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.AMLauncherEventType;
 import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ASMEvent;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationMasterEvents.AMLauncherEventType;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationMasterEvents.ApplicationEventType;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationMasterEvents.ApplicationTrackerEventType;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationEvent;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationEventType;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationTrackerEventType;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.ApplicationsStore.ApplicationStore;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.MemStore;
 import org.apache.hadoop.yarn.server.resourcemanager.resource.Resources;
@@ -67,6 +71,7 @@ public class TestAMLaunchFailure {
   YarnScheduler scheduler = new DummyYarnScheduler();
   ApplicationTokenSecretManager applicationTokenSecretManager = 
     new ApplicationTokenSecretManager();
+  private ClientRMService clientService;
 
   private RMContext context;
 
@@ -131,7 +136,7 @@ public class TestAMLaunchFailure {
 
     private  class DummyApplicationMasterLauncher implements EventHandler<ASMEvent<AMLauncherEventType>> {
       private AtomicInteger notify = new AtomicInteger();
-      private AppContext app;
+      private Application app;
 
       public DummyApplicationMasterLauncher(RMContext context) {
         context.getDispatcher().register(AMLauncherEventType.class, this);
@@ -142,7 +147,7 @@ public class TestAMLaunchFailure {
         switch(appEvent.getType()) {
         case LAUNCH:
           LOG.info("LAUNCH called ");
-          app = appEvent.getAppContext();
+          app = appEvent.getApplication();
           synchronized (notify) {
             notify.addAndGet(1);
             notify.notify();
@@ -162,7 +167,7 @@ public class TestAMLaunchFailure {
               e.printStackTrace();
             }
             context.getDispatcher().getEventHandler().handle(
-                new ApplicationMasterInfoEvent(ApplicationEventType.LAUNCHED,
+                new ApplicationEvent(ApplicationEventType.LAUNCHED,
                     app.getApplicationID()));
           }
         }
@@ -187,9 +192,18 @@ public class TestAMLaunchFailure {
   public void setUp() {
     context = new ResourceManager.RMContextImpl(new MemStore());
     Configuration conf = new Configuration();
+
+    context.getDispatcher().register(ApplicationEventType.class,
+        new ResourceManager.ApplicationEventDispatcher(context));
+
     context.getDispatcher().init(conf);
     context.getDispatcher().start();
+
     asmImpl = new ExtApplicationsManagerImpl(applicationTokenSecretManager, scheduler);
+    clientService = new ClientRMService(context, asmImpl
+        .getAmLivelinessMonitor(), asmImpl.getClientToAMSecretManager(),
+        null, scheduler);
+    clientService.init(conf);
     new DummyApplicationTracker();
     conf.setLong(YarnConfiguration.AM_EXPIRY_INTERVAL, 3000L);
     conf.setInt(RMConfig.AM_MAX_RETRIES, 1);
@@ -210,17 +224,20 @@ public class TestAMLaunchFailure {
 
   @Test
   public void testAMLaunchFailure() throws Exception {
-    ApplicationId appID = asmImpl.getNewApplicationID();
-    ApplicationSubmissionContext context = createDummyAppContext(appID);
-    asmImpl.submitApplication(context);
-    ApplicationMaster master = asmImpl.getApplicationMaster(appID);
+    ApplicationId appID = clientService.getNewApplicationId();
+    ApplicationSubmissionContext submissionContext = createDummyAppContext(appID);
+    SubmitApplicationRequest request = recordFactory
+        .newRecordInstance(SubmitApplicationRequest.class);
+    request.setApplicationSubmissionContext(submissionContext);
+    clientService.submitApplication(request);
+    Application application = context.getApplications().get(appID); 
 
-    while (master.getState() != ApplicationState.FAILED) {
+    while (application.getState() != ApplicationState.FAILED) {
       LOG.info("Waiting for application to go to FAILED state."
-          + " Current state is " + master.getState());
+          + " Current state is " + application.getState());
       Thread.sleep(200);
-      master = asmImpl.getApplicationMaster(appID);
+      application = context.getApplications().get(appID);
     }
-    Assert.assertEquals(ApplicationState.FAILED, master.getState());
+    Assert.assertEquals(ApplicationState.FAILED, application.getState());
   }
 }



Mime
View raw message