From aff21d727194bd089d4b4df5ff3ce1106bece7e2 Mon Sep 17 00:00:00 2001 From: bibinchundatt Date: Mon, 15 Oct 2018 16:10:25 +0530 Subject: [PATCH] YARN-8830. SLS tool fix node addition. Contributed by Bibin A Chundatt. (cherry picked from commit b4a38e7b3e530756fb79d23dd4e218beeb5e3190) --- .../org/apache/hadoop/yarn/sls/SLSRunner.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/SLSRunner.java b/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/SLSRunner.java index 1e83e405597..1fadd42c3dc 100644 --- a/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/SLSRunner.java +++ b/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/SLSRunner.java @@ -45,6 +45,8 @@ import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.GnuParser; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; +import org.apache.commons.collections.SetUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.conf.Configuration; @@ -1029,5 +1031,32 @@ public class SLSRunner extends Configured implements Tool { public void setLabels(Set labels) { this.labels = labels; } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof NodeDetails)) { + return false; + } + + NodeDetails that = (NodeDetails) o; + + return StringUtils.equals(hostname, that.hostname) && ( + nodeResource == null ? + that.nodeResource == null : + nodeResource.equals(that.nodeResource)) && SetUtils + .isEqualSet(labels, that.labels); + } + + @Override + public int hashCode() { + int result = hostname == null ? 0 : hostname.hashCode(); + result = + 31 * result + (nodeResource == null ? 0 : nodeResource.hashCode()); + result = 31 * result + (labels == null ? 0 : labels.hashCode()); + return result; + } } }