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 2015/03/19 16:53:38 UTC
ambari git commit: AMBARI-10129 Pig Client needs Tez Client on same
host, ambari web need to update HostRoles it sends. (atkach)
Repository: ambari
Updated Branches:
refs/heads/trunk d461e3330 -> 9a7cfc80d
AMBARI-10129 Pig Client needs Tez Client on same host, ambari web need to update HostRoles it sends. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9a7cfc80
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9a7cfc80
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9a7cfc80
Branch: refs/heads/trunk
Commit: 9a7cfc80d34cbb643029d0e6fec5be627e324ae4
Parents: d461e33
Author: Andrii Tkach <at...@hortonworks.com>
Authored: Thu Mar 19 15:27:41 2015 +0200
Committer: Andrii Tkach <at...@hortonworks.com>
Committed: Thu Mar 19 17:52:03 2015 +0200
----------------------------------------------------------------------
.../app/controllers/wizard/step8_controller.js | 36 ++-
.../test/controllers/wizard/step8_test.js | 231 +++++++++++++++++++
2 files changed, 258 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/9a7cfc80/ambari-web/app/controllers/wizard/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js
index ce2c39a..ed26710 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -1255,10 +1255,10 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
}, this);
},
- getClientsToMasterMap: function () {
+ getClientsMap: function (flag) {
var clientNames = App.StackServiceComponent.find().filterProperty('isClient').mapProperty('componentName'),
clientsMap = {},
- dependedComponents = App.StackServiceComponent.find().filterProperty('isMaster');
+ dependedComponents = flag ? App.StackServiceComponent.find().filterProperty(flag) : App.StackServiceComponent.find();
clientNames.forEach(function (clientName) {
clientsMap[clientName] = Em.A([]);
dependedComponents.forEach(function (component) {
@@ -1290,7 +1290,7 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
* }
* </code>
*/
- var clientsToMasterMap = this.getClientsToMasterMap();
+ var clientsToMasterMap = this.getClientsMap('isMaster');
slaveHosts.forEach(function (_slave) {
if (_slave.componentName !== 'CLIENT') {
@@ -1324,7 +1324,13 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
*/
createAdditionalClientComponents: function () {
var masterHosts = this.get('content.masterComponentHosts');
- var clientsToMasterMap = this.getClientsToMasterMap();
+ var clientHosts = [];
+ if (this.get('content.slaveComponentHosts').someProperty('componentName', 'CLIENT')) {
+ clientHosts = this.get('content.slaveComponentHosts').findProperty('componentName', 'CLIENT').hosts;
+ }
+ var clients = this.get('content.clients').filterProperty('isInstalled', false);
+ var clientsToMasterMap = this.getClientsMap('isMaster');
+ var clientsToClientMap = this.getClientsMap('isClient');
var installedClients = [];
// Get all the installed Client components
@@ -1337,13 +1343,25 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
// Check if there is a dependency for being co-hosted between existing client and selected new master
installedClients.forEach(function (_clientName) {
- if (clientsToMasterMap[_clientName]) {
+ if (clientsToMasterMap[_clientName] || clientsToClientMap[_clientName]) {
var hostNames = [];
- clientsToMasterMap[_clientName].forEach(function (componentName) {
- masterHosts.filterProperty('component', componentName).filterProperty('isInstalled', false).forEach(function (_masterHost) {
- hostNames.pushObject(_masterHost.hostName);
+ if (clientsToMasterMap[_clientName]) {
+ clientsToMasterMap[_clientName].forEach(function (componentName) {
+ masterHosts.filterProperty('component', componentName).filterProperty('isInstalled', false).forEach(function (_masterHost) {
+ hostNames.pushObject(_masterHost.hostName);
+ }, this);
}, this);
- }, this);
+ }
+ if (clientsToClientMap[_clientName]) {
+ clientsToClientMap[_clientName].forEach(function (componentName) {
+ clientHosts.forEach(function (_clientHost) {
+ var host = this.get('content.hosts')[_clientHost.hostName];
+ if (host.isInstalled && !host.hostComponents.someProperty('HostRoles.component_name', componentName)) {
+ hostNames.pushObject(_clientHost.hostName);
+ }
+ }, this);
+ }, this);
+ }
hostNames = hostNames.uniq();
if (hostNames.length > 0) {
this.get('content.additionalClients').pushObject({hostNames: hostNames, componentName: _clientName});
http://git-wip-us.apache.org/repos/asf/ambari/blob/9a7cfc80/ambari-web/test/controllers/wizard/step8_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step8_test.js b/ambari-web/test/controllers/wizard/step8_test.js
index fa1d1a3..87ff0db 100644
--- a/ambari-web/test/controllers/wizard/step8_test.js
+++ b/ambari-web/test/controllers/wizard/step8_test.js
@@ -1731,4 +1731,235 @@ describe('App.WizardStep8Controller', function () {
});
+ describe('#getClientsMap', function () {
+
+ var cases = [
+ {
+ flag: 'isMaster',
+ result: {
+ c8: ['c1', 'c2'],
+ c9: ['c1', 'c2']
+ },
+ title: 'dependencies for masters'
+ },
+ {
+ flag: 'isSlave',
+ result: {
+ c8: ['c5', 'c6'],
+ c9: ['c5', 'c6']
+ },
+ title: 'dependencies for slaves'
+ },
+ {
+ flag: 'isClient',
+ result: {
+ c8: ['c9', 'c10'],
+ c9: ['c9', 'c10']
+ },
+ title: 'dependencies for clients'
+ },
+ {
+ flag: null,
+ result: {
+ c8: ['c1', 'c2', 'c5', 'c6', 'c9', 'c10'],
+ c9: ['c1', 'c2', 'c5', 'c6', 'c9', 'c10']
+ },
+ title: 'dependencies for all components'
+ }
+ ];
+
+ before(function () {
+ sinon.stub(App.StackServiceComponent, 'find').returns([
+ Em.Object.create({
+ componentName: 'c0',
+ isMaster: true,
+ dependencies: [
+ {
+ componentName: 'c1'
+ },
+ {
+ componentName: 'c2'
+ },
+ {
+ componentName: 'c4'
+ },
+ {
+ componentName: 'c5'
+ }
+ ]
+ }),
+ Em.Object.create({
+ componentName: 'c1',
+ isMaster: true,
+ dependencies: [
+ {
+ componentName: 'c4'
+ },
+ {
+ componentName: 'c5'
+ },
+ {
+ componentName: 'c8'
+ },
+ {
+ componentName: 'c9'
+ }
+ ]
+ }),
+ Em.Object.create({
+ componentName: 'c2',
+ isMaster: true,
+ dependencies: [
+ {
+ componentName: 'c1'
+ },
+ {
+ componentName: 'c2'
+ },
+ {
+ componentName: 'c8'
+ },
+ {
+ componentName: 'c9'
+ }
+ ]
+ }),
+ Em.Object.create({
+ componentName: 'c3',
+ isMaster: true,
+ dependencies: []
+ }),
+ Em.Object.create({
+ componentName: 'c4',
+ isSlave: true,
+ dependencies: [
+ {
+ componentName: 'c1'
+ },
+ {
+ componentName: 'c2'
+ },
+ {
+ componentName: 'c4'
+ },
+ {
+ componentName: 'c5'
+ }
+ ]
+ }),
+ Em.Object.create({
+ componentName: 'c5',
+ isSlave: true,
+ dependencies: [
+ {
+ componentName: 'c4'
+ },
+ {
+ componentName: 'c5'
+ },
+ {
+ componentName: 'c8'
+ },
+ {
+ componentName: 'c9'
+ }
+ ]
+ }),
+ Em.Object.create({
+ componentName: 'c6',
+ isSlave: true,
+ dependencies: [
+ {
+ componentName: 'c1'
+ },
+ {
+ componentName: 'c2'
+ },
+ {
+ componentName: 'c8'
+ },
+ {
+ componentName: 'c9'
+ }
+ ]
+ }),
+ Em.Object.create({
+ componentName: 'c7',
+ isSlave: true,
+ dependencies: []
+ }),
+ Em.Object.create({
+ componentName: 'c8',
+ isClient: true,
+ dependencies: [
+ {
+ componentName: 'c1'
+ },
+ {
+ componentName: 'c2'
+ },
+ {
+ componentName: 'c4'
+ },
+ {
+ componentName: 'c5'
+ }
+ ]
+ }),
+ Em.Object.create({
+ componentName: 'c9',
+ isClient: true,
+ dependencies: [
+ {
+ componentName: 'c4'
+ },
+ {
+ componentName: 'c5'
+ },
+ {
+ componentName: 'c8'
+ },
+ {
+ componentName: 'c9'
+ }
+ ]
+ }),
+ Em.Object.create({
+ componentName: 'c10',
+ isClient: true,
+ dependencies: [
+ {
+ componentName: 'c1'
+ },
+ {
+ componentName: 'c2'
+ },
+ {
+ componentName: 'c8'
+ },
+ {
+ componentName: 'c9'
+ }
+ ]
+ }),
+ Em.Object.create({
+ componentName: 'c11',
+ isClient: true,
+ dependencies: []
+ })
+ ]);
+ });
+
+ after(function () {
+ App.StackServiceComponent.find.restore();
+ });
+
+ cases.forEach(function (item) {
+ it(item.title, function () {
+ expect(installerStep8Controller.getClientsMap(item.flag)).to.eql(item.result);
+ });
+ });
+
+ });
+
});