You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2013/12/03 15:03:24 UTC

git commit: AMBARI-3954. hbase.zookeeper.quorum changing inconsistently on hosts after adding ZookeeperServer. (onechiporenko)

Updated Branches:
  refs/heads/trunk b6b1980a6 -> 8f309f4e8


AMBARI-3954. hbase.zookeeper.quorum changing inconsistently on hosts after adding ZookeeperServer. (onechiporenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8f309f4e
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8f309f4e
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8f309f4e

Branch: refs/heads/trunk
Commit: 8f309f4e8ce1cd49f861ef25846dd55242743d6a
Parents: b6b1980
Author: Oleg Nechiporenko <cv...@yahoo.com>
Authored: Tue Dec 3 15:58:27 2013 +0200
Committer: Oleg Nechiporenko <cv...@yahoo.com>
Committed: Tue Dec 3 16:03:18 2013 +0200

----------------------------------------------------------------------
 ambari-web/app/controllers/main/host/details.js | 63 ++++++++++++++------
 1 file changed, 46 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8f309f4e/ambari-web/app/controllers/main/host/details.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js
index 0f7dcc4..d0dcfa3 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -480,10 +480,12 @@ App.MainHostDetailsController = Em.Controller.extend({
               if (initValue) {
                 App.router.get('backgroundOperationsController').showPopup();
               }
+              if (componentName === 'ZOOKEEPER_SERVER') {
+                self.set('zkRequestId', requestId);
+                self.addObserver('App.router.backgroundOperationsController.serviceTimestamp', self, self.checkZkConfigs);
+                self.checkZkConfigs();
+              }
             });
-            if (componentName === 'ZOOKEEPER_SERVER') {
-              self.checkZkConfigs();
-            }
           });
       });
   },
@@ -491,17 +493,25 @@ App.MainHostDetailsController = Em.Controller.extend({
    * Load tags
    */
   checkZkConfigs: function() {
+    var bg = App.router.get('backgroundOperationsController.services').findProperty('id', this.get('zkRequestId'));
+    if (!bg) return;
+    if (!bg.get('isRunning')) {
+      this.loadConfigs();
+    }
+  },
+  loadConfigs: function() {
+    this.removeObserver('App.router.backgroundOperationsController.serviceTimestamp', this, this.checkZkConfigs);
     App.ajax.send({
       name: 'config.tags',
       sender: this,
-      success: 'checkZkConfigsSuccessCallback'
+      success: 'loadConfigsSuccessCallback'
     });
   },
   /**
    * Load needed configs
    * @param data
    */
-  checkZkConfigsSuccessCallback: function(data) {
+  loadConfigsSuccessCallback: function(data) {
     var urlParams = [];
     urlParams.push('(type=core-site&tag=' + data.Clusters.desired_configs['core-site'].tag + ')');
     if (App.Service.find().someProperty('serviceName', 'HBASE')) {
@@ -520,7 +530,7 @@ App.MainHostDetailsController = Em.Controller.extend({
     });
   },
   /**
-   * Set new values for some configs
+   * Set new values for some configs (based on available ZooKeeper Servers)
    * @param data
    */
   setNewZkConfigs: function(data) {
@@ -528,23 +538,24 @@ App.MainHostDetailsController = Em.Controller.extend({
     data.items.forEach(function (item) {
       configs[item.type] = item.properties;
     }, this);
-    if (App.isHadoop2Stack) {
+
+    var zks = this.getZkServerHosts();
+    var zks_with_port = '';
+    zks.forEach(function(zk) {
+      zks_with_port += zk + ':2181,';
+    });
+    zks_with_port = zks_with_port.slice(0,-1);
+
+    if (App.get('isHadoop2Stack')) {
       if (!App.HostComponent.find().someProperty('componentName', 'SECONDARY_NAMENODE')) {
-        var zks = App.HostComponent.find().filterProperty('componentName', 'ZOOKEEPER_SERVER').mapProperty('host.hostName');
-        var value = '';
-        zks.forEach(function(zk) {
-          value += zk + ':2181,';
-        });
-        value.slice(0,-1);
-        configs['core-site']['ha.zookeeper.quorum'] = value;
+        configs['core-site']['ha.zookeeper.quorum'] = zks_with_port;
       }
     }
-    var oneZk = App.HostComponent.find().findProperty('componentName', 'ZOOKEEPER_SERVER').get('host.hostName');
     if (configs['hbase-site']) {
-      configs['hbase-site']['hbase.zookeeper.quorum'] = oneZk;
+      configs['hbase-site']['hbase.zookeeper.quorum'] = zks.join(',');
     }
     if (configs['webhcat-site']) {
-      configs['webhcat-site']['templeton.zookeeper.hosts'] = oneZk;
+      configs['webhcat-site']['templeton.zookeeper.hosts'] = zks_with_port;
     }
     for (var site in configs) {
       if (!configs.hasOwnProperty(site)) continue;
@@ -560,6 +571,19 @@ App.MainHostDetailsController = Em.Controller.extend({
   },
 
   /**
+   * Is deleteHost action id fired
+   */
+  fromDeleteHost: false,
+
+  getZkServerHosts: function() {
+    var zks = App.HostComponent.find().filterProperty('componentName', 'ZOOKEEPER_SERVER').mapProperty('host.hostName');
+    if (this.get('fromDeleteHost')) {
+      return zks.without(this.get('content.hostName'));
+    }
+    return zks;
+  },
+
+  /**
    * send command to server to install selected host component
    * @param event
    * @param context
@@ -921,6 +945,7 @@ App.MainHostDetailsController = Em.Controller.extend({
         templateName: require('templates/main/host/details/doDeleteHostPopup')
       }),
       onPrimary: function() {
+        self.set('fromDeleteHost', true);
         if (!this.get('enablePrimary')) return;
         var allComponents = self.get('content.hostComponents');
         var deleteError = null;
@@ -950,6 +975,8 @@ App.MainHostDetailsController = Em.Controller.extend({
       deleteHostSuccessCallback: function(data) {
         var dialogSelf = this;
         App.router.get('updateController').updateHost(function(){
+          self.loadConfigs();
+          self.set('fromDeleteHost', false);
           dialogSelf.hide();
           App.router.transitionTo('hosts.index');
         });
@@ -959,6 +986,8 @@ App.MainHostDetailsController = Em.Controller.extend({
         console.log(textStatus);
         console.log(errorThrown);
         xhr.responseText = "{\"message\": \"" + xhr.statusText + "\"}";
+        self.loadConfigs();
+        this.set('fromDeleteHost', false);
         this.hide();
         App.ajax.defaultErrorHandler(xhr, opt.url, 'DELETE', xhr.status);
       }