Browse Source

AMBARI-7059. FE: Adding Sqoop service right after install doesnt auto-select Client. (Max Shepel via akovalenko)

Aleksandr Kovalenko 10 years ago
parent
commit
f2f5dff251

+ 13 - 11
ambari-web/app/controllers/main/service/add_controller.js

@@ -391,18 +391,20 @@ App.AddServiceController = App.WizardController.extend({
    */
    */
   installAdditionalClients: function () {
   installAdditionalClients: function () {
     this.get('content.additionalClients').forEach(function (c) {
     this.get('content.additionalClients').forEach(function (c) {
-      var queryStr = 'HostRoles/component_name='+ c.componentName + '&HostRoles/host_name.in(' + c.hostNames.join() + ')';
-      App.ajax.send({
-        name: 'common.host_component.update',
-        sender: this,
-        data: {
-          query: queryStr,
-          context: 'Install ' + App.format.role(c.componentName),
-          HostRoles: {
-            state: 'INSTALLED'
+      if (c.hostNames.length > 0) {
+        var queryStr = 'HostRoles/component_name='+ c.componentName + '&HostRoles/host_name.in(' + c.hostNames.join() + ')';
+        App.ajax.send({
+          name: 'common.host_component.update',
+          sender: this,
+          data: {
+            query: queryStr,
+            context: 'Install ' + App.format.role(c.componentName),
+            HostRoles: {
+              state: 'INSTALLED'
+            }
           }
           }
-        }
-      });
+        });
+      }
     }, this);
     }, this);
   }
   }
 });
 });

+ 7 - 5
ambari-web/app/controllers/wizard/step8_controller.js

@@ -1285,11 +1285,13 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, {
           }, this);
           }, this);
         }, this);
         }, this);
         hostNames = hostNames.uniq();
         hostNames = hostNames.uniq();
-        this.get('content.additionalClients').pushObject({hostNames: hostNames, componentName: _clientName});
-        // If a dependency for being co-hosted is derived between existing client and selected new master but that
-        // dependency is already satisfied in the cluster then disregard the derived dependency
-        this.removeClientsFromList(_clientName, hostNames);
-        this.registerHostsToComponent(hostNames, _clientName);
+        if (hostNames.length > 0) {
+          this.get('content.additionalClients').pushObject({hostNames: hostNames, componentName: _clientName});
+          // If a dependency for being co-hosted is derived between existing client and selected new master but that
+          // dependency is already satisfied in the cluster then disregard the derived dependency
+          this.removeClientsFromList(_clientName, hostNames);
+          this.registerHostsToComponent(hostNames, _clientName);
+        }
       }
       }
     }, this);
     }, this);
   },
   },

+ 2 - 0
ambari-web/app/routes/add_host_routes.js

@@ -154,11 +154,13 @@ module.exports = App.WizardRoute.extend({
     next: function (router, context) {
     next: function (router, context) {
       var addHostController = router.get('addHostController');
       var addHostController = router.get('addHostController');
       var wizardStep3Controller = router.get('wizardStep3Controller');
       var wizardStep3Controller = router.get('wizardStep3Controller');
+      var wizardStep6Controller = router.get('wizardStep6Controller');
       addHostController.saveConfirmedHosts(wizardStep3Controller);
       addHostController.saveConfirmedHosts(wizardStep3Controller);
       addHostController.saveClients();
       addHostController.saveClients();
 
 
       addHostController.setDBProperty('bootStatus', true);
       addHostController.setDBProperty('bootStatus', true);
       addHostController.setDBProperty('slaveComponentHosts', undefined);
       addHostController.setDBProperty('slaveComponentHosts', undefined);
+      wizardStep6Controller.set('isClientsSet', false);
       router.transitionTo('step3');
       router.transitionTo('step3');
     },
     },
     /**
     /**

+ 2 - 0
ambari-web/app/routes/add_service_routes.js

@@ -137,8 +137,10 @@ module.exports = App.WizardRoute.extend({
     next: function (router) {
     next: function (router) {
       var addServiceController = router.get('addServiceController');
       var addServiceController = router.get('addServiceController');
       var wizardStep5Controller = router.get('wizardStep5Controller');
       var wizardStep5Controller = router.get('wizardStep5Controller');
+      var wizardStep6Controller = router.get('wizardStep6Controller');
       addServiceController.saveMasterComponentHosts(wizardStep5Controller);
       addServiceController.saveMasterComponentHosts(wizardStep5Controller);
       addServiceController.setDBProperty('slaveComponentHosts', undefined);
       addServiceController.setDBProperty('slaveComponentHosts', undefined);
+      wizardStep6Controller.set('isClientsSet', false);
       router.transitionTo('step3');
       router.transitionTo('step3');
     }
     }
   }),
   }),

+ 2 - 0
ambari-web/app/routes/installer.js

@@ -272,9 +272,11 @@ module.exports = Em.Route.extend({
     next: function (router) {
     next: function (router) {
       var controller = router.get('installerController');
       var controller = router.get('installerController');
       var wizardStep5Controller = router.get('wizardStep5Controller');
       var wizardStep5Controller = router.get('wizardStep5Controller');
+      var wizardStep6Controller = router.get('wizardStep6Controller');
       controller.saveMasterComponentHosts(wizardStep5Controller);
       controller.saveMasterComponentHosts(wizardStep5Controller);
       controller.setDBProperty('slaveComponentHosts', undefined);
       controller.setDBProperty('slaveComponentHosts', undefined);
       controller.setDBProperty('recommendations', wizardStep5Controller.get('content.recommendations'));
       controller.setDBProperty('recommendations', wizardStep5Controller.get('content.recommendations'));
+      wizardStep6Controller.set('isClientsSet', false);
       router.transitionTo('step6');
       router.transitionTo('step6');
     }
     }
   }),
   }),

+ 10 - 0
ambari-web/test/controllers/main/service/add_controller_test.js

@@ -34,6 +34,10 @@ describe('App.AddServiceController', function() {
         componentName: "TEZ_CLIENT",
         componentName: "TEZ_CLIENT",
         hostNames: ["hostName1", "hostName2"]
         hostNames: ["hostName1", "hostName2"]
       },
       },
+      additionalClientsWithoutHosts: {
+        componentName: "TEZ_CLIENT",
+        hostNames: []
+      },
       RequestInfo: {
       RequestInfo: {
         "context": Em.I18n.t('requestInfo.installHostComponent') + ' ' + App.format.role("TEZ_CLIENT"),
         "context": Em.I18n.t('requestInfo.installHostComponent') + ' ' + App.format.role("TEZ_CLIENT"),
         "query": "HostRoles/component_name=TEZ_CLIENT&HostRoles/host_name.in(hostName1,hostName2)"
         "query": "HostRoles/component_name=TEZ_CLIENT&HostRoles/host_name.in(hostName1,hostName2)"
@@ -66,6 +70,12 @@ describe('App.AddServiceController', function() {
       expect(JSON.parse($.ajax.args[0][0].data).Body).to.deep.eql(t.Body);
       expect(JSON.parse($.ajax.args[0][0].data).Body).to.deep.eql(t.Body);
       expect(JSON.parse($.ajax.args[0][0].data).RequestInfo).to.eql(t.RequestInfo);
       expect(JSON.parse($.ajax.args[0][0].data).RequestInfo).to.eql(t.RequestInfo);
     });
     });
+
+    it('should not send request to install client', function () {
+      addServiceController.set("content.additionalClients", [t.additionalClientsWithoutHosts]);
+      expect($.ajax.called).to.be.false;
+    });
+
   });
   });
 
 
 });
 });