Browse Source

Follow up on the previous commit to do with rack-awareness. Contributed by Devaraj Das.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/MR-279@1135852 13f79535-47bb-0310-9956-ffa450edef68
Devaraj Das 14 years ago
parent
commit
29a27f9051

+ 3 - 2
mapreduce/mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/rm/RMContainerAllocator.java

@@ -51,6 +51,7 @@ import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.ContainerState;
 import org.apache.hadoop.yarn.api.records.ContainerState;
 import org.apache.hadoop.yarn.api.records.Priority;
 import org.apache.hadoop.yarn.api.records.Priority;
 import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
 import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
+import org.apache.hadoop.yarn.util.RackResolver;
 
 
 /**
 /**
  * Allocates the container from the ResourceManager scheduler.
  * Allocates the container from the ResourceManager scheduler.
@@ -136,6 +137,7 @@ public class RMContainerAllocator extends RMContainerRequestor
     maxReducePreemptionLimit = conf.getFloat(
     maxReducePreemptionLimit = conf.getFloat(
         AMConstants.REDUCE_PREEMPTION_LIMIT,
         AMConstants.REDUCE_PREEMPTION_LIMIT,
         AMConstants.DEFAULT_REDUCE_PREEMPTION_LIMIT);
         AMConstants.DEFAULT_REDUCE_PREEMPTION_LIMIT);
+    RackResolver.init(conf);
   }
   }
 
 
   @Override
   @Override
@@ -616,8 +618,7 @@ public class RMContainerAllocator extends RMContainerRequestor
           }
           }
         }
         }
         if (assigned == null) {
         if (assigned == null) {
-          // TODO: get rack
-          String rack = "";
+          String rack = RackResolver.resolve(host).getNetworkLocation();
           list = mapsRackMapping.get(rack);
           list = mapsRackMapping.get(rack);
           while (list != null && list.size() > 0) {
           while (list != null && list.size() > 0) {
             TaskAttemptId tId = list.removeFirst();
             TaskAttemptId tId = list.removeFirst();