diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 36d304c7876..871829ac369 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -157,6 +157,9 @@ Release 2.6.0 - UNRELEASED YARN-1326. RM should log using RMStore at startup time. (Tsuyoshi Ozawa via kasha) + YARN-2182. Updated ContainerId#toString() to append RM Epoch number. + (Tsuyoshi OZAWA via jianhe) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerId.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerId.java index 73e80859049..fc7f40488ec 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerId.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerId.java @@ -83,7 +83,7 @@ public abstract class ContainerId implements Comparable{ // TODO: fail the app submission if attempts are more than 10 or something - private static final ThreadLocal appAttemptIdFormat = + private static final ThreadLocal appAttemptIdAndEpochFormat = new ThreadLocal() { @Override public NumberFormat initialValue() { @@ -153,9 +153,13 @@ public abstract class ContainerId implements Comparable{ sb.append(ApplicationId.appIdFormat.get().format(appId.getId())) .append("_"); sb.append( - appAttemptIdFormat.get().format( + appAttemptIdAndEpochFormat.get().format( getApplicationAttemptId().getAttemptId())).append("_"); - sb.append(containerIdFormat.get().format(getId())); + sb.append(containerIdFormat.get().format(0x3fffff & getId())); + int epoch = getId() >> 22; + if (epoch > 0) { + sb.append("_").append(appAttemptIdAndEpochFormat.get().format(epoch)); + } return sb.toString(); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerId.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerId.java index f92df8a8d0c..b23d0ed3fbc 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerId.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerId.java @@ -54,7 +54,9 @@ public class TestContainerId { long ts = System.currentTimeMillis(); ContainerId c6 = newContainerId(36473, 4365472, ts, 25645811); Assert.assertEquals("container_10_0001_01_000001", c1.toString()); - Assert.assertEquals("container_" + ts + "_36473_4365472_25645811", + Assert.assertEquals(479987, 0x003fffff & c6.getId()); + Assert.assertEquals(6, c6.getId() >> 22); + Assert.assertEquals("container_" + ts + "_36473_4365472_479987_06", c6.toString()); }