YARN-2602. Fixed possible NPE in ApplicationHistoryManagerOnTimelineStore. Contributed by Zhijie Shen
This commit is contained in:
parent
d7075ada5d
commit
bbff96be48
|
@ -491,6 +491,9 @@ Release 2.6.0 - UNRELEASED
|
||||||
YARN-2594. Potential deadlock in RM when querying
|
YARN-2594. Potential deadlock in RM when querying
|
||||||
ApplicationResourceUsageReport. (Wangda Tan via kasha)
|
ApplicationResourceUsageReport. (Wangda Tan via kasha)
|
||||||
|
|
||||||
|
YARN-2602. Fixed possible NPE in ApplicationHistoryManagerOnTimelineStore.
|
||||||
|
(Zhijie Shen via jianhe)
|
||||||
|
|
||||||
Release 2.5.1 - 2014-09-05
|
Release 2.5.1 - 2014-09-05
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -227,8 +227,10 @@ public class ApplicationHistoryManagerOnTimelineStore extends AbstractService
|
||||||
if (entityInfo.containsKey(ApplicationMetricsConstants.APP_VIEW_ACLS_ENTITY_INFO)) {
|
if (entityInfo.containsKey(ApplicationMetricsConstants.APP_VIEW_ACLS_ENTITY_INFO)) {
|
||||||
String appViewACLsStr = entityInfo.get(
|
String appViewACLsStr = entityInfo.get(
|
||||||
ApplicationMetricsConstants.APP_VIEW_ACLS_ENTITY_INFO).toString();
|
ApplicationMetricsConstants.APP_VIEW_ACLS_ENTITY_INFO).toString();
|
||||||
|
if (appViewACLsStr.length() > 0) {
|
||||||
appViewACLs.put(ApplicationAccessType.VIEW_APP, appViewACLsStr);
|
appViewACLs.put(ApplicationAccessType.VIEW_APP, appViewACLsStr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (field == ApplicationReportField.USER_AND_ACLS) {
|
if (field == ApplicationReportField.USER_AND_ACLS) {
|
||||||
return new ApplicationReportExt(ApplicationReport.newInstance(
|
return new ApplicationReportExt(ApplicationReport.newInstance(
|
||||||
ConverterUtils.toApplicationId(entity.getEntityId()),
|
ConverterUtils.toApplicationId(entity.getEntityId()),
|
||||||
|
|
|
@ -122,7 +122,11 @@ public class TestApplicationHistoryManagerOnTimelineStore {
|
||||||
for (int i = 1; i <= SCALE; ++i) {
|
for (int i = 1; i <= SCALE; ++i) {
|
||||||
TimelineEntities entities = new TimelineEntities();
|
TimelineEntities entities = new TimelineEntities();
|
||||||
ApplicationId appId = ApplicationId.newInstance(0, i);
|
ApplicationId appId = ApplicationId.newInstance(0, i);
|
||||||
entities.addEntity(createApplicationTimelineEntity(appId));
|
if (i == 2) {
|
||||||
|
entities.addEntity(createApplicationTimelineEntity(appId, true));
|
||||||
|
} else {
|
||||||
|
entities.addEntity(createApplicationTimelineEntity(appId, false));
|
||||||
|
}
|
||||||
store.put(entities);
|
store.put(entities);
|
||||||
for (int j = 1; j <= SCALE; ++j) {
|
for (int j = 1; j <= SCALE; ++j) {
|
||||||
entities = new TimelineEntities();
|
entities = new TimelineEntities();
|
||||||
|
@ -142,7 +146,8 @@ public class TestApplicationHistoryManagerOnTimelineStore {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetApplicationReport() throws Exception {
|
public void testGetApplicationReport() throws Exception {
|
||||||
final ApplicationId appId = ApplicationId.newInstance(0, 1);
|
for (int i = 1; i <= 2; ++i) {
|
||||||
|
final ApplicationId appId = ApplicationId.newInstance(0, i);
|
||||||
ApplicationReport app;
|
ApplicationReport app;
|
||||||
if (callerUGI == null) {
|
if (callerUGI == null) {
|
||||||
app = historyManager.getApplication(appId);
|
app = historyManager.getApplication(appId);
|
||||||
|
@ -164,7 +169,13 @@ public class TestApplicationHistoryManagerOnTimelineStore {
|
||||||
Assert.assertEquals(Integer.MAX_VALUE + 2L, app.getStartTime());
|
Assert.assertEquals(Integer.MAX_VALUE + 2L, app.getStartTime());
|
||||||
Assert.assertEquals(Integer.MAX_VALUE + 3L, app.getFinishTime());
|
Assert.assertEquals(Integer.MAX_VALUE + 3L, app.getFinishTime());
|
||||||
Assert.assertTrue(Math.abs(app.getProgress() - 1.0F) < 0.0001);
|
Assert.assertTrue(Math.abs(app.getProgress() - 1.0F) < 0.0001);
|
||||||
if (callerUGI != null && callerUGI.getShortUserName().equals("user3")) {
|
// App 2 doesn't have the ACLs, such that the default ACLs " " will be used.
|
||||||
|
// Nobody except admin and owner has access to the details of the app.
|
||||||
|
if ((i == 1 && callerUGI != null &&
|
||||||
|
callerUGI.getShortUserName().equals("user3")) ||
|
||||||
|
(i == 2 && callerUGI != null &&
|
||||||
|
(callerUGI.getShortUserName().equals("user2") ||
|
||||||
|
callerUGI.getShortUserName().equals("user3")))) {
|
||||||
Assert.assertEquals(ApplicationAttemptId.newInstance(appId, -1),
|
Assert.assertEquals(ApplicationAttemptId.newInstance(appId, -1),
|
||||||
app.getCurrentApplicationAttemptId());
|
app.getCurrentApplicationAttemptId());
|
||||||
Assert.assertEquals(null, app.getHost());
|
Assert.assertEquals(null, app.getHost());
|
||||||
|
@ -187,6 +198,7 @@ public class TestApplicationHistoryManagerOnTimelineStore {
|
||||||
Assert.assertEquals(YarnApplicationState.FINISHED,
|
Assert.assertEquals(YarnApplicationState.FINISHED,
|
||||||
app.getYarnApplicationState());
|
app.getYarnApplicationState());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetApplicationAttemptReport() throws Exception {
|
public void testGetApplicationAttemptReport() throws Exception {
|
||||||
|
@ -396,7 +408,7 @@ public class TestApplicationHistoryManagerOnTimelineStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TimelineEntity createApplicationTimelineEntity(
|
private static TimelineEntity createApplicationTimelineEntity(
|
||||||
ApplicationId appId) {
|
ApplicationId appId, boolean emptyACLs) {
|
||||||
TimelineEntity entity = new TimelineEntity();
|
TimelineEntity entity = new TimelineEntity();
|
||||||
entity.setEntityType(ApplicationMetricsConstants.ENTITY_TYPE);
|
entity.setEntityType(ApplicationMetricsConstants.ENTITY_TYPE);
|
||||||
entity.setEntityId(appId.toString());
|
entity.setEntityId(appId.toString());
|
||||||
|
@ -410,8 +422,12 @@ public class TestApplicationHistoryManagerOnTimelineStore {
|
||||||
entityInfo.put(ApplicationMetricsConstants.QUEUE_ENTITY_INFO, "test queue");
|
entityInfo.put(ApplicationMetricsConstants.QUEUE_ENTITY_INFO, "test queue");
|
||||||
entityInfo.put(ApplicationMetricsConstants.SUBMITTED_TIME_ENTITY_INFO,
|
entityInfo.put(ApplicationMetricsConstants.SUBMITTED_TIME_ENTITY_INFO,
|
||||||
Integer.MAX_VALUE + 1L);
|
Integer.MAX_VALUE + 1L);
|
||||||
|
if (emptyACLs) {
|
||||||
|
entityInfo.put(ApplicationMetricsConstants.APP_VIEW_ACLS_ENTITY_INFO, "");
|
||||||
|
} else {
|
||||||
entityInfo.put(ApplicationMetricsConstants.APP_VIEW_ACLS_ENTITY_INFO,
|
entityInfo.put(ApplicationMetricsConstants.APP_VIEW_ACLS_ENTITY_INFO,
|
||||||
"user2");
|
"user2");
|
||||||
|
}
|
||||||
entity.setOtherInfo(entityInfo);
|
entity.setOtherInfo(entityInfo);
|
||||||
TimelineEvent tEvent = new TimelineEvent();
|
TimelineEvent tEvent = new TimelineEvent();
|
||||||
tEvent.setEventType(ApplicationMetricsConstants.CREATED_EVENT_TYPE);
|
tEvent.setEventType(ApplicationMetricsConstants.CREATED_EVENT_TYPE);
|
||||||
|
|
|
@ -137,7 +137,7 @@ public class SystemMetricsPublisher extends CompositeService {
|
||||||
dispatcher.getEventHandler().handle(
|
dispatcher.getEventHandler().handle(
|
||||||
new ApplicationACLsUpdatedEvent(
|
new ApplicationACLsUpdatedEvent(
|
||||||
app.getApplicationId(),
|
app.getApplicationId(),
|
||||||
appViewACLs,
|
appViewACLs == null ? "" : appViewACLs,
|
||||||
updatedTime));
|
updatedTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,11 +95,17 @@ public class TestSystemMetricsPublisher {
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test(timeout = 10000)
|
||||||
public void testPublishApplicationMetrics() throws Exception {
|
public void testPublishApplicationMetrics() throws Exception {
|
||||||
ApplicationId appId = ApplicationId.newInstance(0, 1);
|
for (int i = 1; i <= 2; ++i) {
|
||||||
|
ApplicationId appId = ApplicationId.newInstance(0, i);
|
||||||
RMApp app = createRMApp(appId);
|
RMApp app = createRMApp(appId);
|
||||||
metricsPublisher.appCreated(app, app.getStartTime());
|
metricsPublisher.appCreated(app, app.getStartTime());
|
||||||
metricsPublisher.appFinished(app, RMAppState.FINISHED, app.getFinishTime());
|
metricsPublisher.appFinished(app, RMAppState.FINISHED, app.getFinishTime());
|
||||||
|
if (i == 1) {
|
||||||
metricsPublisher.appACLsUpdated(app, "uers1,user2", 4L);
|
metricsPublisher.appACLsUpdated(app, "uers1,user2", 4L);
|
||||||
|
} else {
|
||||||
|
// in case user doesn't specify the ACLs
|
||||||
|
metricsPublisher.appACLsUpdated(app, null, 4L);
|
||||||
|
}
|
||||||
TimelineEntity entity = null;
|
TimelineEntity entity = null;
|
||||||
do {
|
do {
|
||||||
entity =
|
entity =
|
||||||
|
@ -134,9 +140,14 @@ public class TestSystemMetricsPublisher {
|
||||||
Assert.assertEquals(app.getSubmitTime(),
|
Assert.assertEquals(app.getSubmitTime(),
|
||||||
entity.getOtherInfo().get(
|
entity.getOtherInfo().get(
|
||||||
ApplicationMetricsConstants.SUBMITTED_TIME_ENTITY_INFO));
|
ApplicationMetricsConstants.SUBMITTED_TIME_ENTITY_INFO));
|
||||||
|
if (i == 1) {
|
||||||
Assert.assertEquals("uers1,user2",
|
Assert.assertEquals("uers1,user2",
|
||||||
entity.getOtherInfo().get(
|
entity.getOtherInfo().get(
|
||||||
ApplicationMetricsConstants.APP_VIEW_ACLS_ENTITY_INFO));
|
ApplicationMetricsConstants.APP_VIEW_ACLS_ENTITY_INFO));
|
||||||
|
} else {
|
||||||
|
Assert.assertEquals("", entity.getOtherInfo().get(
|
||||||
|
ApplicationMetricsConstants.APP_VIEW_ACLS_ENTITY_INFO));
|
||||||
|
}
|
||||||
boolean hasCreatedEvent = false;
|
boolean hasCreatedEvent = false;
|
||||||
boolean hasFinishedEvent = false;
|
boolean hasFinishedEvent = false;
|
||||||
boolean hasACLsUpdatedEvent = false;
|
boolean hasACLsUpdatedEvent = false;
|
||||||
|
@ -167,6 +178,7 @@ public class TestSystemMetricsPublisher {
|
||||||
}
|
}
|
||||||
Assert.assertTrue(hasCreatedEvent && hasFinishedEvent && hasACLsUpdatedEvent);
|
Assert.assertTrue(hasCreatedEvent && hasFinishedEvent && hasACLsUpdatedEvent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test(timeout = 10000)
|
||||||
public void testPublishAppAttemptMetrics() throws Exception {
|
public void testPublishAppAttemptMetrics() throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue