Преглед изворни кода

AMBARI-9655. Added Second Hive Metastore, two alert instances but both OK (alexantonenko)

Alex Antonenko пре 10 година
родитељ
комит
bff7124bb9

+ 67 - 35
ambari-web/app/controllers/main/host/details.js

@@ -43,6 +43,12 @@ App.MainHostDetailsController = Em.Controller.extend({
    */
   referer: '',
 
+  /**
+   *  Host on which Hive Metastore will be added
+   * @type {string}
+   */
+  hiveMetastoreHost: '',
+
   /**
    * Deferred object will be resolved when Oozie configs are downloaded
    * @type {object}
@@ -427,13 +433,16 @@ App.MainHostDetailsController = Em.Controller.extend({
    * @method addComponent
    */
   addComponent: function (event) {
-    var self = this;
-    var component = event.context;
-    var componentName = component.get('componentName');
-    var missedComponents = componentsUtils.checkComponentDependencies(componentName, {
-      scope: 'host',
-      installedComponents: this.get('content.hostComponents').mapProperty('componentName')
-    });
+    var
+      returnFunc,
+      self = this,
+      hiveHost = event.hiveMetastoreHost ? event.hiveMetastoreHost : "";
+      component = event.context,
+      componentName = component.get('componentName'),
+      missedComponents = !!hiveHost ? [] : componentsUtils.checkComponentDependencies(componentName, {
+        scope: 'host',
+        installedComponents: this.get('content.hostComponents').mapProperty('componentName')
+      });
     if (!!missedComponents.length) {
       var popupMessage = Em.I18n.t('host.host.addComponent.popup.dependedComponents.body').format(component.get('displayName'),
         stringUtils.getFormattedStringFromArray(missedComponents.map(function(cName) {
@@ -441,20 +450,28 @@ App.MainHostDetailsController = Em.Controller.extend({
         })));
       return App.showAlertPopup(Em.I18n.t('host.host.addComponent.popup.dependedComponents.header'), popupMessage);
     }
-    if (componentName === 'ZOOKEEPER_SERVER' || componentName === 'HIVE_METASTORE') {
-      return App.showConfirmationPopup(function () {
-        self.primary(component);
-      }, Em.I18n.t('hosts.host.addComponent.' + componentName ));
-    } else {
-      if (this.get('securityEnabled') && componentName !== 'CLIENTS') {
-        return App.showConfirmationPopup(function () {
+
+    switch (componentName) {
+      case 'ZOOKEEPER_SERVER':
+        returnFunc = App.showConfirmationPopup(function () {
           self.primary(component);
-        }, Em.I18n.t('hosts.host.addComponent.securityNote').format(componentName, self.get('content.hostName')));
-      }
-      else {
-        return this.addClientComponent(component);
-      }
+        }, Em.I18n.t('hosts.host.addComponent.' + componentName ));
+        break;
+      case 'HIVE_METASTORE':
+        this.set('hiveMetastoreHost',hiveHost);
+        this.loadConfigs("loadHiveConfigs");
+        break;
+      default:
+        if (this.get('securityEnabled') && componentName !== 'CLIENTS') {
+          returnFunc = App.showConfirmationPopup(function () {
+            self.primary(component);
+          }, Em.I18n.t('hosts.host.addComponent.securityNote').format(componentName, self.get('content.hostName')));
+        }
+        else {
+          returnFunc = this.addClientComponent(component);
+        }
     }
+    return returnFunc;
   },
   /**
    * Send command to server to install client on selected host
@@ -528,7 +545,7 @@ App.MainHostDetailsController = Em.Controller.extend({
    * @param {object} data
    * @param {object} opt
    * @param {object} params
-   * @method installNewComponentSuccessCallback
+   * @method installNewComponentSuccessCallbƒack
    */
   installNewComponentSuccessCallback: function (data, opt, params) {
     if (!data.Requests || !data.Requests.id) {
@@ -542,7 +559,7 @@ App.MainHostDetailsController = Em.Controller.extend({
     }
 
     this.showBackgroundOperationsPopup(function () {
-      if (params.componentName === 'ZOOKEEPER_SERVER' || params.componentName === 'HIVE_METASTORE' ||  params.componentName === 'HIVE_SERVER') {
+      if (params.componentName === 'ZOOKEEPER_SERVER' || params.componentName === 'HIVE_SERVER') {
         self.set(params.componentName === 'ZOOKEEPER_SERVER' ? 'zkRequestId' : 'hiveRequestId', data.Requests.id);
         self.addObserver(
           'App.router.backgroundOperationsController.serviceTimestamp',
@@ -625,13 +642,15 @@ App.MainHostDetailsController = Em.Controller.extend({
    * @method onLoadHiveConfigs
    */
   onLoadHiveConfigs: function (data) {
-    var hiveMSHosts = this.getHiveHosts();
-    var hiveMasterHosts = hiveMSHosts.concat(App.HostComponent.find().filterProperty('componentName', 'HIVE_SERVER').mapProperty('hostName')).uniq().sort().join(',');
-    var configs = {};
-    var attributes = {};
-    var port = "";
-    var hiveUser = "";
-    var webhcatUser = "";
+    var
+      hiveMetastoreHost = this.get('hiveMetastoreHost'),
+      hiveMSHosts = this.getHiveHosts(),
+      hiveMasterHosts = hiveMSHosts.concat(App.HostComponent.find().filterProperty('componentName', 'HIVE_SERVER').mapProperty('hostName')).uniq().sort().join(','),
+      configs = {},
+      attributes = {},
+      port = "",
+      hiveUser = "",
+      webhcatUser = "";
 
     data.items.forEach(function (item) {
       configs[item.type] = item.properties;
@@ -673,18 +692,21 @@ App.MainHostDetailsController = Em.Controller.extend({
         }
       }
     ];
-    this.saveConfigsBatch(groups);
+    this.saveConfigsBatch(groups, hiveMetastoreHost);
   },
 
   /**
    * save configs' sites in batch
    * @param groups
    */
-  saveConfigsBatch: function (groups) {
+  saveConfigsBatch: function (groups, hiveMetastoreHost) {
     groups.forEach(function (group) {
-      var desiredConfigs = [];
-      var tag = 'version' + (new Date).getTime();
-      var properties = group.properties;
+      var
+        self = this,
+        desiredConfigs = [],
+        tag = 'version' + (new Date).getTime(),
+        properties = group.properties;
+
       for (var site in properties) {
         if (!properties.hasOwnProperty(site)) continue;
         desiredConfigs.push({
@@ -701,7 +723,9 @@ App.MainHostDetailsController = Em.Controller.extend({
           sender: this,
           data: {
             desired_config: desiredConfigs
-          }
+          },
+          defaultSuccessCallback: function () {},
+          success: !!hiveMetastoreHost ? componentsUtils.installHostComponent(hiveMetastoreHost, App.StackServiceComponent.find("HIVE_METASTORE")) : this.defaultSuccessCallback
         });
       }
     }, this);
@@ -714,7 +738,15 @@ App.MainHostDetailsController = Em.Controller.extend({
   deleteHiveMetaStore: false,
 
   getHiveHosts: function () {
-    var hiveHosts = App.HostComponent.find().filterProperty('componentName', 'HIVE_METASTORE').mapProperty('hostName');
+    var
+      hiveHosts = App.HostComponent.find().filterProperty('componentName', 'HIVE_METASTORE').mapProperty('hostName'),
+      hiveMetastoreHost = this.get('hiveMetastoreHost');
+
+    if(!!hiveMetastoreHost){
+      hiveHosts.push(hiveMetastoreHost);
+      this.set('hiveMetastoreHost', '');
+    }
+
     if (this.get('fromDeleteHost') || this.get('deleteHiveMetaStore')) {
       this.set('deleteHiveMetaStore', false);
       this.set('fromDeleteHost', false);

+ 10 - 1
ambari-web/app/controllers/main/service/item.js

@@ -623,7 +623,16 @@ App.MainServiceItemController = Em.Controller.extend({
         var selectedHost = this.get('selectedHost');
 
         // Install
-        componentsUtils.installHostComponent(selectedHost, component);
+        if(component.get('componentName') == "HIVE_METASTORE" && !!selectedHost){
+          App.router.get('mainHostDetailsController').addComponent(
+            {
+              context: component,
+              hiveMetastoreHost: selectedHost
+            }
+          );
+        } else {
+          componentsUtils.installHostComponent(selectedHost, component);
+        }
 
         // Remove host from 'without' collection to immediate recalculate add menu item state
         var hostsWithoutComponent = this.get('hostsWithoutComponent');

+ 4 - 3
ambari-web/app/utils/components.js

@@ -19,9 +19,10 @@ var App = require('app');
 
 module.exports = {
   installHostComponent: function(hostName, component) {
-    var self = this;
-    var componentName = component.get('componentName');
-    var displayName = component.get('displayName');
+    var
+      self = this,
+      componentName = component.get('componentName'),
+      displayName = component.get('displayName');
     App.ajax.send({
       name: 'host.host_component.add_new_component',
       sender: self,