123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- /**
- * 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.
- */
- /* globals ENV: true */
- import Ember from 'ember';
- function getTimeLineURL(rmhost) {
- var url = window.location.protocol + '//' +
- (ENV.hosts.localBaseAddress? ENV.hosts.localBaseAddress + '/' : '') + rmhost;
- url += '/conf?name=yarn.timeline-service.reader.webapp.address';
- 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;
- }
- function updateConfigs(application) {
- var hostname = window.location.hostname;
- var rmhost = hostname + (window.location.port ? ':' + window.location.port: '') + skipTrailingSlash(window.location.pathname);
- if(!ENV.hosts.rmWebAddress) {
- ENV.hosts.rmWebAddress = rmhost;
- } else {
- rmhost = ENV.hosts.rmWebAddress;
- }
- Ember.Logger.log("RM Address: " + rmhost);
- if(!ENV.hosts.timelineWebAddress) {
- var timelinehost = "";
- $.ajax({
- type: 'GET',
- dataType: 'json',
- async: true,
- context: this,
- url: getTimeLineURL(rmhost),
- success: function(data) {
- timelinehost = data.property.value;
- ENV.hosts.timelineWebAddress = timelinehost;
- var address = timelinehost.split(":")[0];
- var port = timelinehost.split(":")[1];
- Ember.Logger.log("Timeline Address from RM: " + timelinehost);
- if(address === "0.0.0.0" || address === "localhost") {
- var updatedAddress = hostname + ":" + port;
- ENV.hosts.timelineWebAddress = updatedAddress;
- Ember.Logger.log("Timeline Updated Address: " + updatedAddress);
- }
- application.advanceReadiness();
- },
- error: function() {
- application.advanceReadiness();
- }
- });
- } else {
- 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();
- },
- error: function() {
- application.advanceReadiness();
- }
- });
- } else {
- Ember.Logger.log("Timeline V1 Address: " + ENV.hosts.timelineV1WebAddress);
- application.advanceReadiness();
- }
- }
- export function initialize( application ) {
- application.deferReadiness();
- updateConfigs(application);
- }
- export default {
- name: 'loader',
- before: 'env',
- initialize
- };
- const skipTrailingSlash = function(path) {
- path = path.replace('ui2/', '');
- return path.replace(/\/$/, '');
- };
|