Updated Branches: refs/heads/branch-1.4.2 831e71cc8 -> 17dd05485
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/17dd0548 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/17dd0548 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/17dd0548 Branch: refs/heads/branch-1.4.2 Commit: 17dd05485d50b4e0d1aae5f8b97528849bf9c6af Parents: 831e71c Author: Oleg Nechiporenko <[email protected]> Authored: Tue Dec 3 16:05:47 2013 +0200 Committer: Oleg Nechiporenko <[email protected]> Committed: Tue Dec 3 16:07:13 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/17dd0548/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 91e30eb..7e0d542 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); }
