Przeglądaj źródła

AMBARI-8733. Handle cardinality=all on Assign Slaves page (Metrics Collector must be selected for all hosts). (akovalenko)

Aleksandr Kovalenko 10 lat temu
rodzic
commit
be896c4ec2

+ 15 - 12
ambari-web/app/controllers/wizard/step8_controller.js

@@ -734,7 +734,7 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
       });
       service.get('serviceComponents').forEach(function (component) {
         // show clients for services that have only clients components
-        if ((component.get('isClient') || component.get('isClientBehavior')) && !service.get('isClientOnlyService')) return;
+        if ((component.get('isClient') || component.get('isRequiredOnAllHosts')) && !service.get('isClientOnlyService')) return;
         // skip components that was hide on assign master page
         if (component.get('isMaster') && !component.get('isShownOnInstallerAssignMasterPage')) return;
         // no HA component
@@ -1409,18 +1409,21 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
    */
   createAdditionalHostComponents: function () {
     var masterHosts = this.get('content.masterComponentHosts');
+
+    // add all components with cardinality == ALL of selected services
+    var registeredHosts = this.getRegisteredHosts();
+    var notInstalledHosts = registeredHosts.filterProperty('isInstalled', false);
+    this.get('content.services').filterProperty('isSelected').forEach(function (service) {
+      service.get('serviceComponents').filterProperty('isRequiredOnAllHosts').forEach(function (component) {
+        if (service.get('isInstalled') && notInstalledHosts.length) {
+          this.registerHostsToComponent(notInstalledHosts.mapProperty('hostName'), component.get('componentName'));
+        } else if (!service.get('isInstalled') && registeredHosts.length) {
+          this.registerHostsToComponent(registeredHosts.mapProperty('hostName'), component.get('componentName'));
+        }
+      }, this);
+    }, this);
+
     // add MySQL Server if Hive is selected
-    // add Ganglia Monitor (Slave) to all hosts if Ganglia service is selected
-    var gangliaService = this.get('content.services').filterProperty('isSelected').findProperty('serviceName', 'GANGLIA');
-    if (gangliaService) {
-      var hosts = this.getRegisteredHosts();
-      if (gangliaService.get('isInstalled')) {
-        hosts = hosts.filterProperty('isInstalled', false);
-      }
-      if (hosts.length) {
-        this.registerHostsToComponent(hosts.mapProperty('hostName'), 'GANGLIA_MONITOR');
-      }
-    }
     var hiveService = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).findProperty('serviceName', 'HIVE');
     if (hiveService) {
       var hiveDb = this.get('content.serviceConfigProperties').findProperty('name', 'hive_database');

+ 3 - 13
ambari-web/app/models/stack_service_component.js

@@ -116,9 +116,9 @@ App.StackServiceComponent = DS.Model.extend({
   /** @property {Boolean} isShownOnInstallerSlaveClientPage - component visible on "Assign Slaves and Clients" step of Install Wizard**/
   isShownOnInstallerSlaveClientPage: function() {
     var component = this.get('componentName');
-    var slavesNotShown = ['JOURNALNODE','ZKFC','APP_TIMELINE_SERVER','GANGLIA_MONITOR'];
-    return this.get('isSlave') && !slavesNotShown.contains(component);
-  }.property('isSlave','componentName'),
+    var slavesNotShown = ['JOURNALNODE','ZKFC','APP_TIMELINE_SERVER'];
+    return this.get('isSlave') && !this.get('isRequiredOnAllHosts') && !slavesNotShown.contains(component);
+  }.property('isSlave','componentName', 'isRequiredOnAllHosts'),
 
   /** @property {Boolean} isShownOnAddServiceAssignMasterPage - component visible on "Assign Masters" step of Add Service Wizard **/
   isShownOnAddServiceAssignMasterPage: function() {
@@ -147,16 +147,6 @@ App.StackServiceComponent = DS.Model.extend({
     return this.get('isMaster') && this.get('isMultipleAllowed') && this.get('maxToInstall') > 2;
   }.property('componentName'),
 
-
-  /** @property {Boolean} isClientBehavior - Some non client components can be assigned as clients.
-   *
-   * Used for ignoring such components as Ganglia Monitor on Installer "Review" step.
-   **/
-  isClientBehavior: function() {
-    var componentName = ['GANGLIA_MONITOR'];
-    return componentName.contains(this.get('componentName'));
-  }.property('componentName'),
-
   /** @property {Boolean} isHAComponentOnly - Components that can be installed only if HA enabled **/
   isHAComponentOnly: function() {
     var HAComponentNames = ['ZKFC','JOURNALNODE'];

+ 28 - 6
ambari-web/test/controllers/wizard/step8_test.js

@@ -1308,14 +1308,25 @@ describe('App.WizardStep8Controller', function () {
         installerStep8Controller.registerHostsToComponent.restore();
       });
 
-      it('should add GANGLIA MONITOR (1)', function() {
+      it('should add components with isRequiredOnAllHosts == true (1)', function() {
         installerStep8Controller.reopen({
           getRegisteredHosts: function() {
             return [{hostName: 'h1'}, {hostName: 'h2'}];
           },
           content: {
             services: [
-              Em.Object.create({serviceName: 'GANGLIA', isSelected: true, isInstalled: false})
+              Em.Object.create({
+                serviceName: 'GANGLIA', isSelected: true, isInstalled: false, serviceComponents: [
+                  Em.Object.create({
+                    componentName: 'GANGLIA_MONITOR',
+                    isRequiredOnAllHosts: true
+                  }),
+                  Em.Object.create({
+                    componentName: 'GANGLIA_SERVER',
+                    isRequiredOnAllHosts: false
+                  })
+                ]
+              })
             ]
           }
         });
@@ -1325,14 +1336,25 @@ describe('App.WizardStep8Controller', function () {
         expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR');
       });
 
-      it('should add GANGLIA MONITOR (2)', function() {
+      it('should add components with isRequiredOnAllHosts == true (2)', function() {
         installerStep8Controller.reopen({
           getRegisteredHosts: function() {
             return [{hostName: 'h1', isInstalled: true}, {hostName: 'h2', isInstalled: false}];
           },
           content: {
             services: [
-              Em.Object.create({serviceName: 'GANGLIA', isSelected: true, isInstalled: true})
+              Em.Object.create({
+                serviceName: 'GANGLIA', isSelected: true, isInstalled: true, serviceComponents: [
+                  Em.Object.create({
+                    componentName: 'GANGLIA_MONITOR',
+                    isRequiredOnAllHosts: true
+                  }),
+                  Em.Object.create({
+                    componentName: 'GANGLIA_SERVER',
+                    isRequiredOnAllHosts: false
+                  })
+                ]
+              })
             ]
           }
         });
@@ -1348,7 +1370,7 @@ describe('App.WizardStep8Controller', function () {
         },
         {name: 'New PostgreSQL Database',
           component: 'POSTGRESQL_SERVER'
-        },
+        }
       ];
 
       newDatabases.forEach(function (db) {
@@ -1363,7 +1385,7 @@ describe('App.WizardStep8Controller', function () {
                 {component: 'HIVE_SERVER', hostName: 'h2'}
               ],
               services: [
-                Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false})
+                Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false, serviceComponents: []})
               ],
               serviceConfigProperties: [
                 {name: 'hive_database', value: db.name}