diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-mawo/hadoop-yarn-applications-mawo-core/src/main/java/org/apache/hadoop/applications/mawo/server/common/TaskStatus.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-mawo/hadoop-yarn-applications-mawo-core/src/main/java/org/apache/hadoop/applications/mawo/server/common/TaskStatus.java index 4f780d8dc3a..3529077d875 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-mawo/hadoop-yarn-applications-mawo-core/src/main/java/org/apache/hadoop/applications/mawo/server/common/TaskStatus.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-mawo/hadoop-yarn-applications-mawo-core/src/main/java/org/apache/hadoop/applications/mawo/server/common/TaskStatus.java @@ -22,6 +22,7 @@ import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; +import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.hadoop.applications.mawo.server.worker.WorkerId; import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.WritableUtils; @@ -344,4 +345,39 @@ public class TaskStatus implements Writable, Cloneable { public final void setWorkerId(final WorkerId localworkerId) { this.workerId = localworkerId; } + + @Override + public boolean equals(Object obj) { + if (obj == null || obj.getClass() != this.getClass()) { + return false; + } + TaskStatus other = (TaskStatus) obj; + return (getWorkerId().equals(other.getWorkerId()) && + getTaskId().equals(other.getTaskId()) && + getRunState().equals(other.getRunState()) && + getStartTime() == other.getStartTime() && + getEndTime() == other.getEndTime() && + getTaskCMD().equals(other.getTaskCMD()) && + getTaskType().equals(other.getTaskType()) && + getExitCode() == other.getExitCode()); + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + builder.append(getWorkerId()) + .append(getTaskId()) + .append(getRunState()) + .append(getStartTime()) + .append(getEndTime()) + .append(getTaskCMD()) + .append(getTaskType()) + .append(getExitCode()); + return builder.hashCode(); + } + + @Override + protected Object clone() throws CloneNotSupportedException { + return super.clone(); + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-mawo/hadoop-yarn-applications-mawo-core/src/main/java/org/apache/hadoop/applications/mawo/server/worker/WorkerId.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-mawo/hadoop-yarn-applications-mawo-core/src/main/java/org/apache/hadoop/applications/mawo/server/worker/WorkerId.java index dfb356b105e..cefc8641e40 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-mawo/hadoop-yarn-applications-mawo-core/src/main/java/org/apache/hadoop/applications/mawo/server/worker/WorkerId.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-mawo/hadoop-yarn-applications-mawo-core/src/main/java/org/apache/hadoop/applications/mawo/server/worker/WorkerId.java @@ -86,6 +86,7 @@ public class WorkerId implements Writable { * Print workerId. * @return workeId in string */ + @Override public final String toString() { return workerId.toString(); } @@ -111,11 +112,15 @@ public class WorkerId implements Writable { * Implememt equals method for WorkerId. */ public final boolean equals(final Object o) { + if (o == null || this.getClass() != o.getClass()) { + return false; + } WorkerId x = (WorkerId) o; return x.getHostname().equals(this.hostname); } /** {@inheritDoc} */ + @Override public final void write(final DataOutput dataOutput) throws IOException { workerId.write(dataOutput); hostname.write(dataOutput); @@ -123,6 +128,7 @@ public class WorkerId implements Writable { } /** {@inheritDoc} */ + @Override public final void readFields(final DataInput dataInput) throws IOException { workerId.readFields(dataInput); hostname.readFields(dataInput);