From c5bbd6418ed1a7b78bf5bd6c1e0fad1dc9fab300 Mon Sep 17 00:00:00 2001 From: Rohith Sharma K S Date: Fri, 19 Jan 2018 15:48:16 +0530 Subject: [PATCH] YARN-7753. [UI2] Application logs has to be pulled from ATS 1.5 instead of ATS2. Contributed by Sunil G. --- .../src/main/webapp/app/adapters/yarn-log.js | 2 +- .../main/webapp/app/initializers/loader.js | 41 ++++++++++++++++++- .../main/webapp/app/serializers/yarn-log.js | 6 +++ .../src/main/webapp/app/services/hosts.js | 4 ++ .../src/main/webapp/config/default-config.js | 1 + 5 files changed, 52 insertions(+), 2 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-log.js index df29b71b689..979ec79155f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-log.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-log.js @@ -19,7 +19,7 @@ import AbstractAdapter from './abstract'; export default AbstractAdapter.extend({ - address: "timelineWebAddress", + address: "timelineV1WebAddress", // restNameSpace: "timelineV2", // Use ATSv2 when it supports log APIs. restNameSpace: "timeline", //Using ATSv1.5 now, would be supported by ATSv2 very soon. serverName: "ATS", diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/initializers/loader.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/initializers/loader.js index 9d63de3d15e..58c6354f95c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/initializers/loader.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/initializers/loader.js @@ -25,7 +25,16 @@ function getTimeLineURL(rmhost) { (ENV.hosts.localBaseAddress? ENV.hosts.localBaseAddress + '/' : '') + rmhost; url += '/conf?name=yarn.timeline-service.reader.webapp.address'; - Ember.Logger.log("Get Timeline Address URL: " + url); + Ember.Logger.log("Get Timeline V2 Address URL: " + url); + return url; +} + +function getTimeLineV1URL(rmhost) { + var url = window.location.protocol + '//' + + (ENV.hosts.localBaseAddress? ENV.hosts.localBaseAddress + '/' : '') + rmhost; + + url += '/conf?name=yarn.timeline-service.webapp.address'; + Ember.Logger.log("Get Timeline V1 Address URL: " + url); return url; } @@ -70,6 +79,36 @@ function updateConfigs(application) { Ember.Logger.log("Timeline Address: " + ENV.hosts.timelineWebAddress); application.advanceReadiness(); } + + if(!ENV.hosts.timelineV1WebAddress) { + var timelinehost = ""; + $.ajax({ + type: 'GET', + dataType: 'json', + async: true, + context: this, + url: getTimeLineV1URL(rmhost), + success: function(data) { + timelinehost = data.property.value; + ENV.hosts.timelineV1WebAddress = timelinehost; + + var address = timelinehost.split(":")[0]; + var port = timelinehost.split(":")[1]; + + Ember.Logger.log("Timeline V1 Address from RM: " + timelinehost); + + if(address === "0.0.0.0" || address === "localhost") { + var updatedAddress = hostname + ":" + port; + ENV.hosts.timelineV1WebAddress = updatedAddress; + Ember.Logger.log("Timeline V1 Updated Address: " + updatedAddress); + } + application.advanceReadiness(); + } + }); + } else { + Ember.Logger.log("Timeline V1 Address: " + ENV.hosts.timelineV1WebAddress); + application.advanceReadiness(); + } } export function initialize( application ) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-log.js index 93174d026a9..c41170870fa 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-log.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/serializers/yarn-log.js @@ -43,6 +43,12 @@ export default DS.JSONAPISerializer.extend({ payload.containerLogsInfo.containerId, payload.containerLogsInfo.nodeId); }); } + if (payload && payload[0] && payload[0].containerLogInfo) { + normalizedArrayResponse.data = payload[0].containerLogInfo.map((paylog) => { + return this.internalNormalizeSingleResponse(store, primaryModelClass, paylog, + payload[0].containerId, payload[0].nodeId); + }); + } return normalizedArrayResponse; } }); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/services/hosts.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/services/hosts.js index 9359530a93b..738f5f16ca2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/services/hosts.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/services/hosts.js @@ -72,6 +72,10 @@ export default Ember.Service.extend({ return this.normalizeURL(this.get("env.app.hosts.timelineWebAddress")); }), + timelineV1WebAddress: Ember.computed(function () { + return this.normalizeURL(this.get("env.app.hosts.timelineV1WebAddress")); + }), + rmWebAddress: Ember.computed(function () { return this.normalizeURL(this.get("env.app.hosts.rmWebAddress")); }), diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/config/default-config.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/config/default-config.js index 792f4427d48..e916361b5ab 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/config/default-config.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/config/default-config.js @@ -20,6 +20,7 @@ module.exports = { // YARN UI App configurations hosts: { localBaseAddress: "", timelineWebAddress: "localhost:8188", + timelineV1WebAddress: "localhost:8188", rmWebAddress: "localhost:8088", protocolScheme: "http:" },