hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vino...@apache.org
Subject svn commit: r1153430 [9/9] - in /hadoop/common/branches/MR-279/mapreduce: mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/ mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/loc...
Date Wed, 03 Aug 2011 11:32:10 GMT
Modified: hadoop/common/branches/MR-279/mapreduce/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/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestNMExpiry.java?rev=1153430&r1=1153429&r2=1153430&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestNMExpiry.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestNMExpiry.java
Wed Aug  3 11:31:34 2011
@@ -22,24 +22,28 @@ import java.util.List;
 import java.util.Map;
 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;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.api.records.Container;
+import org.apache.hadoop.yarn.api.records.NodeHealthStatus;
 import org.apache.hadoop.yarn.api.records.NodeId;
 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.records.NodeHealthStatus;
+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.RegistrationResponse;
+import org.apache.hadoop.yarn.server.resourcemanager.NMLivelinessMonitor;
 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.RMContext;
+import org.apache.hadoop.yarn.server.resourcemanager.RMContextImpl;
+import org.apache.hadoop.yarn.server.resourcemanager.ResourceTrackerService;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.MemStore;
-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.rmnode.RMNode;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceListener;
 import org.apache.hadoop.yarn.server.security.ContainerTokenSecretManager;
 import org.junit.Before;
@@ -49,7 +53,7 @@ public class TestNMExpiry extends TestCa
   private static final Log LOG = LogFactory.getLog(TestNMExpiry.class);
   private static final RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
   
-  RMResourceTrackerImpl resourceTracker;
+  ResourceTrackerService resourceTrackerService;
   ContainerTokenSecretManager containerTokenSecretManager = 
     new ContainerTokenSecretManager();
   AtomicInteger test = new AtomicInteger();
@@ -58,27 +62,26 @@ public class TestNMExpiry extends TestCa
   private static class VoidResourceListener implements ResourceListener {
    
     @Override
-    public void removeNode(NodeInfo node) {
+    public void removeNode(RMNode node) {
     }
     @Override
-    public void nodeUpdate(NodeInfo nodeInfo,
+    public void nodeUpdate(RMNode nodeInfo,
         Map<String, List<Container>> containers) {
      
     }
     @Override
-    public void addNode(NodeInfo nodeInfo) {
+    public void addNode(RMNode nodeInfo) {
         
     }
   }
 
-  private class TestRMResourceTrackerImpl extends RMResourceTrackerImpl {
-    public TestRMResourceTrackerImpl(
-        ContainerTokenSecretManager containerTokenSecretManager, RMContext context) {
-      super(containerTokenSecretManager, context);
+  private class TestNmLivelinessMonitor extends NMLivelinessMonitor {
+    public TestNmLivelinessMonitor(RMContext context) {
+      super(context);
     }
 
     @Override
-    protected void expireNMs(List<NodeId> ids) {
+    protected void expireNodes(List<NodeId> ids) {
       for (NodeId id: ids) {
         LOG.info("Expired  " + id);
         if (test.addAndGet(1) == 2) {
@@ -100,14 +103,17 @@ public class TestNMExpiry extends TestCa
   @Before
   public void setUp() {
     Configuration conf = new Configuration();
-    RMContext context = new ResourceManager.RMContextImpl(new MemStore());
-    resourceTracker = new TestRMResourceTrackerImpl(containerTokenSecretManager, 
-       context);
-    resourceTracker.addListener(new VoidResourceListener());
+    RMContext context = new RMContextImpl(new MemStore());
+    NMLivelinessMonitor nmLivelinessMonitror = new TestNmLivelinessMonitor(
+        context);
+    nmLivelinessMonitror.start();
+    resourceTrackerService = new ResourceTrackerService(context,
+        nmLivelinessMonitror, containerTokenSecretManager);
+    context.getNodesCollection().addListener(new VoidResourceListener());
     
     conf.setLong(RMConfig.NM_EXPIRY_INTERVAL, 1000);
-    resourceTracker.init(conf);
-    resourceTracker.start();
+    resourceTrackerService.init(conf);
+    resourceTrackerService.start();
   }
 
   private class ThirdNodeHeartBeatThread extends Thread {
@@ -122,9 +128,13 @@ public class TestNMExpiry extends TestCa
           nodeStatus.setResponseId(lastResponseID);
           nodeStatus.setNodeHealthStatus(recordFactory.newRecordInstance(NodeHealthStatus.class));
           nodeStatus.getNodeHealthStatus().setIsNodeHealthy(true);
-          lastResponseID =
-              resourceTracker.nodeHeartbeat(nodeStatus)
-                  .getResponseId();
+
+          NodeHeartbeatRequest request = recordFactory
+              .newRecordInstance(NodeHeartbeatRequest.class);
+          request.setNodeStatus(nodeStatus);
+          lastResponseID = resourceTrackerService.nodeHeartbeat(request)
+              .getHeartbeatResponse().getResponseId();
+
         } catch(Exception e) {
           LOG.info("failed to heartbeat ", e);
         }
@@ -141,10 +151,32 @@ public class TestNMExpiry extends TestCa
     String hostname2 = "localhost2";
     String hostname3 = "localhost3";
     Resource capability = recordFactory.newRecordInstance(Resource.class);
-    resourceTracker.registerNodeManager(hostname1, 0, 0, capability);
-    resourceTracker.registerNodeManager(hostname2, 0, 0, capability);
-    thirdNodeRegResponse =
-        resourceTracker.registerNodeManager(hostname3, 0, 0, capability);
+
+    RegisterNodeManagerRequest request1 = recordFactory
+        .newRecordInstance(RegisterNodeManagerRequest.class);
+    request1.setContainerManagerPort(0);
+    request1.setHost(hostname1);
+    request1.setHttpPort(0);
+    request1.setResource(capability);
+    resourceTrackerService.registerNodeManager(request1);
+
+    RegisterNodeManagerRequest request2 = recordFactory
+        .newRecordInstance(RegisterNodeManagerRequest.class);
+    request2.setContainerManagerPort(0);
+    request2.setHost(hostname2);
+    request2.setHttpPort(0);
+    request2.setResource(capability);
+    resourceTrackerService.registerNodeManager(request2);
+
+    RegisterNodeManagerRequest request3 = recordFactory
+        .newRecordInstance(RegisterNodeManagerRequest.class);
+    request3.setContainerManagerPort(0);
+    request3.setHost(hostname3);
+    request3.setHttpPort(0);
+    request3.setResource(capability);
+    thirdNodeRegResponse = resourceTrackerService.registerNodeManager(
+        request3).getRegistrationResponse();
+
     /* test to see if hostanme 3 does not expire */
     stopT = false;
     new ThirdNodeHeartBeatThread().start();
@@ -154,8 +186,7 @@ public class TestNMExpiry extends TestCa
         notify.wait(1000);
       }
     }
-    if (test.get() != 2) 
-      assertTrue(false);
+    Assert.assertEquals(2, test.get()); 
 
     stopT = true;
   }

Modified: hadoop/common/branches/MR-279/mapreduce/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/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestRMNMRPCResponseId.java?rev=1153430&r1=1153429&r2=1153430&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestRMNMRPCResponseId.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestRMNMRPCResponseId.java
Wed Aug  3 11:31:34 2011
@@ -22,30 +22,32 @@ import java.io.IOException;
 import java.util.List;
 import java.util.Map;
 
+import junit.framework.TestCase;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.api.records.Container;
+import org.apache.hadoop.yarn.api.records.NodeHealthStatus;
 import org.apache.hadoop.yarn.api.records.NodeId;
 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.NodeHealthStatus;
-import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
-import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager.RMContext;
+import org.apache.hadoop.yarn.server.resourcemanager.NMLivelinessMonitor;
+import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
+import org.apache.hadoop.yarn.server.resourcemanager.RMContextImpl;
+import org.apache.hadoop.yarn.server.resourcemanager.ResourceTrackerService;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.MemStore;
-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.rmnode.RMNode;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceListener;
 import org.apache.hadoop.yarn.server.security.ContainerTokenSecretManager;
 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;
+  ResourceTrackerService resourceTrackerService;
   ContainerTokenSecretManager containerTokenSecretManager =
     new ContainerTokenSecretManager();
   ResourceListener listener = new DummyResourceListener();
@@ -54,27 +56,28 @@ public class TestRMNMRPCResponseId exten
   private class DummyResourceListener implements ResourceListener {
 
     @Override
-    public void addNode(NodeInfo nodeManager) {
+    public void addNode(RMNode nodeManager) {
       nodeid = nodeManager.getNodeID();
     }
 
     @Override
-    public void removeNode(NodeInfo node) {
+    public void removeNode(RMNode node) {
       /* do nothing */
     }
 
     @Override
-    public void nodeUpdate(NodeInfo nodeInfo,
+    public void nodeUpdate(RMNode nodeInfo,
         Map<String, List<Container>> containers) {
     }
   }
   
   @Before
   public void setUp() {
-    RMContext context = new ResourceManager.RMContextImpl(new MemStore());
-    rmResourceTrackerImpl = new RMResourceTrackerImpl(containerTokenSecretManager, context);
-    rmResourceTrackerImpl.init(new Configuration());
-    rmResourceTrackerImpl.addListener(listener);
+    RMContext context = new RMContextImpl(new MemStore());
+    resourceTrackerService = new ResourceTrackerService(context,
+        new NMLivelinessMonitor(context), containerTokenSecretManager);
+    resourceTrackerService.init(new Configuration());
+    context.getNodesCollection().addListener(listener);
   }
   
   @After
@@ -90,24 +93,43 @@ public class TestRMNMRPCResponseId exten
     request.setContainerManagerPort(0);
     request.setHttpPort(0);
     request.setResource(capability);
-    rmResourceTrackerImpl.registerNodeManager(node, 0, 0, capability);
+
+    RegisterNodeManagerRequest request1 = recordFactory
+        .newRecordInstance(RegisterNodeManagerRequest.class);
+    request1.setContainerManagerPort(0);
+    request1.setHost(node);
+    request1.setHttpPort(0);
+    request1.setResource(capability);
+    resourceTrackerService.registerNodeManager(request1);
+
     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);
     NodeHealthStatus nodeHealthStatus = recordFactory.newRecordInstance(NodeHealthStatus.class);
     nodeHealthStatus.setIsNodeHealthy(true);
     nodeStatus.setNodeHealthStatus(nodeHealthStatus);
-    HeartbeatResponse response = rmResourceTrackerImpl.nodeHeartbeat(nodeStatus);
+    NodeHeartbeatRequest nodeHeartBeatRequest = recordFactory
+        .newRecordInstance(NodeHeartbeatRequest.class);
+    nodeHeartBeatRequest.setNodeStatus(nodeStatus);
+
+    nodeStatus.setResponseId(0);
+    HeartbeatResponse response = resourceTrackerService.nodeHeartbeat(
+        nodeHeartBeatRequest).getHeartbeatResponse();
     assertTrue(response.getResponseId() == 1);
+
     nodeStatus.setResponseId(response.getResponseId());
-    response = rmResourceTrackerImpl.nodeHeartbeat(nodeStatus);
+    response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest)
+        .getHeartbeatResponse();
     assertTrue(response.getResponseId() == 2);   
+
     /* try calling with less response id */
-    response = rmResourceTrackerImpl.nodeHeartbeat(nodeStatus);
-    assertTrue(response.getResponseId() == 2);   
+    response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest)
+        .getHeartbeatResponse();
+    assertTrue(response.getResponseId() == 2);
+
     nodeStatus.setResponseId(0);
-    response = rmResourceTrackerImpl.nodeHeartbeat(nodeStatus);
+    response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest)
+        .getHeartbeatResponse();
     assertTrue(response.getReboot() == true);
   }
 }
\ 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/scheduler/TestQueueMetrics.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/scheduler/TestQueueMetrics.java?rev=1153430&r1=1153429&r2=1153430&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestQueueMetrics.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestQueueMetrics.java
Wed Aug  3 11:31:34 2011
@@ -27,7 +27,7 @@ public class TestQueueMetrics {
 
     QueueMetrics metrics = QueueMetrics.forQueue(ms, queueName, null, false);
     MetricsSource queueSource= queueSource(ms, queueName);
-    Application app = mockApp(user);
+    AppSchedulingInfo app = mockApp(user);
 
     metrics.submitApp(user);
     MetricsSource userSource = userSource(ms, queueName, user);
@@ -59,7 +59,7 @@ public class TestQueueMetrics {
 
     QueueMetrics metrics = QueueMetrics.forQueue(ms, queueName, null, true);
     MetricsSource queueSource = queueSource(ms, queueName);
-    Application app = mockApp(user);
+    AppSchedulingInfo app = mockApp(user);
 
     metrics.submitApp(user);
     MetricsSource userSource = userSource(ms, queueName, user);
@@ -105,7 +105,7 @@ public class TestQueueMetrics {
         QueueMetrics.forQueue(ms, leafQueueName, parentQueue, true);
     MetricsSource parentQueueSource = queueSource(ms, parentQueueName);
     MetricsSource queueSource = queueSource(ms, leafQueueName);
-    Application app = mockApp(user);
+    AppSchedulingInfo app = mockApp(user);
 
     metrics.submitApp(user);
     MetricsSource userSource = userSource(ms, leafQueueName, user);
@@ -177,8 +177,8 @@ public class TestQueueMetrics {
     assertGauge("ReservedContainers", reservedCtnrs, rb);
   }
 
-  private static Application mockApp(String user) {
-    Application app = mock(Application.class);
+  private static AppSchedulingInfo mockApp(String user) {
+    AppSchedulingInfo app = mock(AppSchedulingInfo.class);
     when(app.getState()).thenReturn(ApplicationState.RUNNING);
     when(app.getUser()).thenReturn(user);
     return app;

Modified: hadoop/common/branches/MR-279/mapreduce/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/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java?rev=1153430&r1=1153429&r2=1153430&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java
Wed Aug  3 11:31:34 2011
@@ -21,6 +21,9 @@ package org.apache.hadoop.yarn.server.re
 
 import java.io.IOException;
 
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
@@ -33,18 +36,13 @@ import org.apache.hadoop.yarn.server.res
 import org.apache.hadoop.yarn.server.resourcemanager.Task;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.Store;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.StoreFactory;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.NodeManager;
+import org.apache.hadoop.yarn.server.resourcemanager.resource.Resources;
+import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
 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.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
-import org.apache.hadoop.yarn.server.resourcemanager.resource.Resources;
-
 public class TestCapacityScheduler extends TestCase {
   private static final Log LOG = LogFactory.getLog(TestCapacityScheduler.class);
   
@@ -73,7 +71,8 @@ public class TestCapacityScheduler exten
           throws IOException {
     return new org.apache.hadoop.yarn.server.resourcemanager.NodeManager(
         hostName, containerManagerPort, httpPort, rackName, memory,
-        resourceManager.getResourceTracker());
+        resourceManager.getResourceTrackerService(), resourceManager
+            .getRMContext());
   }  
 
   @Test
@@ -160,7 +159,7 @@ public class TestCapacityScheduler exten
     LOG.info("Adding new tasks...");
     
     Task task_1_1 = new Task(application_1, priority_0, 
-        new String[] {NodeManager.ANY});
+        new String[] {RMNode.ANY});
     application_1.addTask(task_1_1);
 
     application_1.schedule();

Modified: hadoop/common/branches/MR-279/mapreduce/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/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/TestFifoScheduler.java?rev=1153430&r1=1153429&r2=1153430&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/TestFifoScheduler.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/TestFifoScheduler.java
Wed Aug  3 11:31:34 2011
@@ -20,6 +20,9 @@ package org.apache.hadoop.yarn.server.re
 
 import java.io.IOException;
 
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
@@ -31,15 +34,12 @@ import org.apache.hadoop.yarn.server.res
 import org.apache.hadoop.yarn.server.resourcemanager.Task;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.Store;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.StoreFactory;
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.NodeManager;
+import org.apache.hadoop.yarn.server.resourcemanager.resource.Resources;
+import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
-import org.apache.hadoop.yarn.server.resourcemanager.resource.Resources;
-
 public class TestFifoScheduler extends TestCase {
   private static final Log LOG = LogFactory.getLog(TestFifoScheduler.class);
   
@@ -61,7 +61,8 @@ public class TestFifoScheduler extends T
           String rackName, int memory) throws IOException {
     return new org.apache.hadoop.yarn.server.resourcemanager.NodeManager(
         hostName, containerManagerPort, nmHttpPort, rackName, memory,
-        resourceManager.getResourceTracker());
+        resourceManager.getResourceTrackerService(), resourceManager
+            .getRMContext());
   }
   
 
@@ -153,15 +154,15 @@ public class TestFifoScheduler extends T
     LOG.info("Adding new tasks...");
     
     Task task_1_1 = new Task(application_1, priority_1, 
-        new String[] {NodeManager.ANY});
+        new String[] {RMNode.ANY});
     application_1.addTask(task_1_1);
 
     Task task_1_2 = new Task(application_1, priority_1, 
-        new String[] {NodeManager.ANY});
+        new String[] {RMNode.ANY});
     application_1.addTask(task_1_2);
 
     Task task_1_3 = new Task(application_1, priority_0, 
-        new String[] {NodeManager.ANY});
+        new String[] {RMNode.ANY});
     application_1.addTask(task_1_3);
     
     application_1.schedule();
@@ -175,7 +176,7 @@ public class TestFifoScheduler extends T
     application_0.addTask(task_0_2);
     
     Task task_0_3 = new Task(application_0, priority_0, 
-        new String[] {NodeManager.ANY});
+        new String[] {RMNode.ANY});
     application_0.addTask(task_0_3);
 
     application_0.schedule();

Modified: hadoop/common/branches/MR-279/mapreduce/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/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java?rev=1153430&r1=1153429&r2=1153430&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java
Wed Aug  3 11:31:34 2011
@@ -18,8 +18,6 @@
 
 package org.apache.hadoop.yarn.server.resourcemanager.webapp;
 
-import static org.apache.hadoop.test.MockitoMaker.make;
-import static org.apache.hadoop.test.MockitoMaker.stub;
 import static org.apache.hadoop.yarn.server.resourcemanager.MockNodes.newResource;
 import static org.apache.hadoop.yarn.webapp.Params.TITLE;
 import static org.junit.Assert.assertEquals;
@@ -27,21 +25,19 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.util.List;
-import java.util.Map;
 import java.util.concurrent.ConcurrentMap;
 
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.server.resourcemanager.ApplicationsManager;
 import org.apache.hadoop.yarn.server.resourcemanager.MockNodes;
+import org.apache.hadoop.yarn.server.resourcemanager.NodesCollection;
+import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
+import org.apache.hadoop.yarn.server.resourcemanager.RMContextImpl;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
-import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager.RMContext;
-import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager.RMContextImpl;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.Application;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.AppAttempt;
 import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.MockAsm;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.MemStore;
-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.resourcetracker.RMResourceTrackerImpl;
+import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
 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;
@@ -49,7 +45,6 @@ import org.apache.hadoop.yarn.webapp.Web
 import org.apache.hadoop.yarn.webapp.test.WebAppTests;
 import org.junit.Test;
 
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.inject.Injector;
 
@@ -65,36 +60,44 @@ public class TestRMWebApp {
 
   @Test public void testView() {
     Injector injector = WebAppTests.createMockInjector(RMContext.class,
-                                                       mockRMContext(3));
+                                               mockRMContext(3, 1, 2, 8*GiB));
     injector.getInstance(RmView.class).render();
     WebAppTests.flushOutput(injector);
   }
 
   @Test public void testNodesPage() {
-    WebAppTests.testPage(NodesPage.class, ClusterTracker.class,
-                         mockResource(1, 2, 8*GiB));
+    WebAppTests.testPage(NodesPage.class, RMContext.class,
+                         mockRMContext(3, 1, 2, 8*GiB));
   }
 
-  public static RMResourceTrackerImpl mockResource(int racks, int nodes,
-                                                   int mbsPerNode) {
-    final List<NodeInfo> list =
-        MockNodes.newNodes(racks, nodes, newResource(mbsPerNode));
-    return make(stub(RMResourceTrackerImpl.class).returning(list).from.
-        getAllNodeInfo());
-  }
-
-  public static RMContext mockRMContext(int n) {
-    final List<Application> apps = MockAsm.newApplications(n);
-    final ConcurrentMap<ApplicationId, Application> map = Maps
+  public static RMContext mockRMContext(int numApps, int racks, int nodes,
+      int mbsPerNode) {
+    final List<AppAttempt> apps = MockAsm.newApplications(numApps);
+    final ConcurrentMap<ApplicationId, AppAttempt> map = Maps
         .newConcurrentMap();
-    for (Application app : apps) {
+    for (AppAttempt app : apps) {
       map.put(app.getApplicationID(), app);
     }
+    final List<RMNode> list = MockNodes.newNodes(racks, nodes,
+        newResource(mbsPerNode));
     return new RMContextImpl(new MemStore()) {
       @Override
-      public ConcurrentMap<ApplicationId, Application> getApplications() {
+      public ConcurrentMap<ApplicationId, AppAttempt> getApplications() {
         return map;
       }
+      @Override
+      public NodesCollection getNodesCollection() {
+        NodesCollection nodesCollection = new NodesCollection(new MemStore());
+        try {
+          nodesCollection.addListener(mockCapacityScheduler());
+        } catch (Exception e) {
+          e.printStackTrace();
+        }
+        for (RMNode node : list) {
+          nodesCollection.addNode(node);
+        }
+        return nodesCollection;
+      }
     };
   }
 
@@ -103,11 +106,10 @@ public class TestRMWebApp {
   throws Exception {
     ResourceManager rm = mock(ResourceManager.class);
     ApplicationsManager asm = MockAsm.create();
-    RMContext rmContext = mockRMContext(apps);
-    RMResourceTrackerImpl rt = mockResource(racks, nodes, mbsPerNode);
+    RMContext rmContext = mockRMContext(apps, racks, nodes,
+        mbsPerNode);
     ResourceScheduler rs = mockCapacityScheduler();
     when(rm.getApplicationsManager()).thenReturn(asm);
-    when(rm.getResourceTracker()).thenReturn(rt);
     when(rm.getResourceScheduler()).thenReturn(rs);
     when(rm.getRMContext()).thenReturn(rmContext);
     return rm;

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java?rev=1153430&r1=1153429&r2=1153430&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java
Wed Aug  3 11:31:34 2011
@@ -44,9 +44,9 @@ import org.apache.hadoop.yarn.server.nod
 import org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdater;
 import org.apache.hadoop.yarn.server.nodemanager.NodeStatusUpdaterImpl;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
+import org.apache.hadoop.yarn.server.resourcemanager.ResourceTrackerService;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.Store;
 import org.apache.hadoop.yarn.server.resourcemanager.recovery.StoreFactory;
-import org.apache.hadoop.yarn.server.resourcemanager.resourcetracker.RMResourceTrackerImpl;
 import org.apache.hadoop.yarn.service.AbstractService;
 import org.apache.hadoop.yarn.service.CompositeService;
 
@@ -180,7 +180,8 @@ public class MiniYARNCluster extends Com
                 healthChecker, metrics) {
               @Override
               protected ResourceTracker getRMClient() {
-                final RMResourceTrackerImpl rt = resourceManager.getResourceTracker();
+                final ResourceTrackerService rt = resourceManager
+                    .getResourceTrackerService();
                 final RecordFactory recordFactory =
                   RecordFactoryProvider.getRecordFactory(null);
 
@@ -193,8 +194,8 @@ public class MiniYARNCluster extends Com
                     NodeHeartbeatResponse response = recordFactory.newRecordInstance(
                         NodeHeartbeatResponse.class);
                     try {
-                    response.setHeartbeatResponse(
-                        rt.nodeHeartbeat(request.getNodeStatus()));
+                      response.setHeartbeatResponse(rt.nodeHeartbeat(request)
+                          .getHeartbeatResponse());
                     } catch (IOException ioe) {
                       LOG.info("Exception in heartbeat from node " + 
                           request.getNodeStatus().getNodeId(), ioe);
@@ -210,10 +211,9 @@ public class MiniYARNCluster extends Com
                     RegisterNodeManagerResponse response = recordFactory.newRecordInstance(
                         RegisterNodeManagerResponse.class);
                     try {
-                      response.setRegistrationResponse(
-                          rt.registerNodeManager(
-                              request.getHost(), request.getContainerManagerPort(), 
-                              request.getHttpPort(), request.getResource()));
+                      response.setRegistrationResponse(rt
+                          .registerNodeManager(request)
+                          .getRegistrationResponse());
                     } catch (IOException ioe) {
                       LOG.info("Exception in node registration from " + request.getHost(),
ioe);
                       throw RPCUtil.getRemoteException(ioe);

Modified: hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerTokenSecretManager.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerTokenSecretManager.java?rev=1153430&r1=1153429&r2=1153430&view=diff
==============================================================================
--- hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerTokenSecretManager.java
(original)
+++ hadoop/common/branches/MR-279/mapreduce/yarn/yarn-server/yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerTokenSecretManager.java
Wed Aug  3 11:31:34 2011
@@ -80,7 +80,7 @@ import org.apache.hadoop.yarn.security.C
 import org.apache.hadoop.yarn.security.ContainerTokenIdentifier;
 import org.apache.hadoop.yarn.security.SchedulerSecurityInfo;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
-import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.Application;
+import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.AppAttempt;
 import org.apache.hadoop.yarn.util.ConverterUtils;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -163,7 +163,7 @@ public class TestContainerTokenSecretMan
 
     // Wait till container gets allocated for AM
     int waitCounter = 0;
-    Application app =
+    AppAttempt app =
         resourceManager.getRMContext().getApplications().get(appID);
     while (app.getState() != ApplicationState.LAUNCHED && waitCounter <= 20) {
       Thread.sleep(1000);



Mime
View raw message