YARN-2182. Updated ContainerId#toString() to append RM Epoch number. Contributed by Tsuyoshi OZAWA

This commit is contained in:
Jian He 2014-08-27 10:02:45 -07:00
parent c5d9a4a91e
commit e2d0ff364a
3 changed files with 13 additions and 4 deletions

View File

@ -157,6 +157,9 @@ Release 2.6.0 - UNRELEASED
YARN-1326. RM should log using RMStore at startup time. YARN-1326. RM should log using RMStore at startup time.
(Tsuyoshi Ozawa via kasha) (Tsuyoshi Ozawa via kasha)
YARN-2182. Updated ContainerId#toString() to append RM Epoch number.
(Tsuyoshi OZAWA via jianhe)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -83,7 +83,7 @@ public static ContainerId newInstance(ApplicationAttemptId appAttemptId,
// TODO: fail the app submission if attempts are more than 10 or something // TODO: fail the app submission if attempts are more than 10 or something
private static final ThreadLocal<NumberFormat> appAttemptIdFormat = private static final ThreadLocal<NumberFormat> appAttemptIdAndEpochFormat =
new ThreadLocal<NumberFormat>() { new ThreadLocal<NumberFormat>() {
@Override @Override
public NumberFormat initialValue() { public NumberFormat initialValue() {
@ -153,9 +153,13 @@ public String toString() {
sb.append(ApplicationId.appIdFormat.get().format(appId.getId())) sb.append(ApplicationId.appIdFormat.get().format(appId.getId()))
.append("_"); .append("_");
sb.append( sb.append(
appAttemptIdFormat.get().format( appAttemptIdAndEpochFormat.get().format(
getApplicationAttemptId().getAttemptId())).append("_"); 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(); return sb.toString();
} }

View File

@ -54,7 +54,9 @@ public void testContainerId() {
long ts = System.currentTimeMillis(); long ts = System.currentTimeMillis();
ContainerId c6 = newContainerId(36473, 4365472, ts, 25645811); ContainerId c6 = newContainerId(36473, 4365472, ts, 25645811);
Assert.assertEquals("container_10_0001_01_000001", c1.toString()); 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()); c6.toString());
} }