hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wan...@apache.org
Subject hadoop git commit: YARN-3963. AddNodeLabel on duplicate label addition shows success. (Bibin A Chundatt via wangda)
Date Thu, 30 Jul 2015 16:45:12 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 3faf7bc3f -> a28e23d04


YARN-3963. AddNodeLabel on duplicate label addition shows success. (Bibin A Chundatt via wangda)

(cherry picked from commit 8acb30b0167e498991aef6993df7e36020428844)


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

Branch: refs/heads/branch-2
Commit: a28e23d049478bf1210539bb60f0f262e8cefce2
Parents: 3faf7bc
Author: Wangda Tan <wangda@apache.org>
Authored: Thu Jul 30 09:42:55 2015 -0700
Committer: Wangda Tan <wangda@apache.org>
Committed: Thu Jul 30 09:43:45 2015 -0700

----------------------------------------------------------------------
 hadoop-yarn-project/CHANGES.txt                 |  3 +++
 .../nodelabels/CommonNodeLabelsManager.java     | 20 +++++++++++++++++++-
 .../nodelabels/TestCommonNodeLabelsManager.java | 17 ++++++++++++++++-
 3 files changed, 38 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/a28e23d0/hadoop-yarn-project/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
index ff36abc..9cc6081 100644
--- a/hadoop-yarn-project/CHANGES.txt
+++ b/hadoop-yarn-project/CHANGES.txt
@@ -658,6 +658,9 @@ Release 2.8.0 - UNRELEASED
     YARN-3919. NPEs' while stopping service after exception during
     CommonNodeLabelsManager#start. (varun saxane via rohithsharmaks)
 
+    YARN-3963. AddNodeLabel on duplicate label addition shows success.
+    (Bibin A Chundatt via wangda)
+
 Release 2.7.2 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/a28e23d0/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java
index f741f68..34e6832 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java
@@ -288,7 +288,8 @@ public class CommonNodeLabelsManager extends AbstractService {
     }
     List<NodeLabel> newLabels = new ArrayList<NodeLabel>();
     normalizeNodeLabels(labels);
-
+    // check any mismatch in exclusivity no mismatch with skip
+    checkExclusivityMatch(labels);
     // do a check before actual adding them, will throw exception if any of them
     // doesn't meet label name requirement
     for (NodeLabel label : labels) {
@@ -931,6 +932,23 @@ public class CommonNodeLabelsManager extends AbstractService {
     }
   }
 
+  private void checkExclusivityMatch(Collection<NodeLabel> labels)
+      throws IOException {
+    ArrayList<NodeLabel> mismatchlabels = new ArrayList<NodeLabel>();
+    for (NodeLabel label : labels) {
+      RMNodeLabel rmNodeLabel = this.labelCollections.get(label.getName());
+      if (rmNodeLabel != null
+          && rmNodeLabel.getIsExclusive() != label.isExclusive()) {
+        mismatchlabels.add(label);
+      }
+    }
+    if (mismatchlabels.size() > 0) {
+      throw new IOException(
+          "Exclusivity cannot be modified for an existing label with : "
+              + StringUtils.join(mismatchlabels.iterator(), ","));
+    }
+  }
+
   protected String normalizeLabel(String label) {
     if (label != null) {
       return label.trim();

http://git-wip-us.apache.org/repos/asf/hadoop/blob/a28e23d0/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestCommonNodeLabelsManager.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestCommonNodeLabelsManager.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestCommonNodeLabelsManager.java
index c25b0bf..95e9002 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestCommonNodeLabelsManager.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestCommonNodeLabelsManager.java
@@ -70,7 +70,22 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
 
     Assert.assertTrue(mgr.getClusterNodeLabelNames().containsAll(
         Sets.newHashSet("hello", "world", "hello1", "world1")));
-
+    try {
+      mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("hello1",
+          false)));
+      Assert.fail("IOException not thrown on exclusivity change of labels");
+    } catch (Exception e) {
+      Assert.assertTrue("IOException is expected when exclusivity is modified",
+          e instanceof IOException);
+    }
+    try {
+      mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("hello1",
+          true)));
+    } catch (Exception e) {
+      Assert.assertFalse(
+          "IOException not expected when no change in exclusivity",
+          e instanceof IOException);
+    }
     // try to remove null, empty and non-existed label, should fail
     for (String p : Arrays.asList(null, CommonNodeLabelsManager.NO_LABEL, "xx")) {
       boolean caught = false;


Mime
View raw message