YARN-10152. Fix findbugs warnings in hadoop-yarn-applications-mawo-core module (#1852)

This commit is contained in:
Akira Ajisaka 2020-02-27 10:36:49 +09:00 committed by GitHub
parent 033a3d7ff9
commit 7dfa37e8f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import java.io.DataInput;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.hadoop.applications.mawo.server.worker.WorkerId; import org.apache.hadoop.applications.mawo.server.worker.WorkerId;
import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableUtils; import org.apache.hadoop.io.WritableUtils;
@ -344,4 +345,39 @@ public class TaskStatus implements Writable, Cloneable {
public final void setWorkerId(final WorkerId localworkerId) { public final void setWorkerId(final WorkerId localworkerId) {
this.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();
}
} }

View File

@ -86,6 +86,7 @@ public class WorkerId implements Writable {
* Print workerId. * Print workerId.
* @return workeId in string * @return workeId in string
*/ */
@Override
public final String toString() { public final String toString() {
return workerId.toString(); return workerId.toString();
} }
@ -111,11 +112,15 @@ public class WorkerId implements Writable {
* Implememt equals method for WorkerId. * Implememt equals method for WorkerId.
*/ */
public final boolean equals(final Object o) { public final boolean equals(final Object o) {
if (o == null || this.getClass() != o.getClass()) {
return false;
}
WorkerId x = (WorkerId) o; WorkerId x = (WorkerId) o;
return x.getHostname().equals(this.hostname); return x.getHostname().equals(this.hostname);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public final void write(final DataOutput dataOutput) throws IOException { public final void write(final DataOutput dataOutput) throws IOException {
workerId.write(dataOutput); workerId.write(dataOutput);
hostname.write(dataOutput); hostname.write(dataOutput);
@ -123,6 +128,7 @@ public class WorkerId implements Writable {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public final void readFields(final DataInput dataInput) throws IOException { public final void readFields(final DataInput dataInput) throws IOException {
workerId.readFields(dataInput); workerId.readFields(dataInput);
hostname.readFields(dataInput); hostname.readFields(dataInput);