|
@@ -41,9 +41,9 @@ public abstract class ContainerId implements Comparable<ContainerId>{
|
|
|
@Private
|
|
|
@Unstable
|
|
|
public static ContainerId newInstance(ApplicationAttemptId appAttemptId,
|
|
|
- int containerId) {
|
|
|
+ long containerId) {
|
|
|
ContainerId id = Records.newRecord(ContainerId.class);
|
|
|
- id.setId(containerId);
|
|
|
+ id.setContainerId(containerId);
|
|
|
id.setApplicationAttemptId(appAttemptId);
|
|
|
id.build();
|
|
|
return id;
|
|
@@ -74,16 +74,28 @@ public abstract class ContainerId implements Comparable<ContainerId>{
|
|
|
protected abstract void setApplicationAttemptId(ApplicationAttemptId atId);
|
|
|
|
|
|
/**
|
|
|
- * Get the identifier of the <code>ContainerId</code>.
|
|
|
- * @return identifier of the <code>ContainerId</code>
|
|
|
+ * Get the lower 32 bits of identifier of the <code>ContainerId</code>,
|
|
|
+ * which doesn't include epoch. Note that this method will be marked as
|
|
|
+ * deprecated, so please use <code>getContainerId</code> instead.
|
|
|
+ * @return lower 32 bits of identifier of the <code>ContainerId</code>
|
|
|
*/
|
|
|
@Public
|
|
|
@Stable
|
|
|
public abstract int getId();
|
|
|
|
|
|
+ /**
|
|
|
+ * Get the identifier of the <code>ContainerId</code>. Upper 24 bits are
|
|
|
+ * reserved as epoch of cluster, and lower 40 bits are reserved as
|
|
|
+ * sequential number of containers.
|
|
|
+ * @return identifier of the <code>ContainerId</code>
|
|
|
+ */
|
|
|
+ @Public
|
|
|
+ @Unstable
|
|
|
+ public abstract long getContainerId();
|
|
|
+
|
|
|
@Private
|
|
|
@Unstable
|
|
|
- protected abstract void setId(int id);
|
|
|
+ protected abstract void setContainerId(long id);
|
|
|
|
|
|
|
|
|
// TODO: fail the app submission if attempts are more than 10 or something
|
|
@@ -109,14 +121,12 @@ public abstract class ContainerId implements Comparable<ContainerId>{
|
|
|
return fmt;
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public int hashCode() {
|
|
|
- // Generated by eclipse.
|
|
|
- final int prime = 435569;
|
|
|
- int result = 7507;
|
|
|
- result = prime * result + getId();
|
|
|
- result = prime * result + getApplicationAttemptId().hashCode();
|
|
|
+ // Generated by IntelliJ IDEA 13.1.
|
|
|
+ int result = (int) (getContainerId() ^ (getContainerId() >>> 32));
|
|
|
+ result = 31 * result + getApplicationAttemptId().hashCode();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -131,7 +141,7 @@ public abstract class ContainerId implements Comparable<ContainerId>{
|
|
|
ContainerId other = (ContainerId) obj;
|
|
|
if (!this.getApplicationAttemptId().equals(other.getApplicationAttemptId()))
|
|
|
return false;
|
|
|
- if (this.getId() != other.getId())
|
|
|
+ if (this.getContainerId() != other.getContainerId())
|
|
|
return false;
|
|
|
return true;
|
|
|
}
|
|
@@ -140,12 +150,12 @@ public abstract class ContainerId implements Comparable<ContainerId>{
|
|
|
public int compareTo(ContainerId other) {
|
|
|
if (this.getApplicationAttemptId().compareTo(
|
|
|
other.getApplicationAttemptId()) == 0) {
|
|
|
- return this.getId() - other.getId();
|
|
|
+ return Long.valueOf(getContainerId())
|
|
|
+ .compareTo(Long.valueOf(other.getContainerId()));
|
|
|
} else {
|
|
|
return this.getApplicationAttemptId().compareTo(
|
|
|
other.getApplicationAttemptId());
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -159,8 +169,8 @@ public abstract class ContainerId implements Comparable<ContainerId>{
|
|
|
sb.append(
|
|
|
appAttemptIdAndEpochFormat.get().format(
|
|
|
getApplicationAttemptId().getAttemptId())).append("_");
|
|
|
- sb.append(containerIdFormat.get().format(0x3fffff & getId()));
|
|
|
- int epoch = getId() >> 22;
|
|
|
+ sb.append(containerIdFormat.get().format(0xffffffffffL & getContainerId()));
|
|
|
+ long epoch = getContainerId() >> 40;
|
|
|
if (epoch > 0) {
|
|
|
sb.append("_").append(appAttemptIdAndEpochFormat.get().format(epoch));
|
|
|
}
|
|
@@ -177,12 +187,12 @@ public abstract class ContainerId implements Comparable<ContainerId>{
|
|
|
}
|
|
|
try {
|
|
|
ApplicationAttemptId appAttemptID = toApplicationAttemptId(it);
|
|
|
- int id = Integer.parseInt(it.next());
|
|
|
- int epoch = 0;
|
|
|
+ long id = Long.parseLong(it.next());
|
|
|
+ long epoch = 0;
|
|
|
if (it.hasNext()) {
|
|
|
epoch = Integer.parseInt(it.next());
|
|
|
}
|
|
|
- int cid = (epoch << 22) | id;
|
|
|
+ long cid = (epoch << 40) | id;
|
|
|
ContainerId containerId = ContainerId.newInstance(appAttemptID, cid);
|
|
|
return containerId;
|
|
|
} catch (NumberFormatException n) {
|