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 1e83e40559..1fadd42c3d 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.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 Set getLabels() { 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; + } } }