diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 872eb398673..92af0a84d9b 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -597,6 +597,9 @@ Release 2.6.0 - UNRELEASED YARN-2652 Add hadoop-yarn-registry package under hadoop-yarn. (stevel) + YARN-2598 GHS should show N/A instead of null for the inaccessible information + (Zhijie Shen via mayank) + Release 2.5.1 - 2014-09-05 INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerOnTimelineStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerOnTimelineStore.java index 5381bd6cb21..e1a4d1b1e9f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerOnTimelineStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerOnTimelineStore.java @@ -59,10 +59,15 @@ import org.apache.hadoop.yarn.server.timeline.TimelineReader.Field; import org.apache.hadoop.yarn.util.ConverterUtils; import org.apache.hadoop.yarn.webapp.util.WebAppUtils; +import com.google.common.annotations.VisibleForTesting; + public class ApplicationHistoryManagerOnTimelineStore extends AbstractService implements ApplicationHistoryManager { + @VisibleForTesting + static final String UNAVAILABLE = "N/A"; + private TimelineDataManager timelineDataManager; private ApplicationACLsManager aclsManager; private String serverHttpAddress; @@ -508,6 +513,21 @@ public class ApplicationHistoryManagerOnTimelineStore extends AbstractService app.appReport.setCurrentApplicationAttemptId( ApplicationAttemptId.newInstance(app.appReport.getApplicationId(), -1)); } + if (app.appReport.getHost() == null) { + app.appReport.setHost(UNAVAILABLE); + } + if (app.appReport.getRpcPort() < 0) { + app.appReport.setRpcPort(-1); + } + if (app.appReport.getTrackingUrl() == null) { + app.appReport.setTrackingUrl(UNAVAILABLE); + } + if (app.appReport.getOriginalTrackingUrl() == null) { + app.appReport.setOriginalTrackingUrl(UNAVAILABLE); + } + if (app.appReport.getDiagnostics() == null) { + app.appReport.setDiagnostics(""); + } return app; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryManagerOnTimelineStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryManagerOnTimelineStore.java index f6c14817021..311626eef50 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryManagerOnTimelineStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryManagerOnTimelineStore.java @@ -178,16 +178,19 @@ public class TestApplicationHistoryManagerOnTimelineStore { callerUGI.getShortUserName().equals("user3")))) { Assert.assertEquals(ApplicationAttemptId.newInstance(appId, -1), app.getCurrentApplicationAttemptId()); - Assert.assertEquals(null, app.getHost()); + Assert.assertEquals(ApplicationHistoryManagerOnTimelineStore.UNAVAILABLE, + app.getHost()); Assert.assertEquals(-1, app.getRpcPort()); - Assert.assertEquals(null, app.getTrackingUrl()); - Assert.assertEquals(null, app.getOriginalTrackingUrl()); - Assert.assertEquals(null, app.getDiagnostics()); + Assert.assertEquals(ApplicationHistoryManagerOnTimelineStore.UNAVAILABLE, + app.getTrackingUrl()); + Assert.assertEquals(ApplicationHistoryManagerOnTimelineStore.UNAVAILABLE, + app.getOriginalTrackingUrl()); + Assert.assertEquals("", app.getDiagnostics()); } else { Assert.assertEquals(ApplicationAttemptId.newInstance(appId, 1), app.getCurrentApplicationAttemptId()); Assert.assertEquals("test host", app.getHost()); - Assert.assertEquals(-100, app.getRpcPort()); + Assert.assertEquals(100, app.getRpcPort()); Assert.assertEquals("test tracking url", app.getTrackingUrl()); Assert.assertEquals("test original tracking url", app.getOriginalTrackingUrl()); @@ -236,7 +239,7 @@ public class TestApplicationHistoryManagerOnTimelineStore { Assert.assertEquals(ContainerId.newInstance(appAttemptId, 1), appAttempt.getAMContainerId()); Assert.assertEquals("test host", appAttempt.getHost()); - Assert.assertEquals(-100, appAttempt.getRpcPort()); + Assert.assertEquals(100, appAttempt.getRpcPort()); Assert.assertEquals("test tracking url", appAttempt.getTrackingUrl()); Assert.assertEquals("test original tracking url", appAttempt.getOriginalTrackingUrl()); @@ -282,7 +285,7 @@ public class TestApplicationHistoryManagerOnTimelineStore { Assert.assertEquals(Integer.MAX_VALUE + 2L, container.getFinishTime()); Assert.assertEquals(Resource.newInstance(-1, -1), container.getAllocatedResource()); - Assert.assertEquals(NodeId.newInstance("test host", -100), + Assert.assertEquals(NodeId.newInstance("test host", 100), container.getAssignedNode()); Assert.assertEquals(Priority.UNDEFINED, container.getPriority()); Assert @@ -290,7 +293,7 @@ public class TestApplicationHistoryManagerOnTimelineStore { Assert.assertEquals(ContainerState.COMPLETE, container.getContainerState()); Assert.assertEquals(-1, container.getContainerExitStatus()); Assert.assertEquals("http://0.0.0.0:8188/applicationhistory/logs/" + - "test host:-100/container_0_0001_01_000001/" + "test host:100/container_0_0001_01_000001/" + "container_0_0001_01_000001/user1", container.getLogUrl()); } @@ -471,7 +474,7 @@ public class TestApplicationHistoryManagerOnTimelineStore { eventInfo.put(AppAttemptMetricsConstants.ORIGINAL_TRACKING_URL_EVENT_INFO, "test original tracking url"); eventInfo.put(AppAttemptMetricsConstants.HOST_EVENT_INFO, "test host"); - eventInfo.put(AppAttemptMetricsConstants.RPC_PORT_EVENT_INFO, -100); + eventInfo.put(AppAttemptMetricsConstants.RPC_PORT_EVENT_INFO, 100); eventInfo.put(AppAttemptMetricsConstants.MASTER_CONTAINER_EVENT_INFO, ContainerId.newInstance(appAttemptId, 1)); tEvent.setEventInfo(eventInfo); @@ -509,7 +512,7 @@ public class TestApplicationHistoryManagerOnTimelineStore { entityInfo.put(ContainerMetricsConstants.ALLOCATED_VCORE_ENTITY_INFO, -1); entityInfo.put(ContainerMetricsConstants.ALLOCATED_HOST_ENTITY_INFO, "test host"); - entityInfo.put(ContainerMetricsConstants.ALLOCATED_PORT_ENTITY_INFO, -100); + entityInfo.put(ContainerMetricsConstants.ALLOCATED_PORT_ENTITY_INFO, 100); entityInfo .put(ContainerMetricsConstants.ALLOCATED_PRIORITY_ENTITY_INFO, -1); entity.setOtherInfo(entityInfo);