hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acmur...@apache.org
Subject svn commit: r1087462 [20/20] - in /hadoop/mapreduce/branches/MR-279: ./ mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapred/ mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/jobhistory/ mr-client/...
Date Thu, 31 Mar 2011 22:23:34 GMT
Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRestart.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRestart.java?rev=1087462&r1=1087461&r2=1087462&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRestart.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRestart.java Thu Mar 31 22:23:22 2011
@@ -2,9 +2,7 @@ package org.apache.hadoop.yarn.server.re
 
 import java.io.IOException;
 import java.nio.ByteBuffer;
-import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -15,20 +13,22 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.net.Node;
-import org.apache.hadoop.yarn.ApplicationID;
-import org.apache.hadoop.yarn.ApplicationMaster;
-import org.apache.hadoop.yarn.ApplicationState;
-import org.apache.hadoop.yarn.ApplicationStatus;
-import org.apache.hadoop.yarn.ApplicationSubmissionContext;
-import org.apache.hadoop.yarn.Container;
-import org.apache.hadoop.yarn.ContainerID;
-import org.apache.hadoop.yarn.ContainerToken;
-import org.apache.hadoop.yarn.NodeID;
-import org.apache.hadoop.yarn.Resource;
-import org.apache.hadoop.yarn.ResourceRequest;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationMaster;
+import org.apache.hadoop.yarn.api.records.ApplicationState;
+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.ContainerId;
+import org.apache.hadoop.yarn.api.records.ContainerToken;
+import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.hadoop.yarn.api.records.ResourceRequest;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 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.ApplicationTokenSecretManager;
+import org.apache.hadoop.yarn.server.api.records.NodeId;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager.ASMContext;
 import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ASMEvent;
@@ -56,7 +56,7 @@ public class TestAMRestart extends TestC
     new ApplicationTokenSecretManager();
   DummyResourceScheduler scheduler;
   int count = 0;
-  ApplicationID appID;
+  ApplicationId appID;
   final int maxFailures = 3;
   AtomicInteger launchNotify = new AtomicInteger();
   AtomicInteger schedulerNotify = new AtomicInteger();
@@ -66,6 +66,7 @@ public class TestAMRestart extends TestC
   int launcherLaunchCalled = 0;
   int launcherCleanupCalled = 0;
   ApplicationMasterInfo masterInfo;
+  private final static RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
   
   private class ExtApplicationsManagerImpl extends ApplicationsManagerImpl {
     public ExtApplicationsManagerImpl(
@@ -128,7 +129,7 @@ public class TestAMRestart extends TestC
 
   private class DummyResourceScheduler implements ResourceScheduler {
     @Override
-    public NodeInfo addNode(NodeID nodeId, String hostName, Node node,
+    public NodeInfo addNode(NodeId nodeId, String hostName, Node node,
         Resource capability) {
       return null;
     }
@@ -137,19 +138,19 @@ public class TestAMRestart extends TestC
     }
     @Override
     public NodeResponse nodeUpdate(NodeInfo nodeInfo,
-        Map<CharSequence, List<Container>> containers) {
+        Map<String, List<Container>> containers) {
       return null;
     }
 
     @Override
-    public List<Container> allocate(ApplicationID applicationId,
+    public List<Container> allocate(ApplicationId applicationId,
         List<ResourceRequest> ask, List<Container> release) throws IOException {
-      Container container = new Container();
-      container.containerToken = new ContainerToken();
-      container.hostName = "localhost";
-      container.id = new ContainerID();
-      container.id.appID = appID;
-      container.id.id = count;
+      Container container = recordFactory.newRecordInstance(Container.class);
+      container.setContainerToken(recordFactory.newRecordInstance(ContainerToken.class));
+      container.setHostName("localhost");
+      container.setId(recordFactory.newRecordInstance(ContainerId.class));
+      container.getId().setAppId(appID);
+      container.getId().setId(count);
       count++;
       return Arrays.asList(container);
     }
@@ -183,9 +184,9 @@ public class TestAMRestart extends TestC
 
   @Before
   public void setUp() {
-    appID = new ApplicationID();
-    appID.clusterTimeStamp = System.currentTimeMillis();
-    appID.id = 1;
+    appID = recordFactory.newRecordInstance(ApplicationId.class);
+    appID.setClusterTimestamp(System.currentTimeMillis());
+    appID.setId(1);
     scheduler = new DummyResourceScheduler();
     asmContext.getDispatcher().register(ApplicationTrackerEventType.class, scheduler);
     appImpl = new ExtApplicationsManagerImpl(appTokenSecretManager, scheduler, asmContext);
@@ -211,9 +212,9 @@ public class TestAMRestart extends TestC
   }
   
   private class TestAppContext implements AppContext {
-    private ApplicationID appID;
+    private ApplicationId appID;
    
-    public TestAppContext(ApplicationID appID) {
+    public TestAppContext(ApplicationId appID) {
       this.appID = appID;
     }
     @Override
@@ -227,7 +228,7 @@ public class TestAMRestart extends TestC
     }
 
     @Override
-    public ApplicationID getApplicationID() {
+    public ApplicationId getApplicationID() {
       return appID;
     }
 
@@ -275,13 +276,13 @@ public class TestAMRestart extends TestC
 
   @Test
   public void testAMRestart() throws Exception {
-    ApplicationSubmissionContext subContext = new ApplicationSubmissionContext();
-    subContext.applicationId = appID;
-    subContext.applicationName = "dummyApp";
-    subContext.command = new ArrayList<CharSequence>();
-    subContext.environment = new HashMap<CharSequence, CharSequence>();
-    subContext.fsTokens = new ArrayList<CharSequence>();
-    subContext.fsTokens_todo = ByteBuffer.wrap(new byte[0]);
+    ApplicationSubmissionContext subContext = recordFactory.newRecordInstance(ApplicationSubmissionContext.class);
+    subContext.setApplicationId(appID);
+    subContext.setApplicationName("dummyApp");
+//    subContext.command = new ArrayList<String>();
+//    subContext.environment = new HashMap<String, String>();
+//    subContext.fsTokens = new ArrayList<String>();
+    subContext.setFsTokensTodo(ByteBuffer.wrap(new byte[0]));
     appImpl.submitApplication(subContext);
     masterInfo = appImpl.getApplicationMasterInfo(appID);
     synchronized (schedulerNotify) {

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestASMStateMachine.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestASMStateMachine.java?rev=1087462&r1=1087461&r2=1087462&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestASMStateMachine.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestASMStateMachine.java Thu Mar 31 22:23:22 2011
@@ -25,14 +25,16 @@ import junit.framework.TestCase;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.yarn.ApplicationID;
-import org.apache.hadoop.yarn.ApplicationMaster;
-import org.apache.hadoop.yarn.ApplicationState;
-import org.apache.hadoop.yarn.ApplicationStatus;
-import org.apache.hadoop.yarn.ApplicationSubmissionContext;
-import org.apache.hadoop.yarn.Container;
-import org.apache.hadoop.yarn.Resource;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationMaster;
+import org.apache.hadoop.yarn.api.records.ApplicationState;
+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.Resource;
 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;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager.ASMContext;
 import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ASMEvent;
@@ -46,6 +48,7 @@ import org.junit.Test;
 
 public class TestASMStateMachine extends TestCase {
   private static final Log LOG = LogFactory.getLog(TestASMStateMachine.class);
+  private static RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
   ASMContext context = new ResourceManager.ASMContextImpl();
   EventHandler handler;
   private boolean snreceivedCleanUp = false;
@@ -178,13 +181,13 @@ private static class StatusContext imple
     return null;
   }
   @Override
-  public ApplicationID getApplicationID() {
+  public ApplicationId getApplicationID() {
     return null;
   }
   @Override
   public ApplicationStatus getStatus() {
-    ApplicationStatus status = new ApplicationStatus();
-    status.lastSeen = -99;
+    ApplicationStatus status = recordFactory.newRecordInstance(ApplicationStatus.class);
+    status.setLastSeen(-99);
     return status;
   }
   @Override
@@ -264,10 +267,10 @@ public void waitForState(ApplicationStat
  */
 @Test
 public void testStateMachine() {
-  ApplicationSubmissionContext submissioncontext = new ApplicationSubmissionContext();
-  submissioncontext.applicationId = new ApplicationID();
-  submissioncontext.applicationId.id = 1;
-  submissioncontext.applicationId.clusterTimeStamp = System.currentTimeMillis();
+  ApplicationSubmissionContext submissioncontext = recordFactory.newRecordInstance(ApplicationSubmissionContext.class);
+  submissioncontext.setApplicationId(recordFactory.newRecordInstance(ApplicationId.class));
+  submissioncontext.getApplicationId().setId(1);
+  submissioncontext.getApplicationId().setClusterTimestamp(System.currentTimeMillis());
 
   ApplicationMasterInfo masterInfo 
   = new ApplicationMasterInfo(handler, "dummyuser", submissioncontext, "dummyToken");

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestApplicationCleanup.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestApplicationCleanup.java?rev=1087462&r1=1087461&r2=1087462&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestApplicationCleanup.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestApplicationCleanup.java Thu Mar 31 22:23:22 2011
@@ -24,6 +24,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 
+
 import junit.framework.Assert;
 import junit.framework.TestCase;
 
@@ -33,16 +34,18 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.net.NetworkTopology;
 import org.apache.hadoop.net.Node;
 import org.apache.hadoop.net.NodeBase;
-import org.apache.hadoop.yarn.ApplicationID;
-import org.apache.hadoop.yarn.ApplicationState;
-import org.apache.hadoop.yarn.ApplicationSubmissionContext;
-import org.apache.hadoop.yarn.Container;
-import org.apache.hadoop.yarn.NodeID;
-import org.apache.hadoop.yarn.Priority;
-import org.apache.hadoop.yarn.Resource;
-import org.apache.hadoop.yarn.ResourceRequest;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationState;
+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.ResourceRequest;
+import org.apache.hadoop.yarn.api.records.Resource;
 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.ApplicationTokenSecretManager;
+import org.apache.hadoop.yarn.server.api.records.NodeId;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager.ASMContext;
 import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ASMEvent;
@@ -65,6 +68,7 @@ import org.junit.Test;
  */
 public class TestApplicationCleanup extends TestCase {
   private static final Log LOG = LogFactory.getLog(TestApplicationCleanup.class);
+  private static RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
   private AtomicInteger waitForState = new AtomicInteger(0);
   private ResourceScheduler scheduler;
   private final int memoryCapability = 1024;
@@ -238,33 +242,33 @@ public class TestApplicationCleanup exte
   }
 
   private ResourceRequest createNewResourceRequest(int capability, int i) {
-    ResourceRequest request = new ResourceRequest();
-    request.capability = new Resource();
-    request.capability.memory = capability;
-    request.numContainers = 1;
-    request.priority = new Priority();
-    request.priority.priority = i;
-    request.hostName = "*";
+    ResourceRequest request = recordFactory.newRecordInstance(ResourceRequest.class);
+    request.setCapability(recordFactory.newRecordInstance(Resource.class));
+    request.getCapability().setMemory(capability);
+    request.setNumContainers(1);
+    request.setPriority(recordFactory.newRecordInstance(Priority.class));
+    request.getPriority().setPriority(i);
+    request.setHostName("*");
     return request;
   }
 
   protected NodeInfo addNodes(String commonName, int i, int memoryCapability) {
-    NodeID nodeId = new NodeID();
-    nodeId.id = i;
+    NodeId nodeId = recordFactory.newRecordInstance(NodeId.class);
+    nodeId.setId(i);
     String hostName = commonName + "_" + i;
     Node node = new NodeBase(hostName, NetworkTopology.DEFAULT_RACK);
-    Resource capability = new Resource();
-    capability.memory = 1024;
+    Resource capability = recordFactory.newRecordInstance(Resource.class);
+    capability.setMemory(1024);
     return scheduler.addNode(nodeId, hostName, node, capability);
   }
 
   @Test
   public void testApplicationCleanUp() throws Exception {
-    ApplicationID appID = asm.getNewApplicationID();
-    ApplicationSubmissionContext context = new ApplicationSubmissionContext();
-    context.applicationId = appID;
-    context.queue = "queuename";
-    context.user = "dummyuser";
+    ApplicationId appID = asm.getNewApplicationID();
+    ApplicationSubmissionContext context = recordFactory.newRecordInstance(ApplicationSubmissionContext.class);
+    context.setApplicationId(appID);
+    context.setQueue("queuename");
+    context.setUser("dummyuser");
     asm.submitApplication(context);
     waitForState(ApplicationState.LAUNCHED, asm.getApplicationMasterInfo(appID));
     List<ResourceRequest> reqs = new ArrayList<ResourceRequest>();
@@ -278,16 +282,16 @@ public class TestApplicationCleanup exte
       nodesAdded.add(addNodes("localhost", i, memoryCapability));
     }
     /* let one node heartbeat */
-    Map<CharSequence, List<Container>> containers = new HashMap<CharSequence, List<Container>>();
+    Map<String, List<Container>> containers = new HashMap<String, List<Container>>();
     NodeInfo firstNode = nodesAdded.get(0);
-    int firstNodeMemory = firstNode.getAvailableResource().memory;
+    int firstNodeMemory = firstNode.getAvailableResource().getMemory();
     NodeInfo secondNode = nodesAdded.get(1);
     scheduler.nodeUpdate(firstNode, containers);
     scheduler.nodeUpdate(secondNode, containers);
     LOG.info("Available resource on first node" + firstNode.getAvailableResource());
     LOG.info("Available resource on second node" + secondNode.getAvailableResource());
     /* only allocate the containers to the first node */
-    assertTrue(firstNode.getAvailableResource().memory == 
+    assertTrue(firstNode.getAvailableResource().getMemory() == 
       (firstNodeMemory - (2*memoryNeeded)));
     ApplicationMasterInfo masterInfo = asm.getApplicationMasterInfo(appID);
     asm.finishApplication(appID);

Modified: hadoop/mapreduce/branches/MR-279/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/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestApplicationMasterExpiry.java?rev=1087462&r1=1087461&r2=1087462&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestApplicationMasterExpiry.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestApplicationMasterExpiry.java Thu Mar 31 22:23:22 2011
@@ -24,13 +24,12 @@ import junit.framework.TestCase;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.yarn.ApplicationID;
-import org.apache.hadoop.yarn.ApplicationMaster;
-import org.apache.hadoop.yarn.ApplicationState;
-import org.apache.hadoop.yarn.ApplicationStatus;
-import org.apache.hadoop.yarn.ApplicationSubmissionContext;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 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;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager.ASMContext;
 import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ASMEvent;
@@ -48,6 +47,7 @@ import org.junit.Test;
  */
 public class TestApplicationMasterExpiry extends TestCase {
   private static final Log LOG = LogFactory.getLog(TestApplicationMasterExpiry.class);
+  private static RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
   AMTracker tracker;
   
   private final ASMContext context = new ResourceManager.ASMContextImpl();
@@ -119,15 +119,15 @@ public class TestApplicationMasterExpiry
   
   @Test
   public void testAMExpiry() throws Exception {
-    ApplicationSubmissionContext context = new ApplicationSubmissionContext();
-    context.applicationId = new ApplicationID();
-    context.applicationId.clusterTimeStamp = System.currentTimeMillis();
-    context.applicationId.id = 1;
+    ApplicationSubmissionContext context = recordFactory.newRecordInstance(ApplicationSubmissionContext.class);
+    context.setApplicationId(recordFactory.newRecordInstance(ApplicationId.class));
+    context.getApplicationId().setClusterTimestamp(System.currentTimeMillis());
+    context.getApplicationId().setId(1);
     
     tracker.addMaster(
         "dummy", 
         context, "dummytoken");
-    ApplicationMasterInfo masterInfo = tracker.get(context.applicationId);
+    ApplicationMasterInfo masterInfo = tracker.get(context.getApplicationId());
     this.context.getDispatcher().getEventHandler().handle(
         new ASMEvent<ApplicationEventType>(ApplicationEventType.ALLOCATED, masterInfo));
     this.context.getDispatcher().getEventHandler().handle(

Modified: hadoop/mapreduce/branches/MR-279/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/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestApplicationMasterLauncher.java?rev=1087462&r1=1087461&r2=1087462&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestApplicationMasterLauncher.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestApplicationMasterLauncher.java Thu Mar 31 22:23:22 2011
@@ -25,9 +25,11 @@ import junit.framework.TestCase;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.yarn.ApplicationID;
-import org.apache.hadoop.yarn.ApplicationSubmissionContext;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
 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.server.resourcemanager.ResourceManager;
@@ -45,6 +47,7 @@ import org.junit.Test;
  */
 public class TestApplicationMasterLauncher extends TestCase {
   private static final Log LOG = LogFactory.getLog(TestApplicationMasterLauncher.class);
+  private static RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
   private ApplicationMasterLauncher amLauncher;
   private DummyASM asmHandle;
   private final ApplicationTokenSecretManager applicationTokenSecretManager =
@@ -135,11 +138,11 @@ public class TestApplicationMasterLaunch
 
   @Test
   public void testAMLauncher() throws Exception {
-    ApplicationSubmissionContext context = new ApplicationSubmissionContext();
-    context.applicationId = new ApplicationID();
-    context.applicationId.clusterTimeStamp = System.currentTimeMillis();
-    context.applicationId.id = 1;
-    context.user = "dummyuser";
+    ApplicationSubmissionContext context = recordFactory.newRecordInstance(ApplicationSubmissionContext.class);
+    context.setApplicationId(recordFactory.newRecordInstance(ApplicationId.class));
+    context.getApplicationId().setClusterTimestamp(System.currentTimeMillis());
+    context.getApplicationId().setId(1);
+    context.setUser("dummyuser");
     ApplicationMasterInfo masterInfo = new ApplicationMasterInfo(this.context.
         getDispatcher().getEventHandler(),
         "dummyuser", context,

Modified: hadoop/mapreduce/branches/MR-279/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/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestSchedulerNegotiator.java?rev=1087462&r1=1087461&r2=1087462&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestSchedulerNegotiator.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestSchedulerNegotiator.java Thu Mar 31 22:23:22 2011
@@ -25,16 +25,18 @@ import java.util.Map;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.net.Node;
-import org.apache.hadoop.yarn.ApplicationID;
-import org.apache.hadoop.yarn.ApplicationState;
-import org.apache.hadoop.yarn.ApplicationSubmissionContext;
-import org.apache.hadoop.yarn.Container;
-import org.apache.hadoop.yarn.ContainerID;
-import org.apache.hadoop.yarn.NodeID;
-import org.apache.hadoop.yarn.Priority;
-import org.apache.hadoop.yarn.Resource;
-import org.apache.hadoop.yarn.ResourceRequest;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationState;
+import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
+import org.apache.hadoop.yarn.api.records.Container;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.api.records.Priority;
+import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.hadoop.yarn.api.records.ResourceRequest;
 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.api.records.NodeId;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager.ASMContext;
 import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.events.ASMEvent;
@@ -52,6 +54,7 @@ import junit.framework.Assert;
 import junit.framework.TestCase;
 
 public class TestSchedulerNegotiator extends TestCase {
+  private static RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
   private SchedulerNegotiator schedulerNegotiator;
   private DummyScheduler scheduler;
   private final int testNum = 99999;
@@ -62,29 +65,28 @@ public class TestSchedulerNegotiator ext
   
   private class DummyScheduler implements ResourceScheduler {
     @Override
-    public List<Container> allocate(ApplicationID applicationId,
+    public List<Container> allocate(ApplicationId applicationId,
         List<ResourceRequest> ask, List<Container> release) throws IOException {
       ArrayList<Container> containers = new ArrayList<Container>();
-      Container container = new Container();
-      container.id = new ContainerID();
-      container.id.appID = applicationId;
-      container.id.id = testNum;
+      Container container = recordFactory.newRecordInstance(Container.class);
+      container.setId(recordFactory.newRecordInstance(ContainerId.class));
+      container.getId().setAppId(applicationId);
+      container.getId().setId(testNum);
       containers.add(container);
       return containers;
     }
-
     @Override
     public void reinitialize(Configuration conf,
         ContainerTokenSecretManager secretManager) {
     }
     @Override
-    public NodeInfo addNode(NodeID nodeId, String hostName, Node node,
+    public NodeInfo addNode(NodeId nodeId, String hostName, Node node,
         Resource capability) {
       return null;
     }
     @Override
     public NodeResponse nodeUpdate(NodeInfo nodeInfo,
-        Map<CharSequence, List<Container>> containers) {
+        Map<String, List<Container>> containers) {
       return null;
     }
     @Override
@@ -125,10 +127,11 @@ public class TestSchedulerNegotiator ext
   
   @Test
   public void testSchedulerNegotiator() throws Exception {
-    ApplicationSubmissionContext submissionContext = new ApplicationSubmissionContext();
-    submissionContext.applicationId = new ApplicationID();
-    submissionContext.applicationId.clusterTimeStamp = System.currentTimeMillis();
-    submissionContext.applicationId.id = 1;
+    ApplicationSubmissionContext submissionContext = recordFactory.newRecordInstance(ApplicationSubmissionContext.class);
+    submissionContext.setApplicationId(recordFactory.newRecordInstance(ApplicationId.class));
+    submissionContext.getApplicationId().setClusterTimestamp(System.currentTimeMillis());
+    submissionContext.getApplicationId().setId(1);
+    
     masterInfo =
       new ApplicationMasterInfo(this.context.getDispatcher().getEventHandler(),
           "dummy", submissionContext, "dummyClientToken");
@@ -137,6 +140,6 @@ public class TestSchedulerNegotiator ext
     ALLOCATE, masterInfo));
     waitForState(ApplicationState.ALLOCATED, masterInfo);
     Container container = masterInfo.getMasterContainer();
-    assertTrue(container.id.id == testNum);
+    assertTrue(container.getId().getId() == testNum);
   }
-}
\ No newline at end of file
+}

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestNMExpiry.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestNMExpiry.java?rev=1087462&r1=1087461&r2=1087462&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestNMExpiry.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestNMExpiry.java Thu Mar 31 22:23:22 2011
@@ -29,25 +29,30 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.net.Node;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.Container;
+import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.factories.RecordFactory;
+import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
+import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatRequest;
+import org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerRequest;
+import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse;
+import org.apache.hadoop.yarn.server.api.records.NodeId;
+import org.apache.hadoop.yarn.server.api.records.RegistrationResponse;
 import org.apache.hadoop.yarn.server.resourcemanager.resourcetracker.NodeInfo;
 import org.apache.hadoop.yarn.server.resourcemanager.resourcetracker.RMResourceTrackerImpl;
 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.ResourceListener;
 import org.apache.hadoop.yarn.server.security.ContainerTokenSecretManager;
-import org.apache.hadoop.yarn.ApplicationID;
-import org.apache.hadoop.yarn.Container;
-import org.apache.hadoop.yarn.HeartbeatResponse;
-import org.apache.hadoop.yarn.NodeID;
-import org.apache.hadoop.yarn.RegistrationResponse;
-import org.apache.hadoop.yarn.Resource;
 import org.junit.Before;
 import org.junit.Test;
 
 public class TestNMExpiry extends TestCase {
   private static final Log LOG = LogFactory.getLog(TestNMExpiry.class);
-
+  private static final RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
+  
   RMResourceTrackerImpl resourceTracker;
   ContainerTokenSecretManager containerTokenSecretManager = 
     new ContainerTokenSecretManager();
@@ -56,7 +61,7 @@ public class TestNMExpiry extends TestCa
 
   private static class VoidResourceListener implements ResourceListener {
     @Override
-    public NodeInfo addNode(NodeID nodeId, String hostName, Node node,
+    public NodeInfo addNode(NodeId nodeId, String hostName, Node node,
         Resource capability) {
       return new NodeManager(nodeId, hostName, node, capability);
     }
@@ -65,8 +70,8 @@ public class TestNMExpiry extends TestCa
     }
     @Override
     public NodeResponse nodeUpdate(NodeInfo nodeInfo,
-        Map<CharSequence, List<Container>> containers) {
-      return new NodeResponse(new ArrayList<ApplicationID>(),
+        Map<String, List<Container>> containers) {
+      return new NodeResponse(new ArrayList<ApplicationId>(),
           new ArrayList<Container>(), new ArrayList<Container>());
     }
   }
@@ -78,8 +83,8 @@ public class TestNMExpiry extends TestCa
     }
 
     @Override
-    protected void expireNMs(List<NodeID> ids) {
-      for (NodeID id: ids) {
+    protected void expireNMs(List<NodeId> ids) {
+      for (NodeId id: ids) {
         LOG.info("Expired  " + id);
         if (test.addAndGet(1) == 2) {
           try {
@@ -108,13 +113,15 @@ public class TestNMExpiry extends TestCa
 
   private class TestThread extends Thread {
     public void run() {
-      HeartbeatResponse res = new HeartbeatResponse();
+      HeartbeatResponse res = recordFactory.newRecordInstance(HeartbeatResponse.class);
       while (!stopT) {
         try {
-          org.apache.hadoop.yarn.NodeStatus nodeStatus = new org.apache.hadoop.yarn.NodeStatus();
-          nodeStatus.nodeId = response.nodeID;
-          nodeStatus.responseId = res.responseId;
-          res = resourceTracker.nodeHeartbeat(nodeStatus);
+          org.apache.hadoop.yarn.server.api.records.NodeStatus nodeStatus = recordFactory.newRecordInstance(org.apache.hadoop.yarn.server.api.records.NodeStatus.class);
+          nodeStatus.setNodeId(response.getNodeId());
+          nodeStatus.setResponseId(res.getResponseId());
+          NodeHeartbeatRequest request = recordFactory.newRecordInstance(NodeHeartbeatRequest.class);
+          request.setNodeStatus(nodeStatus);
+          res = resourceTracker.nodeHeartbeat(request).getHeartbeatResponse();
         } catch(Exception e) {
           LOG.info("failed to heartbeat ", e);
         }
@@ -130,10 +137,19 @@ public class TestNMExpiry extends TestCa
     String hostname1 = "localhost:1";
     String hostname2 = "localhost:2";
     String hostname3 = "localhost:3";
-    Resource capability = new Resource();
-    resourceTracker.registerNodeManager(hostname1, capability);
-    resourceTracker.registerNodeManager(hostname2, capability);
-    response = resourceTracker.registerNodeManager(hostname3, capability);
+    Resource capability = recordFactory.newRecordInstance(Resource.class);
+    RegisterNodeManagerRequest request1 = recordFactory.newRecordInstance(RegisterNodeManagerRequest.class);
+    request1.setNode(hostname1);
+    request1.setResource(capability);
+    RegisterNodeManagerRequest request2 = recordFactory.newRecordInstance(RegisterNodeManagerRequest.class);
+    request2.setNode(hostname2);
+    request2.setResource(capability);
+    RegisterNodeManagerRequest request3 = recordFactory.newRecordInstance(RegisterNodeManagerRequest.class);
+    request3.setNode(hostname3);
+    request3.setResource(capability);
+    resourceTracker.registerNodeManager(request1);
+    resourceTracker.registerNodeManager(request2);
+    response = resourceTracker.registerNodeManager(request3).getRegistrationResponse();
     /* test to see if hostanme 3 does not expire */
     stopT = false;
     new TestThread().start();

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestRMNMRPCResponseId.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestRMNMRPCResponseId.java?rev=1087462&r1=1087461&r2=1087462&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestRMNMRPCResponseId.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestRMNMRPCResponseId.java Thu Mar 31 22:23:22 2011
@@ -24,33 +24,38 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.hadoop.net.Node;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.Container;
+import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.hadoop.yarn.factories.RecordFactory;
+import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
+import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatRequest;
+import org.apache.hadoop.yarn.server.api.protocolrecords.RegisterNodeManagerRequest;
+import org.apache.hadoop.yarn.server.api.records.HeartbeatResponse;
+import org.apache.hadoop.yarn.server.api.records.NodeId;
 import org.apache.hadoop.yarn.server.resourcemanager.resourcetracker.NodeInfo;
 import org.apache.hadoop.yarn.server.resourcemanager.resourcetracker.RMResourceTrackerImpl;
 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.ResourceListener;
 import org.apache.hadoop.yarn.server.security.ContainerTokenSecretManager;
-import org.apache.hadoop.yarn.ApplicationID;
-import org.apache.hadoop.yarn.Container;
-import org.apache.hadoop.yarn.HeartbeatResponse;
-import org.apache.hadoop.yarn.NodeID;
-import org.apache.hadoop.yarn.Resource;
 import org.junit.After;
 import org.junit.Before;
 
 import junit.framework.TestCase;
 
 public class TestRMNMRPCResponseId extends TestCase {
+  private static final RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
   RMResourceTrackerImpl rmResourceTrackerImpl;
   ContainerTokenSecretManager containerTokenSecretManager =
     new ContainerTokenSecretManager();
   ResourceListener listener = new DummyResourceListener();
-  private NodeID nodeid;
+  private NodeId nodeid;
   
   private class DummyResourceListener implements ResourceListener {
 
     @Override
-    public NodeInfo addNode(NodeID nodeId, String hostName, Node node,
+    public NodeInfo addNode(NodeId nodeId, String hostName, Node node,
         Resource capability) {
       nodeid = nodeId;
       return new NodeManager(nodeId, hostName, node, capability);
@@ -63,8 +68,8 @@ public class TestRMNMRPCResponseId exten
 
     @Override
     public NodeResponse nodeUpdate(NodeInfo nodeInfo,
-        Map<CharSequence, List<Container>> containers) {
-      return new NodeResponse(new ArrayList<ApplicationID>(),
+        Map<String, List<Container>> containers) {
+      return new NodeResponse(new ArrayList<ApplicationId>(),
           new ArrayList<Container>(), new ArrayList<Container>());
     }
   }
@@ -81,21 +86,28 @@ public class TestRMNMRPCResponseId exten
   
   public void testRPCResponseId() throws IOException {
     String node = "localhost";
-    Resource capability = new Resource();
-    rmResourceTrackerImpl.registerNodeManager(node, capability);
-    org.apache.hadoop.yarn.NodeStatus nodeStatus = new org.apache.hadoop.yarn.NodeStatus();
-    nodeStatus.nodeId = nodeid;
-    nodeStatus.responseId = 0;
-    HeartbeatResponse response = rmResourceTrackerImpl.nodeHeartbeat(nodeStatus);
-    assertTrue(response.responseId == 1);
-    nodeStatus.responseId = response.responseId;
-    response = rmResourceTrackerImpl.nodeHeartbeat(nodeStatus);
-    assertTrue(response.responseId == 2);   
+    Resource capability = recordFactory.newRecordInstance(Resource.class);
+    RegisterNodeManagerRequest request = recordFactory.newRecordInstance(RegisterNodeManagerRequest.class);
+    request.setNode(node);
+    request.setResource(capability);
+    rmResourceTrackerImpl.registerNodeManager(request);
+    org.apache.hadoop.yarn.server.api.records.NodeStatus nodeStatus = recordFactory.newRecordInstance(org.apache.hadoop.yarn.server.api.records.NodeStatus.class);
+    nodeStatus.setNodeId(nodeid);
+    nodeStatus.setResponseId(0);
+    NodeHeartbeatRequest hbRequest = recordFactory.newRecordInstance(NodeHeartbeatRequest.class);
+    hbRequest.setNodeStatus(nodeStatus);
+    HeartbeatResponse response = rmResourceTrackerImpl.nodeHeartbeat(hbRequest).getHeartbeatResponse();
+    assertTrue(response.getResponseId() == 1);
+    nodeStatus.setResponseId(response.getResponseId());
+    hbRequest.setNodeStatus(nodeStatus);
+    response = rmResourceTrackerImpl.nodeHeartbeat(hbRequest).getHeartbeatResponse();
+    assertTrue(response.getResponseId() == 2);   
     /* try calling with less response id */
-    response = rmResourceTrackerImpl.nodeHeartbeat(nodeStatus);
-    assertTrue(response.responseId == 2);   
-    nodeStatus.responseId = 0;
-    response = rmResourceTrackerImpl.nodeHeartbeat(nodeStatus);
-    assertTrue(response.reboot == true);
+    response = rmResourceTrackerImpl.nodeHeartbeat(hbRequest).getHeartbeatResponse();
+    assertTrue(response.getResponseId() == 2);   
+    nodeStatus.setResponseId(0);
+    hbRequest.setNodeStatus(nodeStatus);
+    response = rmResourceTrackerImpl.nodeHeartbeat(hbRequest).getHeartbeatResponse();
+    assertTrue(response.getReboot() == true);
   }
 }
\ No newline at end of file

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java?rev=1087462&r1=1087461&r2=1087462&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java Thu Mar 31 22:23:22 2011
@@ -24,7 +24,11 @@ import java.io.IOException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.net.NetworkTopology;
+import org.apache.hadoop.yarn.api.records.Priority;
+import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.factories.RecordFactory;
+import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
 import org.apache.hadoop.yarn.server.resourcemanager.Application;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
 import org.apache.hadoop.yarn.server.resourcemanager.Task;
@@ -32,8 +36,6 @@ import org.apache.hadoop.yarn.server.res
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
-import org.apache.hadoop.yarn.Priority;
-import org.apache.hadoop.yarn.Resource;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -43,6 +45,7 @@ import junit.framework.TestCase;
 
 public class TestCapacityScheduler extends TestCase {
   private static final Log LOG = LogFactory.getLog(TestCapacityScheduler.class);
+  private static final RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
   
   private ResourceManager resourceManager = null;
   
@@ -233,12 +236,12 @@ public class TestCapacityScheduler exten
   
   private void checkApplicationResourceUsage(int expected, 
       Application application) {
-    Assert.assertEquals(expected, application.getUsedResources().memory);
+    Assert.assertEquals(expected, application.getUsedResources().getMemory());
   }
   
   private void checkNodeResourceUsage(int expected,
       org.apache.hadoop.yarn.server.resourcemanager.NodeManager node) {
-    Assert.assertEquals(expected, node.getUsed().memory);
+    Assert.assertEquals(expected, node.getUsed().getMemory());
     node.checkResourceUsage();
   }
 

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/TestFifoScheduler.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/TestFifoScheduler.java?rev=1087462&r1=1087461&r2=1087462&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/TestFifoScheduler.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/TestFifoScheduler.java Thu Mar 31 22:23:22 2011
@@ -24,12 +24,14 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.net.NetworkTopology;
+import org.apache.hadoop.yarn.api.records.Priority;
+import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.hadoop.yarn.factories.RecordFactory;
+import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
 import org.apache.hadoop.yarn.server.resourcemanager.Application;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
 import org.apache.hadoop.yarn.server.resourcemanager.Task;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.NodeManager;
-import org.apache.hadoop.yarn.Priority;
-import org.apache.hadoop.yarn.Resource;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -39,6 +41,7 @@ import junit.framework.TestCase;
 
 public class TestFifoScheduler extends TestCase {
   private static final Log LOG = LogFactory.getLog(TestFifoScheduler.class);
+  private static final RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
   
   private ResourceManager resourceManager = null;
   
@@ -272,12 +275,12 @@ public class TestFifoScheduler extends T
   
   private void checkApplicationResourceUsage(int expected, 
       Application application) {
-    Assert.assertEquals(expected, application.getUsedResources().memory);
+    Assert.assertEquals(expected, application.getUsedResources().getMemory());
   }
   
   private void checkNodeResourceUsage(int expected,
       org.apache.hadoop.yarn.server.resourcemanager.NodeManager node) {
-    Assert.assertEquals(expected, node.getUsed().memory);
+    Assert.assertEquals(expected, node.getUsed().getMemory());
     node.checkResourceUsage();
   }
 

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java?rev=1087462&r1=1087461&r2=1087462&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java Thu Mar 31 22:23:22 2011
@@ -31,6 +31,11 @@ import static org.apache.hadoop.yarn.web
 
 import org.apache.hadoop.yarn.Application;
 import org.apache.hadoop.yarn.MockApps;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationMaster;
+import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
+import org.apache.hadoop.yarn.factories.RecordFactory;
+import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
 import org.apache.hadoop.yarn.server.resourcemanager.MockNodes;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
 import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.AppContext;
@@ -43,9 +48,6 @@ import org.apache.hadoop.yarn.server.res
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
 import org.apache.hadoop.yarn.webapp.WebApps;
 import org.apache.hadoop.yarn.webapp.test.WebAppTests;
-import org.apache.hadoop.yarn.ApplicationID;
-import org.apache.hadoop.yarn.ApplicationMaster;
-import org.apache.hadoop.yarn.ApplicationSubmissionContext;
 
 import org.junit.Test;
 import static org.junit.Assert.*;
@@ -53,10 +55,11 @@ import static org.mockito.Mockito.*;
 
 public class TestRMWebApp {
   static final int GiB = 1024; // MiB
+  private static final RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
 
   static class TestAsm implements ApplicationsManager {
     final List<Application> appsList;
-    final Map<ApplicationID, Application> appsMap = Maps.newHashMap();
+    final Map<ApplicationId, Application> appsMap = Maps.newHashMap();
 
     TestAsm(int n) {
       appsList = MockApps.genApps(n);
@@ -66,17 +69,17 @@ public class TestRMWebApp {
     }
 
     @Override
-    public ApplicationID getNewApplicationID() {
+    public ApplicationId getNewApplicationID() {
       throw new UnsupportedOperationException("Not supported yet.");
     }
 
     @Override
-    public ApplicationMaster getApplicationMaster(ApplicationID applicationId) {
+    public ApplicationMaster getApplicationMaster(ApplicationId applicationId) {
       throw new UnsupportedOperationException("Not supported yet.");
     }
 
     @Override
-    public Application getApplication(ApplicationID applicationID) {
+    public Application getApplication(ApplicationId applicationID) {
       return appsMap.get(applicationID);
     }
 
@@ -86,7 +89,7 @@ public class TestRMWebApp {
     }
 
     @Override
-    public void finishApplication(ApplicationID applicationId) throws IOException {
+    public void finishApplication(ApplicationId applicationId) throws IOException {
       throw new UnsupportedOperationException("Not supported yet.");
     }
 

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java?rev=1087462&r1=1087461&r2=1087462&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java Thu Mar 31 22:23:22 2011
@@ -27,6 +27,7 @@ import org.apache.hadoop.NodeHealthCheck
 import org.apache.hadoop.fs.FileContext;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.yarn.YarnException;
+import org.apache.hadoop.yarn.server.api.ResourceTracker;
 import org.apache.hadoop.yarn.event.Dispatcher;
 import org.apache.hadoop.yarn.server.nodemanager.NMConfig;
 import org.apache.hadoop.yarn.server.nodemanager.NodeManager;
@@ -139,7 +140,7 @@ public class MiniYARNCluster extends Com
             return new NodeStatusUpdaterImpl(context, dispatcher,
                 healthChecker) {
               @Override
-              protected org.apache.hadoop.yarn.ResourceTracker getRMClient() {
+              protected ResourceTracker getRMClient() {
                 // For in-process communication without RPC
                 return resourceManager.getResourceTracker();
               };

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerTokenSecretManager.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerTokenSecretManager.java?rev=1087462&r1=1087461&r2=1087462&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerTokenSecretManager.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerTokenSecretManager.java Thu Mar 31 22:23:22 2011
@@ -24,13 +24,11 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 
 import junit.framework.Assert;
 
 import org.apache.avro.AvroRuntimeException;
-import org.apache.avro.ipc.AvroRemoteException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
@@ -45,8 +43,26 @@ import org.apache.hadoop.security.UserGr
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.yarn.Application;
 import org.apache.hadoop.yarn.YarnException;
+import org.apache.hadoop.yarn.api.AMRMProtocol;
+import org.apache.hadoop.yarn.api.ContainerManager;
+import org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusRequest;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationState;
+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.ContainerId;
+import org.apache.hadoop.yarn.api.records.ContainerToken;
+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.api.records.URL;
 import org.apache.hadoop.yarn.conf.YARNApplicationConstants;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
+import org.apache.hadoop.yarn.factories.RecordFactory;
+import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
 import org.apache.hadoop.yarn.ipc.YarnRPC;
 import org.apache.hadoop.yarn.security.ApplicationTokenIdentifier;
 import org.apache.hadoop.yarn.security.ApplicationTokenSecretManager;
@@ -56,31 +72,19 @@ import org.apache.hadoop.yarn.security.S
 import org.apache.hadoop.yarn.server.nodemanager.NodeManager;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
 import org.apache.hadoop.yarn.server.security.ContainerTokenSecretManager;
-import org.apache.hadoop.yarn.util.AvroUtil;
-import org.apache.hadoop.yarn.AMRMProtocol;
-import org.apache.hadoop.yarn.ApplicationID;
-import org.apache.hadoop.yarn.ApplicationState;
-import org.apache.hadoop.yarn.ApplicationStatus;
-import org.apache.hadoop.yarn.ApplicationSubmissionContext;
-import org.apache.hadoop.yarn.Container;
-import org.apache.hadoop.yarn.ContainerID;
-import org.apache.hadoop.yarn.ContainerManager;
-import org.apache.hadoop.yarn.ContainerToken;
-import org.apache.hadoop.yarn.Priority;
-import org.apache.hadoop.yarn.Resource;
-import org.apache.hadoop.yarn.ResourceRequest;
-import org.apache.hadoop.yarn.URL;
+import org.apache.hadoop.yarn.util.ConverterUtils;
 import org.junit.Test;
 
 public class TestContainerTokenSecretManager {
 
   private static Log LOG = LogFactory
       .getLog(TestContainerTokenSecretManager.class);
+  private static final RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
 
   @Test
   public void test() throws IOException, InterruptedException {
-    final ContainerID containerID = new ContainerID();
-    containerID.appID = new ApplicationID();
+    final ContainerId containerID = recordFactory.newRecordInstance(ContainerId.class);
+    containerID.setAppId(recordFactory.newRecordInstance(ApplicationId.class));
     ContainerTokenSecretManager secretManager =
         new ContainerTokenSecretManager();
     final Configuration conf = new Configuration();
@@ -100,21 +104,20 @@ public class TestContainerTokenSecretMan
     final YarnRPC yarnRPC = YarnRPC.create(conf);
 
     // Submit an application
-    ApplicationSubmissionContext appSubmissionContext =
-        new ApplicationSubmissionContext();
-    appSubmissionContext.applicationId = containerID.appID;
-    appSubmissionContext.masterCapability = new Resource();
-    appSubmissionContext.masterCapability.memory = 1024;
-    appSubmissionContext.resources = new HashMap<CharSequence, URL>();
-    appSubmissionContext.user = "testUser";
-    appSubmissionContext.environment = new HashMap<CharSequence, CharSequence>();
-    appSubmissionContext.command = new ArrayList<CharSequence>();
-    appSubmissionContext.command.add("sleep");
-    appSubmissionContext.command.add("100");
+    ApplicationSubmissionContext appSubmissionContext = recordFactory.newRecordInstance(ApplicationSubmissionContext.class);
+    appSubmissionContext.setApplicationId(containerID.getAppId());
+    appSubmissionContext.setMasterCapability(recordFactory.newRecordInstance(Resource.class));
+    appSubmissionContext.getMasterCapability().setMemory(1024);
+//    appSubmissionContext.resources = new HashMap<String, URL>();
+    appSubmissionContext.setUser("testUser");
+//    appSubmissionContext.environment = new HashMap<String, String>();
+//    appSubmissionContext.command = new ArrayList<String>();
+    appSubmissionContext.addCommand("sleep");
+    appSubmissionContext.addCommand("100");
     URL yarnUrlForJobSubmitDir =
-        AvroUtil.getYarnUrlFromPath(FileContext.getFileContext()
+        ConverterUtils.getYarnUrlFromPath(FileContext.getFileContext()
             .makeQualified(new Path("testPath")));
-    appSubmissionContext.resources.put(
+    appSubmissionContext.setResource(
         YARNApplicationConstants.JOB_SUBMIT_DIR, yarnUrlForJobSubmitDir);
     resourceManager.getApplicationsManager().submitApplication(
         appSubmissionContext);
@@ -123,14 +126,14 @@ public class TestContainerTokenSecretMan
     int waitCounter = 0;
     Application app =
         resourceManager.getApplicationsManager().getApplication(
-            containerID.appID);
+            containerID.getAppId());
     while (app.state() != ApplicationState.LAUNCHED && waitCounter <= 20) {
       Thread.sleep(1000);
       LOG.info("Waiting for AM to be allocated a container. Current state is "
           + app.state());
       app =
           resourceManager.getApplicationsManager().getApplication(
-              containerID.appID);
+              containerID.getAppId());
     }
 
     Assert.assertTrue(ApplicationState.PENDING != app.state());
@@ -144,7 +147,7 @@ public class TestContainerTokenSecretMan
     final InetSocketAddress schedulerAddr =
         NetUtils.createSocketAddr(schedulerAddressString);
     ApplicationTokenIdentifier appTokenIdentifier =
-        new ApplicationTokenIdentifier(containerID.appID);
+        new ApplicationTokenIdentifier(containerID.getAppId());
     ApplicationTokenSecretManager appTokenSecretManager =
         new ApplicationTokenSecretManager();
     appTokenSecretManager.setMasterKey(ApplicationTokenSecretManager
@@ -168,18 +171,23 @@ public class TestContainerTokenSecretMan
           }
         });       
     List<ResourceRequest> ask = new ArrayList<ResourceRequest>();
-    ResourceRequest rr = new ResourceRequest();
-    rr.capability = new Resource();
-    rr.capability.memory = 1024;
-    rr.hostName = "*";
-    rr.numContainers = 1;
-    rr.priority = new Priority();
+    ResourceRequest rr = recordFactory.newRecordInstance(ResourceRequest.class);
+    rr.setCapability(recordFactory.newRecordInstance(Resource.class));
+    rr.getCapability().setMemory(1024);
+    rr.setHostName("*");
+    rr.setNumContainers(1);
+    rr.setPriority(recordFactory.newRecordInstance(Priority.class));
     ask.add(rr);
     ArrayList<Container> release = new ArrayList<Container>();
-    ApplicationStatus status = new ApplicationStatus();
-    status.applicationId = containerID.appID;
+    ApplicationStatus status = recordFactory.newRecordInstance(ApplicationStatus.class);
+    status.setApplicationId(containerID.getAppId());
+    
+    AllocateRequest allocateRequest = recordFactory.newRecordInstance(AllocateRequest.class);
+    allocateRequest.setApplicationStatus(status);
+    allocateRequest.addAllAsks(ask);
+    allocateRequest.addAllReleases(release);
     List<Container> allocatedContainers =
-        scheduler.allocate(status, ask, release).containers;
+        scheduler.allocate(allocateRequest).getAMResponse().getContainerList();
     ask.clear();
 
     waitCounter = 0;
@@ -187,9 +195,10 @@ public class TestContainerTokenSecretMan
         && waitCounter++ != 20) {
       LOG.info("Waiting for container to be allocated..");
       Thread.sleep(1000);
-      status.responseID++;
+      status.setResponseId(status.getResponseId() + 1);
+      allocateRequest.setApplicationStatus(status);
       allocatedContainers =
-          scheduler.allocate(status, ask, release).containers;
+          scheduler.allocate(allocateRequest).getAMResponse().getContainerList();
     }
 
     Assert.assertNotNull("Container is not allocted!", allocatedContainers);
@@ -198,13 +207,13 @@ public class TestContainerTokenSecretMan
 
     // Now talk to the NM for launching the container.
     final Container allocatedContainer = allocatedContainers.get(0);
-    ContainerToken containerToken = allocatedContainer.containerToken;
+    ContainerToken containerToken = allocatedContainer.getContainerToken();
     Token<ContainerTokenIdentifier> token =
         new Token<ContainerTokenIdentifier>(
-            containerToken.identifier.array(),
-            containerToken.password.array(), new Text(
-                containerToken.kind.toString()), new Text(
-                containerToken.service.toString()));
+            containerToken.getIdentifier().array(),
+            containerToken.getPassword().array(), new Text(
+                containerToken.getKind()), new Text(
+                containerToken.getService()));
     currentUser.addToken(token);
     conf.setClass(
         CommonConfigurationKeysPublic.HADOOP_SECURITY_INFO_CLASS_NAME,
@@ -214,11 +223,13 @@ public class TestContainerTokenSecretMan
       public Void run() {
         ContainerManager client =
             (ContainerManager) yarnRPC.getProxy(ContainerManager.class,
-                NetUtils.createSocketAddr(allocatedContainer.hostName
-                    .toString()), conf);
+                NetUtils.createSocketAddr(allocatedContainer.getHostName()
+                    ), conf);
         try {
-          client.getContainerStatus(containerID);
-        } catch (AvroRemoteException e) {
+          GetContainerStatusRequest request = recordFactory.newRecordInstance(GetContainerStatusRequest.class);
+          request.setContainerId(containerID);
+          client.getContainerStatus(request);
+        } catch (YarnRemoteException e) {
           LOG.info("Error", e);
         } catch (AvroRuntimeException e) {
           LOG.info("Got the expected exception");
@@ -229,29 +240,29 @@ public class TestContainerTokenSecretMan
 
     UserGroupInformation maliceUser =
         UserGroupInformation.createRemoteUser(currentUser.getShortUserName());
-    byte[] identifierBytes = containerToken.identifier.array();
+    byte[] identifierBytes = containerToken.getIdentifier().array();
     DataInputBuffer di = new DataInputBuffer();
     di.reset(identifierBytes, identifierBytes.length);
     ContainerTokenIdentifier dummyIdentifier = new ContainerTokenIdentifier();
     dummyIdentifier.readFields(di);
-    Resource modifiedResource = new Resource();
-    modifiedResource.memory = 2048;
+    Resource modifiedResource = recordFactory.newRecordInstance(Resource.class);
+    modifiedResource.setMemory(2048);
     ContainerTokenIdentifier modifiedIdentifier =
         new ContainerTokenIdentifier(dummyIdentifier.getContainerID(),
             dummyIdentifier.getNmHostName(), modifiedResource);
     // Malice user modifies the resource amount
     Token<ContainerTokenIdentifier> modifiedToken =
         new Token<ContainerTokenIdentifier>(modifiedIdentifier.getBytes(),
-            containerToken.password.array(), new Text(
-                containerToken.kind.toString()), new Text(
-                containerToken.service.toString()));
+            containerToken.getPassword().array(), new Text(
+                containerToken.getKind()), new Text(
+                containerToken.getService()));
     maliceUser.addToken(modifiedToken);
     maliceUser.doAs(new PrivilegedAction<Void>() {
       @Override
       public Void run() {
         try {
           yarnRPC.getProxy(ContainerManager.class, NetUtils
-              .createSocketAddr(allocatedContainer.hostName.toString()), conf);
+              .createSocketAddr(allocatedContainer.getHostName()), conf);
           fail("Connection initiation with illegally modified tokens is expected to fail.");
         } catch (YarnException e) {
           LOG.info("Error", e);



Mime
View raw message