Browse Source

AMBARI-8669. UI: Support Hive Metastore HA (alexantonenko)

Alex Antonenko 10 năm trước cách đây
mục cha
commit
8ead0a50b8

+ 74 - 7
ambari-web/app/controllers/main/host/details.js

@@ -209,6 +209,12 @@ App.MainHostDetailsController = Em.Controller.extend({
       bodyClass: Em.View.extend({
         templateName: require('templates/main/host/details/deleteComponentPopup')
       }),
+      isHiveMetastore: function () {
+        return componentName == 'HIVE_METASTORE';
+      }.property(),
+      deleteHiveMetastoreMsg: Em.View.extend({
+        template: Em.Handlebars.compile(Em.I18n.t('hosts.host.deleteComponent.popup.deleteHiveMetastore'))
+      }),
       isChecked: false,
       disablePrimary: function () {
         return !this.get('isChecked');
@@ -305,6 +311,9 @@ App.MainHostDetailsController = Em.Controller.extend({
     if (data.componentName == 'ZOOKEEPER_SERVER') {
       this.set('fromDeleteZkServer', true);
       this.loadConfigs();
+    } else if (data.componentName == 'HIVE_METASTORE') {
+      this.set('deleteHiveMetaStore', true);
+      this.loadConfigs('loadHiveConfigs');
     }
   },
 
@@ -424,12 +433,11 @@ App.MainHostDetailsController = Em.Controller.extend({
         })));
       return App.showAlertPopup(Em.I18n.t('host.host.addComponent.popup.dependedComponents.header'), popupMessage);
     }
-    if (componentName === 'ZOOKEEPER_SERVER') {
+    if (componentName === 'ZOOKEEPER_SERVER' || componentName === 'HIVE_METASTORE') {
       return App.showConfirmationPopup(function () {
         self.primary(component);
-      }, Em.I18n.t('hosts.host.addComponent.addZooKeeper'));
-    }
-    else {
+      }, Em.I18n.t('hosts.host.addComponent.' + componentName ));
+    } else {
       if (this.get('securityEnabled') && componentName !== 'CLIENTS') {
         return App.showConfirmationPopup(function () {
           self.primary(component);
@@ -507,7 +515,6 @@ App.MainHostDetailsController = Em.Controller.extend({
    * @method primary
    */
   primary: function (component) {
-
     var self = this;
     componentsUtils.installHostComponent(self.get('content.hostName'), component);
   },
@@ -535,11 +542,70 @@ App.MainHostDetailsController = Em.Controller.extend({
         self.set('zkRequestId', data.Requests.id);
         self.addObserver('App.router.backgroundOperationsController.serviceTimestamp', self, self.checkZkConfigs);
         self.checkZkConfigs();
+      }else if (params.componentName === 'HIVE_METASTORE'){
+       self.loadConfigs('loadHiveConfigs');
       }
     });
     return true;
   },
 
+  /**
+   * Success callback for load configs request
+   * @param {object} data
+   * @method loadHiveConfigs
+   */
+  loadHiveConfigs: function (data) {
+    App.ajax.send({
+      name: 'admin.get.all_configurations',
+      sender: this,
+      data: {
+        urlParams: '(type=hive-site&tag=' + data.Clusters.desired_configs['hive-site'].tag + ')'
+      },
+      success: 'onLoadHiveConfigs'
+    });
+  },
+
+  /**
+   * update and save Hive hive.metastore.uris config to server
+   * @param {object} data
+   * @method onLoadHiveConfigs
+   */
+  onLoadHiveConfigs: function (data) {
+    var hiveMSHosts = this.getHiveHosts();
+
+    for (var i = 0; i < hiveMSHosts.length; i++) {
+      hiveMSHosts[i] = hiveMSHosts[i] + ":9083";
+    }
+    data.items[0].properties['hive.metastore.uris'] = hiveMSHosts.join(',');
+    App.ajax.send({
+      name: 'reassign.save_configs',
+      sender: this,
+      data: {
+        siteName: 'hive-site',
+        properties: data.items[0].properties,
+        service_config_version_note: Em.I18n.t('hosts.host.hive.configs.save.note')
+      }
+    });
+  },
+
+  /**
+   * Delete Hive Metastore is performed
+   * @type {bool}
+   */
+  deleteHiveMetaStore: false,
+
+  getHiveHosts: function () {
+    var hiveHosts = App.HostComponent.find().filterProperty('componentName', 'HIVE_METASTORE').mapProperty('hostName');
+    if (this.get('fromDeleteHost') || this.get('deleteHiveMetaStore')) {
+      this.set('deleteHiveMetaStore', false);
+      this.set('fromDeleteHost', false);
+      hiveHosts = hiveHosts.without(this.get('content.hostName'));
+    } else if (!hiveHosts.contains(this.get('content.hostName'))) {
+      hiveHosts.push(this.get('content.hostName'));
+    }
+    return hiveHosts;
+  },
+
   /**
    * Send command to server to resfresh configs of selected component
    * @param {object} event
@@ -607,11 +673,11 @@ App.MainHostDetailsController = Em.Controller.extend({
    * Load configs
    * @method loadConfigs
    */
-  loadConfigs: function () {
+  loadConfigs: function (callback) {
     App.ajax.send({
       name: 'config.tags',
       sender: this,
-      success: 'loadConfigsSuccessCallback'
+      success: callback ? callback : 'loadConfigsSuccessCallback'
     });
   },
 
@@ -1648,6 +1714,7 @@ App.MainHostDetailsController = Em.Controller.extend({
   deleteHostSuccessCallback: function (data) {
     var self = this;
     App.router.get('updateController').updateHost(function () {
+      self.loadConfigs('loadHiveConfigs');
       self.loadConfigs();
       App.router.transitionTo('hosts.index');
     });

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

@@ -52,7 +52,7 @@ App.MainServiceItemController = Em.Controller.extend({
       var hostNames = App.Host.find().mapProperty('hostName');
       this.set('allHosts', hostNames);
 
-      ['HBASE_MASTER', 'ZOOKEEPER_SERVER', 'FLUME_HANDLER'].forEach(function(componentName) {
+      ['HBASE_MASTER', 'HIVE_METASTORE', 'ZOOKEEPER_SERVER', 'FLUME_HANDLER'].forEach(function(componentName) {
         self.loadHostsWithoutComponent(componentName);
       });
     }

+ 5 - 1
ambari-web/app/messages.js

@@ -2020,7 +2020,7 @@ Em.I18n.translations = {
   'hosts.host.installComponent.popup.confirm':'Confirm Install',
   'hosts.host.installComponent.msg':'Are you sure you want to install {0}?',
   'hosts.host.addComponent.msg':'Are you sure you want to add {0}?',
-  'hosts.host.addComponent.addZooKeeper':'Adding ZooKeeper Server may reconfigure such properties:<ul><li>ha.zookeeper.quorum</li><li>hbase.zookeeper.quorum</li><li>templeton.zookeeper.hosts</li><li>yarn.resourcemanager.zk-address</li><li>hive.zookeeper.quorum</li><li>hive.cluster.delegation.token.store.zookeeper.connectString</li></ul>',
+  'hosts.host.addComponent.ZOOKEEPER_SERVER':'Adding ZooKeeper Server may reconfigure such properties:<ul><li>ha.zookeeper.quorum</li><li>hbase.zookeeper.quorum</li><li>templeton.zookeeper.hosts</li><li>yarn.resourcemanager.zk-address</li><li>hive.zookeeper.quorum</li><li>hive.cluster.delegation.token.store.zookeeper.connectString</li></ul>',
   'hosts.host.addComponent.deleteHostWithZooKeeper':'Deleting host with ZooKeeper Server may reconfigure such properties:<ul><li>ha.zookeeper.quorum</li><li>hbase.zookeeper.quorum</li><li>templeton.zookeeper.hosts</li><li>yarn.resourcemanager.zk-address</li><li>hive.zookeeper.quorum</li><li>hive.cluster.delegation.token.store.zookeeper.connectString</li></ul>',
   'host.host.addComponent.popup.dependedComponents.body': '{0} requires {1} to be installed along with it on the same host. Please add them first and then try adding {0}',
   'host.host.addComponent.popup.dependedComponents.header': 'Component dependencies',
@@ -2043,6 +2043,9 @@ Em.I18n.translations = {
   'hosts.host.hbase_regionserver.decommission.warning':'Last RegionServer can\'t be decommissioned',
   'hosts.host.decommissioned':'Decommissioned',
   'hosts.host.decommissioning':'Decommissioning',
+  'hosts.host.addComponent.HIVE_METASTORE':'Adding Hive Metastore will reconfigure such properties:<ul><li>hive.metastore.uris</li></ul>',
+  'hosts.host.deleteComponent.popup.deleteHiveMetastore':'Deleting <i>Hive Metastorer</i> reconfigure such properties:<ul><li>hive.metastore.uris</li></ul>',
+  'hosts.host.hive.configs.save.note': 'This configuration is created by ambari while installing/deleting hive component on a host',
 
   'hosts.component.passive.implied.host.mode.tooltip':'Cannot Turn Off Maintenance Mode because Host is in Maintenance Mode',
   'hosts.component.passive.implied.service.mode.tooltip':'Cannot Turn Off Maintenance Mode because {0} is in Maintenance Mode',
@@ -2309,6 +2312,7 @@ Em.I18n.translations = {
 
   'dashboard.services.hive.clients':'Hive Clients',
   'dashboard.services.hive.client':'Hive Client',
+  'dashboard.services.hive.metastore':'Hive Metastore',
 
   'dashboard.services.oozie.clients':'Oozie Clients',
   'dashboard.services.oozie.client':'Oozie Client',

+ 14 - 4
ambari-web/app/models/service_config.js

@@ -435,10 +435,6 @@ App.ServiceConfigProperty = Ember.Object.extend({
       case 'hivemetastore_host':
         this.set('value', masterComponentHostsInDB.findProperty('component', 'HIVE_SERVER').hostName);
         break;
-      case 'hive.metastore.uris':
-        var hiveHost = masterComponentHostsInDB.findProperty('component', 'HIVE_SERVER').hostName;
-        this.setDefaultValue(hostWithPrefix,'://' + hiveHost);
-        break;
       case 'hive_ambari_host':
         this.set('value', masterComponentHostsInDB.findProperty('component', 'HIVE_SERVER').hostName);
         break;
@@ -482,6 +478,20 @@ App.ServiceConfigProperty = Ember.Object.extend({
         var hiveServerHost = masterComponentHostsInDB.findProperty('component', 'HIVE_SERVER').hostName;
         this.set('value', hiveServerHost).set('defaultValue', hiveServerHost);
         break;
+      case 'hive.metastore.uris':
+        var hiveMSHosts = masterComponentHostsInDB.filterProperty('component', 'HIVE_METASTORE').mapProperty('hostName'),
+            hiveMSHostPort = hiveMSHosts,
+            regex = "\\w*:(\\d+)",
+            portValue = this.get('defaultValue').match(new RegExp(regex));
+
+        if (!portValue) return;
+        if (portValue[1]) {
+          for (var i = 0; i < hiveMSHosts.length; i++) {
+            hiveMSHostPort[i] = hiveMSHosts[i] + ":" + portValue[1];
+          }
+        }
+        this.setDefaultValue("(.*)", hiveMSHostPort);
+        break;
       case 'oozie_existing_mysql_host':
       case 'oozie_existing_postgresql_host':
       case 'oozie_existing_oracle_host':

+ 2 - 1
ambari-web/app/styles/application.less

@@ -4175,7 +4175,8 @@ table.graphs {
   .hostName {
     word-wrap: break-word!important;
     white-space: normal;
-    width: 220px
+    width: 220px;
+    display: inline-block;
   }
   .hostString {
     margin-bottom: 5px;

+ 4 - 0
ambari-web/app/templates/main/host/details/deleteComponentPopup.hbs

@@ -27,4 +27,8 @@
   <br />
   <div class='alert'>{{view deleteZkServerMsg}}</div>
 {{/if}}
+{{#if isHiveMetastore}}
+  <br />
+  <div class='alert'>{{view deleteHiveMetastoreMsg}}</div>
+{{/if}}
 <div class='alert'>{{view restartNagiosMsg}}</div>

+ 6 - 0
ambari-web/app/templates/wizard/step5.hbs

@@ -61,6 +61,12 @@
                       <div class="hostName">
                         {{selectedHost}}<i class="icon-asterisks">&#10037;</i>
                       </div>
+                      {{#if showAddControl}}
+                        {{view App.AddControlView componentNameBinding="component_name"}}
+                      {{/if}}
+                      {{#if showRemoveControl}}
+                        {{view App.RemoveControlView componentNameBinding="component_name" serviceComponentIdBinding="serviceComponentId"}}
+                      {{/if}}
                     {{else}}
                       <div {{bindAttr class="errorMessage:error: warnMessage:warning: :control-group"}}>
                         {{#if view.shouldUseInputs}}

+ 7 - 0
ambari-web/app/views/main/service/item.js

@@ -152,6 +152,13 @@ App.MainServiceItemView = Em.View.extend({
         service: 'HBASE',
         component: 'HBASE_MASTER'
       },
+      {
+       cssClass: 'icon-plus',
+       'label': '{0} {1}'.format(Em.I18n.t('add'), Em.I18n.t('dashboard.services.hive.metastore')),
+       service: 'HIVE',
+       component: 'HIVE_METASTORE',
+       isHidden: !App.get('isHadoop22Stack')
+      },
       {
         cssClass: 'icon-plus',
         'label': '{0} {1}'.format(Em.I18n.t('add'), Em.I18n.t('dashboard.services.zookeeper.server')),

+ 1 - 1
ambari-web/test/controllers/main/host/details_test.js

@@ -2285,7 +2285,7 @@ describe('App.MainHostDetailsController', function () {
       controller.deleteHostSuccessCallback();
       expect(App.router.get.calledWith('updateController')).to.be.true;
       expect(mock.updateHost.calledOnce).to.be.true;
-      expect(controller.loadConfigs.calledOnce).to.be.true;
+      expect(controller.loadConfigs.called).to.be.true;
       expect(App.router.transitionTo.calledWith('hosts.index')).to.be.true;
       expect(App.router.get.calledWith('clusterController')).to.be.true;
       expect(mock.getAllHostNames.calledOnce).to.be.true;