hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r1139443 [2/2] - in /hadoop/common/branches/MR-279/mapreduce: ./ .eclipse.templates/ yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ yarn/yarn-api/src/m...
Date Fri, 24 Jun 2011 21:30:53 GMT
Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestApplicationMasterExpiry.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/TestApplicationMasterExpiry.java?rev=1139443&r1=1139442&r2=1139443&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestApplicationMasterExpiry.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestApplicationMasterExpiry.java
Fri Jun 24 21:30:53 2011
@@ -21,7 +21,6 @@ package org.apache.hadoop.yarn.server.re
 import java.util.concurrent.atomic.AtomicInteger;
 
 import junit.framework.Assert;
-import junit.framework.TestCase;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -49,7 +48,7 @@ import org.junit.Test;
  * A test case that tests the expiry of the application master.
  * More tests can be added to this. 
  */
-public class TestApplicationMasterExpiry extends TestCase {
+public class TestApplicationMasterExpiry {
   private static final Log LOG = LogFactory.getLog(TestApplicationMasterExpiry.class);
   private static RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
   AMTracker tracker;
@@ -88,16 +87,17 @@ public class TestApplicationMasterExpiry
   private AtomicInteger expiry = new AtomicInteger();
   private boolean expired = false;
   
-  private class ApplicationEventTypeListener implements EventHandler<ASMEvent<ApplicationEventType>>
{
+  private class ApplicationEventTypeListener implements
+      EventHandler<ApplicationMasterInfoEvent> {
     ApplicationEventTypeListener() {
       context.getDispatcher().register(ApplicationEventType.class, this);
     }
     @Override
-    public void handle(ASMEvent<ApplicationEventType> event) {
+    public void handle(ApplicationMasterInfoEvent event) {
       switch(event.getType()) {
       case EXPIRE:
         expired = true;
-        LOG.info("Received expiry from application " + event.getAppContext().getApplicationID());
+        LOG.info("Received expiry from application " + event.getApplicationId());
         synchronized(expiry) {
           expiry.addAndGet(1);
         }
@@ -130,26 +130,31 @@ public class TestApplicationMasterExpiry
       Thread.sleep(500);
       count++;
     }
-    assertTrue(masterInfo.getState() == finalState);
+    Assert.assertEquals(finalState, masterInfo.getState());
   }
 
   @Test
   public void testAMExpiry() throws Exception {
-    ApplicationSubmissionContext context = recordFactory.newRecordInstance(ApplicationSubmissionContext.class);
-    context.setApplicationId(recordFactory.newRecordInstance(ApplicationId.class));
-    context.getApplicationId().setClusterTimestamp(System.currentTimeMillis());
-    context.getApplicationId().setId(1);
+    ApplicationSubmissionContext submissionContext = recordFactory
+        .newRecordInstance(ApplicationSubmissionContext.class);
+    submissionContext.setApplicationId(recordFactory
+        .newRecordInstance(ApplicationId.class));
+    submissionContext.getApplicationId().setClusterTimestamp(
+        System.currentTimeMillis());
+    submissionContext.getApplicationId().setId(1);
     
     tracker.addMaster(
         "dummy", 
-        context, "dummytoken");
-    ApplicationMasterInfo masterInfo = tracker.get(context.getApplicationId());
-    tracker.runApplication(context.getApplicationId());
+        submissionContext, "dummytoken");
+    ApplicationMasterInfo masterInfo = tracker.get(submissionContext.getApplicationId());
+    tracker.runApplication(submissionContext.getApplicationId());
     this.context.getDispatcher().getEventHandler().handle(
-        new ASMEvent<ApplicationEventType>(ApplicationEventType.ALLOCATED, masterInfo));
+        new ApplicationMasterAllocatedEvent(masterInfo.getApplicationID(),
+            masterInfo.getMasterContainer()));
     waitForState(masterInfo, ApplicationState.LAUNCHING);
     this.context.getDispatcher().getEventHandler().handle(
-    new ASMEvent<ApplicationEventType>(ApplicationEventType.LAUNCHED, masterInfo));
+        new ApplicationMasterInfoEvent(ApplicationEventType.LAUNCHED,
+            masterInfo.getApplicationID()));
     synchronized(expiry) {
       while (expiry.get() == 0) {
         expiry.wait(1000);

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestApplicationMasterLauncher.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/TestApplicationMasterLauncher.java?rev=1139443&r1=1139442&r2=1139443&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestApplicationMasterLauncher.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestApplicationMasterLauncher.java
Fri Jun 24 21:30:53 2011
@@ -20,7 +20,7 @@ package org.apache.hadoop.yarn.server.re
 
 import java.util.concurrent.atomic.AtomicInteger;
 
-import junit.framework.TestCase;
+import junit.framework.Assert;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -31,12 +31,11 @@ import org.apache.hadoop.yarn.api.record
 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.security.client.ClientToAMSecretManager;
 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.ResourceManager.RMContext;
 import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ASMEvent;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ApplicationFinishEvent;
 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.recovery.MemStore;
@@ -49,7 +48,7 @@ import org.junit.Test;
  * Testing the applications manager launcher.
  *
  */
-public class TestApplicationMasterLauncher extends TestCase {
+public class TestApplicationMasterLauncher {
   private static final Log LOG = LogFactory.getLog(TestApplicationMasterLauncher.class);
   private static RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
   private ApplicationMasterLauncher amLauncher;
@@ -63,10 +62,12 @@ public class TestApplicationMasterLaunch
   AtomicInteger launched = new AtomicInteger();
   AtomicInteger cleanedUp = new AtomicInteger();
   private RMContext context = new ResourceManager.RMContextImpl(new MemStore());
+
+  private Configuration conf = new Configuration();
   
-  private class DummyASM implements EventHandler<ASMEvent<ApplicationEventType>>
{
+  private class DummyASM implements EventHandler<ApplicationMasterInfoEvent> {
     @Override
-    public void handle(ASMEvent<ApplicationEventType> appEvent) {
+    public void handle(ApplicationMasterInfoEvent appEvent) {
       ApplicationEventType event = appEvent.getType();
       switch (event) {
       case FINISH:
@@ -132,7 +133,6 @@ public class TestApplicationMasterLaunch
     asmHandle = new DummyASM();
     amLauncher = new DummyApplicationMasterLauncher(applicationTokenSecretManager,
         clientToAMSecretManager, asmHandle);
-    Configuration conf = new Configuration();
     context.getDispatcher().init(conf);
     amLauncher.init(conf);
     context.getDispatcher().start();
@@ -147,14 +147,15 @@ public class TestApplicationMasterLaunch
 
   @Test
   public void testAMLauncher() throws Exception {
-    ApplicationSubmissionContext context = recordFactory.newRecordInstance(ApplicationSubmissionContext.class);
-    context.setApplicationId(recordFactory.newRecordInstance(ApplicationId.class));
-    context.getApplicationId().setClusterTimestamp(System.currentTimeMillis());
-    context.getApplicationId().setId(1);
-    context.setUser("dummyuser");
+    ApplicationSubmissionContext submissionContext = recordFactory.newRecordInstance(ApplicationSubmissionContext.class);
+    submissionContext.setApplicationId(recordFactory.newRecordInstance(ApplicationId.class));
+    submissionContext.getApplicationId().setClusterTimestamp(System.currentTimeMillis());
+    submissionContext.getApplicationId().setId(1);
+    submissionContext.setUser("dummyuser");
     ApplicationMasterInfo masterInfo = new ApplicationMasterInfo(this.context,
-        "dummyuser", context,
-        "dummyclienttoken", StoreFactory.createVoidAppStore());
+        this.conf, "dummyuser", submissionContext, "dummyclienttoken",
+        StoreFactory.createVoidAppStore(), new AMLivelinessMonitor(context
+            .getDispatcher().getEventHandler()));
     amLauncher.handle(new ASMEvent<AMLauncherEventType>(AMLauncherEventType.LAUNCH,

       masterInfo));
     amLauncher.handle(new ASMEvent<AMLauncherEventType>(AMLauncherEventType.CLEANUP,
 
@@ -162,7 +163,7 @@ public class TestApplicationMasterLaunch
     synchronized (doneLaunching) {
       doneLaunching.wait(10000);
     }
-    assertTrue(launched.get() == 1);
-    assertTrue(cleanedUp.get() == 1);
+    Assert.assertEquals(1, launched.get());
+    Assert.assertEquals(1, cleanedUp.get());
   }
 }
\ No newline at end of file

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestSchedulerNegotiator.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/TestSchedulerNegotiator.java?rev=1139443&r1=1139442&r2=1139443&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestSchedulerNegotiator.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestSchedulerNegotiator.java
Fri Jun 24 21:30:53 2011
@@ -24,7 +24,6 @@ import java.util.List;
 import java.util.Map;
 
 import junit.framework.Assert;
-import junit.framework.TestCase;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
@@ -44,26 +43,24 @@ import org.apache.hadoop.yarn.factory.pr
 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.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.recovery.ApplicationsStore.ApplicationStore;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.MemStore;
-import org.apache.hadoop.yarn.server.resourcemanager.recovery.Store;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.Store.RMState;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.StoreFactory;
 import org.apache.hadoop.yarn.server.resourcemanager.resource.Resources;
 import org.apache.hadoop.yarn.server.resourcemanager.resourcetracker.ClusterTracker;
 import org.apache.hadoop.yarn.server.resourcemanager.resourcetracker.NodeInfo;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.NodeManager;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.NodeResponse;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.security.ContainerTokenSecretManager;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-public class TestSchedulerNegotiator extends TestCase {
+public class TestSchedulerNegotiator {
   private static RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
   private SchedulerNegotiator schedulerNegotiator;
   private DummyScheduler scheduler;
@@ -72,7 +69,7 @@ public class TestSchedulerNegotiator ext
   private final RMContext context = new ResourceManager.RMContextImpl(new MemStore());
   ApplicationMasterInfo masterInfo;
   private EventHandler handler;
-  
+  private Configuration conf = new Configuration();
   private class DummyScheduler implements ResourceScheduler {
     @Override
     public Allocation allocate(ApplicationId applicationId,
@@ -157,7 +154,6 @@ public class TestSchedulerNegotiator ext
   public void setUp() {
     scheduler = new DummyScheduler();
     schedulerNegotiator = new SchedulerNegotiator(context, scheduler);
-    Configuration conf = new Configuration();
     schedulerNegotiator.init(conf);
     schedulerNegotiator.start();
     handler = context.getDispatcher().getEventHandler();
@@ -182,10 +178,10 @@ public class TestSchedulerNegotiator ext
     }
     Assert.assertEquals(state, info.getState());
   }
-  
-  private class DummyEventHandler implements EventHandler<ASMEvent<ApplicationTrackerEventType>>
{
+
+  private class DummyEventHandler implements EventHandler<ASMEvent<AMLauncherEventType>>
{
     @Override
-    public void handle(ASMEvent<ApplicationTrackerEventType> event) {
+    public void handle(ASMEvent<AMLauncherEventType> event) {
     }
   }
 
@@ -196,15 +192,18 @@ public class TestSchedulerNegotiator ext
     submissionContext.getApplicationId().setClusterTimestamp(System.currentTimeMillis());
     submissionContext.getApplicationId().setId(1);
     
-    masterInfo =
-      new ApplicationMasterInfo(this.context,
-          "dummy", submissionContext, "dummyClientToken", StoreFactory.createVoidAppStore());
+    masterInfo = new ApplicationMasterInfo(this.context, this.conf, "dummy",
+        submissionContext, "dummyClientToken", StoreFactory
+            .createVoidAppStore(), new AMLivelinessMonitor(context
+            .getDispatcher().getEventHandler()));
     context.getDispatcher().register(ApplicationEventType.class, masterInfo);
-    context.getDispatcher().register(ApplicationTrackerEventType.class, masterInfo);
-    handler.handle(new ASMEvent<ApplicationEventType>(ApplicationEventType.
-    ALLOCATE, masterInfo));
-    waitForState(ApplicationState.ALLOCATED, masterInfo);
+    context.getDispatcher().register(ApplicationTrackerEventType.class, scheduler);
+    context.getDispatcher().register(AMLauncherEventType.class,
+        new DummyEventHandler());
+    handler.handle(new ApplicationMasterInfoEvent(
+        ApplicationEventType.ALLOCATE, submissionContext.getApplicationId()));
+    waitForState(ApplicationState.LAUNCHING, masterInfo); // LAUNCHING because ALLOCATED
automatically movesto LAUNCHING for now.
     Container container = masterInfo.getMasterContainer();
-    assertTrue(container.getId().getId() == testNum);
+    Assert.assertTrue(container.getId().getId() == testNum);
   }
 }



Mime
View raw message