From a651b335d7316c540633c59f7799cb1ac2d707a0 Mon Sep 17 00:00:00 2001 From: Sunil Date: Thu, 13 Oct 2016 00:16:47 +0530 Subject: [PATCH] YARN-5145-YARN-3368 --- .../src/main/webapp/app/initializers/loader.js | 63 ++++++++++++++++++++++ .../webapp/tests/unit/initializers/loader-test.js | 40 ++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/initializers/loader.js create mode 100644 hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/tests/unit/initializers/loader-test.js 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 new file mode 100644 index 0000000..757af34 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/initializers/loader.js @@ -0,0 +1,63 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +function getTimeLineURL(parameters) { + return '/conf?name=yarn.timeline-service.webapp.address'; +} + +function updateConfigs(parameters) { + var rmhost = + window.location.hostname + + (window.location.port ? ':' + window.location.port: ''); + + console.log("RM Info:" + rmhost); + + var result = []; + var timelinehost = ""; + $.ajax({ + type: 'GET', + dataType: 'json', + async: true, + context: this, + url: getTimeLineURL(), + success: function(data) { + timelinehost = data.property.value; + console.log("Timeline Info:" + timelinehost); + ENV = { + hosts: { + rmWebAddress: rmhost, + timelineWebAddress: timelinehost, + }, + }; + }, + }); +} + +export function initialize( application ) { + application.deferReadiness(); + updateConfigs(); + + application.advanceReadiness(); +} + +export default { + name: 'loader', + before: 'env', + initialize +}; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/tests/unit/initializers/loader-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/tests/unit/initializers/loader-test.js new file mode 100644 index 0000000..cc32e92 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/tests/unit/initializers/loader-test.js @@ -0,0 +1,40 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ember from 'ember'; +import LoaderInitializer from '../../../initializers/loader'; +import { module, test } from 'qunit'; + +let application; + +module('Unit | Initializer | loader', { + beforeEach() { + Ember.run(function() { + application = Ember.Application.create(); + application.deferReadiness(); + }); + } +}); + +// Replace this with your real tests. +test('it works', function(assert) { + LoaderInitializer.initialize(application); + + // you would normally confirm the results of the initializer here + assert.ok(true); +}); -- 2.7.4 (Apple Git-66)