Ver Fonte

YARN-7564. Cleanup to fix checkstyle issues of YARN-5881 branch. Contributed by Sunil G.

Sunil G há 7 anos atrás
pai
commit
3f40fdc8b7
9 ficheiros alterados com 70 adições e 45 exclusões
  1. 9 9
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/StringUtils.java
  2. 5 5
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueConfigurationsPBImpl.java
  3. 1 1
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/resource/DominantResourceCalculator.java
  4. 5 7
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/resource/ResourceCalculator.java
  5. 7 1
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AbstractResourceUsage.java
  6. 0 6
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/ResourceUsage.java
  7. 25 3
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CSQueue.java
  8. 17 11
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerConfiguration.java
  9. 1 2
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestReservations.java

+ 9 - 9
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/StringUtils.java

@@ -1171,16 +1171,16 @@ public class StringUtils {
    * @return <code>true</code> if only contains letters, and is non-null
    */
   public static boolean isAlpha(String str) {
-      if (str == null) {
-          return false;
-      }
-      int sz = str.length();
-      for (int i = 0; i < sz; i++) {
-          if (Character.isLetter(str.charAt(i)) == false) {
-              return false;
-          }
+    if (str == null) {
+      return false;
+    }
+    int sz = str.length();
+    for (int i = 0; i < sz; i++) {
+      if (!Character.isLetter(str.charAt(i))) {
+        return false;
       }
-      return true;
+    }
+    return true;
   }
 
 }

+ 5 - 5
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueConfigurationsPBImpl.java

@@ -236,12 +236,12 @@ public class QueueConfigurationsPBImpl extends QueueConfigurations {
   }
 
   @Override
-  public void setConfiguredMinCapacity(Resource configuredMinResource) {
+  public void setConfiguredMinCapacity(Resource minResource) {
     maybeInitBuilder();
-    if (configuredMinResource == null) {
+    if (minResource == null) {
       builder.clearConfiguredMinCapacity();
     }
-    this.configuredMinResource = configuredMinResource;
+    this.configuredMinResource = minResource;
   }
 
   @Override
@@ -259,11 +259,11 @@ public class QueueConfigurationsPBImpl extends QueueConfigurations {
   }
 
   @Override
-  public void setConfiguredMaxCapacity(Resource configuredMaxResource) {
+  public void setConfiguredMaxCapacity(Resource maxResource) {
     maybeInitBuilder();
     if (configuredMaxResource == null) {
       builder.clearConfiguredMaxCapacity();
     }
-    this.configuredMaxResource = configuredMaxResource;
+    this.configuredMaxResource = maxResource;
   }
 }

+ 1 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/resource/DominantResourceCalculator.java

@@ -515,7 +515,7 @@ public class DominantResourceCalculator extends ResourceCalculator {
     }
     return ret;
   }
-  
+
   @Override
   public Resource multiplyAndNormalizeUp(Resource r, double by,
       Resource stepFactor) {

+ 5 - 7
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/resource/ResourceCalculator.java

@@ -127,12 +127,12 @@ public abstract class ResourceCalculator {
       Resource r, double by, Resource stepFactor);
 
   /**
-   * Multiply resource <code>r</code> by factor <code>by</code> 
+   * Multiply resource <code>r</code> by factor <code>by</code>
    * and normalize up using step-factor <code>stepFactor</code>.
-   * 
+   *
    * @param r resource to be multiplied
    * @param by multiplier array for all resource types
-   * @param stepFactor factor by which to normalize up 
+   * @param stepFactor factor by which to normalize up
    * @return resulting normalized resource
    */
   public abstract Resource multiplyAndNormalizeUp(
@@ -149,7 +149,7 @@ public abstract class ResourceCalculator {
    */
   public abstract Resource multiplyAndNormalizeDown(
       Resource r, double by, Resource stepFactor);
-  
+
   /**
    * Normalize resource <code>r</code> given the base 
    * <code>minimumResource</code> and verify against max allowed
@@ -162,9 +162,7 @@ public abstract class ResourceCalculator {
    * @return normalized resource
    */
   public abstract Resource normalize(Resource r, Resource minimumResource,
-                                     Resource maximumResource, 
-                                     Resource stepFactor);
-
+      Resource maximumResource, Resource stepFactor);
 
   /**
    * Round-up resource <code>r</code> given factor <code>stepFactor</code>.

+ 7 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AbstractResourceUsage.java

@@ -55,7 +55,10 @@ public class AbstractResourceUsage {
     usages.put(CommonNodeLabelsManager.NO_LABEL, noLabelUsages);
   }
 
-  // Usage enum here to make implement cleaner
+  /**
+   * Use enum here to make implementation more cleaner and readable.
+   * Indicates array index for each resource usage type.
+   */
   public enum ResourceType {
     // CACHED_USED and CACHED_PENDING may be read by anyone, but must only
     // be written by ordering policies
@@ -70,6 +73,9 @@ public class AbstractResourceUsage {
     }
   }
 
+  /**
+   * UsageByLabel stores resource array for all resource usage types.
+   */
   public static class UsageByLabel {
     // usage by label, contains all UsageType
     private final AtomicReferenceArray<Resource> resArr;

+ 0 - 6
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/ResourceUsage.java

@@ -18,13 +18,7 @@
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler;
 
-import java.util.HashMap;
-import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
 
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager;

+ 25 - 3
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CSQueue.java

@@ -366,7 +366,7 @@ public interface CSQueue extends SchedulerQueue<CSQueue> {
   public QueueResourceQuotas getQueueResourceQuotas();
 
   /**
-   * Get CapacityConfigType as PERCENTAGE or ABSOLUTE_RESOURCE
+   * Get CapacityConfigType as PERCENTAGE or ABSOLUTE_RESOURCE.
    * @return CapacityConfigType
    */
   public CapacityConfigType getCapacityConfigType();
@@ -374,24 +374,46 @@ public interface CSQueue extends SchedulerQueue<CSQueue> {
   /**
    * Get effective capacity of queue. If min/max resource is configured,
    * preference will be given to absolute configuration over normal capacity.
-   * Also round down the result to normalizeDown.
    *
    * @param label
    *          partition
    * @return effective queue capacity
    */
   Resource getEffectiveCapacity(String label);
+
+  /**
+   * Get effective capacity of queue. If min/max resource is configured,
+   * preference will be given to absolute configuration over normal capacity.
+   * Also round down the result to normalizeDown.
+   *
+   * @param label
+   *          partition
+   * @param factor
+   *          factor to normalize down 
+   * @return effective queue capacity
+   */
   Resource getEffectiveCapacityDown(String label, Resource factor);
 
   /**
    * Get effective max capacity of queue. If min/max resource is configured,
    * preference will be given to absolute configuration over normal capacity.
-   * Also round down the result to normalizeDown.
    *
    * @param label
    *          partition
    * @return effective max queue capacity
    */
   Resource getEffectiveMaxCapacity(String label);
+
+  /**
+   * Get effective max capacity of queue. If min/max resource is configured,
+   * preference will be given to absolute configuration over normal capacity.
+   * Also round down the result to normalizeDown.
+   *
+   * @param label
+   *          partition
+   * @param factor
+   *          factor to normalize down 
+   * @return effective max queue capacity
+   */
   Resource getEffectiveMaxCapacityDown(String label, Resource factor);
 }

+ 17 - 11
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerConfiguration.java

@@ -32,6 +32,7 @@ import org.apache.hadoop.yarn.api.records.QueueACL;
 import org.apache.hadoop.yarn.api.records.QueueState;
 import org.apache.hadoop.yarn.api.records.ReservationACL;
 import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.hadoop.yarn.api.records.ResourceInformation;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
 import org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager;
@@ -320,7 +321,7 @@ public class CapacitySchedulerConfiguration extends ReservationSchedulerConfigur
   @Private
   public static final int DEFAULT_MAX_ASSIGN_PER_HEARTBEAT = -1;
 
-  /** Configuring absolute min/max resources in a queue **/
+  /** Configuring absolute min/max resources in a queue. **/
   @Private
   public static final String MINIMUM_RESOURCE = "min-resource";
 
@@ -333,6 +334,9 @@ public class CapacitySchedulerConfiguration extends ReservationSchedulerConfigur
 
   private static final Pattern RESOURCE_PATTERN = Pattern.compile(PATTERN_FOR_ABSOLUTE_RESOURCE);
 
+  /**
+   * Different resource types supported.
+   */
   public enum AbsoluteResourceType {
     MEMORY, VCORES;
   }
@@ -1825,7 +1829,7 @@ public class CapacitySchedulerConfiguration extends ReservationSchedulerConfigur
     }
 
     // Define resource here.
-    Resource resource = Resource.newInstance(0l, 0);
+    Resource resource = Resource.newInstance(0L, 0);
     Matcher matcher = RESOURCE_PATTERN.matcher(resourceString);
 
     /*
@@ -1852,7 +1856,7 @@ public class CapacitySchedulerConfiguration extends ReservationSchedulerConfigur
     }
 
     // Memory has to be configured always.
-    if (resource.getMemorySize() == 0l) {
+    if (resource.getMemorySize() == 0L) {
       return Resources.none();
     }
 
@@ -1884,14 +1888,16 @@ public class CapacitySchedulerConfiguration extends ReservationSchedulerConfigur
     AbsoluteResourceType resType = AbsoluteResourceType
         .valueOf(StringUtils.toUpperCase(splits[0].trim()));
     switch (resType) {
-      case MEMORY :
-        resource.setMemorySize(resourceValue);
-        break;
-      case VCORES :
-        resource.setVirtualCores(resourceValue.intValue());
-        break;
-      default :
-        break;
+    case MEMORY :
+      resource.setMemorySize(resourceValue);
+      break;
+    case VCORES :
+      resource.setVirtualCores(resourceValue.intValue());
+      break;
+    default :
+      resource.setResourceInformation(splits[0].trim(), ResourceInformation
+          .newInstance(splits[0].trim(), units, resourceValue));
+      break;
     }
   }
 }

+ 1 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestReservations.java

@@ -904,12 +904,11 @@ public class TestReservations {
     String host_1 = "host_1";
     FiCaSchedulerNode node_1 = TestUtils.getMockNode(host_1, DEFAULT_RACK, 0,
         8 * GB);
-    
+
     Resource clusterResource = Resources.createResource(2 * 8 * GB);
     root.updateClusterResource(clusterResource,
         new ResourceLimits(clusterResource));
 
-
     // Setup resource-requests
     Priority p = TestUtils.createMockPriority(5);
     SchedulerRequestKey priorityMap = toSchedulerKey(p);