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/09/18 10:42:51 UTC
ambari git commit: AMBARI-21969 Manage config groups at Add Service
Wizard doesn't show host with selected components from filter. (atkach)
Repository: ambari
Updated Branches:
refs/heads/trunk 7e61e3a90 -> fca80cbe0
AMBARI-21969 Manage config groups at Add Service Wizard doesn't show host with selected components from filter. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fca80cbe
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fca80cbe
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fca80cbe
Branch: refs/heads/trunk
Commit: fca80cbe0a19fdb3bfae1240ecb715bd3059e02b
Parents: 7e61e3a
Author: Andrii Tkach <at...@apache.org>
Authored: Fri Sep 15 19:25:18 2017 +0300
Committer: Andrii Tkach <at...@apache.org>
Committed: Mon Sep 18 13:42:39 2017 +0300
----------------------------------------------------------------------
.../service/manage_config_groups_controller.js | 55 +++++++++++-
ambari-web/app/utils/hosts.js | 4 +-
.../manage_config_groups_controller_test.js | 89 +++++++++++++++++++-
ambari-web/test/utils/hosts_test.js | 3 +-
4 files changed, 144 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca80cbe/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
index cca3d89..7e4b090 100644
--- a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
+++ b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
@@ -321,15 +321,16 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
* @private
*/
_loadHostsFromServerSuccessCallback: function (data) {
- var wrappedHosts = [];
+ var wrappedHosts = [],
+ newlyAddedHostComponentsMap = this.getNewlyAddedHostComponentsMap();
data.items.forEach(function (host) {
var hostComponents = [];
- var diskInfo = host.Hosts.disk_info.filter(function(item) {
+ var diskInfo = host.Hosts.disk_info.filter(function (item) {
return /^ext|^ntfs|^fat|^xfs/i.test(item.type);
});
if (diskInfo.length) {
- diskInfo = diskInfo.reduce(function(a, b) {
+ diskInfo = diskInfo.reduce(function (a, b) {
return {
available: parseInt(a.available) + parseInt(b.available),
size: parseInt(a.size) + parseInt(b.size)
@@ -342,6 +343,9 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
displayName: App.format.role(hostComponent.HostRoles.component_name, false)
}));
}, this);
+ if (this.get('isAddService') && newlyAddedHostComponentsMap[host.Hosts.host_name]) {
+ hostComponents.pushObjects(newlyAddedHostComponentsMap[host.Hosts.host_name]);
+ }
wrappedHosts.pushObject(Em.Object.create({
id: host.Hosts.host_name,
ip: host.Hosts.ip,
@@ -372,6 +376,51 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
},
/**
+ *
+ * @returns {{}}
+ */
+ getNewlyAddedHostComponentsMap: function () {
+ var newlyAddedHostComponentsMap = {};
+ var clients = App.router.get('addServiceController.content.clients').filterProperty('isInstalled', false).map(function (component) {
+ return Em.Object.create({
+ componentName: component.component_name,
+ displayName: component.display_name
+ });
+ });
+
+ App.router.get('addServiceController.content.masterComponentHosts').forEach(function (component) {
+ if (!component.isInstalled) {
+ if (!newlyAddedHostComponentsMap[component.hostName]) {
+ newlyAddedHostComponentsMap[component.hostName] = [];
+ }
+ newlyAddedHostComponentsMap[component.hostName].push(Em.Object.create({
+ componentName: component.component,
+ displayName: component.display_name
+ }));
+ }
+ });
+
+ App.router.get('addServiceController.content.slaveComponentHosts').forEach(function (component) {
+ component.hosts.forEach(function (host) {
+ if (!host.isInstalled) {
+ if (!newlyAddedHostComponentsMap[host.hostName]) {
+ newlyAddedHostComponentsMap[host.hostName] = [];
+ }
+ if (component.componentName === 'CLIENT') {
+ newlyAddedHostComponentsMap[host.hostName].pushObjects(clients);
+ } else {
+ newlyAddedHostComponentsMap[host.hostName].push(Em.Object.create({
+ componentName: component.componentName,
+ displayName: component.displayName
+ }));
+ }
+ }
+ });
+ });
+ return newlyAddedHostComponentsMap;
+ },
+
+ /**
* Load config groups from server if user is on the already installed cluster
* If not - use loaded data form wizardStep7Controller
* @param {string} serviceName
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca80cbe/ambari-web/app/utils/hosts.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/hosts.js b/ambari-web/app/utils/hosts.js
index 98d4d50..ab95459 100644
--- a/ambari-web/app/utils/hosts.js
+++ b/ambari-web/app/utils/hosts.js
@@ -156,12 +156,12 @@ module.exports = {
skip = true;
}
if (!skip && filterComponent && hostComponentNames.length > 0) {
- skip = !hostComponentNames.contains(filterComponent.get('componentName'));
+ skip = !hostComponentNames.contains(filterComponent.get('componentName'));
}
host.set('filtered', !skip);
}, this);
- this.set('startIndex', 1);
+ this.set('startIndex', this.get('parentView.availableHosts').someProperty('filtered') ? 1 : 0);
}.observes('parentView.availableHosts', 'filterColumn', 'filterText', 'filterComponent', 'filterComponent.componentName', 'showOnlySelectedHosts'),
hostSelectMessage: function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca80cbe/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js b/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
index e0ca439..19d0a49 100644
--- a/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
+++ b/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
@@ -20,7 +20,6 @@ var App = require('app');
var c;
describe('App.ManageConfigGroupsController', function() {
- var controller = App.ManageConfigGroupsController.create({});
beforeEach(function() {
c = App.ManageConfigGroupsController.create({});
@@ -589,4 +588,92 @@ describe('App.ManageConfigGroupsController', function() {
});
+ describe('#getNewlyAddedHostComponentsMap', function() {
+ beforeEach(function() {
+ this.mockGet = sinon.stub(App.router, 'get');
+ this.mockGet.withArgs('addServiceController.content.clients').returns([
+ {
+ isInstalled: true,
+ component_name: 'Client1',
+ display_name: 'client1'
+ },
+ {
+ isInstalled: false,
+ component_name: 'Client2',
+ display_name: 'client2'
+ }
+ ]);
+ this.mockGet.withArgs('addServiceController.content.masterComponentHosts').returns([
+ {
+ isInstalled: true,
+ hostName: 'host1',
+ component: 'Master1',
+ display_name: 'master1'
+ },
+ {
+ isInstalled: false,
+ hostName: 'host2',
+ component: 'Master2',
+ display_name: 'master2'
+ }
+ ]);
+ this.mockGet.withArgs('addServiceController.content.slaveComponentHosts').returns([
+ {
+ componentName: 'Slave1',
+ displayName: 'slave1',
+ hosts: [
+ {
+ hostName: 'host1',
+ isInstalled: false
+ }
+ ]
+ },
+ {
+ componentName: 'Slave2',
+ displayName: 'slave2',
+ hosts: [
+ {
+ hostName: 'host2',
+ isInstalled: true
+ }
+ ]
+ },
+ {
+ componentName: 'CLIENT',
+ displayName: 'client',
+ hosts: [
+ {
+ hostName: 'host1',
+ isInstalled: false
+ }
+ ]
+ }
+ ]);
+ });
+ afterEach(function() {
+ this.mockGet.restore();
+ });
+
+ it('should return host-components map', function() {
+ expect(JSON.stringify(c.getNewlyAddedHostComponentsMap())).to.be.equal(JSON.stringify({
+ "host2": [
+ {
+ "componentName": "Master2",
+ "displayName": "master2"
+ }
+ ],
+ "host1": [
+ {
+ "componentName": "Slave1",
+ "displayName": "slave1"
+ },
+ {
+ "componentName": "Client2",
+ "displayName": "client2"
+ }
+ ]
+ }));
+ });
+ });
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca80cbe/ambari-web/test/utils/hosts_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/hosts_test.js b/ambari-web/test/utils/hosts_test.js
index 41fe555..0b20999 100644
--- a/ambari-web/test/utils/hosts_test.js
+++ b/ambari-web/test/utils/hosts_test.js
@@ -2858,8 +2858,9 @@ describe('hosts utils', function () {
it('start index', function () {
view.set('startIndex', 0);
+ view.set('parentView.availableHosts', []);
view.propertyDidChange('filterColumn');
- expect(view.get('startIndex')).to.equal(1);
+ expect(view.get('startIndex')).to.equal(0);
});
});