|
@@ -23,23 +23,25 @@ import java.io.DataOutput;
|
|
|
import java.io.IOException;
|
|
|
import java.text.NumberFormat;
|
|
|
|
|
|
-class JVMId extends ID {
|
|
|
+class JVMId {
|
|
|
boolean isMap;
|
|
|
- JobID jobId;
|
|
|
+ final JobID jobId;
|
|
|
+ private long jvmId;
|
|
|
private static final String JVM = "jvm";
|
|
|
+ private static final char SEPARATOR = '_';
|
|
|
private static NumberFormat idFormat = NumberFormat.getInstance();
|
|
|
static {
|
|
|
idFormat.setGroupingUsed(false);
|
|
|
idFormat.setMinimumIntegerDigits(6);
|
|
|
}
|
|
|
|
|
|
- public JVMId(JobID jobId, boolean isMap, int id) {
|
|
|
- super(id);
|
|
|
+ public JVMId(JobID jobId, boolean isMap, long id) {
|
|
|
+ this.jvmId = id;
|
|
|
this.isMap = isMap;
|
|
|
this.jobId = jobId;
|
|
|
}
|
|
|
|
|
|
- public JVMId (String jtIdentifier, int jobId, boolean isMap, int id) {
|
|
|
+ public JVMId (String jtIdentifier, int jobId, boolean isMap, long id) {
|
|
|
this(new JobID(jtIdentifier, jobId), isMap, id);
|
|
|
}
|
|
|
|
|
@@ -53,27 +55,50 @@ class JVMId extends ID {
|
|
|
public JobID getJobId() {
|
|
|
return jobId;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
public boolean equals(Object o) {
|
|
|
- if(o == null)
|
|
|
+ // Generated by IntelliJ IDEA 13.1.
|
|
|
+ if (this == o) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (o == null || getClass() != o.getClass()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ JVMId jvmId1 = (JVMId) o;
|
|
|
+
|
|
|
+ if (isMap != jvmId1.isMap) {
|
|
|
return false;
|
|
|
- if(o.getClass().equals(this.getClass())) {
|
|
|
- JVMId that = (JVMId)o;
|
|
|
- return this.id==that.id
|
|
|
- && this.isMap == that.isMap
|
|
|
- && this.jobId.equals(that.jobId);
|
|
|
}
|
|
|
- else return false;
|
|
|
+ if (jvmId != jvmId1.jvmId) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (!jobId.equals(jvmId1.jobId)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
- /**Compare TaskInProgressIds by first jobIds, then by tip numbers. Reduces are
|
|
|
- * defined as greater then maps.*/
|
|
|
@Override
|
|
|
- public int compareTo(org.apache.hadoop.mapreduce.ID o) {
|
|
|
- JVMId that = (JVMId)o;
|
|
|
+ public int hashCode() {
|
|
|
+ // Generated by IntelliJ IDEA 13.1.
|
|
|
+ int result = (isMap ? 1 : 0);
|
|
|
+ result = 31 * result + jobId.hashCode();
|
|
|
+ result = 31 * result + (int) (jvmId ^ (jvmId >>> 32));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Compare TaskInProgressIds by first jobIds, then by tip numbers. Reduces are
|
|
|
+ * defined as greater then maps.
|
|
|
+ **/
|
|
|
+ public int compareTo(JVMId that) {
|
|
|
int jobComp = this.jobId.compareTo(that.jobId);
|
|
|
if(jobComp == 0) {
|
|
|
if(this.isMap == that.isMap) {
|
|
|
- return this.id - that.id;
|
|
|
+ return Long.valueOf(this.jvmId).compareTo(that.jvmId);
|
|
|
} else {
|
|
|
return this.isMap ? -1 : 1;
|
|
|
}
|
|
@@ -87,6 +112,15 @@ class JVMId extends ID {
|
|
|
return appendTo(new StringBuilder(JVM)).toString();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * This method does NOT override org.apache.hadoop.mapred.ID to accept 64-bit
|
|
|
+ * ID to support work-preserving RM restart.
|
|
|
+ * @return 64-bit JVM id.
|
|
|
+ */
|
|
|
+ public long getId() {
|
|
|
+ return jvmId;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Add the unique id to the given StringBuilder.
|
|
|
* @param builder the builder to append to
|
|
@@ -97,24 +131,17 @@ class JVMId extends ID {
|
|
|
append(SEPARATOR).
|
|
|
append(isMap ? 'm' : 'r').
|
|
|
append(SEPARATOR).
|
|
|
- append(idFormat.format(id));
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public int hashCode() {
|
|
|
- return jobId.hashCode() * 11 + id;
|
|
|
+ append(idFormat.format(jvmId));
|
|
|
}
|
|
|
-
|
|
|
- @Override
|
|
|
+
|
|
|
public void readFields(DataInput in) throws IOException {
|
|
|
- super.readFields(in);
|
|
|
+ this.jvmId = in.readLong();
|
|
|
this.jobId.readFields(in);
|
|
|
this.isMap = in.readBoolean();
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
public void write(DataOutput out) throws IOException {
|
|
|
- super.write(out);
|
|
|
+ out.writeLong(jvmId);
|
|
|
jobId.write(out);
|
|
|
out.writeBoolean(isMap);
|
|
|
}
|