You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2017/11/15 15:37:15 UTC
ambari git commit: AMBARI-22451 Components with stale_configs should
be updated via websockets. (atkach)
Repository: ambari
Updated Branches:
refs/heads/branch-3.0-perf eec5936bd -> 54e84d403
AMBARI-22451 Components with stale_configs should be updated via websockets. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/54e84d40
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/54e84d40
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/54e84d40
Branch: refs/heads/branch-3.0-perf
Commit: 54e84d4036f737916dadc7c3231ffc3773795219
Parents: eec5936
Author: Andrii Tkach <at...@apache.org>
Authored: Wed Nov 15 15:36:41 2017 +0200
Committer: Andrii Tkach <at...@apache.org>
Committed: Wed Nov 15 15:36:41 2017 +0200
----------------------------------------------------------------------
.../controllers/global/cluster_controller.js | 19 +++-
.../app/controllers/global/update_controller.js | 9 --
ambari-web/app/mappers.js | 1 -
.../app/mappers/component_config_mapper.js | 105 -------------------
.../app/mappers/components_state_mapper.js | 13 +++
ambari-web/app/mappers/hosts_mapper.js | 42 +++++++-
.../socket/host_component_status_mapper.js | 18 ++++
.../app/mixins/common/configs/configs_saver.js | 1 -
ambari-web/app/utils/ajax/ajax.js | 5 +
.../views/common/configs/config_history_flow.js | 1 -
.../global/cluster_controller_test.js | 46 +++++++-
.../global/update_controller_test.js | 9 +-
.../socket/host_component_status_mapper_test.js | 34 ++++++
.../mixins/common/configs/configs_saver_test.js | 7 --
14 files changed, 171 insertions(+), 139 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/54e84d40/ambari-web/app/controllers/global/cluster_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/cluster_controller.js b/ambari-web/app/controllers/global/cluster_controller.js
index b5003df..32b5db5 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -250,7 +250,7 @@ App.ClusterController = Em.Controller.extend(App.ReloadPopupMixin, {
self.set('isHostComponentMetricsLoaded', true);
});
// components config loading doesn't affect overall progress
- updater.updateComponentConfig(function () {
+ self.loadComponentWithStaleConfigs(function () {
self.set('isComponentsConfigLoaded', true);
});
});
@@ -258,6 +258,23 @@ App.ClusterController = Em.Controller.extend(App.ReloadPopupMixin, {
});
},
+ loadComponentWithStaleConfigs: function (callback) {
+ return App.ajax.send({
+ name: 'components.get.staleConfigs',
+ sender: this,
+ success: 'loadComponentWithStaleConfigsSuccessCallback',
+ callback: callback
+ });
+ },
+
+ loadComponentWithStaleConfigsSuccessCallback: function(json) {
+ json.items.forEach((item) => {
+ const componentName = item.ServiceComponentInfo.component_name;
+ const hosts = item.host_components.mapProperty('HostRoles.host_name') || [];
+ App.componentsStateMapper.updateStaleConfigsHosts(componentName, hosts);
+ });
+ },
+
loadConfigProperties: function() {
var self = this;
http://git-wip-us.apache.org/repos/asf/ambari/blob/54e84d40/ambari-web/app/controllers/global/update_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js
index 9a5ae20..56f9ab6 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -200,7 +200,6 @@ App.UpdateController = Em.Controller.extend({
App.updater.run(this, 'updateServiceMetric', 'isWorking', App.componentsUpdateInterval, '\/main\/(dashboard|services).*');
App.updater.run(this, 'updateComponentsState', 'isWorking', App.componentsUpdateInterval, '\/main\/(dashboard|services|hosts).*');
App.updater.run(this, 'graphsUpdate', 'isWorking');
- App.updater.run(this, 'updateComponentConfig', 'isWorking');
if (!App.get('router.mainAlertInstancesController.isUpdating')) {
App.updater.run(this, 'updateUnhealthyAlertInstances', 'updateAlertInstances', App.alertInstancesUpdateInterval, '\/main\/alerts.*');
@@ -556,14 +555,6 @@ App.UpdateController = Em.Controller.extend({
});
},
- updateComponentConfig: function (callback) {
- var testUrl = '/data/services/host_component_stale_configs.json';
- var componentConfigUrl = this.getUrl(testUrl, '/components?host_components/HostRoles/stale_configs=true&fields=host_components/HostRoles/display_name,host_components/HostRoles/service_name,host_components/HostRoles/state,host_components/HostRoles/maintenance_state,host_components/HostRoles/host_name,host_components/HostRoles/public_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/?fields=ServiceComponentInfo/service_name,' +
http://git-wip-us.apache.org/repos/asf/ambari/blob/54e84d40/ambari-web/app/mappers.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers.js b/ambari-web/app/mappers.js
index 945b1dc..93cd319 100644
--- a/ambari-web/app/mappers.js
+++ b/ambari-web/app/mappers.js
@@ -34,7 +34,6 @@ require('mappers/users_mapper');
require('mappers/service_mapper');
require('mappers/service_metrics_mapper');
require('mappers/target_cluster_mapper');
-require('mappers/component_config_mapper');
require('mappers/components_state_mapper');
require('mappers/alert_definitions_mapper');
require('mappers/alert_definition_summary_mapper');
http://git-wip-us.apache.org/repos/asf/ambari/blob/54e84d40/ambari-web/app/mappers/component_config_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/component_config_mapper.js b/ambari-web/app/mappers/component_config_mapper.js
deleted file mode 100644
index 8df81f4..0000000
--- a/ambari-web/app/mappers/component_config_mapper.js
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * 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.componentConfigMapper = App.QuickDataMapper.create({
- model: App.HostComponent,
- config: {
- id: 'id',
- work_status: 'HostRoles.state',
- passive_state: 'HostRoles.maintenance_state',
- component_name: 'HostRoles.component_name',
- display_name: 'HostRoles.display_name',
- host_name: 'HostRoles.host_name',
- public_host_name: 'HostRoles.public_host_name',
- $ha_status: '',
- $display_name_advanced: '',
- stale_configs: 'HostRoles.stale_configs',
- host_id: 'HostRoles.host_name',
- service_id: 'HostRoles.service_name',
- admin_state: 'HostRoles.desired_admin_state'
- },
- map: function (json) {
- console.time('App.componentConfigMapper execution time');
- var staleConfigHostsMap = App.cache.staleConfigsComponentHosts;
- var componentsNeedRestart = json.items.mapProperty('ServiceComponentInfo.component_name');
- var components = App.MasterComponent.find().toArray()
- .concat(App.ClientComponent.find().toArray())
- .concat(App.SlaveComponent.find().toArray());
-
- //clear stale config hosts of component after restart
- components.forEach(function(component) {
- if (!componentsNeedRestart.contains(component.get('componentName'))) {
- staleConfigHostsMap[component.get('componentName')] = [];
- component.set('staleConfigHosts', []);
- }
- });
-
- json.items.forEach(function(item) {
- var componentName = item.ServiceComponentInfo.component_name;
- var hosts = item.host_components.mapProperty('HostRoles.host_name') || [];
- staleConfigHostsMap[componentName] = hosts;
- if (App.HostComponent.isMaster(componentName)) {
- App.MasterComponent.find(componentName).set('staleConfigHosts', hosts);
- } else if (App.HostComponent.isSlave(componentName)) {
- App.SlaveComponent.find(componentName).set('staleConfigHosts', hosts);
- } else if (App.HostComponent.isClient(componentName)) {
- App.ClientComponent.find(componentName).set('staleConfigHosts', hosts);
- }
- });
- console.timeEnd('App.componentConfigMapper execution time');
- },
-
- /**
- * build map that include loaded host-components to avoid duplicate loading
- * @param cacheServices
- * @return {Object}
- */
- buildServiceComponentMap: function (cacheServices) {
- var loadedServiceComponentsMap = {};
-
- cacheServices.forEach(function (cacheService) {
- var componentsMap = {};
-
- cacheService.host_components.forEach(function (componentId) {
- componentsMap[componentId] = true;
- });
- loadedServiceComponentsMap[cacheService.ServiceInfo.service_name] = componentsMap;
- });
- return loadedServiceComponentsMap;
- },
-
- /**
- * add only new host-components to every service
- * to update service - host-component relations in model
- * @param {object} newHostComponentsMap
- * @param {Array} cacheServices
- * @return {boolean}
- */
- addNewHostComponents: function (newHostComponentsMap, cacheServices) {
- if (!newHostComponentsMap || !cacheServices) return false;
- cacheServices.forEach(function (service) {
- if (newHostComponentsMap[service.ServiceInfo.service_name]) {
- newHostComponentsMap[service.ServiceInfo.service_name].forEach(function (componentId) {
- service.host_components.push(componentId)
- });
- }
- }, this);
- return true;
- }
-});
http://git-wip-us.apache.org/repos/asf/ambari/blob/54e84d40/ambari-web/app/mappers/components_state_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/components_state_mapper.js b/ambari-web/app/mappers/components_state_mapper.js
index a7e6d60..44d1555 100644
--- a/ambari-web/app/mappers/components_state_mapper.js
+++ b/ambari-web/app/mappers/components_state_mapper.js
@@ -223,5 +223,18 @@ App.componentsStateMapper = App.QuickDataMapper.create({
}
console.timeEnd('App.componentsStateMapper execution time');
+ },
+
+ updateStaleConfigsHosts: function(componentName, hosts) {
+ let staleConfigHostsMap = App.cache.staleConfigsComponentHosts;
+
+ staleConfigHostsMap[componentName] = hosts;
+ if (App.HostComponent.isMaster(componentName)) {
+ App.MasterComponent.find(componentName).set('staleConfigHosts', hosts);
+ } else if (App.HostComponent.isSlave(componentName)) {
+ App.SlaveComponent.find(componentName).set('staleConfigHosts', hosts);
+ } else if (App.HostComponent.isClient(componentName)) {
+ App.ClientComponent.find(componentName).set('staleConfigHosts', hosts);
+ }
}
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/54e84d40/ambari-web/app/mappers/hosts_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/hosts_mapper.js b/ambari-web/app/mappers/hosts_mapper.js
index 8fd07f3..d3864b4 100644
--- a/ambari-web/app/mappers/hosts_mapper.js
+++ b/ambari-web/app/mappers/hosts_mapper.js
@@ -101,7 +101,7 @@ App.hostsMapper = App.QuickDataMapper.create({
var stackVersions = [];
var componentsIdMap = {};
var cacheServices = App.cache['services'];
- var currentServiceComponentsMap = App.get('componentConfigMapper').buildServiceComponentMap(cacheServices);
+ var currentServiceComponentsMap = this.buildServiceComponentMap(cacheServices);
var newHostComponentsMap = {};
var selectedHosts = App.db.getSelectedHosts();
var clusterName = App.get('clusterName');
@@ -235,7 +235,7 @@ App.hostsMapper = App.QuickDataMapper.create({
App.router.set('mainHostController.filteredCount', itemTotal);
}
//bind host-components with service records
- App.get('componentConfigMapper').addNewHostComponents(newHostComponentsMap, cacheServices);
+ this.addNewHostComponents(newHostComponentsMap, cacheServices);
}
console.timeEnd('App.hostsMapper execution time');
},
@@ -256,5 +256,43 @@ App.hostsMapper = App.QuickDataMapper.create({
loadOne: Em.get(hostMetrics, 'metrics.load.load_one')
});
}
+ },
+
+ /**
+ * build map that include loaded host-components to avoid duplicate loading
+ * @param cacheServices
+ * @return {Object}
+ */
+ buildServiceComponentMap: function (cacheServices) {
+ var loadedServiceComponentsMap = {};
+
+ cacheServices.forEach(function (cacheService) {
+ var componentsMap = {};
+
+ cacheService.host_components.forEach(function (componentId) {
+ componentsMap[componentId] = true;
+ });
+ loadedServiceComponentsMap[cacheService.ServiceInfo.service_name] = componentsMap;
+ });
+ return loadedServiceComponentsMap;
+ },
+
+ /**
+ * add only new host-components to every service
+ * to update service - host-component relations in model
+ * @param {object} newHostComponentsMap
+ * @param {Array} cacheServices
+ * @return {boolean}
+ */
+ addNewHostComponents: function (newHostComponentsMap, cacheServices) {
+ if (!newHostComponentsMap || !cacheServices) return false;
+ cacheServices.forEach(function (service) {
+ if (newHostComponentsMap[service.ServiceInfo.service_name]) {
+ newHostComponentsMap[service.ServiceInfo.service_name].forEach(function (componentId) {
+ service.host_components.push(componentId)
+ });
+ }
+ }, this);
+ return true;
}
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/54e84d40/ambari-web/app/mappers/socket/host_component_status_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/socket/host_component_status_mapper.js b/ambari-web/app/mappers/socket/host_component_status_mapper.js
index 8244e67..120b84b 100644
--- a/ambari-web/app/mappers/socket/host_component_status_mapper.js
+++ b/ambari-web/app/mappers/socket/host_component_status_mapper.js
@@ -32,6 +32,24 @@ App.hostComponentStatusMapper = App.QuickDataMapper.create({
event.hostComponents.forEach((componentState) => {
const hostComponent = App.HostComponent.find(componentState.componentName + '_' + componentState.hostName);
this.updatePropertiesByConfig(hostComponent, componentState, this.config);
+ this.updateComponentsWithStaleConfigs(componentState);
});
+ },
+
+ /**
+ * @param {object} componentState
+ */
+ updateComponentsWithStaleConfigs: function (componentState) {
+ const staleConfigHostsMap = App.cache.staleConfigsComponentHosts;
+
+ if (!Em.isNone(componentState.staleConfigs)) {
+ const hosts = staleConfigHostsMap[componentState.componentName] || [];
+ if (componentState.staleConfigs) {
+ hosts.push(componentState.hostName);
+ } else {
+ hosts.removeObject(componentState.hostName);
+ }
+ App.componentsStateMapper.updateStaleConfigsHosts(componentState.componentName, hosts);
+ }
}
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/54e84d40/ambari-web/app/mixins/common/configs/configs_saver.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/configs_saver.js b/ambari-web/app/mixins/common/configs/configs_saver.js
index 33a90a3..c2245fb 100644
--- a/ambari-web/app/mixins/common/configs/configs_saver.js
+++ b/ambari-web/app/mixins/common/configs/configs_saver.js
@@ -693,7 +693,6 @@ App.ConfigsSaverMixin = Em.Mixin.create({
}
App.router.get('clusterController').updateClusterData();
- App.router.get('updateController').updateComponentConfig(Em.K);
var popupOptions = this.getSaveConfigsPopupOptions(result);
if (currentService) {
App.router.get('clusterController').triggerQuickLinksUpdate();
http://git-wip-us.apache.org/repos/asf/ambari/blob/54e84d40/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 8859725..94b3737 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -2585,6 +2585,11 @@ var urls = {
'real': '/clusters/{clusterName}/components?fields=ServiceComponentInfo/component_name,ServiceComponentInfo/service_name,ServiceComponentInfo/category,ServiceComponentInfo/recovery_enabled,ServiceComponentInfo/total_count&minimal_response=true',
'mock': ''
},
+ 'components.get.staleConfigs': {
+ 'real': '/clusters/{clusterName}/components?host_components/HostRoles/stale_configs=true' +
+ '&fields=host_components/HostRoles/host_name&minimal_response=true',
+ 'mock': ''
+ },
'components.update': {
'real': '/clusters/{clusterName}/components?{urlParams}',
'mock': '',
http://git-wip-us.apache.org/repos/asf/ambari/blob/54e84d40/ambari-web/app/views/common/configs/config_history_flow.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/config_history_flow.js b/ambari-web/app/views/common/configs/config_history_flow.js
index 32a5e71..aaaae48 100644
--- a/ambari-web/app/views/common/configs/config_history_flow.js
+++ b/ambari-web/app/views/common/configs/config_history_flow.js
@@ -432,7 +432,6 @@ App.ConfigHistoryFlowView = Em.View.extend({
sendRevertCallSuccess: function (data, opt, params) {
// revert to an old version would generate a new version with latest version number,
// so, need to loadStep to update
- App.router.get('updateController').updateComponentConfig(Em.K);
this.get('controller').loadStep();
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/54e84d40/ambari-web/test/controllers/global/cluster_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/global/cluster_controller_test.js b/ambari-web/test/controllers/global/cluster_controller_test.js
index 074e5c0..988379d 100644
--- a/ambari-web/test/controllers/global/cluster_controller_test.js
+++ b/ambari-web/test/controllers/global/cluster_controller_test.js
@@ -1082,7 +1082,7 @@ describe('App.clusterController', function () {
sinon.stub(controller, 'loadConfigProperties');
sinon.stub(updater, 'updateComponentsState', Em.clb);
sinon.stub(updater, 'updateServiceMetric', Em.clb);
- sinon.stub(updater, 'updateComponentConfig', Em.clb);
+ sinon.stub(controller, 'loadComponentWithStaleConfigs', Em.clb);
controller.loadServicesAndComponents();
});
@@ -1095,7 +1095,7 @@ describe('App.clusterController', function () {
controller.updateLoadStatus.restore();
updater.updateComponentsState.restore();
updater.updateServiceMetric.restore();
- updater.updateComponentConfig.restore();
+ controller.loadComponentWithStaleConfigs.restore();
});
it('updateServices should be called', function() {
@@ -1142,12 +1142,50 @@ describe('App.clusterController', function () {
expect(controller.get('isHostComponentMetricsLoaded')).to.be.true;
});
- it('updateComponentConfig should be called', function() {
- expect(updater.updateComponentConfig.calledOnce).to.be.true;
+ it('loadComponentWithStaleConfigs should be called', function() {
+ expect(controller.loadComponentWithStaleConfigs.calledOnce).to.be.true;
});
it('isComponentsConfigLoaded should be true', function() {
expect(controller.get('isComponentsConfigLoaded')).to.be.true;
});
});
+
+ describe('#loadComponentWithStaleConfigs', function() {
+ it('App.ajax.send should be called', function() {
+ controller.loadComponentWithStaleConfigs();
+ var args = testHelpers.findAjaxRequest('name', 'components.get.staleConfigs');
+ expect(args).to.exist;
+ });
+ });
+
+ describe('#loadComponentWithStaleConfigsSuccessCallback', function() {
+ beforeEach(function() {
+ sinon.stub(App.componentsStateMapper, 'updateStaleConfigsHosts');
+ });
+ afterEach(function() {
+ App.componentsStateMapper.updateStaleConfigsHosts.restore();
+ });
+
+ it('updateStaleConfigsHosts should be called', function() {
+ var json = {
+ items: [
+ {
+ ServiceComponentInfo: {
+ component_name: 'C1'
+ },
+ host_components: [
+ {
+ HostRoles: {
+ host_name: 'host1'
+ }
+ }
+ ]
+ }
+ ]
+ };
+ controller.loadComponentWithStaleConfigsSuccessCallback(json);
+ expect(App.componentsStateMapper.updateStaleConfigsHosts.calledWith('C1', ['host1'])).to.be.true;
+ });
+ });
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/54e84d40/ambari-web/test/controllers/global/update_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/global/update_controller_test.js b/ambari-web/test/controllers/global/update_controller_test.js
index f842654..78a4064 100644
--- a/ambari-web/test/controllers/global/update_controller_test.js
+++ b/ambari-web/test/controllers/global/update_controller_test.js
@@ -80,7 +80,7 @@ describe('App.UpdateController', function () {
it('isWorking = true', function () {
controller.set('isWorking', true);
- expect(App.updater.run.callCount).to.equal(8);
+ expect(App.updater.run.callCount).to.equal(7);
expect(App.StompClient.subscribe.calledWith('/events/hostcomponents')).to.be.true;
expect(App.StompClient.subscribe.calledWith('/events/alerts')).to.be.true;
expect(App.StompClient.subscribe.calledWith('/events/ui_topologies')).to.be.true;
@@ -628,13 +628,6 @@ describe('App.UpdateController', function () {
});
});
- describe('#updateComponentConfig()', function() {
- it('App.HttpClient.get should be called', function() {
- c.updateComponentConfig();
- expect(App.HttpClient.get.calledOnce).to.be.true;
- });
- });
-
describe('#updateComponentsState()', function() {
it('App.HttpClient.get should be called', function() {
c.updateComponentsState();
http://git-wip-us.apache.org/repos/asf/ambari/blob/54e84d40/ambari-web/test/mappers/socket/host_component_status_mapper_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mappers/socket/host_component_status_mapper_test.js b/ambari-web/test/mappers/socket/host_component_status_mapper_test.js
index 5aa59d8..29674d9 100644
--- a/ambari-web/test/mappers/socket/host_component_status_mapper_test.js
+++ b/ambari-web/test/mappers/socket/host_component_status_mapper_test.js
@@ -42,9 +42,11 @@ describe('App.hostComponentStatusMapper', function () {
};
beforeEach(function() {
sinon.stub(App.HostComponent, 'find').returns(hc);
+ sinon.stub(App.hostComponentStatusMapper, 'updateComponentsWithStaleConfigs');
});
afterEach(function() {
App.HostComponent.find.restore();
+ App.hostComponentStatusMapper.updateComponentsWithStaleConfigs.restore();
});
it('host-component should have STARTED status', function() {
@@ -61,5 +63,37 @@ describe('App.hostComponentStatusMapper', function () {
App.hostComponentStatusMapper.map(event);
expect(hc.get('passiveState')).to.be.equal('OFF');
});
+
+ it('updateComponentsWithStaleConfigs should be called', function() {
+ App.hostComponentStatusMapper.map(event);
+ expect(App.hostComponentStatusMapper.updateComponentsWithStaleConfigs.calledWith(
+ {
+ componentName: 'C1',
+ hostName: 'host1',
+ currentState: 'STARTED',
+ staleConfigs: false,
+ maintenanceState: 'OFF'
+ }
+ )).to.be.true;
+ });
+ });
+
+ describe('#updateComponentsWithStaleConfigs', function() {
+ beforeEach(function() {
+ sinon.stub(App.componentsStateMapper, 'updateStaleConfigsHosts');
+ });
+ afterEach(function() {
+ App.componentsStateMapper.updateStaleConfigsHosts.restore();
+ });
+
+ it('updateStaleConfigsHosts should be called', function() {
+ var state = {
+ staleConfigs: true,
+ componentName: 'C1',
+ hostName: 'host1'
+ };
+ App.hostComponentStatusMapper.updateComponentsWithStaleConfigs(state);
+ expect(App.componentsStateMapper.updateStaleConfigsHosts.calledWith('C1', ['host1'])).to.be.true;
+ });
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/54e84d40/ambari-web/test/mixins/common/configs/configs_saver_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/configs/configs_saver_test.js b/ambari-web/test/mixins/common/configs/configs_saver_test.js
index f20a49f..ff238c1 100644
--- a/ambari-web/test/mixins/common/configs/configs_saver_test.js
+++ b/ambari-web/test/mixins/common/configs/configs_saver_test.js
@@ -1030,7 +1030,6 @@ describe('App.ConfigsSaverMixin', function() {
describe("#onDoPUTClusterConfigurations", function () {
var mockController = {
updateClusterData: Em.K,
- updateComponentConfig: Em.K,
triggerQuickLinksUpdate: Em.K,
loadConfigs: Em.K
};
@@ -1039,7 +1038,6 @@ describe('App.ConfigsSaverMixin', function() {
sinon.stub(App.router, 'get').returns(mockController);
sinon.stub(App.Service, 'find').returns({});
sinon.stub(mockController, 'updateClusterData');
- sinon.stub(mockController, 'updateComponentConfig');
sinon.stub(mockController, 'triggerQuickLinksUpdate');
sinon.stub(mockController, 'loadConfigs');
sinon.stub(mixin, 'showSaveConfigsPopup');
@@ -1059,7 +1057,6 @@ describe('App.ConfigsSaverMixin', function() {
App.Service.find.restore();
App.router.get.restore();
mockController.updateClusterData.restore();
- mockController.updateComponentConfig.restore();
mockController.triggerQuickLinksUpdate.restore();
mockController.loadConfigs.restore();
mixin.showSaveConfigsPopup.restore();
@@ -1071,10 +1068,6 @@ describe('App.ConfigsSaverMixin', function() {
expect(mockController.updateClusterData.calledOnce).to.be.true;
});
- it("updateComponentConfig should be called", function() {
- expect(mockController.updateComponentConfig.calledOnce).to.be.true;
- });
-
it("triggerQuickLinksUpdate should be called", function() {
expect(mockController.triggerQuickLinksUpdate.calledOnce).to.be.true;
});