Repository: ambari Updated Branches: refs/heads/trunk 273e1b107 -> 76b7d3d46
AMBARI-9046. templeton.hive.properties set incorrectly (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/76b7d3d4 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/76b7d3d4 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/76b7d3d4 Branch: refs/heads/trunk Commit: 76b7d3d465324f73b2d8e3a6f92cf3b9e24430d7 Parents: 273e1b1 Author: Oleg Nechiporenko <[email protected]> Authored: Thu Jan 8 18:10:10 2015 +0200 Committer: Oleg Nechiporenko <[email protected]> Committed: Thu Jan 8 20:49:15 2015 +0200 ---------------------------------------------------------------------- .../0.12.0.2.0/configuration/webhcat-site.xml | 2 +- .../package/configuration/webhcat-site.xml | 2 +- .../HIVE/configuration/webhcat-site.xml | 2 +- .../HIVE/configuration/webhcat-site.xml | 2 +- ambari-web/app/models/service_config.js | 43 ++++-- ambari-web/app/utils/config.js | 7 +- ambari-web/test/models/service_config_test.js | 137 +++++++++++++++++++ 7 files changed, 175 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/76b7d3d4/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/webhcat-site.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/webhcat-site.xml b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/webhcat-site.xml index 335048e..3a81c60 100644 --- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/webhcat-site.xml +++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/webhcat-site.xml @@ -97,7 +97,7 @@ limitations under the License. <property> <name>templeton.hive.properties</name> - <value>hive.metastore.local=false, hive.metastore.uris=thrift://localhost:9933, hive.metastore.sasl.enabled=false</value> + <value>hive.metastore.local=false,hive.metastore.uris=thrift://localhost:9083,hive.metastore.sasl.enabled=false</value> <description>Properties to set when running hive.</description> </property> http://git-wip-us.apache.org/repos/asf/ambari/blob/76b7d3d4/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/configuration/webhcat-site.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/configuration/webhcat-site.xml b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/configuration/webhcat-site.xml index 335048e..31cd342 100644 --- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/configuration/webhcat-site.xml +++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/configuration/webhcat-site.xml @@ -97,7 +97,7 @@ limitations under the License. <property> <name>templeton.hive.properties</name> - <value>hive.metastore.local=false, hive.metastore.uris=thrift://localhost:9933, hive.metastore.sasl.enabled=false</value> + <value>hive.metastore.local=false,hive.metastore.uris=thrift://localhost:9933,hive.metastore.sasl.enabled=false</value> <description>Properties to set when running hive.</description> </property> http://git-wip-us.apache.org/repos/asf/ambari/blob/76b7d3d4/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/HIVE/configuration/webhcat-site.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/HIVE/configuration/webhcat-site.xml b/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/HIVE/configuration/webhcat-site.xml index 0523dab..951dcda 100644 --- a/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/HIVE/configuration/webhcat-site.xml +++ b/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/HIVE/configuration/webhcat-site.xml @@ -98,7 +98,7 @@ limitations under the License. <property> <name>templeton.hive.properties</name> - <value>hive.metastore.local=false, hive.metastore.uris=thrift://localhost:9933, hive.metastore.sasl.enabled=false</value> + <value>hive.metastore.local=false,hive.metastore.uris=thrift://localhost:9933,hive.metastore.sasl.enabled=false</value> <description>Properties to set when running hive.</description> </property> http://git-wip-us.apache.org/repos/asf/ambari/blob/76b7d3d4/ambari-server/src/main/resources/stacks/PHD/3.0.0.0/services/HIVE/configuration/webhcat-site.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/PHD/3.0.0.0/services/HIVE/configuration/webhcat-site.xml b/ambari-server/src/main/resources/stacks/PHD/3.0.0.0/services/HIVE/configuration/webhcat-site.xml index 0523dab..951dcda 100644 --- a/ambari-server/src/main/resources/stacks/PHD/3.0.0.0/services/HIVE/configuration/webhcat-site.xml +++ b/ambari-server/src/main/resources/stacks/PHD/3.0.0.0/services/HIVE/configuration/webhcat-site.xml @@ -98,7 +98,7 @@ limitations under the License. <property> <name>templeton.hive.properties</name> - <value>hive.metastore.local=false, hive.metastore.uris=thrift://localhost:9933, hive.metastore.sasl.enabled=false</value> + <value>hive.metastore.local=false,hive.metastore.uris=thrift://localhost:9933,hive.metastore.sasl.enabled=false</value> <description>Properties to set when running hive.</description> </property> http://git-wip-us.apache.org/repos/asf/ambari/blob/76b7d3d4/ambari-web/app/models/service_config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/service_config.js b/ambari-web/app/models/service_config.js index 655d81d..cb1b693 100644 --- a/ambari-web/app/models/service_config.js +++ b/ambari-web/app/models/service_config.js @@ -276,7 +276,7 @@ App.ServiceConfigProperty = Em.Object.extend({ return result; }.property('displayType'), - initialValue: function (localDB) { + initialValue: function (localDB, hiveMetastoreUrisDefault) { var masterComponentHostsInDB = localDB.masterComponentHosts; //console.log("value in initialvalue: " + JSON.stringify(masterComponentHostsInDB)); var hostsInfo = localDB.hosts; // which we are setting in installerController in step3. @@ -481,18 +481,10 @@ App.ServiceConfigProperty = Em.Object.extend({ 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] = "thrift://" + hiveMSHosts[i] + ":" + portValue[1]; - } + var hiveMSUris = this.getHiveMetastoreUris(masterComponentHostsInDB, hiveMetastoreUrisDefault); + if (hiveMSUris) { + this.setDefaultValue("(.*)", hiveMSUris); } - this.setDefaultValue("(.*)", hiveMSHostPort); break; case 'oozie_existing_mysql_host': case 'oozie_existing_postgresql_host': @@ -566,11 +558,11 @@ App.ServiceConfigProperty = Em.Object.extend({ this.setDefaultValue("(.*)", zkHostPort); break; case 'templeton.hive.properties': - var hiveMetaStoreHost = masterComponentHostsInDB.findProperty('component', 'HIVE_METASTORE').hostName; + var hiveMSUris = this.getHiveMetastoreUris(masterComponentHostsInDB, hiveMetastoreUrisDefault).replace(',', '\\,'); if (/\/\/localhost:/g.test(this.get('value'))) { - this.set('defaultValue', this.get('value') + ', hive.metastore.execute.setugi=true'); - this.setDefaultValue("(localhost)", hiveMetaStoreHost); + this.set('defaultValue', this.get('value') + ',hive.metastore.execute.setugi=true'); } + this.setDefaultValue("(hive\\.metastore\\.uris=)([^\\,]+)", "$1" + hiveMSUris); break; case 'dfs.name.dir': case 'dfs.namenode.name.dir': @@ -605,6 +597,27 @@ App.ServiceConfigProperty = Em.Object.extend({ }, /** + * Get hive.metastore.uris initial value + * @param hosts + * @param defaultValue + * @returns {string} + */ + getHiveMetastoreUris: function (hosts, defaultValue) { + var hiveMSHosts = hosts.filterProperty('component', 'HIVE_METASTORE').mapProperty('hostName'), + hiveMSUris = hiveMSHosts, + regex = "\\w*:(\\d+)", + portValue = defaultValue && defaultValue.match(new RegExp(regex)); + + if (!portValue) return ''; + if (portValue[1]) { + for (var i = 0; i < hiveMSHosts.length; i++) { + hiveMSUris[i] = "thrift://" + hiveMSHosts[i] + ":" + portValue[1]; + } + } + return hiveMSUris.join(','); + }, + + /** * @param regex : String * @param replaceWith : String */ http://git-wip-us.apache.org/repos/asf/ambari/blob/76b7d3d4/ambari-web/app/utils/config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js index d4d8ea1..f3a2fc6 100644 --- a/ambari-web/app/utils/config.js +++ b/ambari-web/app/utils/config.js @@ -682,7 +682,12 @@ App.config = Em.Object.create({ var serviceConfigProperty = App.ServiceConfigProperty.create(_config); this.updateHostOverrides(serviceConfigProperty, _config); if (!storedConfigs && !serviceConfigProperty.get('hasInitialValue')) { - serviceConfigProperty.initialValue(localDB); + var hiveMetastoreUrisDefault; + var hiveMetastoreUrisConfig = serviceConfigs.findProperty('name', 'hive.metastore.uris'); + if (hiveMetastoreUrisConfig) { + hiveMetastoreUrisDefault = hiveMetastoreUrisConfig.defaultValue; + } + serviceConfigProperty.initialValue(localDB, hiveMetastoreUrisDefault); } if (storedConfigs && storedConfigs.filterProperty('name', _config.name).length && !!_config.filename) { var storedConfig = storedConfigs.filterProperty('name', _config.name).findProperty('filename', _config.filename); http://git-wip-us.apache.org/repos/asf/ambari/blob/76b7d3d4/ambari-web/test/models/service_config_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/service_config_test.js b/ambari-web/test/models/service_config_test.js index 64964df..2b9e458 100644 --- a/ambari-web/test/models/service_config_test.js +++ b/ambari-web/test/models/service_config_test.js @@ -776,6 +776,41 @@ describe('App.ServiceConfigProperty', function () { }, value: 'h0,h1', title: 'comma separated list of hosts with Hive Server and Metastore' + }, + 'hive.metastore.uris': { + localDB: { + masterComponentHosts: [ + { + component: 'HIVE_METASTORE', + hostName: 'h0' + }, + { + component: 'HIVE_METASTORE', + hostName: 'h1' + } + ] + }, + defaultValue: 'thrift://localhost:9083', + value: 'thrift://h0:9083,thrift://h1:9083', + title: 'comma separated list of Metastore hosts with thrift prefix and port' + }, + 'templeton.hive.properties': { + localDB: { + masterComponentHosts: [ + { + component: 'HIVE_METASTORE', + hostName: 'h0' + }, + { + component: 'HIVE_METASTORE', + hostName: 'h1' + } + ] + }, + hiveMSUrisDefaultValue: 'thrift://localhost:9083', + defaultValue: 'hive.metastore.local=false,hive.metastore.uris=thrift://localhost:9933,hive.metastore.sasl.enabled=false', + value: 'hive.metastore.local=false,hive.metastore.uris=thrift://h0:9083\\,thrift://h1:9083,hive.metastore.sasl.enabled=false,hive.metastore.execute.setugi=true', + title: 'should add relevant hive.metastore.uris value' } }; @@ -861,5 +896,107 @@ describe('App.ServiceConfigProperty', function () { expect(serviceConfigProperty.get('value')).to.equal(cases['hive_master_hosts'].value); }); + it(cases['hive.metastore.uris'].title, function () { + serviceConfigProperty.setProperties({ + name: 'hive.metastore.uris', + defaultValue: cases['hive.metastore.uris'].defaultValue + }); + serviceConfigProperty.initialValue(cases['hive.metastore.uris'].localDB, cases['hive.metastore.uris'].defaultValue); + expect(serviceConfigProperty.get('value')).to.equal(cases['hive.metastore.uris'].value); + expect(serviceConfigProperty.get('defaultValue')).to.equal(cases['hive.metastore.uris'].value); + }); + + it(cases['templeton.hive.properties'].title, function () { + serviceConfigProperty.setProperties({ + name: 'templeton.hive.properties', + defaultValue: cases['templeton.hive.properties'].defaultValue, + value: cases['templeton.hive.properties'].defaultValue + }); + serviceConfigProperty.initialValue(cases['templeton.hive.properties'].localDB, cases['templeton.hive.properties'].hiveMSUrisDefaultValue); + expect(serviceConfigProperty.get('value')).to.equal(cases['templeton.hive.properties'].value); + expect(serviceConfigProperty.get('defaultValue')).to.equal(cases['templeton.hive.properties'].value); + }); + + }); + + describe('#getHiveMetastoreUris', function () { + + var cases = [ + { + hosts: [ + { + hostName: 'h0', + component: 'HIVE_SERVER' + }, + { + hostName: 'h1', + component: 'HIVE_METASTORE' + }, + { + hostName: 'h2', + component: 'HIVE_METASTORE' + } + ], + defaultValue: 'thrift://localhost:9083', + expected: 'thrift://h1:9083,thrift://h2:9083', + title: 'typical case' + }, + { + hosts: [ + { + hostName: 'h0', + component: 'HIVE_SERVER' + } + ], + defaultValue: 'thrift://localhost:9083', + expected: '', + title: 'no Metastore hosts in DB' + }, + { + hosts: [ + { + hostName: 'h0', + component: 'HIVE_SERVER' + }, + { + hostName: 'h1', + component: 'HIVE_METASTORE' + }, + { + hostName: 'h2', + component: 'HIVE_METASTORE' + } + ], + defaultValue: '', + expected: '', + title: 'default value without port' + }, + { + hosts: [ + { + hostName: 'h0', + component: 'HIVE_SERVER' + }, + { + hostName: 'h1', + component: 'HIVE_METASTORE' + }, + { + hostName: 'h2', + component: 'HIVE_METASTORE' + } + ], + expected: '', + title: 'no default value specified' + } + ]; + + cases.forEach(function (item) { + it(item.title, function () { + expect(serviceConfigProperty.getHiveMetastoreUris(item.hosts, item.defaultValue)).to.equal(item.expected); + }); + }); + }); + });
