hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ka...@apache.org
Subject [1/2] hadoop git commit: YARN-2168. [YARN-2139] Avoid over-allocation of disk resources. (Wei Yan via kasha)
Date Mon, 15 Dec 2014 19:50:16 GMT
Repository: hadoop
Updated Branches:
  refs/heads/YARN-2139 6e13fc62e -> bad01fe30


http://git-wip-us.apache.org/repos/asf/hadoop/blob/bad01fe3/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerTestBase.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerTestBase.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerTestBase.java
index 7b6aaf3..c6bab00 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerTestBase.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerTestBase.java
@@ -102,8 +102,15 @@ public class FairSchedulerTestBase {
   protected ResourceRequest createResourceRequest(
       int memory, int vcores, String host, int priority, int numContainers,
       boolean relaxLocality) {
+    return createResourceRequest(memory, vcores, 0, host, priority,
+        numContainers, relaxLocality);
+  }
+
+  protected ResourceRequest createResourceRequest(
+      int memory, int vcores, int vDisks, String host, int priority,
+      int numContainers, boolean relaxLocality) {
     ResourceRequest request = recordFactory.newRecordInstance(ResourceRequest.class);
-    request.setCapability(BuilderUtils.newResource(memory, vcores));
+    request.setCapability(Resource.newInstance(memory, vcores, vDisks));
     request.setResourceName(host);
     request.setNumContainers(numContainers);
     Priority prio = recordFactory.newRecordInstance(Priority.class);
@@ -146,6 +153,13 @@ public class FairSchedulerTestBase {
   protected ApplicationAttemptId createSchedulingRequest(
       int memory, int vcores, String queueId, String userId, int numContainers,
       int priority) {
+    return createSchedulingRequest(memory, vcores, 0, queueId, userId,
+        numContainers, priority);
+  }
+
+  protected ApplicationAttemptId createSchedulingRequest(
+      int memory, int vcores, int vDisks, String queueId, String userId,
+      int numContainers, int priority) {
     ApplicationAttemptId id = createAppAttemptId(this.APP_ID++, this.ATTEMPT_ID++);
     scheduler.addApplication(id.getApplicationId(), queueId, userId, false);
     // This conditional is for testAclSubmitApplication where app is rejected
@@ -154,8 +168,8 @@ public class FairSchedulerTestBase {
       scheduler.addApplicationAttempt(id, false, false);
     }
     List<ResourceRequest> ask = new ArrayList<ResourceRequest>();
-    ResourceRequest request = createResourceRequest(memory, vcores, ResourceRequest.ANY,
-        priority, numContainers, true);
+    ResourceRequest request = createResourceRequest(memory, vcores, vDisks,
+        ResourceRequest.ANY, priority, numContainers, true);
     ask.add(request);
     scheduler.allocate(id, ask,  new ArrayList<ContainerId>(), null, null);
     RMApp rmApp = mock(RMApp.class);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/bad01fe3/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestAllocationFileLoaderService.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestAllocationFileLoaderService.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestAllocationFileLoaderService.java
index 9a66a94..751d9ca 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestAllocationFileLoaderService.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestAllocationFileLoaderService.java
@@ -232,9 +232,9 @@ public class TestAllocationFileLoaderService {
     assertEquals(Resources.createResource(0),
         queueConf.getMinResources("root." + YarnConfiguration.DEFAULT_QUEUE_NAME));
 
-    assertEquals(Resources.createResource(1024, 0),
+    assertEquals(Resources.createResource(1024, 0, 0),
         queueConf.getMinResources("root.queueA"));
-    assertEquals(Resources.createResource(2048, 0),
+    assertEquals(Resources.createResource(2048, 0, 0),
         queueConf.getMinResources("root.queueB"));
     assertEquals(Resources.createResource(0),
         queueConf.getMinResources("root.queueC"));
@@ -405,9 +405,9 @@ public class TestAllocationFileLoaderService {
     assertEquals(Resources.createResource(0),
         queueConf.getMinResources("root." + YarnConfiguration.DEFAULT_QUEUE_NAME));
 
-    assertEquals(Resources.createResource(1024, 0),
+    assertEquals(Resources.createResource(1024, 0, 0),
         queueConf.getMinResources("root.queueA"));
-    assertEquals(Resources.createResource(2048, 0),
+    assertEquals(Resources.createResource(2048, 0, 0),
         queueConf.getMinResources("root.queueB"));
     assertEquals(Resources.createResource(0),
         queueConf.getMinResources("root.queueC"));

http://git-wip-us.apache.org/repos/asf/hadoop/blob/bad01fe3/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestComputeFairShares.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestComputeFairShares.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestComputeFairShares.java
index 9d8dd07..d729963 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestComputeFairShares.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestComputeFairShares.java
@@ -177,19 +177,19 @@ public class TestComputeFairShares {
    */
   @Test
   public void testCPU() {
-    scheds.add(new FakeSchedulable(Resources.createResource(0, 20),
+    scheds.add(new FakeSchedulable(Resources.createResource(0, 20, 0),
         new ResourceWeights(2.0f)));
-    scheds.add(new FakeSchedulable(Resources.createResource(0, 0),
+    scheds.add(new FakeSchedulable(Resources.createResource(0, 0, 0),
         new ResourceWeights(1.0f)));
-    scheds.add(new FakeSchedulable(Resources.createResource(0, 5),
+    scheds.add(new FakeSchedulable(Resources.createResource(0, 5, 0),
         new ResourceWeights(1.0f)));
-    scheds.add(new FakeSchedulable(Resources.createResource(0, 15),
+    scheds.add(new FakeSchedulable(Resources.createResource(0, 15, 0),
         new ResourceWeights(0.5f)));
     ComputeFairShares.computeShares(scheds,
-        Resources.createResource(0, 45), ResourceType.CPU);
+        Resources.createResource(0, 45, 0), ResourceType.CPU);
     verifyCPUShares(20, 5, 5, 15);
   }
-  
+
   /**
    * Check that a given list of shares have been assigned to this.scheds.
    */
@@ -199,7 +199,7 @@ public class TestComputeFairShares {
       Assert.assertEquals(shares[i], scheds.get(i).getFairShare().getMemory());
     }
   }
-  
+
   /**
    * Check that a given list of shares have been assigned to this.scheds.
    */

http://git-wip-us.apache.org/repos/asf/hadoop/blob/bad01fe3/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java
index 67cea37..00078cc 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java
@@ -197,7 +197,7 @@ public class TestFairScheduler extends FairSchedulerTestBase {
             5000);
     conf.setInt(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB, 1024);
     conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, 512);
-    conf.setInt(FairSchedulerConfiguration.RM_SCHEDULER_INCREMENT_ALLOCATION_MB, 
+    conf.setInt(FairSchedulerConfiguration.RM_SCHEDULER_INCREMENT_ALLOCATION_MB,
       128);
     scheduler.init(conf);
     scheduler.start();
@@ -2822,6 +2822,47 @@ public class TestFairScheduler extends FairSchedulerTestBase {
   }
 
   @Test
+  public void testNoMoreVDisksOnNode() throws IOException {
+    scheduler.init(conf);
+    scheduler.start();
+    scheduler.reinitialize(conf, resourceManager.getRMContext());
+
+    RMNode node1 = MockNodes.newNodeInfo(1, Resources.createResource(2048, 2, 2),
+        1, "127.0.0.1");
+    NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1);
+    scheduler.handle(nodeEvent1);
+
+    RMNode node2 = MockNodes.newNodeInfo(1, Resources.createResource(2048, 2, 1),
+        1, "127.0.0.2");
+    NodeAddedSchedulerEvent nodeEvent2 = new NodeAddedSchedulerEvent(node2);
+    scheduler.handle(nodeEvent2);
+
+    ApplicationAttemptId attId1 = createSchedulingRequest(1024, 1, 1, "default",
+        "user1", 2, 1);
+    FSAppAttempt app1 = scheduler.getSchedulerApp(attId1);
+    scheduler.update();
+
+    // For node1, it has enough resources for running two containers
+    NodeUpdateSchedulerEvent updateEvent1 = new NodeUpdateSchedulerEvent(node1);
+    scheduler.handle(updateEvent1);
+    assertEquals(1, app1.getLiveContainers().size());
+    scheduler.handle(updateEvent1);
+    assertEquals(2, app1.getLiveContainers().size());
+
+    ApplicationAttemptId attId2 = createSchedulingRequest(1024, 1, 1, "default",
+        "user1", 2, 1);
+    FSAppAttempt app2 = scheduler.getSchedulerApp(attId2);
+    scheduler.update();
+
+    // For node2, it can only run one container as it only has 1 vDisk.
+    NodeUpdateSchedulerEvent updateEvent2 = new NodeUpdateSchedulerEvent(node2);
+    scheduler.handle(updateEvent2);
+    assertEquals(1, app2.getLiveContainers().size());
+    scheduler.handle(updateEvent2);
+    assertEquals(1, app2.getLiveContainers().size());
+  }
+
+  @Test
   public void testBasicDRFAssignment() throws Exception {
     scheduler.init(conf);
     scheduler.start();
@@ -3455,6 +3496,7 @@ public class TestFairScheduler extends FairSchedulerTestBase {
     Configuration conf = createConfiguration();
     conf.setBoolean(FairSchedulerConfiguration.CONTINUOUS_SCHEDULING_ENABLED,
             true);
+    conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_DISK_VDISKS, 0);
     scheduler.setRMContext(resourceManager.getRMContext());
     scheduler.init(conf);
     scheduler.start();
@@ -3510,7 +3552,7 @@ public class TestFairScheduler extends FairSchedulerTestBase {
 
     // Wait until app gets resources
     while (app.getCurrentConsumption()
-            .equals(Resources.createResource(1024, 1))) { }
+            .equals(Resources.createResource(1024, 1, 0))) { }
 
     Assert.assertEquals(2048, app.getCurrentConsumption().getMemory());
     Assert.assertEquals(2, app.getCurrentConsumption().getVirtualCores());

http://git-wip-us.apache.org/repos/asf/hadoop/blob/bad01fe3/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/policies/TestDominantResourceFairnessPolicy.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/policies/TestDominantResourceFairnessPolicy.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/policies/TestDominantResourceFairnessPolicy.java
index a5c20c1..eb7e792 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/policies/TestDominantResourceFairnessPolicy.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/policies/TestDominantResourceFairnessPolicy.java
@@ -27,7 +27,6 @@ import org.apache.hadoop.yarn.server.resourcemanager.resource.ResourceType;
 import org.apache.hadoop.yarn.server.resourcemanager.resource.ResourceWeights;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FakeSchedulable;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.Schedulable;
-import org.apache.hadoop.yarn.server.utils.BuilderUtils;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.junit.Test;
 
@@ -38,126 +37,135 @@ import org.junit.Test;
 public class TestDominantResourceFairnessPolicy {
 
   private Comparator<Schedulable> createComparator(int clusterMem,
-      int clusterCpu) {
+      int clusterCpu, int clusterVdisk) {
+    return createComparator(
+        Resource.newInstance(clusterMem, clusterCpu, clusterVdisk));
+  }
+
+  private Comparator<Schedulable> createComparator(Resource capacity) {
     DominantResourceFairnessPolicy policy = new DominantResourceFairnessPolicy();
-    policy.initialize(BuilderUtils.newResource(clusterMem, clusterCpu));
+    policy.initialize(capacity);
     return policy.getComparator();
   }
-  
-  private Schedulable createSchedulable(int memUsage, int cpuUsage) {
-    return createSchedulable(memUsage, cpuUsage, ResourceWeights.NEUTRAL, 0, 0);
+
+  private Schedulable createSchedulable(int memUsage, int cpuUsage,
+      int vdiskUsage) {
+    return createSchedulable(memUsage, cpuUsage, vdiskUsage,
+        ResourceWeights.NEUTRAL, 0, 0, 0);
   }
-  
+
   private Schedulable createSchedulable(int memUsage, int cpuUsage,
-      int minMemShare, int minCpuShare) {
-    return createSchedulable(memUsage, cpuUsage, ResourceWeights.NEUTRAL,
-        minMemShare, minCpuShare);
+      int vdiskUsage, int minMemShare, int minCpuShare, int minVdiskShare) {
+    return createSchedulable(memUsage, cpuUsage, vdiskUsage,
+        ResourceWeights.NEUTRAL, minMemShare, minCpuShare, minVdiskShare);
   }
-  
   private Schedulable createSchedulable(int memUsage, int cpuUsage,
-      ResourceWeights weights) {
-    return createSchedulable(memUsage, cpuUsage, weights, 0, 0);
+      int vdiskUsage, ResourceWeights weights) {
+    return createSchedulable(memUsage, cpuUsage, vdiskUsage, weights, 0, 0, 0);
   }
 
-  
   private Schedulable createSchedulable(int memUsage, int cpuUsage,
-      ResourceWeights weights, int minMemShare, int minCpuShare) {
-    Resource usage = BuilderUtils.newResource(memUsage, cpuUsage);
-    Resource minShare = BuilderUtils.newResource(minMemShare, minCpuShare);
+      int vdiskUsage, ResourceWeights weights, int minMemShare,
+      int minCpuShare, int minVdiskShare) {
+    Resource usage = Resource.newInstance(memUsage, cpuUsage, vdiskUsage);
+    Resource minShare =
+        Resource.newInstance(minMemShare, minCpuShare, minVdiskShare);
     return new FakeSchedulable(minShare,
         Resources.createResource(Integer.MAX_VALUE, Integer.MAX_VALUE),
         weights, Resources.none(), usage, 0l);
   }
-  
+
   @Test
   public void testSameDominantResource() {
-    assertTrue(createComparator(8000, 4).compare(
-        createSchedulable(1000, 1),
-        createSchedulable(2000, 1)) < 0);
+    assertTrue(createComparator(8000, 4, 4).compare(
+        createSchedulable(1000, 1, 1),
+        createSchedulable(2000, 1, 1)) < 0);
   }
-  
+
   @Test
   public void testDifferentDominantResource() {
-    assertTrue(createComparator(8000, 8).compare(
-        createSchedulable(4000, 3),
-        createSchedulable(2000, 5)) < 0);
+    assertTrue(createComparator(8000, 8, 20).compare(
+        createSchedulable(4000, 3, 2),
+        createSchedulable(2000, 5, 3)) < 0);
   }
-  
+
   @Test
   public void testOneIsNeedy() {
-    assertTrue(createComparator(8000, 8).compare(
-        createSchedulable(2000, 5, 0, 6),
-        createSchedulable(4000, 3, 0, 0)) < 0);
+    assertTrue(createComparator(8000, 8, 20).compare(
+        createSchedulable(2000, 5, 1, 0, 6, 0),
+        createSchedulable(4000, 3, 1, 0, 0, 0)) < 0);
   }
-  
+
   @Test
   public void testBothAreNeedy() {
-    assertTrue(createComparator(8000, 100).compare(
+    assertTrue(createComparator(8000, 100, 200).compare(
         // dominant share is 2000/8000
-        createSchedulable(2000, 5),
+        createSchedulable(2000, 5, 10),
         // dominant share is 4000/8000
-        createSchedulable(4000, 3)) < 0);
-    assertTrue(createComparator(8000, 100).compare(
+        createSchedulable(4000, 3, 6)) < 0);
+    assertTrue(createComparator(8000, 100, 200).compare(
         // dominant min share is 2/3
-        createSchedulable(2000, 5, 3000, 6),
+        createSchedulable(2000, 5, 5, 3000, 6, 6),
         // dominant min share is 4/5
-        createSchedulable(4000, 3, 5000, 4)) < 0);
+        createSchedulable(4000, 3, 3, 5000, 4, 4)) < 0);
   }
-  
+
   @Test
   public void testEvenWeightsSameDominantResource() {
-    assertTrue(createComparator(8000, 8).compare(
-        createSchedulable(3000, 1, new ResourceWeights(2.0f)),
-        createSchedulable(2000, 1)) < 0);
-    assertTrue(createComparator(8000, 8).compare(
-        createSchedulable(1000, 3, new ResourceWeights(2.0f)),
-        createSchedulable(1000, 2)) < 0);
+    assertTrue(createComparator(8000, 8, 20).compare(
+        createSchedulable(3000, 1, 2, new ResourceWeights(2.0f)),
+        createSchedulable(2000, 1, 2)) < 0);
+    assertTrue(createComparator(8000, 8, 20).compare(
+        createSchedulable(1000, 3, 6, new ResourceWeights(2.0f)),
+        createSchedulable(1000, 2, 4)) < 0);
   }
-  
+
   @Test
   public void testEvenWeightsDifferentDominantResource() {
-    assertTrue(createComparator(8000, 8).compare(
-        createSchedulable(1000, 3, new ResourceWeights(2.0f)),
-        createSchedulable(2000, 1)) < 0);
-    assertTrue(createComparator(8000, 8).compare(
-        createSchedulable(3000, 1, new ResourceWeights(2.0f)),
-        createSchedulable(1000, 2)) < 0);
+    assertTrue(createComparator(8000, 8, 20).compare(
+        createSchedulable(1000, 3, 6, new ResourceWeights(2.0f)),
+        createSchedulable(2000, 1, 2)) < 0);
+    assertTrue(createComparator(8000, 8, 20).compare(
+        createSchedulable(3000, 1, 2, new ResourceWeights(2.0f)),
+        createSchedulable(1000, 2, 4)) < 0);
   }
-  
+
   @Test
   public void testUnevenWeightsSameDominantResource() {
-    assertTrue(createComparator(8000, 8).compare(
-        createSchedulable(3000, 1, new ResourceWeights(2.0f, 1.0f)),
-        createSchedulable(2000, 1)) < 0);
-    assertTrue(createComparator(8000, 8).compare(
-        createSchedulable(1000, 3, new ResourceWeights(1.0f, 2.0f)),
-        createSchedulable(1000, 2)) < 0);
+    assertTrue(createComparator(8000, 8, 20).compare(
+        createSchedulable(3000, 1, 2, new ResourceWeights(3.0f, 2.0f, 1.0f)),
+        createSchedulable(2000, 1, 2)) < 0);
+    assertTrue(createComparator(8000, 8, 20).compare(
+        createSchedulable(1000, 3, 6, new ResourceWeights(1.0f, 2.0f, 3.0f)),
+        createSchedulable(1000, 2, 4)) < 0);
   }
-  
+
   @Test
   public void testUnevenWeightsDifferentDominantResource() {
-    assertTrue(createComparator(8000, 8).compare(
-        createSchedulable(1000, 3, new ResourceWeights(1.0f, 2.0f)),
-        createSchedulable(2000, 1)) < 0);
-    assertTrue(createComparator(8000, 8).compare(
-        createSchedulable(3000, 1, new ResourceWeights(2.0f, 1.0f)),
-        createSchedulable(1000, 2)) < 0);
+    assertTrue(createComparator(8000, 8, 20).compare(
+        createSchedulable(1000, 3, 6, new ResourceWeights(1.0f, 2.0f, 3.0f)),
+        createSchedulable(2000, 1, 2)) < 0);
+    assertTrue(createComparator(8000, 8, 20).compare(
+        createSchedulable(3000, 1, 2, new ResourceWeights(3.0f, 2.0f, 1.0f)),
+        createSchedulable(1000, 2, 4)) < 0);
   }
-  
+
   @Test
   public void testCalculateShares() {
-    Resource used = Resources.createResource(10, 5);
-    Resource capacity = Resources.createResource(100, 10);
-    ResourceType[] resourceOrder = new ResourceType[2];
+    Resource used = Resources.createResource(10, 5, 8);
+    Resource capacity = Resources.createResource(100, 10, 20);
+    ResourceType[] resourceOrder = new ResourceType[3];
     ResourceWeights shares = new ResourceWeights();
     DominantResourceFairnessPolicy.DominantResourceFairnessComparator comparator =
         new DominantResourceFairnessPolicy.DominantResourceFairnessComparator();
     comparator.calculateShares(used, capacity, shares, resourceOrder,
         ResourceWeights.NEUTRAL);
-    
+
     assertEquals(.1, shares.getWeight(ResourceType.MEMORY), .00001);
     assertEquals(.5, shares.getWeight(ResourceType.CPU), .00001);
+    assertEquals(.4, shares.getWeight(ResourceType.DISKIO), .00001);
     assertEquals(ResourceType.CPU, resourceOrder[0]);
-    assertEquals(ResourceType.MEMORY, resourceOrder[1]);
+    assertEquals(ResourceType.DISKIO, resourceOrder[1]);
+    assertEquals(ResourceType.MEMORY, resourceOrder[2]);
   }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/bad01fe3/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java
index c7c403d..08fba32 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySched.java
@@ -591,10 +591,7 @@ public class TestRMWebServicesCapacitySched extends JerseyTestBase {
 
   @Test
   public void testResourceInfo() {
-    Resource res = Resources.createResource(10, 1);
-    // If we add a new resource (e.g disks), then
-    // CapacitySchedulerPage and these RM WebServices + docs need to be updated
-    // eg. ResourceInfo
-    assertEquals("<memory:10, vCores:1>", res.toString());
+    Resource res = Resources.createResource(10, 1, 1);
+    assertEquals("<memory:10, vCores:1, vDisks:1>", res.toString());
   }
 }


Mime
View raw message