Bläddra i källkod

AMBARI-6764. HiveServer2 Start fails after adding services. (jaimin)

Jaimin Jetly 10 år sedan
förälder
incheckning
9515e6c824

+ 1 - 0
ambari-web/app/controllers/installer.js

@@ -37,6 +37,7 @@ App.InstallerController = App.WizardController.extend({
     configGroups: [],
     slaveGroupProperties: null,
     stacks: null,
+    clients:[],
     controllerName: 'installerController'
   }),
 

+ 16 - 27
ambari-web/app/controllers/main/service/add_controller.js

@@ -51,6 +51,7 @@ App.AddServiceController = App.WizardController.extend({
     advancedServiceConfig: null,
     controllerName: 'addServiceController',
     configGroups: [],
+    clients: [],
     additionalClients: []
   }),
 
@@ -90,8 +91,8 @@ App.AddServiceController = App.WizardController.extend({
         item.set('isInstalled', isInstalled);
       }, this);
       var isServiceWithSlave = App.StackService.find().filterProperty('isSelected').filterProperty('hasSlave').filterProperty('isInstalled', false).mapProperty('serviceName').length;
-
-      this.set('content.skipSlavesStep', !isServiceWithSlave);
+      var isServiceWithClient = App.StackService.find().filterProperty('isSelected').filterProperty('hasClient').filterProperty('isInstalled', false).mapProperty('serviceName').length;
+      this.set('content.skipSlavesStep', !isServiceWithSlave && !isServiceWithClient);
       if (this.get('content.skipSlavesStep')) {
         this.get('isStepDisabled').findProperty('step', 3).set('value', this.get('content.skipSlavesStep'));
       }
@@ -117,7 +118,8 @@ App.AddServiceController = App.WizardController.extend({
     this.set('content.selectedServiceNames', selectedServices);
     this.setDBProperty('selectedServiceNames', selectedServices);
     var isServiceWithSlave = stepController.get('content').filterProperty('isSelected').filterProperty('hasSlave').filterProperty('isInstalled', false).mapProperty('serviceName').length;
-    this.set('content.skipSlavesStep', !isServiceWithSlave);
+    var isServiceWithClient = App.StackService.find().filterProperty('isSelected').filterProperty('hasClient').filterProperty('isInstalled', false).mapProperty('serviceName').length;
+    this.set('content.skipSlavesStep', !isServiceWithSlave && !isServiceWithClient);
     if (this.get('content.skipSlavesStep')) {
       this.get('isStepDisabled').findProperty('step', 3).set('value', this.get('content.skipSlavesStep'));
     }
@@ -247,7 +249,6 @@ App.AddServiceController = App.WizardController.extend({
         uninstalledComponents.push(component);
       }
     }, this);
-    installedComponentsMap['HDFS_CLIENT'] = [];
 
     for (var hostName in hosts) {
       if (hosts[hostName].isInstalled) {
@@ -260,10 +261,9 @@ App.AddServiceController = App.WizardController.extend({
     }
 
     for (var componentName in installedComponentsMap) {
-      var name = (componentName === 'HDFS_CLIENT') ? 'CLIENT' : componentName;
       var component = {
-        componentName: name,
-        displayName: App.format.role(name),
+        componentName: componentName,
+        displayName: App.format.role(componentName),
         hosts: [],
         isInstalled: true
       };
@@ -298,24 +298,15 @@ App.AddServiceController = App.WizardController.extend({
   saveClients: function (stepController) {
     var clients = [];
     var serviceComponents = App.StackServiceComponent.find();
-    var clientComponents = [];
-    var dbHosts = this.get('content.hosts');
-
-    for (var hostName in dbHosts) {
-      dbHosts[hostName].hostComponents.forEach(function (component) {
-        clientComponents[component.HostRoles.component_name] = true;
-      }, this);
-    }
-
-    this.get('content.services').filterProperty('isSelected').forEach(function (_service) {
-      var client = serviceComponents.filterProperty('serviceName', _service.serviceName).findProperty('isClient');
-      if (client) {
+    this.get('content.services').filterProperty('isSelected').filterProperty('isInstalled',false).forEach(function (_service) {
+      var serviceClients = serviceComponents.filterProperty('serviceName', _service.get('serviceName')).filterProperty('isClient');
+      serviceClients.forEach(function (client) {
         clients.push({
           component_name: client.get('componentName'),
           display_name: client.get('displayName'),
-          isInstalled: !!clientComponents[client.get('componentName')]
+          isInstalled: false
         });
-      }
+      }, this);
     }, this);
 
     this.setDBProperty('clientInfo', clients);
@@ -380,7 +371,6 @@ App.AddServiceController = App.WizardController.extend({
       "urlParams": "ServiceInfo/service_name.in(" + selectedServices.join(',')  + ")"
     };
     this.installServicesRequest(name, data, callback);
-
   },
 
   installServicesRequest: function (name, data, callback) {
@@ -401,14 +391,13 @@ App.AddServiceController = App.WizardController.extend({
    */
   installAdditionalClients: function () {
     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.host_component.update',
+        name: 'common.host_component.update',
         sender: this,
         data: {
-          hostName: c.hostName,
-          componentName: c.componentName,
-          serviceName: c.componentName.slice(0, -7),
-          context: Em.I18n.t('requestInfo.installHostComponent') + " " + c.hostName,
+          query: queryStr,
+          context: 'Install ' + App.format.role(c.componentName),
           HostRoles: {
             state: 'INSTALLED'
           }

+ 38 - 39
ambari-web/app/controllers/wizard/step6_controller.js

@@ -81,7 +81,7 @@ App.WizardStep6Controller = Em.Controller.extend({
     return this.get('content.controllerName') === 'addServiceController';
   }.property('content.controllerName'),
 
-  installedServiceNames: function() {
+  installedServiceNames: function () {
     return this.get('content.services').filterProperty('isInstalled').mapProperty('serviceName');
   }.property('content.services').cacheable(),
 
@@ -181,20 +181,6 @@ App.WizardStep6Controller = Em.Controller.extend({
     this.checkCallback(component);
   },
 
-  /**
-   * Return whether service was selected or not
-   * @param {string} name serviceName
-   * @return {bool}
-   * @method isServiceSelected
-   */
-  isServiceSelected: function (name) {
-    var serviceName = this.get('content.services').findProperty('serviceName', name);
-    if (!serviceName) {
-      return !!serviceName;
-    }
-    return serviceName.get('isSelected') || serviceName.get('isInstalled');
-  },
-
   /**
    * Checkbox check callback
    * Verify if all/none checkboxes for current component are checked
@@ -227,8 +213,6 @@ App.WizardStep6Controller = Em.Controller.extend({
    */
   loadStep: function () {
 
-    var self = this;
-
     console.log("WizardStep6Controller: Loading step6: Assign Slaves");
     this.clearStep();
     var selectedServices = App.StackService.find().filterProperty('isSelected');
@@ -282,7 +266,7 @@ App.WizardStep6Controller = Em.Controller.extend({
     for (var index in hostInfo) {
       if (hostInfo.hasOwnProperty(index)) {
         if (hostInfo[index].bootStatus === 'REGISTERED') {
-          if(!getUninstalledHosts || !hostInfo[index].isInstalled) {
+          if (!getUninstalledHosts || !hostInfo[index].isInstalled) {
             hostNames.push(hostInfo[index].name);
           }
         }
@@ -346,25 +330,13 @@ App.WizardStep6Controller = Em.Controller.extend({
     var slaveComponents = this.get('content.slaveComponentHosts');
     if (!slaveComponents) { // we are at this page for the first time
       if (!App.supports.serverRecommendValidate) {
-        var client_is_set = false;
         hostsObj.forEach(function (host) {
           var checkboxes = host.get('checkboxes');
           checkboxes.setEach('checked', !host.hasMaster);
           checkboxes.setEach('isInstalled', false);
           checkboxes.findProperty('title', headers.findProperty('name', 'CLIENT').get('label')).set('checked', false);
-          // First not Master should have Client (only first!)
-          if (!client_is_set) {
-            var dfs = App.StackService.find().findProperty('isPrimaryDFS');
-            if (dfs.get('isSelected') || dfs.get('isInstalled')) {
-              var checkboxServiceComponent = checkboxes.findProperty('title', headers.findProperty('name', dfs.get('serviceComponents').
-                findProperty('isShownOnInstallerSlaveClientPage').get('componentName')).get('label'));
-              if (checkboxServiceComponent && checkboxServiceComponent.get('checked')) {
-                checkboxes.findProperty('title', headers.findProperty('name', 'CLIENT').get('label')).set('checked', true);
-                client_is_set = true;
-              }
-            }
-          }
         });
+        this.selectClientHost(hostsObj);
 
         if (this.get('isInstallerWizard') && hostsObj.everyProperty('hasMaster', true)) {
           var lastHost = hostsObj[hostsObj.length - 1];
@@ -373,9 +345,9 @@ App.WizardStep6Controller = Em.Controller.extend({
       } else {
         var recommendations = App.router.get('installerController.recommendations');
         // Get all host-component pairs from recommendations
-        var componentHostPairs = recommendations.blueprint.host_groups.map(function(group) {
-          return group.components.map(function(component) {
-            return recommendations.blueprint_cluster_binding.host_groups.findProperty('name', group.name).hosts.map(function(host) {
+        var componentHostPairs = recommendations.blueprint.host_groups.map(function (group) {
+          return group.components.map(function (component) {
+            return recommendations.blueprint_cluster_binding.host_groups.findProperty('name', group.name).hosts.map(function (host) {
               return { component: component.name, host: host.fqdn};
             });
           });
@@ -390,8 +362,8 @@ App.WizardStep6Controller = Em.Controller.extend({
 
         hostsObj.forEach(function (host) {
           var checkboxes = host.get('checkboxes');
-          checkboxes.forEach(function(checkbox) {
-            var recommended = componentHostPairs.some(function(pair) {
+          checkboxes.forEach(function (checkbox) {
+            var recommended = componentHostPairs.some(function (pair) {
               var componentMatch = pair.component === checkbox.component;
               if (checkbox.component === 'CLIENT' && !componentMatch) {
                 componentMatch = clientComponents.contains(pair.component);
@@ -416,9 +388,32 @@ App.WizardStep6Controller = Em.Controller.extend({
         }
       });
     }
+    this.selectClientHost(hostsObj);
     return hostsObj;
   },
 
+
+  /**
+   *
+   * @param hostsObj
+   */
+  selectClientHost: function (hostsObj) {
+    var headers = this.get('headers');
+    var client_is_set = false;
+    hostsObj.forEach(function (host) {
+      if (!client_is_set) {
+        var checkboxes = host.get('checkboxes');
+        var dfsService = App.StackService.find().findProperty('isPrimaryDFS');
+        var checkboxServiceComponent = checkboxes.findProperty('title', headers.findProperty('name', dfsService.get('serviceComponents').
+          findProperty('isShownOnInstallerSlaveClientPage').get('componentName')).get('label'));
+        if (checkboxServiceComponent && checkboxServiceComponent.get('checked')) {
+          checkboxes.findProperty('title', headers.findProperty('name', 'CLIENT').get('label')).set('checked', true);
+          client_is_set = true;
+        }
+      }
+    }, this);
+  },
+
   /**
    * Select checkboxes which correspond to master components
    *
@@ -518,15 +513,19 @@ App.WizardStep6Controller = Em.Controller.extend({
     var headers = this.get('headers');
     var componentsToInstall = [];
     headers.forEach(function (header) {
-      var checkboxes = hosts.mapProperty('checkboxes').reduce(function(cItem, pItem) { return cItem.concat(pItem); });
+      var checkboxes = hosts.mapProperty('checkboxes').reduce(function (cItem, pItem) {
+        return cItem.concat(pItem);
+      });
       var selectedCount = checkboxes.filterProperty('component', header.get('name')).filterProperty('checked').length;
       if (header.get('name') == 'CLIENT') {
         var clientsMinCount = 0;
         var serviceNames = this.get('installedServiceNames').concat(this.get('content.selectedServiceNames'));
         // find max value for `minToInstall` property
-        serviceNames.forEach(function(serviceName) {
+        serviceNames.forEach(function (serviceName) {
           App.StackServiceComponent.find().filterProperty('stackService.serviceName', serviceName).filterProperty('isClient')
-            .mapProperty('minToInstall').forEach(function(ctMinCount) { clientsMinCount = ctMinCount > clientsMinCount ? ctMinCount : clientsMinCount; });
+            .mapProperty('minToInstall').forEach(function (ctMinCount) {
+              clientsMinCount = ctMinCount > clientsMinCount ? ctMinCount : clientsMinCount;
+            });
         });
         if (selectedCount < clientsMinCount) {
           isError = true;

+ 67 - 46
ambari-web/app/controllers/wizard/step8_controller.js

@@ -338,7 +338,7 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, {
     var mappedConfigs = App.config.excludeUnsupportedConfigs(this.get('configMapping'), this.get('selectedServices').mapProperty('serviceName'));
     var uiConfigs = this.loadUiSideConfigs(mappedConfigs);
     var customGroupConfigs = [];
-    var allConfigs = configs.concat(uiConfigs).filter(function(config) {
+    var allConfigs = configs.concat(uiConfigs).filter(function (config) {
       if (config.group) {
         customGroupConfigs.push(config);
         return false;
@@ -1001,6 +1001,9 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, {
       }
       this.createMasterHostComponents();
       this.createSlaveAndClientsHostComponents();
+      if (this.get('content.controllerName') === 'addServiceController') {
+        this.createAdditionalClientComponents();
+      }
       this.createAdditionalHostComponents();
 
       this.set('ajaxQueueLength', this.get('ajaxRequestsQueue.queue.length'));
@@ -1211,9 +1214,9 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, {
    * @method createSlaveAndClientsHostComponents
    */
   createSlaveAndClientsHostComponents: function () {
-    var masterHosts = this.get('content.masterComponentHosts'),
-      slaveHosts = this.get('content.slaveComponentHosts'),
-      clients = this.get('content.clients');
+    var masterHosts = this.get('content.masterComponentHosts');
+    var slaveHosts = this.get('content.slaveComponentHosts');
+    var clients = this.get('content.clients').filterProperty('isInstalled',false);
 
     /**
      * Determines on which hosts client should be installed (based on availability of master components on hosts)
@@ -1236,64 +1239,82 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, {
       }
       else {
         clients.forEach(function (_client) {
-
           var hostNames = _slave.hosts.mapProperty('hostName');
           if (clientsToMasterMap[_client.component_name]) {
             clientsToMasterMap[_client.component_name].forEach(function (componentName) {
-              masterHosts.filterProperty('component', componentName).filterProperty('isInstalled', false).forEach(function (_masterHost) {
+              masterHosts.filterProperty('component', componentName).forEach(function (_masterHost) {
                 hostNames.pushObject(_masterHost.hostName);
               });
             });
           }
           hostNames = hostNames.uniq();
+          this.registerHostsToComponent(hostNames, _client.component_name);
+        }, this);
+      }
+    }, this);
+  },
 
-          if (_client.isInstalled) {
-            /**
-             * check whether clients are already installed on selected master hosts!!!
-             */
-            var clientHosts = [];
-            var installedHosts = this.get('content.hosts');
-            for (var hostName in installedHosts) {
-              if (installedHosts[hostName].isInstalled &&
-                installedHosts[hostName].hostComponents.filterProperty('HostRoles.state', 'INSTALLED').mapProperty('HostRoles.component_name').contains(_client.component_name)) {
-                clientHosts.push(hostName);
-              }
-            }
-
-            if (clientHosts.length > 0) {
-              clientHosts.forEach(function (hostName) {
-                if (hostNames.contains(hostName)) {
-                  hostNames.splice(hostNames.indexOf(hostName), 1);
-                }
-              }, this);
-            }
-            /**
-             * For Add Service Only
-             * if client is not added to host or is not installed add Object
-             * {
-             *    componentName: {String},
-             *    hostName: {String}
-             * }
-             * to content.additionalClients
-             * later it will be used to install client on host before installing new services
-             */
-            if (this.get('content.controllerName') === 'addServiceController' && hostNames.length > 0) {
-              hostNames.forEach(function (hostName) {
-                this.get('content.additionalClients').push(Em.Object.create({
-                  componentName: _client.component_name, hostName: hostName
-                }))
-              }, this)
-
-            }
-          }
+  /**
+   * This function is specific to addServiceController
+   * Newly introduced master components requires some existing client components to be hosted along with them
+   */
+  createAdditionalClientComponents: function () {
+    var masterHosts = this.get('content.masterComponentHosts');
+    var clientsToMasterMap = this.getClientsToMasterMap();
+    var installedClients = [];
 
-          this.registerHostsToComponent(hostNames, _client.component_name);
+    // Get all the installed Client components
+    this.get('content.services').filterProperty('isInstalled').forEach(function (_service) {
+      var serviceClients = App.StackServiceComponent.find().filterProperty('serviceName', _service.get('serviceName')).filterProperty('isClient');
+      serviceClients.forEach(function (client) {
+        installedClients.push(client.get('componentName'));
+      }, this);
+    }, this);
 
+    // Check if there is a dependency for being co-hosted between existing client and selected new master
+    installedClients.forEach(function (_clientName) {
+      if (clientsToMasterMap[_clientName]) {
+        var hostNames = [];
+        clientsToMasterMap[_clientName].forEach(function (componentName) {
+          masterHosts.filterProperty('component', componentName).filterProperty('isInstalled', false).forEach(function (_masterHost) {
+            hostNames.pushObject(_masterHost.hostName);
+          }, this);
         }, this);
+        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);
       }
     }, this);
   },
 
+  /**
+   *
+   * @param clientName
+   * @param hostList
+   */
+  removeClientsFromList: function (clientName, hostList) {
+    var clientHosts = [];
+    var installedHosts = this.get('content.hosts');
+    for (var hostName in installedHosts) {
+      if (installedHosts[hostName].isInstalled) {
+        if (installedHosts[hostName].hostComponents.mapProperty('HostRoles.component_name').contains(clientName)) {
+          clientHosts.push(hostName);
+        }
+      }
+    }
+
+    if (clientHosts.length > 0) {
+      clientHosts.forEach(function (hostName) {
+        if (hostList.contains(hostName)) {
+          hostList.splice(hostList.indexOf(hostName), 1);
+        }
+      }, this);
+    }
+  },
+
   /**
    * Register additional components
    * Based on availability of some services

+ 19 - 0
ambari-web/app/utils/ajax/ajax.js

@@ -76,6 +76,25 @@ var urls = {
     }
   },
 
+  'common.host_component.update': {
+    'real': '/clusters/{clusterName}/host_components',
+    'mock': '',
+    'type': 'PUT',
+    'format': function (data) {
+      return {
+        data: JSON.stringify({
+          RequestInfo: {
+            context: data.context,
+            query: data.query
+          },
+          Body: {
+            "HostRoles": data.HostRoles
+          }
+        })
+      }
+    }
+  },
+
   'common.host.host_components.update': {
     'real': '/clusters/{clusterName}/hosts/{hostName}/host_components?{urlParams}',
     'mock': '',