http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/bdd79e46/eagle-external/eagle-ambari/lib/EAGLE/package/patches/app.js ---------------------------------------------------------------------- diff --git a/eagle-external/eagle-ambari/lib/EAGLE/package/patches/app.js b/eagle-external/eagle-ambari/lib/EAGLE/package/patches/app.js new file mode 100644 index 0000000..ee8bd57 --- /dev/null +++ b/eagle-external/eagle-ambari/lib/EAGLE/package/patches/app.js @@ -0,0 +1,173797 @@ +(function(/*! Brunch !*/) { + 'use strict'; + + var globals = typeof window !== 'undefined' ? window : global; + if (typeof globals.require === 'function') return; + + var modules = {}; + var cache = {}; + + var has = function(object, name) { + return ({}).hasOwnProperty.call(object, name); + }; + + var expand = function(root, name) { + var results = [], parts, part; + if (/^\.\.?(\/|$)/.test(name)) { + parts = [root, name].join('/').split('/'); + } else { + parts = name.split('/'); + } + for (var i = 0, length = parts.length; i < length; i++) { + part = parts[i]; + if (part === '..') { + results.pop(); + } else if (part !== '.' && part !== '') { + results.push(part); + } + } + return results.join('/'); + }; + + var dirname = function(path) { + return path.split('/').slice(0, -1).join('/'); + }; + + var localRequire = function(path) { + return function(name) { + var dir = dirname(path); + var absolute = expand(dir, name); + return globals.require(absolute, path); + }; + }; + + var initModule = function(name, definition) { + var module = {id: name, exports: {}}; + cache[name] = module; + definition(module.exports, localRequire(name), module); + return module.exports; + }; + + var require = function(name, loaderPath) { + var path = expand(name, '.'); + if (loaderPath == null) loaderPath = '/'; + + if (has(cache, path)) return cache[path].exports; + if (has(modules, path)) return initModule(path, modules[path]); + + var dirIndex = expand(path, './index'); + if (has(cache, dirIndex)) return cache[dirIndex].exports; + if (has(modules, dirIndex)) return initModule(dirIndex, modules[dirIndex]); + + throw new Error('Cannot find module "' + name + '" from '+ '"' + loaderPath + '"'); + }; + + var define = function(bundle, fn) { + if (typeof bundle === 'object') { + for (var key in bundle) { + if (has(bundle, key)) { + modules[key] = bundle[key]; + } + } + } else { + modules[bundle] = fn; + } + }; + + var list = function() { + var result = []; + for (var item in modules) { + if (has(modules, item)) { + result.push(item); + } + } + return result; + }; + + globals.require = require; + globals.require.define = define; + globals.require.register = define; + globals.require.list = list; + globals.require.brunch = true; +})(); +require.register("app", function(exports, require, module) { +/** + * 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. + */ + +// Application bootstrapper +require('utils/ember_reopen'); +var stringUtils = require('utils/string_utils'); + +module.exports = Em.Application.create({ + name: 'Ambari Web', + rootElement: '#wrapper', + + store: DS.Store.create({ + revision: 4, + adapter: DS.FixtureAdapter.create({ + simulateRemoteResponse: false + }), + typeMaps: {}, + recordCache: [] + }), + isAdmin: false, + isOperator: false, + + /** + * state of stack upgrade process + * states: + * - INIT + * - PENDING + * - IN_PROGRESS + * - HOLDING + * - COMPLETED + * @type {String} + */ + upgradeState: 'INIT', + + /** + * flag is true when upgrade process is running + * @returns {boolean} + */ + upgradeInProgress: function() { + return ["IN_PROGRESS"].contains(this.get('upgradeState')); + }.property('upgradeState'), + + /** + * flag is true when upgrade process is waiting for user action + * to procced, retry, perform manual steps etc. + * @returns {boolean} + */ + upgradeHolding: function() { + return this.get('upgradeState').contains("HOLDING"); + }.property('upgradeState'), + + /** + * RU is running + * @type {boolean} + */ + upgradeIsRunning: function() { + return this.get('upgradeInProgress') || this.get('upgradeHolding'); + }.property('upgradeInProgress', 'upgradeHolding'), + + /** + * compute user access rights by permission type + * types: + * - ADMIN + * - MANAGER + * - OPERATOR + * - ONLY_ADMIN + * prefix "upgrade_" mean that element will not be unconditionally blocked while stack upgrade running + * @param type {string} + * @return {boolean} + */ + isAccessible: function (type) { + if (!App.get('supports.opsDuringRollingUpgrade') && !['INIT', 'COMPLETED'].contains(this.get('upgradeState')) && !type.contains('upgrade_')) { + return false; + } + + if (type.contains('upgrade_')) { + //slice off "upgrade_" prefix to have actual permission type + type = type.slice(8); + } + + switch (type) { + case 'ADMIN': + return this.get('isAdmin'); + case 'NON_ADMIN': + return !this.get('isAdmin'); + case 'MANAGER': + return this.get('isAdmin') || this.get('isOperator'); + case 'OPERATOR': + return this.get('isOperator'); + case 'ONLY_ADMIN': + return this.get('isAdmin') && !this.get('isOperator'); + default: + return false; + } + }, + + isStackServicesLoaded: false, + /** + * return url prefix with number value of version of HDP stack + */ + stackVersionURL: function () { + return '/stacks/{0}/versions/{1}'.format(this.get('currentStackName') || 'HDP', this.get('currentStackVersionNumber')); + }.property('currentStackName','currentStackVersionNumber'), + + falconServerURL: function () { + var falconService = this.Service.find().findProperty('serviceName', 'FALCON'); + if (falconService) { + return falconService.get('hostComponents').findProperty('componentName', 'FALCON_SERVER').get('hostName'); + } + return ''; + }.property().volatile(), + + /* Determine if Application Timeline Service supports Kerberization. + * Because this value is retrieved from the cardinality of the component, it is safe to keep in app.js + * since its value will not change during the lifetime of the application. + */ + doesATSSupportKerberos: function() { + var YARNService = App.StackServiceComponent.find().filterProperty('serviceName', 'YARN'); + if (YARNService.length) { + var ATS = App.StackServiceComponent.find().findProperty('componentName', 'APP_TIMELINE_SERVER'); + return (!!ATS && !!ATS.get('minToInstall')); + } + return false; + }.property('router.clusterController.isLoaded'), + + clusterName: null, + clockDistance: null, // server clock - client clock + currentStackVersion: '', + currentStackName: function() { + return Em.get((this.get('currentStackVersion') || this.get('defaultStackVersion')).match(/(.+)-\d.+/), '1'); + }.property('currentStackVersion', 'defaultStackVersion'), + + /** + * true if cluster has only 1 host + * for now is used to disable move/HA actions + * @type {boolean} + */ + isSingleNode: function() { + return this.get('allHostNames.length') === 1; + }.property('allHostNames.length'), + + allHostNames: [], + + currentStackVersionNumber: function () { + var regExp = new RegExp(this.get('currentStackName') + '-'); + return (this.get('currentStackVersion') || this.get('defaultStackVersion')).replace(regExp, ''); + }.property('currentStackVersion', 'defaultStackVersion', 'currentStackName'), + + isHadoop22Stack: function () { + return (stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.2") > -1); + }.property('currentStackVersionNumber'), + + /** + * Determines if current stack is 2.0.* + * @type {boolean} + */ + isHadoop20Stack: function () { + return (stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.1") == -1 && stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.0") > -1); + }.property('currentStackVersionNumber'), + + isHadoopWindowsStack: function() { + return this.get('currentStackName') == "HDPWIN"; + }.property('currentStackName'), + + /** + * If NameNode High Availability is enabled + * Based on <code>clusterStatus.isInstalled</code>, stack version, <code>SNameNode</code> availability + * + * @type {bool} + */ + isHaEnabled: function () { + var isHDFSInstalled = App.Service.find().findProperty('serviceName','HDFS'); + return !!isHDFSInstalled && !this.HostComponent.find().someProperty('componentName', 'SECONDARY_NAMENODE'); + }.property('router.clusterController.isLoaded', 'router.clusterController.dataLoadList.serviceMetrics'), + + /** + * If ResourceManager High Availability is enabled + * Based on number of ResourceManager components host components installed + * + * @type {bool} + */ + isRMHaEnabled: function () { + var result = false; + var rmStackComponent = App.StackServiceComponent.find().findProperty('componentName','RESOURCEMANAGER'); + if (rmStackComponent && rmStackComponent.get('isMultipleAllowed')) { + result = this.HostComponent.find().filterProperty('componentName', 'RESOURCEMANAGER').length > 1; + } + return result; + }.property('router.clusterController.isLoaded', 'isStackServicesLoaded'), + + /** + * Object with utility functions for list of service names with similar behavior + */ + services: Em.Object.create({ + all: function () { + return App.StackService.find().mapProperty('serviceName'); + }.property('App.router.clusterController.isLoaded'), + + clientOnly: function () { + return App.StackService.find().filterProperty('isClientOnlyService').mapProperty('serviceName'); + }.property('App.router.clusterController.isLoaded'), + + hasClient: function () { + return App.StackService.find().filterProperty('hasClient').mapProperty('serviceName'); + }.property('App.router.clusterController.isLoaded'), + + hasMaster: function () { + return App.StackService.find().filterProperty('hasMaster').mapProperty('serviceName'); + }.property('App.router.clusterController.isLoaded'), + + hasSlave: function () { + return App.StackService.find().filterProperty('hasSlave').mapProperty('serviceName'); + }.property('App.router.clusterController.isLoaded'), + + noConfigTypes: function () { + return App.StackService.find().filterProperty('isNoConfigTypes').mapProperty('serviceName'); + }.property('App.router.clusterController.isLoaded'), + + monitoring: function () { + return App.StackService.find().filterProperty('isMonitoringService').mapProperty('serviceName'); + }.property('App.router.clusterController.isLoaded'), + + hostMetrics: function () { + return App.StackService.find().filterProperty('isHostMetricsService').mapProperty('serviceName'); + }.property('App.router.clusterController.isLoaded'), + + serviceMetrics: function () { + return App.StackService.find().filterProperty('isServiceMetricsService').mapProperty('serviceName'); + }.property('App.router.clusterController.isLoaded'), + + supportsServiceCheck: function() { + return App.StackService.find().filterProperty('serviceCheckSupported').mapProperty('serviceName'); + }.property('App.router.clusterController.isLoaded') + }), + + /** + * List of components with allowed action for them + * @type {Em.Object} + */ + components: Em.Object.create({ + allComponents: function () { + return App.StackServiceComponent.find().mapProperty('componentName') + }.property('App.router.clusterController.isLoaded'), + + reassignable: function () { + return App.StackServiceComponent.find().filterProperty('isReassignable').mapProperty('componentName') + }.property('App.router.clusterController.isLoaded'), + + restartable: function () { + return App.StackServiceComponent.find().filterProperty('isRestartable').mapProperty('componentName') + }.property('App.router.clusterController.isLoaded'), + + deletable: function () { + return App.StackServiceComponent.find().filterProperty('isDeletable').mapProperty('componentName') + }.property('App.router.clusterController.isLoaded'), + + rollinRestartAllowed: function () { + return App.StackServiceComponent.find().filterProperty('isRollinRestartAllowed').mapProperty('componentName') + }.property('App.router.clusterController.isLoaded'), + + decommissionAllowed: function () { + return App.StackServiceComponent.find().filterProperty('isDecommissionAllowed').mapProperty('componentName') + }.property('App.router.clusterController.isLoaded'), + + refreshConfigsAllowed: function () { + return App.StackServiceComponent.find().filterProperty('isRefreshConfigsAllowed').mapProperty('componentName') + }.property('App.router.clusterController.isLoaded'), + + addableToHost: function () { + return App.StackServiceComponent.find().filterProperty('isAddableToHost').mapProperty('componentName') + }.property('App.router.clusterController.isLoaded'), + + addableMasterInstallerWizard: function () { + return App.StackServiceComponent.find().filterProperty('isMasterAddableInstallerWizard').filterProperty('showAddBtnInInstall').mapProperty('componentName') + }.property('App.router.clusterController.isLoaded'), + + multipleMasters: function () { + return App.StackServiceComponent.find().filterProperty('isMasterWithMultipleInstances').mapProperty('componentName') + }.property('App.router.clusterController.isLoaded'), + + slaves: function () { + return App.StackServiceComponent.find().filterProperty('isSlave').mapProperty('componentName') + }.property('App.router.clusterController.isLoaded'), + + masters: function () { + return App.StackServiceComponent.find().filterProperty('isMaster').mapProperty('componentName') + }.property('App.router.clusterController.isLoaded'), + + clients: function () { + return App.StackServiceComponent.find().filterProperty('isClient').mapProperty('componentName') + }.property('App.router.clusterController.isLoaded') + }) +}); + +}); + +require.register("config", function(exports, require, module) { +/** + * 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. + */ + + +var App = require('app'); + +App.version = '2.0.0'; // filled out by set-ambari-version.sh script +App.testMode = (location.port == '3333'); // test mode is automatically enabled if running on brunch server +App.testModeDelayForActions = 10000; +App.skipBootstrap = false; +App.alwaysGoToInstaller = false; +App.testEnableSecurity = true; // By default enable security is tested; turning it false tests disable security +App.testNameNodeHA = true; +App.apiPrefix = '/api/v1'; +App.defaultStackVersion = 'HDP-2.2'; +App.defaultWindowsStackVersion = 'HDPWIN-2.1'; + +App.defaultJavaHome = '/usr/jdk/jdk1.6.0_31'; +App.timeout = 180000; // default AJAX timeout +App.maxRetries = 3; // max number of retries for certain AJAX calls +App.sessionKeepAliveInterval = 60000; +App.bgOperationsUpdateInterval = 6000; +App.componentsUpdateInterval = 6000; +App.contentUpdateInterval = 15000; +App.hostStatusCountersUpdateInterval = 10000; +App.alertDefinitionsUpdateInterval = 10000; +App.alertInstancesUpdateInterval = 10000; +App.alertGroupsUpdateInterval = 10000; +App.pageReloadTime=3600000; +App.singleNodeInstall = true; +App.singleNodeAlias = document.location.hostname; +App.minDiskSpace = 2.0; // minimum disk space required for '/' for each host before install, unit GB +App.minDiskSpaceUsrLib = 1.0; // minimum disk space for '/usr/lib' for each host before install, unit GB +App.healthIconClassGreen = 'icon-ok-sign'; // bootstrap icon class for healthy/started service/host/host-component +App.healthIconClassRed = 'icon-warning-sign'; // bootstrap icon class for master down/stopped service/host/host-component +App.healthIconClassOrange = 'icon-minus-sign'; // bootstrap icon class for slave down/decommissioned host/host-component +App.healthIconClassYellow = 'icon-question-sign'; // bootstrap icon class for heartbeat lost service/host/host-component +App.isManagedMySQLForHiveEnabled = false; +App.isStormMetricsSupported = true; +App.healthStatusRed = '#ff0000'; +App.healthStatusGreen = '#5AB400'; +App.healthStatusOrange = '#FF8E00'; + +App.stackVersionsAvailable = true; + +// experimental features are automatically enabled if running on brunch server +App.enableExperimental = false; + +App.supports = { + preUpgradeCheck: true, + stackUpgrade: true, + displayOlderVersions: false, + autoRollbackHA: false, + alwaysEnableManagedMySQLForHive: false, + preKerberizeCheck: false, + automatedKerberos: true, + customizeAgentUserAccount: false, + installGanglia: false, + opsDuringRollingUpgrade: false +}; + +if (App.enableExperimental) { + for (var support in App.supports) { + App.supports[support] = true; + } +} + +// this is to make sure that IE does not cache data when making AJAX calls to the server +if (!$.mocho) { + $.ajaxSetup({ + cache: false, + headers: {"X-Requested-By": "X-Requested-By"} + }); +} + +/** + * Test Mode values + */ +App.test_hostname = 'hostname'; + +}); + +require.register("controllers", function(exports, require, module) { +/** + * 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. + */ + + +// load all controllers here + +require('controllers/application'); +require('controllers/login_controller'); +require('controllers/wizard'); +require('controllers/installer'); +require('controllers/global/background_operations_controller'); +require('controllers/main'); +require('controllers/main/dashboard'); +require('controllers/main/dashboard/config_history_controller'); +require('controllers/main/admin'); +require('controllers/main/admin/highAvailability_controller'); +require('controllers/main/admin/highAvailability/nameNode/wizard_controller'); +require('controllers/main/admin/highAvailability/progress_controller'); +require('controllers/main/admin/highAvailability/progress_popup_controller'); +require('controllers/main/admin/highAvailability/nameNode/rollback_controller'); +require('controllers/main/admin/highAvailability/nameNode/step1_controller'); +require('controllers/main/admin/highAvailability/nameNode/step2_controller'); +require('controllers/main/admin/highAvailability/nameNode/step3_controller'); +require('controllers/main/admin/highAvailability/nameNode/step4_controller'); +require('controllers/main/admin/highAvailability/nameNode/step5_controller'); +require('controllers/main/admin/highAvailability/nameNode/step6_controller'); +require('controllers/main/admin/highAvailability/nameNode/step7_controller'); +require('controllers/main/admin/highAvailability/nameNode/step8_controller'); +require('controllers/main/admin/highAvailability/nameNode/step9_controller'); +require('controllers/main/admin/highAvailability/nameNode/rollbackHA/step1_controller'); +require('controllers/main/admin/highAvailability/nameNode/rollbackHA/step2_controller'); +require('controllers/main/admin/highAvailability/nameNode/rollbackHA/step3_controller'); +require('controllers/main/admin/highAvailability/nameNode/rollbackHA/rollback_wizard_controller'); +require('controllers/main/admin/highAvailability/resourceManager/wizard_controller'); +require('controllers/main/admin/highAvailability/resourceManager/step1_controller'); +require('controllers/main/admin/highAvailability/resourceManager/step2_controller'); +require('controllers/main/admin/highAvailability/resourceManager/step3_controller'); +require('controllers/main/admin/highAvailability/resourceManager/step4_controller'); +require('controllers/main/admin/stack_and_upgrade_controller'); +require('controllers/main/admin/serviceAccounts_controller'); +require('controllers/main/admin/advanced'); +require('utils/polling'); +require('controllers/main/admin/kerberos'); +require('controllers/main/admin/kerberos/wizard_controller'); +require('controllers/main/admin/kerberos/disable_controller'); +require('controllers/main/admin/kerberos/progress_controller'); +require('controllers/main/admin/kerberos/step1_controller'); +require('controllers/main/admin/kerberos/step2_controller'); +require('controllers/main/admin/kerberos/step3_controller'); +require('controllers/main/admin/kerberos/step4_controller'); +require('controllers/main/admin/kerberos/step5_controller'); +require('controllers/main/admin/kerberos/step6_controller'); +require('controllers/main/admin/kerberos/step7_controller'); +require('controllers/main/admin/security'); +require('controllers/main/admin/security/security_progress_controller'); +require('controllers/main/admin/security/disable'); +require('controllers/main/admin/security/add/addSecurity_controller'); +require('controllers/main/admin/security/add/step1'); +require('controllers/main/admin/security/add/step2'); +require('controllers/main/admin/security/add/step3'); +require('controllers/main/admin/security/add/step4'); +require('controllers/main/admin/authentication'); +require('controllers/main/alert_definitions_controller'); +require('controllers/main/alerts/alert_definitions_actions_controller'); +require('controllers/main/alerts/add_alert_definition/add_alert_definition_controller'); +require('controllers/main/alerts/add_alert_definition/step1_controller'); +require('controllers/main/alerts/add_alert_definition/step2_controller'); +require('controllers/main/alerts/add_alert_definition/step3_controller'); +require('controllers/main/alerts/definition_details_controller'); +require('controllers/main/alerts/definition_configs_controller'); +require('controllers/main/alerts/alert_instances_controller'); +require('controllers/main/alerts/manage_alert_groups_controller'); +require('controllers/main/alerts/manage_alert_notifications_controller'); +require('controllers/main/service'); +require('controllers/main/service/item'); +require('controllers/main/service/info/summary'); +require('controllers/main/service/info/configs'); +require('controllers/main/service/info/audit'); +require('controllers/main/service/add_controller'); +require('controllers/main/service/reassign_controller'); +require('controllers/main/service/reassign/step1_controller'); +require('controllers/main/service/reassign/step2_controller'); +require('controllers/main/service/reassign/step3_controller'); +require('controllers/main/service/reassign/step4_controller'); +require('controllers/main/service/reassign/step5_controller'); +require('controllers/main/service/reassign/step6_controller'); +require('controllers/main/service/manage_config_groups_controller'); +require('controllers/main/host'); +require('controllers/main/host/details'); +require('controllers/main/host/configs_service'); +require('controllers/main/host/add_controller'); +require('controllers/main/host/addHost/step4_controller'); +require('controllers/main/host/host_alerts_controller'); +require('controllers/main/charts'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_processrun'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_diskspaceused'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_cpuWaitIO'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_memoryused'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_dfs'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_bytesread'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_byteswritten'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_gctime'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_dfs_memHeapUsed'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_yarn'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_gctime'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_memHeapUsed'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_ResourceUsed'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_hbase'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_hbase_readrequest'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_hbase_writerequest'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_hbase_compactionqueue'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_hbase_regions'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_hbase_memstoresize'); +require('controllers/main/charts/heatmap'); +require('controllers/main/views_controller'); +require('controllers/main/views/details_controller'); +require('controllers/wizard/slave_component_groups_controller'); +require('controllers/wizard/step0_controller'); +require('controllers/wizard/step1_controller'); +require('controllers/wizard/step2_controller'); +require('controllers/wizard/step3_controller'); +require('controllers/wizard/step4_controller'); +require('controllers/wizard/step5_controller'); +require('controllers/wizard/step6_controller'); +require('controllers/wizard/step7_controller'); +require('controllers/wizard/step8_controller'); +require('controllers/wizard/step9_controller'); +require('controllers/wizard/step10_controller'); +require('controllers/global/cluster_controller'); +require('controllers/global/update_controller'); +require('controllers/global/configuration_controller'); +require('controllers/main/service/reassign/step7_controller'); + +}); + +require.register("controllers/application", function(exports, require, module) { +/** + * 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. + */ + + +var App = require('app'); + +App.ApplicationController = Em.Controller.extend(App.UserPref, { + + name: 'applicationController', + + isPollerRunning: false, + + clusterName: function () { + return (App.router.get('clusterController.clusterName') || 'My Cluster'); + }.property('App.router.clusterController.clusterName'), + + /** + * set ambari server version from installerController or mainController, making sure version shown up all the time + */ + ambariVersion: function () { + return (App.router.get('installerController.ambariServerVersion') || App.router.get('mainController.ambariServerVersion') || Em.I18n.t('common.notAvailable')); + }.property('App.router.installerController.ambariServerVersion', 'App.router.mainController.ambariServerVersion'), + + clusterDisplayName: function () { + var name = this.get('clusterName'); + return name.length > 13 ? name.substr(0, 10) + "..." : name; + }.property('clusterName'), + + isClusterDataLoaded: function() { + return App.router.get('clusterController.isLoaded') && App.router.get('loggedIn'); + }.property('App.router.clusterController.isLoaded','App.router.loggedIn'), + + isExistingClusterDataLoaded: function () { + return App.router.get('clusterInstallCompleted') && this.get('isClusterDataLoaded'); + }.property('App.router.clusterInstallCompleted', 'isClusterDataLoaded'), + + init: function(){ + this._super(); + }, + + startKeepAlivePoller: function() { + if (!this.get('isPollerRunning')) { + this.set('isPollerRunning',true); + App.updater.run(this, 'getStack', 'isPollerRunning', App.sessionKeepAliveInterval); + } + }, + + getStack: function(callback) { + App.ajax.send({ + name: 'router.login.clusters', + sender: this, + callback: callback + }); + }, + + dataLoading: function () { + var dfd = $.Deferred(); + var self = this; + this.getUserPref(this.persistKey()).complete(function () { + var curPref = self.get('currentPrefObject'); + self.set('currentPrefObject', null); + dfd.resolve(curPref); + }); + return dfd.promise(); + }, + persistKey: function (loginName) { + if (App.get('testMode')) { + return 'admin_settings_show_bg'; + } + if (!loginName) + loginName = App.router.get('loginName'); + return 'admin-settings-show-bg-' + loginName; + }, + currentPrefObject: null, + + getUserPrefSuccessCallback: function (response, request, data) { + if (response != null) { + console.log('Got persist value from server with key ' + data.key + '. Value is: ' + response); + this.set('currentPrefObject', response); + return response; + } + }, + getUserPrefErrorCallback: function (request, ajaxOptions, error) { + // this user is first time login + if (request.status == 404) { + console.log('Persist did NOT find the key'); + this.set('currentPrefObject', true); + this.postUserPref(this.persistKey(), true); + return true; + } + }, + + goToAdminView: function () { + App.router.route("adminView"); + }, + + showSettingsPopup: function() { + // Settings only for admins + if (!App.isAccessible('upgrade_ADMIN')) return; + + var self = this; + var curValue = null; + this.dataLoading().done(function (initValue) { + App.ModalPopup.show({ + header: Em.I18n.t('common.userSettings'), + bodyClass: Em.View.extend({ + templateName: require('templates/common/settings'), + isNotShowBgChecked: !initValue, + updateValue: function () { + curValue = !this.get('isNotShowBgChecked'); + }.observes('isNotShowBgChecked') + }), + primary: Em.I18n.t('common.save'), + onPrimary: function() { + if (curValue == null) { + curValue = initValue; + } + var key = self.persistKey(); + if (!App.get('testMode')) { + self.postUserPref(key, curValue); + } + this.hide(); + } + }) + }); + }, + + showAboutPopup: function() { + + var self = this; + App.ModalPopup.show({ + header: Em.I18n.t('common.aboutAmbari'), + secondary: false, + bodyClass: Em.View.extend({ + templateName: require('templates/common/about'), + ambariVersion: this.get('ambariVersion') + }) + }); + } + +}); +}); + +require.register("controllers/global/background_operations_controller", function(exports, require, module) { +/** + * 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. + */ + +var App = require('app'); + +App.BackgroundOperationsController = Em.Controller.extend({ + name: 'backgroundOperationsController', + + /** + * Whether we need to refresh background operations or not + */ + isWorking : false, + + allOperationsCount : 0, + + /** + * For host component popup + */ + services:[], + serviceTimestamp: null, + + /** + * Number of operation to load + */ + operationsCount: 10, + /** + * Possible levels: + * REQUESTS_LIST + * HOSTS_LIST + * TASKS_LIST + * TASK_DETAILS + */ + levelInfo: Em.Object.create({ + name: 'REQUESTS_LIST', + requestId: null, + taskId: null + }), + + /** + * Start polling, when <code>isWorking</code> become true + */ + startPolling: function(){ + if(this.get('isWorking')){ + this.requestMostRecent(); + App.updater.run(this, 'requestMostRecent', 'isWorking', App.bgOperationsUpdateInterval); + } + }.observes('isWorking'), + + /** + * Get requests data from server + * @param callback + */ + requestMostRecent: function (callback) { + var queryParams = this.getQueryParams(); + App.ajax.send({ + 'name': queryParams.name, + 'sender': this, + 'success': queryParams.successCallback, + 'callback': callback, + 'data': queryParams.data + }); + return !this.isInitLoading(); + }, + + /** + * indicate whether data for current level has already been loaded or not + * @return {Boolean} + */ + isInitLoading: function () { + var levelInfo = this.get('levelInfo'); + var request = this.get('services').findProperty('id', levelInfo.get('requestId')); + + if (levelInfo.get('name') === 'HOSTS_LIST') { + return !!(request && App.isEmptyObject(request.get('hostsMap'))); + } + return false; + }, + /** + * construct params of ajax query regarding displayed level + */ + getQueryParams: function () { + var levelInfo = this.get('levelInfo'); + var count = this.get('operationsCount'); + var result = { + name: 'background_operations.get_most_recent', + successCallback: 'callBackForMostRecent', + data: { + 'operationsCount': count + } + }; + if (levelInfo.get('name') === 'TASK_DETAILS' && !App.get('testMode')) { + result.name = 'background_operations.get_by_task'; + result.successCallback = 'callBackFilteredByTask'; + result.data = { + 'taskId': levelInfo.get('taskId'), + 'requestId': levelInfo.get('requestId') + }; + } else if (levelInfo.get('name') === 'TASKS_LIST' || levelInfo.get('name') === 'HOSTS_LIST') { + result.name = 'background_operations.get_by_request'; + result.successCallback = 'callBackFilteredByRequest'; + result.data = { + 'requestId': levelInfo.get('requestId') + }; + } + return result; + }, + + /** + * Push hosts and their tasks to request + * @param data + * @param ajaxQuery + * @param params + */ + callBackFilteredByRequest: function (data, ajaxQuery, params) { + var requestId = data.Requests.id; + var requestInputs = data.Requests.inputs; + var request = this.get('services').findProperty('id', requestId); + var hostsMap = {}; + var previousTaskStatusMap = request.get('previousTaskStatusMap'); + var currentTaskStatusMap = {}; + data.tasks.forEach(function (task) { + var host = hostsMap[task.Tasks.host_name]; + task.Tasks.request_id = requestId; + task.Tasks.request_inputs = requestInputs; + if (host) { + host.logTasks.push(task); + host.isModified = (host.isModified) ? true : previousTaskStatusMap[task.Tasks.id] !== task.Tasks.status; + } else { + hostsMap[task.Tasks.host_name] = { + name: task.Tasks.host_name, + publicName: task.Tasks.host_name, + logTasks: [task], + isModified: previousTaskStatusMap[task.Tasks.id] !== task.Tasks.status + }; + } + currentTaskStatusMap[task.Tasks.id] = task.Tasks.status; + }, this); + /** + * sync up request progress with up to date progress of hosts on Host's list, + * to avoid discrepancies while waiting for response with latest progress of request + * after switching to operation's list + */ + if (request.get('isRunning')) { + request.set('progress', App.HostPopup.getProgress(data.tasks)); + request.set('status', App.HostPopup.getStatus(data.tasks)[0]); + request.set('isRunning', (request.get('progress') !== 100)); + } + request.set('previousTaskStatusMap', currentTaskStatusMap); + request.set('hostsMap', hostsMap); + this.set('serviceTimestamp', App.dateTime()); + }, + /** + * Update task, with uploading two additional properties: stdout and stderr + * @param data + * @param ajaxQuery + * @param params + */ + callBackFilteredByTask: function (data, ajaxQuery, params) { + var request = this.get('services').findProperty('id', data.Tasks.request_id); + var host = request.get('hostsMap')[data.Tasks.host_name]; + var task = host.logTasks.findProperty('Tasks.id', data.Tasks.id); + task.Tasks.status = data.Tasks.status; + task.Tasks.stdout = data.Tasks.stdout; + task.Tasks.stderr = data.Tasks.stderr; + + // Put some command information to task object + task.Tasks.command = data.Tasks.command; + task.Tasks.custom_command_name = data.Tasks.custom_command_name; + task.Tasks.structured_out = data.Tasks.structured_out; + + task.Tasks.output_log = data.Tasks.output_log; + task.Tasks.error_log = data.Tasks.error_log; + this.set('serviceTimestamp', App.dateTime()); + }, + + /** + * returns true if it's upgrade equest + * use this flag to exclude upgrade requests from bgo + * @param {object} request + * @returns {boolean} + */ + isUpgradeRequest: function(request) { + var context = Em.get(request, 'Requests.request_context'); + return context ? /(upgrading|downgrading)/.test(context.toLowerCase()) : false; + }, + /** + * Prepare, received from server, requests for host component popup + * @param data + */ + callBackForMostRecent: function (data) { + var runningServices = 0; + var currentRequestIds = []; + var countIssued = this.get('operationsCount'); + var countGot = data.itemTotal; + + data.items.forEach(function (request) { + if (this.isUpgradeRequest(request)) { + return; + } + var rq = this.get("services").findProperty('id', request.Requests.id); + var isRunning = this.isRequestRunning(request); + var requestParams = this.parseRequestContext(request.Requests.request_context); + this.assignScheduleId(request, requestParams); + currentRequestIds.push(request.Requests.id); + + if (rq) { + rq.set('progress', Math.floor(request.Requests.progress_percent)); + rq.set('status', request.Requests.request_status); + rq.set('isRunning', isRunning); + rq.set('startTime', request.Requests.start_time); + rq.set('endTime', request.Requests.end_time); + } else { + rq = Em.Object.create({ + id: request.Requests.id, + name: requestParams.requestContext, + displayName: requestParams.requestContext, + progress: Math.floor(request.Requests.progress_percent), + status: request.Requests.request_status, + isRunning: isRunning, + hostsMap: {}, + tasks: [], + startTime: request.Requests.start_time, + endTime: request.Requests.end_time, + dependentService: requestParams.dependentService, + sourceRequestScheduleId: request.Requests.request_schedule && request.Requests.request_schedule.schedule_id, + previousTaskStatusMap: {}, + contextCommand: requestParams.contextCommand + }); + this.get("services").unshift(rq); + //To sort DESC by request id + this.set("services", this.get("services").sort( function(a,b) { return b.get('id') - a.get('id'); })); + } + runningServices += ~~isRunning; + }, this); + this.removeOldRequests(currentRequestIds); + this.set("allOperationsCount", runningServices); + this.set('isShowMoreAvailable', countGot >= countIssued); + this.set('serviceTimestamp', App.dateTime()); + }, + isShowMoreAvailable: null, + /** + * remove old requests + * as API returns 10, or 20 , or 30 ...etc latest request, the requests that absent in response should be removed + * @param currentRequestIds + */ + removeOldRequests: function (currentRequestIds) { + this.get('services').forEach(function (service, index, services) { + if (!currentRequestIds.contains(service.id)) { + services.splice(index, 1); + } + }); + }, + /** + * identify whether request is running by task counters + * @param request + * @return {Boolean} + */ + isRequestRunning: function (request) { + return (request.Requests.task_count - + (request.Requests.aborted_task_count + request.Requests.completed_task_count + request.Requests.failed_task_count + + request.Requests.timed_out_task_count - request.Requests.queued_task_count)) > 0; + }, + /** + * identify whether there is only one host in request + * @param inputs + * @return {Boolean} + */ + isOneHost: function (inputs) { + if (!inputs) { + return false; + } + inputs = JSON.parse(inputs); + if (inputs && inputs.included_hosts) { + return inputs.included_hosts.split(',').length < 2; + } + return false + }, + /** + * assign schedule_id of request to null if it's Recommision operation + * @param request + * @param requestParams + */ + assignScheduleId: function (request, requestParams) { + var oneHost = this.isOneHost(request.Requests.inputs); + if (request.Requests.request_schedule && oneHost && /Recommission/.test(requestParams.requestContext)) { + request.Requests.request_schedule.schedule_id = null; + } + }, + + /** + * parse request context and if keyword "_PARSE_" is present then format it + * @param requestContext + * @return {Object} + */ + parseRequestContext: function (requestContext) { + var parsedRequestContext; + var service; + var contextCommand; + if (requestContext) { + if (requestContext.indexOf(App.BackgroundOperationsController.CommandContexts.PREFIX) !== -1) { + var contextSplits = requestContext.split('.'); + contextCommand = contextSplits[1]; + service = contextSplits[2]; + switch(contextCommand){ + case "STOP": + case "START": + if (service === 'ALL_SERVICES') { + parsedRequestContext = Em.I18n.t("requestInfo." + contextCommand.toLowerCase()).format(Em.I18n.t('common.allServices')); + } else { + parsedRequestContext = Em.I18n.t("requestInfo." + contextCommand.toLowerCase()).format(App.format.role(service)); + } + break; + case "ROLLING-RESTART": + parsedRequestContext = Em.I18n.t("rollingrestart.rest.context").format(App.format.role(service), contextSplits[3], contextSplits[4]); + break; + } + } else { + parsedRequestContext = requestContext; + } + } else { + parsedRequestContext = Em.I18n.t('requestInfo.unspecified'); + } + return { + requestContext: parsedRequestContext, + dependentService: service, + contextCommand: contextCommand + } + }, + + popupView: null, + + /** + * Onclick handler for background operations number located right to logo + */ + showPopup: function(){ + // load the checkbox on footer first, then show popup. + var self = this; + App.router.get('applicationController').dataLoading().done(function (initValue) { + App.updater.immediateRun('requestMostRecent'); + if(self.get('popupView') && App.HostPopup.get('isBackgroundOperations')){ + self.set ('popupView.isNotShowBgChecked', !initValue); + self.set('popupView.isOpen', true); + $(self.get('popupView.element')).appendTo('#wrapper'); + } else { + self.set('popupView', App.HostPopup.initPopup("", self, true)); + self.set ('popupView.isNotShowBgChecked', !initValue); + } + }); + }, + + /** + * Called on logout + */ + clear: function () { + // set operations count to default value + this.set('operationsCount', 10); + } + +}); + +/** + * Each background operation has a context in which it operates. + * Generally these contexts are fixed messages. However, we might + * want to associate semantics to this context - like showing, disabling + * buttons when certain operations are in progress. + * + * To make this possible we have command contexts where the context + * is not a human readable string, but a pattern indicating the command + * it is running. When UI shows these, they are translated into human + * readable strings. + * + * General pattern of context names is "_PARSE_.{COMMAND}.{ID}[.{Additional-Data}...]" + */ +App.BackgroundOperationsController.CommandContexts = { + PREFIX : "_PARSE_", + /** + * Stops all services + */ + STOP_ALL_SERVICES : "_PARSE_.STOP.ALL_SERVICES", + /** + * Starts all services + */ + START_ALL_SERVICES : "_PARSE_.START.ALL_SERVICES", + /** + * Starts service indicated by serviceID. + * @param {String} serviceID Parameter {0}. Example: HDFS + */ + START_SERVICE : "_PARSE_.START.{0}", + /** + * Stops service indicated by serviceID. + * @param {String} serviceID Parameter {0}. Example: HDFS + */ + STOP_SERVICE : "_PARSE_.STOP.{0}", + /** + * Performs rolling restart of componentID in batches. + * This context is the batchNumber batch out of totalBatchCount batches. + * @param {String} componentID Parameter {0}. Example "DATANODE" + * @param {Number} batchNumber Parameter {1}. Batch number of this batch. Example 3. + * @param {Number} totalBatchCount Parameter {2}. Total number of batches. Example 10. + */ + ROLLING_RESTART : "_PARSE_.ROLLING-RESTART.{0}.{1}.{2}" +}; +}); + +require.register("controllers/global/cluster_controller", function(exports, require, module) { +/** + * 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. + */ + +var App = require('app'); +var stringUtils = require('utils/string_utils'); + +App.ClusterController = Em.Controller.extend({ + name: 'clusterController', + isLoaded: false, + ambariProperties: null, + clusterDataLoadedPercent: 'width:0', // 0 to 1 + + isGangliaUrlLoaded: false, + + /** + * Provides the URL to use for Ganglia server. This URL + * is helpful in populating links in UI. + * + * If null is returned, it means GANGLIA service is not installed. + */ + gangliaUrl: null, + + clusterName: function () { + return App.get('clusterName'); + }.property('App.clusterName'), + + updateLoadStatus: function (item) { + var loadList = this.get('dataLoadList'); + var loaded = true; + var numLoaded = 0; + var loadListLength = 0; + loadList.set(item, true); + for (var i in loadList) { + if (loadList.hasOwnProperty(i)) { + loadListLength++; + if (!loadList[i] && loaded) { + loaded = false; + } + } + // calculate the number of true + if (loadList.hasOwnProperty(i) && loadList[i]) { + numLoaded++; + } + } + this.set('isLoaded', loaded); + this.set('clusterDataLoadedPercent', 'width:' + (Math.floor(numLoaded / loadListLength * 100)).toString() + '%'); + }, + + dataLoadList: Em.Object.create({ + 'hosts': false, + 'serviceMetrics': false, + 'stackComponents': false, + 'services': false, + 'cluster': false, + 'clusterStatus': false, + 'racks': false, + 'componentConfigs': false, + 'componentsState': false, + 'rootService': false, + 'alertDefinitions': false, + 'securityStatus': false + }), + + /** + * load cluster name + */ + loadClusterName: function (reload) { + var dfd = $.Deferred(); + + if (App.get('clusterName') && !reload) { + App.set('clusterName', this.get('clusterName')); + dfd.resolve(); + } else { + App.ajax.send({ + name: 'cluster.load_cluster_name', + sender: this, + success: 'loadClusterNameSuccessCallback', + error: 'loadClusterNameErrorCallback' + }).complete(function () { + if (!App.get('currentStackVersion')) { + App.set('currentStackVersion', App.defaultStackVersion); + } + dfd.resolve(); + }); + } + return dfd.promise() + }, + + loadClusterNameSuccessCallback: function (data) { + if (data.items && data.items.length > 0) { + App.set('clusterName', data.items[0].Clusters.cluster_name); + App.set('currentStackVersion', data.items[0].Clusters.version); + } + }, + + loadClusterNameErrorCallback: function (request, ajaxOptions, error) { + console.log('failed on loading cluster name'); + this.set('isLoaded', true); + }, + + /** + * load current server clock in milli-seconds + */ + loadClientServerClockDistance: function () { + var dfd = $.Deferred(); + this.getServerClock().done(function () { + dfd.resolve(); + }); + return dfd.promise(); + }, + + getServerClock: function () { + return App.ajax.send({ + name: 'ambari.service.load_server_clock', + sender: this, + success: 'getServerClockSuccessCallback', + error: 'getServerClockErrorCallback' + }); + }, + getServerClockSuccessCallback: function (data) { + var clientClock = new Date().getTime(); + var serverClock = (data.RootServiceComponents.server_clock).toString(); + serverClock = serverClock.length < 13 ? serverClock + '000' : serverClock; + App.set('clockDistance', serverClock - clientClock); + App.set('currentServerTime', parseInt(serverClock)); + console.log('loading ambari server clock distance'); + }, + getServerClockErrorCallback: function () { + console.log('Cannot load ambari server clock'); + }, + + getUrl: function (testUrl, url) { + return (App.get('testMode')) ? testUrl : App.get('apiPrefix') + '/clusters/' + App.get('clusterName') + url; + }, + + setGangliaUrl: function () { + if (App.get('testMode')) { + this.set('gangliaUrl', 'http://gangliaserver/ganglia/?t=yes'); + this.set('isGangliaUrlLoaded', true); + } else { + // We want live data here + var gangliaServer = App.HostComponent.find().findProperty('componentName', 'GANGLIA_SERVER'); + if (this.get('isLoaded') && gangliaServer) { + this.set('isGangliaUrlLoaded', false); + App.ajax.send({ + name: 'hosts.for_quick_links', + sender: this, + data: { + clusterName: App.get('clusterName'), + masterHosts: gangliaServer.get('hostName'), + urlParams: '' + }, + success: 'setGangliaUrlSuccessCallback' + }); + } + } + }.observes('App.router.updateController.isUpdated', 'dataLoadList.hosts', 'gangliaWebProtocol', 'isLoaded'), + + setGangliaUrlSuccessCallback: function (response) { + var url = null; + if (response.items.length > 0) { + url = this.get('gangliaWebProtocol') + "://" + (App.singleNodeInstall ? App.singleNodeAlias + ":42080" : response.items[0].Hosts.public_host_name) + "/ganglia"; + } + this.set('gangliaUrl', url); + this.set('isGangliaUrlLoaded', true); + }, + + gangliaWebProtocol: function () { + var properties = this.get('ambariProperties'); + if (properties && properties.hasOwnProperty('ganglia.https') && properties['ganglia.https']) { + return "https"; + } else { + return "http"; + } + }.property('ambariProperties'), + + isGangliaInstalled: function () { + return !!App.Service.find().findProperty('serviceName', 'GANGLIA'); + }.property('App.router.updateController.isUpdated', 'dataLoadList.serviceMetrics'), + + /** + * load all data and update load status + */ + loadClusterData: function () { + var self = this; + this.getAllHostNames(); + this.loadAmbariProperties(); + if (!App.get('clusterName')) { + return; + } + + if (this.get('isLoaded')) { // do not load data repeatedly + App.router.get('mainController').startPolling(); + return; + } + + var clusterUrl = this.getUrl('/data/clusters/cluster.json', '?fields=Clusters'); + var racksUrl = "/data/racks/racks.json"; + + + var hostsController = App.router.get('mainHostController'); + hostsController.set('isCountersUpdating', true); + hostsController.updateStatusCounters(); + + App.HttpClient.get(racksUrl, App.racksMapper, { + complete: function (jqXHR, textStatus) { + self.updateLoadStatus('racks'); + } + }, function (jqXHR, textStatus) { + self.updateLoadStatus('racks'); + }); + + App.HttpClient.get(clusterUrl, App.clusterMapper, { + complete: function (jqXHR, textStatus) { + self.updateLoadStatus('cluster'); + } + }, function (jqXHR, textStatus) { + self.updateLoadStatus('cluster'); + }); + + if (App.get('testMode')) { + self.updateLoadStatus('clusterStatus'); + } else { + App.clusterStatus.updateFromServer().complete(function () { + self.updateLoadStatus('clusterStatus'); + if (App.get('supports.stackUpgrade')) { + self.restoreUpgradeState(); + } + }); + } + + /** + * Order of loading: + * 1. request for service components supported by stack + * 2. load stack components to model + * 3. request for services + * 4. put services in cache + * 5. request for hosts and host-components (single call) + * 6. request for service metrics + * 7. load host-components to model + * 8. load hosts to model + * 9. load services from cache with metrics to model + * 10. update stale_configs of host-components (depends on App.supports.hostOverrides) + * 11. load root service (Ambari) + * 12. load alert definitions to model + * 13. load unhealthy alert instances + * 14. load security status + */ + self.loadStackServiceComponents(function (data) { + data.items.forEach(function (service) { + service.StackServices.is_selected = true; + service.StackServices.is_installed = false; + }, self); + App.stackServiceMapper.mapStackServices(data); + App.config.setPreDefinedServiceConfigs(true); + var updater = App.router.get('updateController'); + self.updateLoadStatus('stackComponents'); + updater.updateServices(function () { + self.updateLoadStatus('services'); + //force clear filters for hosts page to load all data + App.db.setFilterConditions('mainHostController', null); + + updater.updateHost(function () { + self.updateLoadStatus('hosts'); + }); + + updater.updateServiceMetric(function () { + + updater.updateComponentConfig(function () { + self.updateLoadStatus('componentConfigs'); + }); + + updater.updateComponentsState(function () { + self.updateLoadStatus('componentsState'); + }); + self.updateLoadStatus('serviceMetrics'); + + updater.updateAlertGroups(function () { + updater.updateAlertDefinitions(function() { + updater.updateAlertDefinitionSummary(function () { + updater.updateUnhealthyAlertInstances(function () { + self.updateLoadStatus('alertGroups'); + self.updateLoadStatus('alertDefinitions'); + self.updateLoadStatus('alertInstancesUnhealthy'); + }); + }); + }); + }); + }); + }); + self.loadRootService().done(function (data) { + App.rootServiceMapper.map(data); + self.updateLoadStatus('rootService'); + }); + // load security status + App.router.get('mainAdminKerberosController').getSecurityStatus().always(function() { + self.updateLoadStatus('securityStatus'); + }); + }); + }, + + /** + * restore upgrade status from local storage + * and make call to get latest status from server + */ + restoreUpgradeState: function () { + var dbUpgradeState = App.db.get('MainAdminStackAndUpgrade', 'upgradeState'); + if (!Em.isNone(dbUpgradeState)) { + App.set('upgradeState', dbUpgradeState); + } + App.router.get('mainAdminStackAndUpgradeController').initDBProperties(); + App.router.get('mainAdminStackAndUpgradeController').loadUpgradeData(true); + App.router.get('mainAdminStackAndUpgradeController').loadStackVersionsToModel(true).done(function () { + App.set('stackVersionsAvailable', App.StackVersion.find().content.length > 0); + }); + }, + + loadRootService: function () { + return App.ajax.send({ + name: 'service.ambari', + sender: this + }); + }, + + requestHosts: function (realUrl, callback) { + var testHostUrl = '/data/hosts/HDP2/hosts.json'; + var url = this.getUrl(testHostUrl, realUrl); + App.HttpClient.get(url, App.hostsMapper, { + complete: callback + }, callback) + }, + + /** + * + * @param callback + */ + loadStackServiceComponents: function (callback) { + var callbackObj = { + loadStackServiceComponentsSuccess: callback + }; + App.ajax.send({ + name: 'wizard.service_components', + data: { + stackUrl: App.get('stackVersionURL'), + stackVersion: App.get('currentStackVersionNumber') + }, + sender: callbackObj, + success: 'loadStackServiceComponentsSuccess' + }); + }, + + loadAmbariProperties: function () { + return App.ajax.send({ + name: 'ambari.service', + sender: this, + success: 'loadAmbariPropertiesSuccess', + error: 'loadAmbariPropertiesError' + }); + }, + + loadAmbariPropertiesSuccess: function (data) { + console.log('loading ambari properties'); + this.set('ambariProperties', data.RootServiceComponents.properties); + }, + + loadAmbariPropertiesError: function () { + console.warn('can\'t get ambari properties'); + }, + + updateClusterData: function () { + var testUrl = '/data/clusters/HDP2/cluster.json'; + var clusterUrl = this.getUrl(testUrl, '?fields=Clusters'); + App.HttpClient.get(clusterUrl, App.clusterMapper, { + complete: function () { + } + }); + }, + + /** + * + * @returns {*|Transport|$.ajax|boolean|ServerResponse} + */ + getAllHostNames: function () { + return App.ajax.send({ + name: 'hosts.all', + sender: this, + success: 'getHostNamesSuccess', + error: 'getHostNamesError' + }); + }, + + getHostNamesSuccess: function (data) { + App.set("allHostNames", data.items.mapProperty("Hosts.host_name")); + }, + + getHostNamesError: function () { + console.error('failed to load hostNames'); + }, + + + /** + * puts kerberos admin credentials in the live cluster session + * and resend ajax request + * @param adminPrincipalValue + * @param adminPasswordValue + * @param ajaxOpt + * @returns {$.ajax} + */ + createKerberosAdminSession: function (adminPrincipalValue, adminPasswordValue, ajaxOpt) { + return App.ajax.send({ + name: 'common.cluster.update', + sender: this, + data: { + clusterName: App.get('clusterName'), + data: [{ + session_attributes: { + kerberos_admin: {principal: adminPrincipalValue, password: adminPasswordValue} + } + }] + } + }).success(function () { + if (ajaxOpt) { + $.ajax(ajaxOpt); + } + }); + }, + + //TODO Replace this check with any other which is applicable to non-HDP stack + /** + * Check if HDP stack version is more or equal than 2.2.2 to determine if pluggable metrics for Storm are supported + * @method checkDetailedRepoVersion + * @returns {promise|*|promise|promise|HTMLElement|promise} + */ + checkDetailedRepoVersion: function () { + var dfd; + var currentStackName = App.get('currentStackName'); + var currentStackVersionNumber = App.get('currentStackVersionNumber'); + if (currentStackName == 'HDP' && currentStackVersionNumber == '2.2') { + dfd = App.ajax.send({ + name: 'cluster.load_detailed_repo_version', + sender: this, + success: 'checkDetailedRepoVersionSuccessCallback', + error: 'checkDetailedRepoVersionErrorCallback' + }); + } else { + dfd = $.Deferred(); + App.set('isStormMetricsSupported', currentStackName != 'HDP' || stringUtils.compareVersions(currentStackVersionNumber, '2.2') == 1); + dfd.resolve(); + } + return dfd.promise(); + }, + + checkDetailedRepoVersionSuccessCallback: function (data) { + var items = data.items; + var version; + if (items && items.length) { + var repoVersions = items[0].repository_versions; + if (repoVersions && repoVersions.length) { + version = Em.get(repoVersions[0], 'RepositoryVersions.repository_version'); + } + } + App.set('isStormMetricsSupported', stringUtils.compareVersions(version, '2.2.2') > -1 || !version); + }, + checkDetailedRepoVersionErrorCallback: function () { + App.set('isStormMetricsSupported', true); + } +}); + +}); + +require.register("controllers/global/configuration_controller", function(exports, require, module) { +/** + * 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. + */ + +var App = require('app'); + +App.ConfigurationController = Em.Controller.extend({ + name: 'configurationController', + + /** + * get configs by tags + * return Deferred object with configs as argument + * @param tags {Object} + * ** siteName + * ** tagName (optional) + * @return {object} + */ + getConfigsByTags: function (tags) { + var storedTags = []; + App.db.getConfigs().forEach(function (site) { + storedTags.push({ + siteName: site.type, + tagName: site.tag + }) + }); + if (this.checkTagsChanges(tags, storedTags)) { + return this.loadFromServer(tags); + } else { + return this.loadFromDB(tags.mapProperty('siteName')); + } + }, + /** + * check whether tag versions have been changed + * if they are different then return true + * otherwise false + * @param tags + * @param storedTags + * @return {Boolean} + */ + checkTagsChanges: function (tags, storedTags) { + var isDifferent = false; + var i = 0; + while (i < tags.length && !isDifferent) { + var storedTag = storedTags.findProperty('siteName', tags[i].siteName); + isDifferent = (!storedTag || storedTag.tagName !== tags[i].tagName); + i++; + } + return isDifferent; + }, + loadFromDB: function (siteNames) { + var dfd = $.Deferred(); + var configs = App.db.getConfigs().filter(function (site) { + return (siteNames.contains(site.type)); + }); + dfd.resolve(configs); + return dfd.promise() + }, + /** + * load configs from server + * and update them in local DB + * @param tags + * @return {Array} + */ + loadFromServer: function (tags) { + var self = this; + var dfd = $.Deferred(); + if (!tags.everyProperty('tagName')) { + var configTags; + var jqXhr = this.loadConfigTags(); + jqXhr.done(function (data) { + configTags = data.Clusters.desired_configs; + tags.forEach(function (_tag) { + if (_tag.siteName && !_tag.tagName) { + _tag.tagName = configTags[_tag.siteName].tag; + } + }, self); + self.loadConfigsByTags(tags,dfd); + }); + } else { + self.loadConfigsByTags(tags,dfd); + } + return dfd.promise(); + }, + + /** + * loadConfigsByTags: Loads properties for a config tag + * @params tags + * @params dfd jqXhr promise + */ + loadConfigsByTags: function (tags,dfd) { + var self = this; + var loadedConfigs = []; + App.config.loadConfigsByTags(tags).done(function (data) { + if (data.items) { + data.items.forEach(function (item) { + App.config.loadedConfigurationsCache[item.type + "_" + item.tag] = item.properties; + loadedConfigs.push(item); + }); + } + }).complete(function () { + self.saveToDB(loadedConfigs); + dfd.resolve(loadedConfigs); + }); + }, + + /** + * loadConfigTags: Loads all config tags applied to the cluster + * @return: jqXhr promise + */ + loadConfigTags: function () { + return App.ajax.send({ + name: 'config.tags', + sender: this + }); + }, + + /** + * save properties obtained from server to local DB + * @param loadedConfigs + */ + saveToDB: function (loadedConfigs) { + var storedConfigs = App.db.getConfigs(); + loadedConfigs.forEach(function (loadedSite) { + var storedSite = storedConfigs.findProperty('type', loadedSite.type); + if (storedSite) { + storedSite.tag = loadedSite.tag; + storedSite.properties = loadedSite.properties; + storedSite.properties_attributes = loadedSite.properties_attributes; + } else { + storedConfigs.push(loadedSite); + } + }); + App.db.setConfigs(storedConfigs); + } +}); + +}); + +require.register("controllers/global/update_controller", function(exports, require, module) { +/** + * 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. + */ + +var App = require('app'); + +App.UpdateController = Em.Controller.extend({ + name: 'updateController', + isUpdated: false, + cluster: null, + isWorking: false, + updateAlertInstances: function() { + return this.get('isWorking') && !App.get('router.mainAlertInstancesController.isUpdating'); + }.property('isWorking', 'App.router.mainAlertInstancesController.isUpdating'), + timeIntervalId: null, + clusterName: function () { + return App.router.get('clusterController.clusterName'); + }.property('App.router.clusterController.clusterName'), + location: function () { + return App.router.get('location.lastSetURL'); + }.property('App.router.location.lastSetURL'), + + /** + * keys which should be preloaded in order to filter hosts by host-components + */ + hostsPreLoadKeys: ['host_components/HostRoles/component_name', 'host_components/HostRoles/stale_configs', 'host_components/HostRoles/maintenance_state'], + + paginationKeys: ['page_size', 'from'], + + getUrl: function (testUrl, url) { + return (App.get('testMode')) ? testUrl : App.apiPrefix + '/clusters/' + this.get('clusterName') + url; + }, + + /** + * construct URL from real URL and query parameters + * @param testUrl + * @param realUrl + * @param queryParams + * @return {String} + */ + getComplexUrl: function (testUrl, realUrl, queryParams) { + var prefix = App.get('apiPrefix') + '/clusters/' + App.get('clusterName'), + params = ''; + + if (App.get('testMode')) { + return testUrl; + } else { + if (queryParams) { + params = this.computeParameters(queryParams); + } + return prefix + realUrl.replace('<parameters>', params); + } + }, + + /** + * compute parameters according to their type + * @param queryParams + * @return {String} + */ + computeParameters: function (queryParams) { + var params = ''; + + queryParams.forEach(function (param) { + switch (param.type) { + case 'EQUAL': + params += param.key + '=' + param.value; + break; + case 'LESS': + params += param.key + '<' + param.value; + break; + case 'MORE': + params += param.key + '>' + param.value; + break; + case 'MATCH': + params += param.key + '.matches(' + param.value + ')'; + break; + case 'MULTIPLE': + params += param.key + '.in(' + param.value.join(',') + ')'; + break; + case 'SORT': + params += 'sortBy=' + param.key + '.' + param.value; + break; + case 'CUSTOM': + param.value.forEach(function(item, index){ + param.key = param.key.replace('{' + index + '}', item); + }, this); + params += param.key; + break; + } + params += '&'; + }); + return params; + }, + + /** + * depict query parameters of table + */ + queryParams: Em.Object.create({ + 'Hosts': [] + }), + + /** + * Pagination query-parameters for unhealthy alerts request + * @type {{from: Number, page_size: Number}} + */ + queryParamsForUnhealthyAlertInstances: { + from: 0, + page_size: 10 + }, + + /** + * map describes relations between updater function and table + */ + tableUpdaterMap: { + 'Hosts': 'updateHost' + }, + + /** + * Start polling, when <code>isWorking</code> become true + */ + updateAll: function () { + if (this.get('isWorking')) { + App.updater.run(this, 'updateServices', 'isWorking'); + App.updater.run(this, 'updateHost', 'isWorking'); + App.updater.run(this, 'updateServiceMetricConditionally', 'isWorking', App.componentsUpdateInterval); + App.updater.run(this, 'updateComponentsState', 'isWorking', App.componentsUpdateInterval); + App.updater.run(this, 'graphsUpdate', 'isWorking'); + App.updater.run(this, 'updateComponentConfig', 'isWorking'); + + App.updater.run(this, 'updateAlertGroups', 'isWorking', App.alertGroupsUpdateInterval); + App.updater.run(this, 'updateAlertDefinitions', 'isWorking', App.alertDefinitionsUpdateInterval); + App.updater.run(this, 'updateAlertDefinitionSummary', 'isWorking', App.alertDefinitionsUpdateInterval); + if (!App.get('router.mainAlertInstancesController.isUpdating')) { + App.updater.run(this, 'updateUnhealthyAlertInstances', 'updateAlertInstances', App.alertInstancesUpdateInterval); + } + } + }.observes('isWorking', 'App.router.mainAlertInstancesController.isUpdating'), + /** + * Update service metrics depending on which page is open + * Make a call only on follow pages: + * /main/dashboard + * /main/services/* + * @param callback + */ + updateServiceMetricConditionally: function (callback) { + if (/\/main\/(dashboard|services).*/.test(this.get('location'))) { + this.updateServiceMetric(callback); + } else { + callback(); + } + }, + + updateHost: function (callback, error) { + var testUrl = '/data/hosts/HDP2/hosts.json', + self = this, + hostDetailsFilter = ''; + var realUrl = '/hosts?<parameters>fields=Hosts/host_name,Hosts/maintenance_state,Hosts/public_host_name,Hosts/cpu_count,Hosts/ph_cpu_count,' + + 'alerts_summary,Hosts/host_status,Hosts/last_heartbeat_time,Hosts/ip,host_components/HostRoles/state,host_components/HostRoles/maintenance_state,' + + 'host_components/HostRoles/stale_configs,host_components/HostRoles/service_name,host_components/HostRoles/desired_admin_state,' + + 'metrics/disk,metrics/load/load_one,Hosts/total_mem<hostAuxiliaryInfo><stackVersions>&minimal_response=true'; + var hostAuxiliaryInfo = ',Hosts/os_arch,Hosts/os_type,metrics/cpu/cpu_system,metrics/cpu/cpu_user,metrics/memory/mem_total,metrics/memory/mem_free'; + var stackVersionInfo = ',stack_versions/HostStackVersions,' + + 'stack_versions/repository_versions/RepositoryVersions/repository_version,stack_versions/repository_versions/RepositoryVersions/id,' + + 'stack_versions/repository_versions/RepositoryVersions/display_name'; + realUrl = realUrl.replace("<stackVersions>", (App.get('supports.stackUpgrade') ? stackVersionInfo : "")); + + if (App.router.get('currentState.name') == 'index' && App.router.get('currentState.parentState.name') == 'hosts') { + App.updater.updateInterval('updateHost', App.get('contentUpdateInterval')); + } + else { + if (App.router.get('currentState.parentState.name') == 'hostDetails' && + ['summary', 'alerts', 'stackVersions'].contains(App.router.get('currentState.name'))) { + hostDetailsFilter = App.router.get('location.lastSetURL').match(/\/hosts\/(.*)\/(summary|alerts|stackVersions)/)[1]; + App.updater.updateInterval('updateHost', App.get('componentsUpdateInterval')); + } + else { + callback(); + // On pages except for hosts/hostDetails, making sure hostsMapper loaded only once on page load, no need to update, but at least once + if (App.router.get('clusterController.isLoaded')) { + return; + } + } + } + var mainHostController = App.router.get('mainHostController'), + sortProperties = mainHostController.getSortProps(); + if (hostDetailsFilter) { + //if host details page opened then request info only of one displayed host + this.get('queryParams').set('Hosts', [ + { + key: 'Hosts/host_name', + value: [hostDetailsFilter], + type: 'MULTIPLE' + } + ]); + } else { + hostAuxiliaryInfo = ''; + this.get('queryParams').set('Hosts', mainHostController.getQueryParameters(true)); + } + realUrl = realUrl.replace('<hostAuxiliaryInfo>', hostAuxiliaryInfo); + + var clientCallback = function (skipCall, queryParams) { + if (skipCall) { + //no hosts match filter by component + App.hostsMapper.map({ + items: [], + itemTotal: '0' + }); + callback(); + } + else { + var params = self.computeParameters(queryParams), + paginationProps = self.computeParameters(queryParams.filter(function (param) { + return (this.get('paginationKeys').contains(param.key)); + }, self)), + sortProps = self.computeParameters(sortProperties); + + if ((params.length + paginationProps.length + sortProps.length) > 0) { + realUrl = App.get('apiPrefix') + '/clusters/' + App.get('clusterName') + + realUrl.replace('<parameters>', '') + + (paginationProps.length > 0 ? '&' + paginationProps.substring(0, paginationProps.length - 1) : '') + + (sortProps.length > 0 ? '&' + sortProps.substring(0, sortProps.length - 1) : ''); + if (App.get('testMode')) { + realUrl = testUrl; + } + App.HttpClient.get(realUrl, App.hostsMapper, { + complete: callback, + doGetAsPost: true, + params: params.substring(0, params.length - 1), + error: error + }); + } + else { + var hostsUrl = self.getComplexUrl(testUrl, realUrl, queryParams); + App.HttpClient.get(hostsUrl, App.hostsMapper, { + complete: callback, + doGetAsPost: false, + error: error + }); + } + } + }; + + if (!this.preLoadHosts(clientCallback)) { + clientCallback(false, self.get('queryParams.Hosts')); + } + }, + + /** + * identify if any filter by host-component is active + * if so run @getHostByHostComponents + * + * @param callback + * @return {Boolean} + */ + preLoadHosts: function (callback) { + var preLoadKeys = this.get('hostsPreLoadKeys'); + + if (this.get('queryParams.Hosts').length > 0 && this.get('queryParams.Hosts').filter(function (param) { + return (preLoadKeys.contains(param.key)); + }, this).length > 0) { + this.getHostByHostComponents(callback); + return true; + } + return false; + }, + + /** + * get hosts' names which match filter by host-component + * @param callback + */ + getHostByHostComponents: function (callback) { + var testUrl = '/data/hosts/HDP2/hosts.json'; + var realUrl = '/hosts?<parameters>minimal_response=true'; + + App.ajax.send({ + name: 'hosts.host_components.pre_load', + sender: this, + data: { + url: this.getComplexUrl(testUrl, realUrl, this.get('queryParams.Hosts')), + callback: callback + }, + success: 'getHostByHostComponentsSuccessCallback', + error: 'getHostByHostComponentsErrorCallback' + }) + }, + getHostByHostComponentsSuccessCallback: function (data, opt, params) { + var preLoadKeys = this.get('hostsPreLoadKeys'); + var queryParams = this.get('queryParams.Hosts'); + var hostNames = data.items.mapProperty('Hosts.host_name'); + var skipCall = hostNames.length === 0; + + /** + * exclude pagination parameters as they were applied in previous call + * to obtain hostnames of filtered hosts + */ + preLoadKeys = preLoadKeys.concat(this.get('paginationKeys')); + + var itemTotal = parseInt(data.itemTotal); + if (!isNaN(itemTotal)) { + App.router.set('mainHostController.filteredCount', itemTotal); + } + + if (skipCall) { + params.callback(skipCall); + } else { + queryParams = queryParams.filter(function (param) { + return !(preLoadKeys.contains(param.key)); + }); + + queryParams.push({ + key: 'Hosts/host_name', + value: hostNames, + type: 'MULTIPLE' + }); + params.callback(skipCall, queryParams); + } + }, + getHostByHostComponentsErrorCallback: function () { + console.warn('ERROR: filtering hosts by host-component failed'); + }, + graphs: [], + graphsUpdate: function (callback) { + var existedGraphs = []; + this.get('graphs').forEach(function (_graph) { + var view = Em.View.views[_graph.id]; + if (view) { + existedGraphs.push(_graph); + //console.log('updated graph', _graph.name); + view.loadData(); + //if graph opened as modal popup update it to + if ($(".modal-graph-line .modal-body #" + _graph.popupId + "-container-popup").length) { + view.loadData(); + } + } + }); + callback(); + this.set('graphs', existedGraphs); + }, + + /** + * Updates the services information. + * + * @param callback + */ + updateServiceMetric: function (callback) { + var self = this; + self.set('isUpdated', false); + var isATSPresent = App.StackServiceComponent.find().findProperty('componentName','APP_TIMELINE_SERVER'); + + var conditionalFields = this.getConditionalFields(), + conditionalFieldsString = conditionalFields.length > 0 ? ',' + conditionalFields.join(',') : '', + testUrl = '/data/dashboard/HDP2/master_components.json', + isFlumeInstalled = App.cache['services'].mapProperty('ServiceInfo.service_name').contains('FLUME'), + isATSInstalled = App.cache['services'].mapProperty('ServiceInfo.service_name').contains('YARN') && isATSPresent, + flumeHandlerParam = isFlumeInstalled ? 'ServiceComponentInfo/component_name=FLUME_HANDLER|' : '', + atsHandlerParam = isATSInstalled ? 'ServiceComponentInfo/component_name=APP_TIMELINE_SERVER|' : '', + haComponents = App.get('isHaEnabled') ? 'ServiceComponentInfo/component_name=JOURNALNODE|ServiceComponentInfo/component_name=ZKFC|' : '', + realUrl = '/components/?' + flumeHandlerParam + atsHandlerParam + haComponents + + 'ServiceComponentInfo/category=MASTER&fields=' + + 'ServiceComponentInfo/Version,' + + 'ServiceComponentInfo/StartTime,' + + 'ServiceComponentInfo/HeapMemoryUsed,' + + 'ServiceComponentInfo/HeapMemoryMax,' + + 'ServiceComponentInfo/service_name,' + + 'host_components/HostRoles/host_name,' + + 'host_components/HostRoles/state,' + + 'host_components/HostRoles/maintenance_state,' + + 'host_components/HostRoles/stale_configs,' + + 'host_components/HostRoles/ha_state,' + + 'host_components/HostRoles/desired_admin_state,' + + 'host_components/metrics/jvm/memHeapUsedM,' + + 'host_components/metrics/jvm/HeapMemoryMax,' + + 'host_components/metrics/jvm/HeapMemoryUsed,' + + 'host_components/metrics/jvm/memHeapCommittedM,' + + 'host_components/metrics/mapred/jobtracker/trackers_decommissioned,' + + 'host_components/metrics/cpu/cpu_wio,' + + 'host_components/metrics/rpc/RpcQueueTime_avg_time,' + + 'host_components/metrics/dfs/FSNamesystem/*,' + + 'host_components/metrics/dfs/namenode/Version,' + + 'host_components/metrics/dfs/namenode/LiveNodes,' + + 'host_components/metrics/dfs/namenode/DeadNodes,' + + 'host_components/metrics/dfs/namenode/DecomNodes,' + + 'host_components/metrics/dfs/namenode/TotalFiles,' + + 'host_components/metrics/dfs/namenode/UpgradeFinalized,' + + 'host_components/metrics/dfs/namenode/Safemode,' + + 'host_components/metrics/runtime/StartTime' + + conditionalFieldsString + + '&minimal_response=true'; + + var servicesUrl = this.getUrl(testUrl, realUrl); + callback = callback || function () { + self.set('isUpdated', true); + }; + App.HttpClient.get(servicesUrl, App.serviceMetricsMapper, { + complete: function () { + callback(); + } + }); + }, + /** + * construct conditional parameters of query, depending on which services are installed + * @return {Array} + */ + getConditionalFields: function () { + var conditionalFields = []; + var serviceSpecificParams = { + 'FLUME': "host_components/processes/HostComponentProcess", + 'YARN': "host_components/metrics/yarn/Queue," + + "ServiceComponentInfo/rm_metrics/cluster/activeNMcount," + + "ServiceComponentInfo/rm_metrics/cluster/lostNMcount," + + "ServiceComponentInfo/rm_metrics/cluster/unhealthyNMcount," + + "ServiceComponentInfo/rm_metrics/cluster/rebootedNMcount," + + "ServiceComponentInfo/rm_metrics/cluster/decommissionedNMcount", + 'HBASE': "host_components/metrics/hbase/master/IsActiveMaster," + + "ServiceComponentInfo/MasterStartTime," + + "ServiceComponentInfo/MasterActiveTime," + + "ServiceComponentInfo/AverageLoad," + + "ServiceComponentInfo/Revision," + + "ServiceComponentInfo/RegionsInTransition", + 'STORM': /^2.1/.test(App.get('currentStackVersionNumber')) ? 'metrics/api/cluster/summary' : 'metrics/api/v1/cluster/summary,metrics/api/v1/topology/summary' + }; + var services = App.cache['services']; + services.forEach(function (service) { + var urlParams = serviceSpecificParams[service.ServiceInfo.service_name]; + if (urlParams) { + conditionalFields.push(urlParams); + } + }); + return conditionalFields; + }, + updateServices: function (callback) { + var testUrl = '/data/services/HDP2/services.json'; + var componentConfigUrl = this.getUrl(testUrl, '/services?fields=ServiceInfo/state,ServiceInfo/maintenance_state&minimal_response=true'); + App.HttpClient.get(componentConfigUrl, App.serviceMapper, { + complete: callback + }); + }, + updateComponentConfig: function (callback) { + var testUrl = '/data/services/host_component_stale_configs.json'; + var componentConfigUrl = this.getUrl(testUrl, '/components?ServiceComponentInfo/category.in(SLAVE,CLIENT)&host_components/HostRoles/stale_configs=true&fields=host_components/HostRoles/service_name,host_components/HostRoles/state,host_components/HostRoles/maintenance_state,host_components/HostRoles/host_name,host_components/HostRoles/stale_configs,host_components/HostRoles/desired_admin_state&minimal_response=true'); + App.HttpClient.get(componentConfigUrl, App.componentConfigMapper, { + complete: callback + }); + }, + updateComponentsState: function (callback) { + var testUrl = '/data/services/HDP2/components_state.json'; + var realUrl = '/components/?ServiceComponentInfo/category.in(SLAVE,CLIENT)&fields=ServiceComponentInfo/service_name,' + + 'ServiceComponentInfo/category,ServiceComponentInfo/installed_count,ServiceComponentInfo/started_count,ServiceComponentInfo/total_count&minimal_response=true'; + var url = this.getUrl(testUrl, realUrl); + + App.HttpClient.get(url, App.componentsStateMapper, { + complete: callback + }); + }, + updateAlertDefinitions: function (callback) { + var testUrl = '/data/alerts/alertDefinitions.json'; + var realUrl = '/alert_definitions?fields=*'; + var url = this.getUrl(testUrl, realUrl); + + App.HttpClient.get(url, App.alertDefinitionsMapper, { + complete: callback + }); + }, + + updateUnhealthyAlertInstances: function (callback) { + var testUrl = '/data/alerts/alert_instances.json'; + var queryParams = this.get('queryParamsForUnhealthyAlertInstances'); + var realUrl = '/alerts?fields=*&Alert/state.in(CRITICAL,WARNING)&Alert/maintenance_state.in(OFF)&from=' + queryParams.from + '&page_size=' + queryParams.page_size; + var url = this.getUrl(testUrl, realUrl); + + App.HttpClient.get(url, App.alertInstanceMapper, { + complete: callback + }); + }, + + updateAlertDefinitionSummary: function(callback) { + var testUrl = '/data/alerts/alert_summary.json'; + var realUrl = '/alerts?format=groupedSummary'; + var url = this.getUrl(testUrl, realUrl); + + App.H
<TRUNCATED> http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/bdd79e46/eagle-external/eagle-ambari/lib/EAGLE/package/patches/app.js.gz ---------------------------------------------------------------------- diff --git a/eagle-external/eagle-ambari/lib/EAGLE/package/patches/app.js.gz b/eagle-external/eagle-ambari/lib/EAGLE/package/patches/app.js.gz deleted file mode 100644 index 8cab877..0000000 Binary files a/eagle-external/eagle-ambari/lib/EAGLE/package/patches/app.js.gz and /dev/null differ