hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kkarana...@apache.org
Subject [2/2] hadoop git commit: YARN-8111. Simplify PlacementConstraints API by removing allocationTagToIntraApp. Contributed by Weiwei Yang.
Date Fri, 20 Apr 2018 19:25:34 GMT
YARN-8111. Simplify PlacementConstraints API by removing allocationTagToIntraApp. Contributed
by Weiwei Yang.

(cherry picked from commit 28e2244390c990877dc2ee2733cf9b8d2c75128e)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/18c86a3f
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/18c86a3f
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/18c86a3f

Branch: refs/heads/branch-3.1
Commit: 18c86a3fb6599baea569ed9d678194e43d2a98a6
Parents: 71b0d52
Author: Konstantinos Karanasos <kkaranasos@apache.org>
Authored: Fri Apr 20 12:24:48 2018 -0700
Committer: Konstantinos Karanasos <kkaranasos@apache.org>
Committed: Fri Apr 20 12:25:08 2018 -0700

----------------------------------------------------------------------
 .../yarn/api/resource/PlacementConstraints.java | 24 +++----------
 .../api/resource/TestPlacementConstraints.java  |  4 ++-
 .../yarn/service/component/Component.java       |  2 +-
 .../yarn/server/resourcemanager/MockAM.java     |  2 +-
 ...stSingleConstraintAppPlacementAllocator.java | 36 ++++++++++----------
 5 files changed, 28 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/18c86a3f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/resource/PlacementConstraints.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/resource/PlacementConstraints.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/resource/PlacementConstraints.java
index 02138bd..d22a6bd 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/resource/PlacementConstraints.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/resource/PlacementConstraints.java
@@ -258,15 +258,17 @@ public final class PlacementConstraints {
 
     /**
      * Constructs a target expression on an allocation tag. It is satisfied if
-     * there are allocations with one of the given tags.
+     * there are allocations with one of the given tags. The default namespace
+     * for these tags is {@link AllocationTagNamespaceType#SELF}, this only
+     * checks tags within the application.
      *
      * @param allocationTags the set of tags that the attribute should take
      *          values from
      * @return the resulting expression on the allocation tags
      */
     public static TargetExpression allocationTag(String... allocationTags) {
-      return new TargetExpression(TargetType.ALLOCATION_TAG, null,
-          allocationTags);
+      return allocationTagWithNamespace(
+          AllocationTagNamespaceType.SELF.toString(), allocationTags);
     }
 
     /**
@@ -282,22 +284,6 @@ public final class PlacementConstraints {
       return new TargetExpression(TargetType.ALLOCATION_TAG,
           namespace, allocationTags);
     }
-
-    /**
-     * Constructs a target expression on an allocation tag. It is satisfied if
-     * there are allocations with one of the given tags. Comparing to
-     * {@link PlacementTargets#allocationTag(String...)}, this only checks tags
-     * within the application.
-     *
-     * @param allocationTags the set of tags that the attribute should take
-     *          values from
-     * @return the resulting expression on the allocation tags
-     */
-    public static TargetExpression allocationTagToIntraApp(
-        String... allocationTags) {
-      return new TargetExpression(TargetType.ALLOCATION_TAG,
-          AllocationTagNamespaceType.SELF.toString(), allocationTags);
-    }
   }
 
   // Creation of compound constraints.

http://git-wip-us.apache.org/repos/asf/hadoop/blob/18c86a3f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/test/java/org/apache/hadoop/yarn/api/resource/TestPlacementConstraints.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/test/java/org/apache/hadoop/yarn/api/resource/TestPlacementConstraints.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/test/java/org/apache/hadoop/yarn/api/resource/TestPlacementConstraints.java
index 2f8cc62..516ecfc 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/test/java/org/apache/hadoop/yarn/api/resource/TestPlacementConstraints.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/test/java/org/apache/hadoop/yarn/api/resource/TestPlacementConstraints.java
@@ -28,6 +28,7 @@ import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.targetNot
 import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.PlacementTargets.allocationTag;
 import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.PlacementTargets.nodeAttribute;
 
+import org.apache.hadoop.yarn.api.records.AllocationTagNamespaceType;
 import org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint;
 import org.apache.hadoop.yarn.api.resource.PlacementConstraint.And;
 import org.apache.hadoop.yarn.api.resource.PlacementConstraint.SingleConstraint;
@@ -55,7 +56,8 @@ public class TestPlacementConstraints {
     Assert.assertEquals(1, sConstraint.getTargetExpressions().size());
     TargetExpression tExpr =
         sConstraint.getTargetExpressions().iterator().next();
-    Assert.assertNull(tExpr.getTargetKey());
+    Assert.assertEquals(AllocationTagNamespaceType.SELF.toString(),
+        tExpr.getTargetKey());
     Assert.assertEquals(TargetType.ALLOCATION_TAG, tExpr.getTargetType());
     Assert.assertEquals(1, tExpr.getTargetValues().size());
     Assert.assertEquals("hbase-m", tExpr.getTargetValues().iterator().next());

http://git-wip-us.apache.org/repos/asf/hadoop/blob/18c86a3f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/component/Component.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/component/Component.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/component/Component.java
index 3a08eaa..782cc3b 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/component/Component.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/component/Component.java
@@ -486,7 +486,7 @@ public class Component implements EventHandler<ComponentEvent> {
         List<TargetExpression> targetExpressions = new ArrayList<>();
         // Currently only intra-application allocation tags are supported.
         if (!yarnServiceConstraint.getTargetTags().isEmpty()) {
-          targetExpressions.add(PlacementTargets.allocationTagToIntraApp(
+          targetExpressions.add(PlacementTargets.allocationTag(
               yarnServiceConstraint.getTargetTags().toArray(new String[0])));
         }
         // Add all node attributes

http://git-wip-us.apache.org/repos/asf/hadoop/blob/18c86a3f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockAM.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/MockAM.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockAM.java
index 5eb667e..d6ffd77 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockAM.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockAM.java
@@ -336,7 +336,7 @@ public class MockAM {
             .placementConstraintExpression(PlacementConstraints
                 .targetNotIn(PlacementConstraints.NODE,
                     PlacementConstraints.PlacementTargets
-                        .allocationTagToIntraApp(tags),
+                        .allocationTag(tags),
                     PlacementConstraints.PlacementTargets
                         .nodePartition(nodePartition)).build())
             .resourceSizing(resourceSizing).build()), null);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/18c86a3f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/TestSingleConstraintAppPlacementAllocator.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/placement/TestSingleConstraintAppPlacementAllocator.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/TestSingleConstraintAppPlacementAllocator.java
index 4c6afd4..ccf4281 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/TestSingleConstraintAppPlacementAllocator.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/placement/TestSingleConstraintAppPlacementAllocator.java
@@ -126,7 +126,7 @@ public class TestSingleConstraintAppPlacementAllocator {
         .placementConstraintExpression(PlacementConstraints
             .targetNotIn(PlacementConstraints.NODE,
                 PlacementConstraints.PlacementTargets
-                    .allocationTagToIntraApp("mapper", "reducer"),
+                    .allocationTag("mapper", "reducer"),
                 PlacementConstraints.PlacementTargets.nodePartition(""))
             .build()).resourceSizing(
             ResourceSizing.newInstance(1, Resource.newInstance(1024, 1)))
@@ -142,7 +142,7 @@ public class TestSingleConstraintAppPlacementAllocator {
         .placementConstraintExpression(PlacementConstraints
             .targetNotIn(PlacementConstraints.NODE,
                 PlacementConstraints.PlacementTargets
-                    .allocationTagToIntraApp("mapper", "reducer"),
+                    .allocationTag("mapper", "reducer"),
                 PlacementConstraints.PlacementTargets.nodePartition("x"))
             .build()).resourceSizing(
             ResourceSizing.newInstance(1, Resource.newInstance(1024, 1)))
@@ -158,7 +158,7 @@ public class TestSingleConstraintAppPlacementAllocator {
         .placementConstraintExpression(PlacementConstraints
             .targetNotIn(PlacementConstraints.NODE,
                 PlacementConstraints.PlacementTargets
-                    .allocationTagToIntraApp("mapper", "reducer")).build())
+                    .allocationTag("mapper", "reducer")).build())
         .resourceSizing(
             ResourceSizing.newInstance(1, Resource.newInstance(1024, 1)))
         .build());
@@ -173,7 +173,7 @@ public class TestSingleConstraintAppPlacementAllocator {
         .placementConstraintExpression(PlacementConstraints
             .targetNotIn(PlacementConstraints.NODE,
                 PlacementConstraints.PlacementTargets
-                    .allocationTagToIntraApp("mapper", "reducer")).build())
+                    .allocationTag("mapper", "reducer")).build())
         .resourceSizing(
             ResourceSizing.newInstance(1, Resource.newInstance(1024, 1)))
         .build());
@@ -189,7 +189,7 @@ public class TestSingleConstraintAppPlacementAllocator {
         .placementConstraintExpression(PlacementConstraints
             .targetNotIn(PlacementConstraints.NODE,
                 PlacementConstraints.PlacementTargets
-                    .allocationTagToIntraApp("mapper", "reducer")).build())
+                    .allocationTag("mapper", "reducer")).build())
         .build(), true);
 
     // Invalid (without target tags)
@@ -207,9 +207,9 @@ public class TestSingleConstraintAppPlacementAllocator {
         .placementConstraintExpression(PlacementConstraints
             .targetNotIn(PlacementConstraints.NODE,
                 PlacementConstraints.PlacementTargets
-                    .allocationTagToIntraApp("mapper"),
+                    .allocationTag("mapper"),
                 PlacementConstraints.PlacementTargets
-                    .allocationTagToIntraApp("reducer"),
+                    .allocationTag("reducer"),
                 PlacementConstraints.PlacementTargets.nodePartition(""))
             .build()).resourceSizing(
             ResourceSizing.newInstance(1, Resource.newInstance(1024, 1)))
@@ -222,9 +222,9 @@ public class TestSingleConstraintAppPlacementAllocator {
         .placementConstraintExpression(PlacementConstraints
             .targetNotIn(PlacementConstraints.NODE,
                 PlacementConstraints.PlacementTargets
-                    .allocationTagToIntraApp("mapper"),
+                    .allocationTag("mapper"),
                 PlacementConstraints.PlacementTargets
-                    .allocationTagToIntraApp(""),
+                    .allocationTag(""),
                 PlacementConstraints.PlacementTargets.nodePartition("x"))
             .build()).resourceSizing(
             ResourceSizing.newInstance(1, Resource.newInstance(1024, 1)))
@@ -237,7 +237,7 @@ public class TestSingleConstraintAppPlacementAllocator {
         .placementConstraintExpression(PlacementConstraints
             .targetCardinality(PlacementConstraints.NODE, 1, 2,
                 PlacementConstraints.PlacementTargets
-                    .allocationTagToIntraApp("mapper"),
+                    .allocationTag("mapper"),
                 PlacementConstraints.PlacementTargets.nodePartition(""))
             .build()).resourceSizing(
             ResourceSizing.newInstance(1, Resource.newInstance(1024, 1)))
@@ -250,7 +250,7 @@ public class TestSingleConstraintAppPlacementAllocator {
         .placementConstraintExpression(PlacementConstraints
             .targetCardinality(PlacementConstraints.NODE, 0, 2,
                 PlacementConstraints.PlacementTargets
-                    .allocationTagToIntraApp("mapper"),
+                    .allocationTag("mapper"),
                 PlacementConstraints.PlacementTargets.nodePartition(""))
             .build()).resourceSizing(
             ResourceSizing.newInstance(1, Resource.newInstance(1024, 1)))
@@ -263,7 +263,7 @@ public class TestSingleConstraintAppPlacementAllocator {
         .placementConstraintExpression(PlacementConstraints
             .targetNotIn(PlacementConstraints.RACK,
                 PlacementConstraints.PlacementTargets
-                    .allocationTagToIntraApp("mapper", "reducer"),
+                    .allocationTag("mapper", "reducer"),
                 PlacementConstraints.PlacementTargets.nodePartition(""))
             .build()).resourceSizing(
             ResourceSizing.newInstance(1, Resource.newInstance(1024, 1)))
@@ -276,7 +276,7 @@ public class TestSingleConstraintAppPlacementAllocator {
         .placementConstraintExpression(PlacementConstraints
             .targetNotIn(PlacementConstraints.NODE,
                 PlacementConstraints.PlacementTargets
-                    .allocationTagToIntraApp("mapper", "reducer"),
+                    .allocationTag("mapper", "reducer"),
                 PlacementConstraints.PlacementTargets.nodePartition(""))
             .build()).resourceSizing(
             ResourceSizing.newInstance(1, Resource.newInstance(1024, 1)))
@@ -292,7 +292,7 @@ public class TestSingleConstraintAppPlacementAllocator {
             .placementConstraintExpression(PlacementConstraints
                 .targetNotIn(PlacementConstraints.NODE,
                     PlacementConstraints.PlacementTargets
-                        .allocationTagToIntraApp("mapper", "reducer"),
+                        .allocationTag("mapper", "reducer"),
                     PlacementConstraints.PlacementTargets.nodePartition(""))
                 .build()).resourceSizing(
             ResourceSizing.newInstance(1, Resource.newInstance(1024, 1)))
@@ -321,7 +321,7 @@ public class TestSingleConstraintAppPlacementAllocator {
         .placementConstraintExpression(PlacementConstraints
             .targetCardinality(PlacementConstraints.NODE, 0, 1,
                 PlacementConstraints.PlacementTargets
-                    .allocationTagToIntraApp("mapper"),
+                    .allocationTag("mapper"),
                 PlacementConstraints.PlacementTargets.nodePartition(""))
             .build()).resourceSizing(
             ResourceSizing.newInstance(1, Resource.newInstance(1024, 1)))
@@ -338,7 +338,7 @@ public class TestSingleConstraintAppPlacementAllocator {
         .placementConstraintExpression(PlacementConstraints
             .targetNotIn(PlacementConstraints.NODE,
                 PlacementConstraints.PlacementTargets
-                    .allocationTagToIntraApp("mapper", "reducer"),
+                    .allocationTag("mapper", "reducer"),
                 PlacementConstraints.PlacementTargets.nodePartition(""))
             .build()).resourceSizing(
             ResourceSizing.newInstance(1, Resource.newInstance(1024, 1)))
@@ -358,7 +358,7 @@ public class TestSingleConstraintAppPlacementAllocator {
             .placementConstraintExpression(PlacementConstraints
                 .targetNotIn(PlacementConstraints.NODE,
                     PlacementConstraints.PlacementTargets
-                        .allocationTagToIntraApp("mapper", "reducer"),
+                        .allocationTag("mapper", "reducer"),
                     PlacementConstraints.PlacementTargets.nodePartition(""))
                 .build()).resourceSizing(
             ResourceSizing.newInstance(1, Resource.newInstance(1024, 1)))
@@ -379,7 +379,7 @@ public class TestSingleConstraintAppPlacementAllocator {
         .placementConstraintExpression(PlacementConstraints
             .targetNotIn(PlacementConstraints.NODE,
                 PlacementConstraints.PlacementTargets
-                    .allocationTagToIntraApp("mapper", "reducer"),
+                    .allocationTag("mapper", "reducer"),
                 PlacementConstraints.PlacementTargets.nodePartition("x"))
             .build()).resourceSizing(
             ResourceSizing.newInstance(1, Resource.newInstance(1024, 1)))


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message