Repository: ambari Updated Branches: refs/heads/trunk 93e79d0d0 -> 261f04b7d
AMBARI-9148 Adding a Hive metastore creates 3 new versions of configs each time. (atkach) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/261f04b7 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/261f04b7 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/261f04b7 Branch: refs/heads/trunk Commit: 261f04b7d00305e9ab36d26ab1a441a82e945cc6 Parents: 93e79d0 Author: Andrii Tkach <[email protected]> Authored: Thu Jan 15 16:12:30 2015 +0200 Committer: Andrii Tkach <[email protected]> Committed: Thu Jan 15 16:52:53 2015 +0200 ---------------------------------------------------------------------- ambari-web/app/controllers/main/host/details.js | 70 +++++++++++++------- .../test/controllers/main/host/details_test.js | 39 +++++------ 2 files changed, 61 insertions(+), 48 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/261f04b7/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 54865b2..901b8b8 100644 --- a/ambari-web/app/controllers/main/host/details.js +++ b/ambari-web/app/controllers/main/host/details.js @@ -614,19 +614,44 @@ App.MainHostDetailsController = Em.Controller.extend({ configs['webhcat-site']['templeton.hive.properties'] = configs['webhcat-site']['templeton.hive.properties'].replace(/thrift.+[0-9]{2,},/i, hiveMSHosts.join('\\,') + ","); configs['core-site']['hadoop.proxyuser.' + hiveUser + '.hosts'] = hiveMasterHosts; configs['core-site']['hadoop.proxyuser.' + webhcatUser + '.hosts'] = hiveMasterHosts; + var groups = [ + { + 'hive-site': configs['hive-site'], + 'webhcat-site': configs['webhcat-site'], + 'hive-env': configs['hive-env'] + }, + {'core-site': configs['core-site']} + ]; + this.saveConfigsBatch(groups); + }, - for (var site in configs) { - if (!configs.hasOwnProperty(site)) continue; - App.ajax.send({ - name: 'reassign.save_configs', - sender: this, - data: { - siteName: site, - properties: configs[site], - service_config_version_note: Em.I18n.t('hosts.host.hive.configs.save.note') - } - }); - } + /** + * save configs' sites in batch + * @param groups + */ + saveConfigsBatch: function (groups) { + groups.forEach(function (configs) { + var desiredConfigs = []; + var tag = 'version' + (new Date).getTime(); + for (var site in configs) { + if (!configs.hasOwnProperty(site)) continue; + desiredConfigs.push({ + "type": site, + "tag": tag, + "properties": configs[site], + "service_config_version_note": Em.I18n.t('hosts.host.hive.configs.save.note') + }); + } + if (desiredConfigs.length > 0) { + App.ajax.send({ + name: 'common.service.configurations', + sender: this, + data: { + desired_config: desiredConfigs + } + }); + } + }, this); }, /** @@ -782,19 +807,14 @@ App.MainHostDetailsController = Em.Controller.extend({ var zks = this.getZkServerHosts(); var zksWithPort = this.concatZkNames(zks); this.setZKConfigs(configs, zksWithPort, zks); - - for (var site in configs) { - if (!configs.hasOwnProperty(site)) continue; - App.ajax.send({ - name: 'reassign.save_configs', - sender: this, - data: { - siteName: site, - properties: configs[site], - service_config_version_note: Em.I18n.t('hosts.host.zooKeeper.configs.save.note') - } - }); - } + var groups = [ + { + 'hive-site': configs['hive-site'], + 'webhcat-site': configs['webhcat-site'] + }, + {'yarn-site': configs['yarn-site']} + ]; + this.saveConfigsBatch(groups); }, /** * http://git-wip-us.apache.org/repos/asf/ambari/blob/261f04b7/ambari-web/test/controllers/main/host/details_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/host/details_test.js b/ambari-web/test/controllers/main/host/details_test.js index acd9b27..546f0c4 100644 --- a/ambari-web/test/controllers/main/host/details_test.js +++ b/ambari-web/test/controllers/main/host/details_test.js @@ -718,41 +718,34 @@ describe('App.MainHostDetailsController', function () { sinon.stub(controller, "getZkServerHosts", Em.K); sinon.stub(controller, "concatZkNames", Em.K); sinon.stub(controller, "setZKConfigs", Em.K); + sinon.stub(controller, 'saveConfigsBatch', Em.K); }); afterEach(function () { controller.getZkServerHosts.restore(); controller.concatZkNames.restore(); controller.setZKConfigs.restore(); + controller.saveConfigsBatch.restore(); }); - it('data.items is empty', function () { + it('call saveConfigsBatch()', function () { var data = {items: []}; controller.saveZkConfigs(data); + expect(controller.saveConfigsBatch.calledOnce).to.be.true; + }); + }); + + describe("#saveConfigsBatch()", function() { + it("no groups", function() { + controller.saveConfigsBatch([]); expect(App.ajax.send.called).to.be.false; }); - it('data.items has one item', function () { - var data = {items: [ - { - type: 'type1', - properties: {} - } - ]}; - controller.saveZkConfigs(data); - expect(App.ajax.send.calledOnce).to.be.true; + it("configs is empty", function() { + controller.saveConfigsBatch([{}]); + expect(App.ajax.send.called).to.be.false; }); - it('data.items has two items', function () { - var data = {items: [ - { - type: 'type1', - properties: {} - }, - { - type: 'type2', - properties: {} - } - ]}; - controller.saveZkConfigs(data); - expect(App.ajax.send.calledTwice).to.be.true; + it("configs is correct", function() { + controller.saveConfigsBatch([{'site': {}}]); + expect(App.ajax.send.calledOnce).to.be.true; }); });
