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 2015/11/09 11:10:14 UTC
[1/2] ambari git commit: AMBARI-13787. Move config_property_helper to
the App.* namespace (onechiporenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 618d843c1 -> da8ca2ae3
http://git-wip-us.apache.org/repos/asf/ambari/blob/da8ca2ae/ambari-web/test/utils/configs/config_initializer_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/configs/config_initializer_test.js b/ambari-web/test/utils/configs/config_initializer_test.js
new file mode 100644
index 0000000..fe55e69
--- /dev/null
+++ b/ambari-web/test/utils/configs/config_initializer_test.js
@@ -0,0 +1,1271 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+require('models/configs/objects/service_config_property');
+require('utils/configs/config_initializer');
+
+var serviceConfig,
+ group,
+ serviceConfigProperty,
+
+ components = [
+ {
+ name: 'NameNode',
+ master: true
+ },
+ {
+ name: 'SNameNode',
+ master: true
+ },
+ {
+ name: 'JobTracker',
+ master: true
+ },
+ {
+ name: 'HBase Master',
+ master: true
+ },
+ {
+ name: 'Oozie Master',
+ master: true
+ },
+ {
+ name: 'Hive Metastore',
+ master: true
+ },
+ {
+ name: 'WebHCat Server',
+ master: true
+ },
+ {
+ name: 'ZooKeeper Server',
+ master: true
+ },
+ {
+ name: 'Ganglia',
+ master: true
+ },
+ {
+ name: 'DataNode',
+ slave: true
+ },
+ {
+ name: 'TaskTracker',
+ slave: true
+ },
+ {
+ name: 'RegionServer',
+ slave: true
+ }
+ ],
+ masters = components.filterProperty('master'),
+ slaves = components.filterProperty('slave');
+
+describe('App.ConfigInitializer', function () {
+
+ beforeEach(function () {
+ serviceConfigProperty = App.ServiceConfigProperty.create();
+ });
+
+ describe('#setRecommendedValue', function () {
+ it('should change the recommended value', function () {
+ serviceConfigProperty.set('recommendedValue', 'value0');
+ App.ConfigInitializer.setRecommendedValue(serviceConfigProperty, /\d/, '1');
+ expect(serviceConfigProperty.get('recommendedValue')).to.equal('value1');
+ });
+ });
+
+ describe('#initialValue', function () {
+
+ var cases = {
+ 'kafka.ganglia.metrics.host': [
+ {
+ message: 'kafka.ganglia.metrics.host property should have the value of ganglia hostname when ganglia is selected',
+ localDB: {
+ masterComponentHosts: [
+ {
+ component: 'GANGLIA_SERVER',
+ hostName: 'c6401'
+ }
+ ]
+ },
+ expected: 'c6401'
+ },
+ {
+ message: 'kafka.ganglia.metrics.host property should have the value "localhost" when ganglia is not selected',
+ localDB: {
+ masterComponentHosts: [
+ {
+ component: 'NAMENODE',
+ hostName: 'c6401'
+ }
+ ]
+ },
+ expected: 'localhost'
+ }
+ ],
+ 'hive_database': [
+ {
+ alwaysEnableManagedMySQLForHive: true,
+ currentStateName: '',
+ isManagedMySQLForHiveEnabled: false,
+ receivedValue: 'New MySQL Database',
+ value: 'New MySQL Database',
+ options: [
+ {
+ displayName: 'New MySQL Database'
+ }
+ ],
+ hidden: false
+ },
+ {
+ alwaysEnableManagedMySQLForHive: false,
+ currentStateName: 'configs',
+ isManagedMySQLForHiveEnabled: false,
+ receivedValue: 'New MySQL Database',
+ value: 'New MySQL Database',
+ options: [
+ {
+ displayName: 'New MySQL Database'
+ }
+ ],
+ hidden: false
+ },
+ {
+ alwaysEnableManagedMySQLForHive: false,
+ currentStateName: '',
+ isManagedMySQLForHiveEnabled: true,
+ receivedValue: 'New MySQL Database',
+ value: 'New MySQL Database',
+ options: [
+ {
+ displayName: 'New MySQL Database'
+ }
+ ],
+ hidden: false
+ },
+ {
+ alwaysEnableManagedMySQLForHive: false,
+ currentStateName: '',
+ isManagedMySQLForHiveEnabled: false,
+ receivedValue: 'New MySQL Database',
+ value: 'Existing MySQL Database',
+ options: [
+ {
+ displayName: 'New MySQL Database'
+ }
+ ],
+ hidden: true
+ },
+ {
+ alwaysEnableManagedMySQLForHive: false,
+ currentStateName: '',
+ isManagedMySQLForHiveEnabled: false,
+ receivedValue: 'New PostgreSQL Database',
+ value: 'New PostgreSQL Database',
+ options: [
+ {
+ displayName: 'New MySQL Database'
+ }
+ ],
+ hidden: true
+ }
+ ],
+ 'hbase.zookeeper.quorum': [
+ {
+ filename: 'hbase-site.xml',
+ value: 'host0,host1',
+ recommendedValue: 'host0,host1',
+ title: 'should set ZooKeeper Server hostnames'
+ },
+ {
+ filename: 'ams-hbase-site.xml',
+ value: 'localhost',
+ recommendedValue: null,
+ title: 'should ignore ZooKeeper Server hostnames'
+ }
+ ],
+ 'hivemetastore_host': {
+ localDB: {
+ masterComponentHosts: [
+ {
+ component: 'HIVE_METASTORE',
+ hostName: 'h0'
+ },
+ {
+ component: 'HIVE_METASTORE',
+ hostName: 'h1'
+ }
+ ]
+ },
+ value: ['h0', 'h1'],
+ title: 'array that contains names of hosts with Hive Metastore'
+ },
+ 'hive_master_hosts': {
+ localDB: {
+ masterComponentHosts: [
+ {
+ component: 'HIVE_SERVER',
+ hostName: 'h0'
+ },
+ {
+ component: 'HIVE_METASTORE',
+ hostName: 'h0'
+ },
+ {
+ component: 'HIVE_METASTORE',
+ hostName: 'h1'
+ },
+ {
+ component: 'WEBHCAT_SERVER',
+ hostName: 'h2'
+ }
+ ]
+ },
+ 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'
+ }
+ ]
+ },
+ dependencies: {
+ 'hive.metastore.uris': 'thrift://localhost:9083'
+ },
+ recommendedValue: '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'
+ }
+ ]
+ },
+ dependencies: {
+ 'hive.metastore.uris': 'thrift://localhost:9083'
+ },
+ recommendedValue: 'hive.metastore.local=false,hive.metastore.uris=thrift://localhost:9083,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'
+ },
+ 'yarn.resourcemanager.zk-address': {
+ localDB: {
+ masterComponentHosts: [
+ {
+ component: 'ZOOKEEPER_SERVER',
+ hostName: 'h0'
+ },
+ {
+ component: 'ZOOKEEPER_SERVER',
+ hostName: 'h1'
+ }
+ ]
+ },
+ dependencies: {
+ clientPort: '2182'
+ },
+ recommendedValue: 'localhost:2181',
+ value: 'h0:2182,h1:2182',
+ title: 'should add ZK host and port dynamically'
+ },
+ 'oozie_hostname': {
+ localDB: {
+ masterComponentHosts: [
+ {
+ component: 'OOZIE_SERVER',
+ hostName: 'h0'
+ },
+ {
+ component: 'OOZIE_SERVER',
+ hostName: 'h1'
+ }
+ ]
+ },
+ value: ['h0', 'h1'],
+ title: 'array that contains names of hosts with Oozie Server'
+ },
+ 'knox_gateway_host': {
+ localDB: {
+ masterComponentHosts: [
+ {
+ component: 'KNOX_GATEWAY',
+ hostName: 'h0'
+ },
+ {
+ component: 'KNOX_GATEWAY',
+ hostName: 'h1'
+ }
+ ]
+ },
+ value: ['h0', 'h1'],
+ title: 'array that contains names of hosts with Knox Gateway'
+ }
+ };
+
+ cases['kafka.ganglia.metrics.host'].forEach(function (item) {
+ it(item.message, function () {
+ serviceConfigProperty.setProperties({
+ name: 'kafka.ganglia.metrics.host',
+ value: 'localhost'
+ });
+ App.ConfigInitializer.initialValue(serviceConfigProperty, item.localDB, []);
+ expect(serviceConfigProperty.get('value')).to.equal(item.expected);
+ });
+ });
+
+ cases['hive_database'].forEach(function (item) {
+ var title = 'hive_database value should be set to {0}';
+ it(title.format(item.value), function () {
+ sinon.stub(App, 'get')
+ .withArgs('supports.alwaysEnableManagedMySQLForHive').returns(item.alwaysEnableManagedMySQLForHive)
+ .withArgs('router.currentState.name').returns(item.currentStateName)
+ .withArgs('isManagedMySQLForHiveEnabled').returns(item.isManagedMySQLForHiveEnabled);
+ serviceConfigProperty.setProperties({
+ name: 'hive_database',
+ value: item.receivedValue,
+ options: item.options
+ });
+ App.ConfigInitializer.initialValue(serviceConfigProperty, {}, []);
+ expect(serviceConfigProperty.get('value')).to.equal(item.value);
+ expect(serviceConfigProperty.get('options').findProperty('displayName', 'New MySQL Database').hidden).to.equal(item.hidden);
+ App.get.restore();
+ });
+ });
+
+ cases['hbase.zookeeper.quorum'].forEach(function (item) {
+ it(item.title, function () {
+ serviceConfigProperty.setProperties({
+ name: 'hbase.zookeeper.quorum',
+ value: 'localhost',
+ 'filename': item.filename
+ });
+ App.ConfigInitializer.initialValue(serviceConfigProperty, {
+ masterComponentHosts: {
+ filterProperty: function () {
+ return {
+ mapProperty: function () {
+ return ['host0', 'host1'];
+ }
+ };
+ }
+ }
+ }, []);
+ expect(serviceConfigProperty.get('value')).to.equal(item.value);
+ expect(serviceConfigProperty.get('recommendedValue')).to.equal(item.recommendedValue);
+ });
+ });
+
+ it(cases['hive_master_hosts'].title, function () {
+ serviceConfigProperty.set('name', 'hive_master_hosts');
+ App.ConfigInitializer.initialValue(serviceConfigProperty, cases['hive_master_hosts'].localDB, []);
+ expect(serviceConfigProperty.get('value')).to.equal(cases['hive_master_hosts'].value);
+ });
+
+ it(cases['hive.metastore.uris'].title, function () {
+ serviceConfigProperty.setProperties({
+ name: 'hive.metastore.uris',
+ recommendedValue: cases['hive.metastore.uris'].recommendedValue
+ });
+ App.ConfigInitializer.initialValue(serviceConfigProperty, cases['hive.metastore.uris'].localDB, {'hive.metastore.uris': cases['hive.metastore.uris'].recommendedValue});
+ expect(serviceConfigProperty.get('value')).to.equal(cases['hive.metastore.uris'].value);
+ expect(serviceConfigProperty.get('recommendedValue')).to.equal(cases['hive.metastore.uris'].value);
+ });
+
+ it(cases['templeton.hive.properties'].title, function () {
+ serviceConfigProperty.setProperties({
+ name: 'templeton.hive.properties',
+ recommendedValue: cases['templeton.hive.properties'].recommendedValue,
+ value: cases['templeton.hive.properties'].recommendedValue
+ });
+ App.ConfigInitializer.initialValue(serviceConfigProperty, cases['templeton.hive.properties'].localDB, {'hive.metastore.uris': cases['templeton.hive.properties'].recommendedValue});
+ expect(serviceConfigProperty.get('value')).to.equal(cases['templeton.hive.properties'].value);
+ expect(serviceConfigProperty.get('recommendedValue')).to.equal(cases['templeton.hive.properties'].value);
+ });
+
+ it(cases['yarn.resourcemanager.zk-address'].title, function () {
+ serviceConfigProperty.setProperties({
+ name: 'yarn.resourcemanager.zk-address',
+ recommendedValue: cases['yarn.resourcemanager.zk-address'].recommendedValue
+ });
+ App.ConfigInitializer.initialValue(serviceConfigProperty, cases['yarn.resourcemanager.zk-address'].localDB, cases['yarn.resourcemanager.zk-address'].dependencies);
+ expect(serviceConfigProperty.get('value')).to.equal(cases['yarn.resourcemanager.zk-address'].value);
+ expect(serviceConfigProperty.get('recommendedValue')).to.equal(cases['yarn.resourcemanager.zk-address'].value);
+ });
+
+ function getLocalDBForSingleComponent(component) {
+ return {
+ masterComponentHosts: [
+ {
+ component: component,
+ hostName: 'h1'
+ },
+ {
+ component: 'FAKE_COMPONENT',
+ hostName: 'FAKE_HOST'
+ }
+ ]
+ };
+ }
+
+ function getLocalDBForMultipleComponents(component, count) {
+ var ret = {
+ masterComponentHosts: [{
+ component: 'FAKE_COMPONENT',
+ hostName: 'FAKE_HOST'
+ }]
+ };
+ for (var i = 1; i <= count; i++) {
+ ret.masterComponentHosts.push({
+ component: component,
+ hostName: 'h' + i
+ })
+ }
+ return ret;
+ }
+
+ Em.A([
+ {
+ config: 'dfs.namenode.rpc-address',
+ localDB: getLocalDBForSingleComponent('NAMENODE'),
+ rValue: 'c6401.ambari.apache.org:8020',
+ expectedValue: 'h1:8020'
+ },
+ {
+ config: 'dfs.http.address',
+ localDB: getLocalDBForSingleComponent('NAMENODE'),
+ rValue: 'c6401.ambari.apache.org:8020',
+ expectedValue: 'h1:8020'
+ },
+ {
+ config: 'dfs.namenode.http-address',
+ localDB: getLocalDBForSingleComponent('NAMENODE'),
+ rValue: 'c6401.ambari.apache.org:8020',
+ expectedValue: 'h1:8020'
+ },
+ {
+ config: 'dfs.https.address',
+ localDB: getLocalDBForSingleComponent('NAMENODE'),
+ rValue: 'c6401.ambari.apache.org:8020',
+ expectedValue: 'h1:8020'
+ },
+ {
+ config: 'dfs.namenode.https-address',
+ localDB: getLocalDBForSingleComponent('NAMENODE'),
+ rValue: 'c6401.ambari.apache.org:8020',
+ expectedValue: 'h1:8020'
+ },
+ {
+ config: 'fs.default.name',
+ localDB: getLocalDBForSingleComponent('NAMENODE'),
+ rValue: 'hdfs://c6401.ambari.apache.org:8020',
+ expectedValue: 'hdfs://h1:8020'
+ },
+ {
+ config: 'fs.defaultFS',
+ localDB: getLocalDBForSingleComponent('NAMENODE'),
+ rValue: 'hdfs://c6401.ambari.apache.org:8020',
+ expectedValue: 'hdfs://h1:8020'
+ },
+ {
+ config: 'hbase.rootdir',
+ localDB: getLocalDBForSingleComponent('NAMENODE'),
+ rValue: 'hdfs://c6401.ambari.apache.org:8020',
+ expectedValue: 'hdfs://h1:8020'
+ },
+ {
+ config: 'instance.volumes',
+ localDB: getLocalDBForSingleComponent('NAMENODE'),
+ rValue: 'hdfs://c6401.ambari.apache.org:8020',
+ expectedValue: 'hdfs://h1:8020'
+ },
+ {
+ config: 'dfs.secondary.http.address',
+ localDB: getLocalDBForSingleComponent('SECONDARY_NAMENODE'),
+ rValue: 'c6401.ambari.apache.org:50090',
+ expectedValue: 'h1:50090'
+ },
+ {
+ config: 'dfs.namenode.secondary.http-address',
+ localDB: getLocalDBForSingleComponent('SECONDARY_NAMENODE'),
+ rValue: 'c6401.ambari.apache.org:50090',
+ expectedValue: 'h1:50090'
+ },
+ {
+ config: 'yarn.log.server.url',
+ localDB: getLocalDBForSingleComponent('HISTORYSERVER'),
+ rValue: 'http://localhost:19888/jobhistory/logs',
+ expectedValue: 'http://h1:19888/jobhistory/logs'
+ },
+ {
+ config: 'mapreduce.jobhistory.webapp.address',
+ localDB: getLocalDBForSingleComponent('HISTORYSERVER'),
+ rValue: 'c6407.ambari.apache.org:19888',
+ expectedValue: 'h1:19888'
+ },
+ {
+ config: 'mapreduce.jobhistory.address',
+ localDB: getLocalDBForSingleComponent('HISTORYSERVER'),
+ rValue: 'c6407.ambari.apache.org:19888',
+ expectedValue: 'h1:19888'
+ },
+ {
+ config: 'yarn.resourcemanager.hostname',
+ localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
+ rValue: 'c6407.ambari.apache.org',
+ expectedValue: 'h1'
+ },
+ {
+ config: 'yarn.resourcemanager.resource-tracker.address',
+ localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
+ rValue: 'c6407.ambari.apache.org:123',
+ expectedValue: 'h1:123'
+ },
+ {
+ config: 'yarn.resourcemanager.webapp.https.address',
+ localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
+ rValue: 'c6407.ambari.apache.org:123',
+ expectedValue: 'h1:123'
+ },
+ {
+ config: 'yarn.resourcemanager.webapp.address',
+ localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
+ rValue: 'c6407.ambari.apache.org:123',
+ expectedValue: 'h1:123'
+ },
+ {
+ config: 'yarn.resourcemanager.scheduler.address',
+ localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
+ rValue: 'c6407.ambari.apache.org:123',
+ expectedValue: 'h1:123'
+ },
+ {
+ config: 'yarn.resourcemanager.address',
+ localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
+ rValue: 'c6407.ambari.apache.org:123',
+ expectedValue: 'h1:123'
+ },
+ {
+ config: 'yarn.resourcemanager.admin.address',
+ localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
+ rValue: 'c6407.ambari.apache.org:123',
+ expectedValue: 'h1:123'
+ },
+ {
+ config: 'yarn.timeline-service.webapp.address',
+ localDB: getLocalDBForSingleComponent('APP_TIMELINE_SERVER'),
+ rValue: 'c6407.ambari.apache.org:432',
+ expectedValue: 'h1:432'
+ },
+ {
+ config: 'yarn.timeline-service.address',
+ localDB: getLocalDBForSingleComponent('APP_TIMELINE_SERVER'),
+ rValue: 'c6407.ambari.apache.org:432',
+ expectedValue: 'h1:432'
+ },
+ {
+ config: 'yarn.timeline-service.webapp.https.address',
+ localDB: getLocalDBForSingleComponent('APP_TIMELINE_SERVER'),
+ rValue: 'c6407.ambari.apache.org:432',
+ expectedValue: 'h1:432'
+ },
+ {
+ config: 'mapred.job.tracker',
+ localDB: getLocalDBForSingleComponent('JOBTRACKER'),
+ rValue: 'c6407.ambari.apache.org:111',
+ expectedValue: 'h1:111'
+ },
+ {
+ config: 'mapred.job.tracker.http.address',
+ localDB: getLocalDBForSingleComponent('JOBTRACKER'),
+ rValue: 'c6407.ambari.apache.org:111',
+ expectedValue: 'h1:111'
+ },
+ {
+ config: 'mapreduce.history.server.http.address',
+ localDB: getLocalDBForSingleComponent('HISTORYSERVER'),
+ rValue: 'c6407.ambari.apache.org:555',
+ expectedValue: 'h1:555'
+ },
+ {
+ config: 'hive_hostname',
+ localDB: getLocalDBForSingleComponent('HIVE_SERVER'),
+ rValue: 'c6407.ambari.apache.org',
+ expectedValue: 'h1'
+ },
+ {
+ config: 'oozie_hostname',
+ localDB: getLocalDBForSingleComponent('OOZIE_SERVER'),
+ rValue: 'c6407.ambari.apache.org',
+ expectedValue: 'h1'
+ },
+ {
+ config: 'oozie.base.url',
+ localDB: getLocalDBForSingleComponent('OOZIE_SERVER'),
+ rValue: 'http://localhost:11000/oozie',
+ expectedValue: 'http://h1:11000/oozie'
+ },
+ {
+ config: 'nimbus.host',
+ localDB: getLocalDBForSingleComponent('NIMBUS'),
+ rValue: 'localhost',
+ expectedValue: 'h1'
+ },
+ {
+ config: '*.broker.url',
+ localDB: getLocalDBForSingleComponent('FALCON_SERVER'),
+ rValue: 'tcp://localhost:61616',
+ expectedValue: 'tcp://h1:61616'
+ },
+ {
+ config: 'storm.zookeeper.servers',
+ localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
+ rValue: "['c6401.ambari.apache.org','c6402.ambari.apache.org']",
+ expectedValue: ['h1', 'h2', 'h3']
+ },
+ {
+ config: 'nimbus.seeds',
+ localDB: getLocalDBForMultipleComponents('NIMBUS', 3),
+ rValue: "['c6401.ambari.apache.org','c6402.ambari.apache.org']",
+ expectedValue: ['h1', 'h2', 'h3']
+ },
+ {
+ config: 'hawq_master_address_host',
+ localDB: getLocalDBForSingleComponent('HAWQMASTER'),
+ rValue: 'localhost',
+ expectedValue: 'h1'
+ },
+ {
+ config: 'hawq_standby_address_host',
+ localDB: getLocalDBForSingleComponent('HAWQSTANDBY'),
+ rValue: 'localhost',
+ expectedValue: 'h1'
+ },
+ {
+ config: 'hawq_dfs_url',
+ localDB: getLocalDBForSingleComponent('NAMENODE'),
+ rValue: 'localhost:8020/hawq_default',
+ expectedValue: 'h1:8020/hawq_default'
+ },
+ {
+ config: 'hawq_rm_yarn_address',
+ localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
+ rValue: 'localhost:8032',
+ expectedValue: 'h1:8032'
+ },
+ {
+ config: 'hawq_rm_yarn_scheduler_address',
+ localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
+ rValue: 'localhost:8030',
+ expectedValue: 'h1:8030'
+ },
+ {
+ config: 'hadoop_host',
+ localDB: getLocalDBForSingleComponent('NAMENODE'),
+ rValue: 'localhost',
+ expectedValue: 'h1'
+ },
+ {
+ config: 'hive_master_hosts',
+ localDB: getLocalDBForMultipleComponents('HIVE_METASTORE', 3),
+ rValue: '',
+ expectedValue: 'h1,h2,h3'
+ },
+ {
+ config: 'hive_master_hosts',
+ localDB: getLocalDBForMultipleComponents('HIVE_SERVER', 3),
+ rValue: '',
+ expectedValue: 'h1,h2,h3'
+ },
+ {
+ config: 'zookeeper.connect',
+ localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
+ rValue: 'localhost:2181',
+ expectedValue: 'h1:2181,h2:2181,h3:2181'
+ },
+ {
+ config: 'hive.zookeeper.quorum',
+ localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
+ rValue: 'localhost:2181',
+ expectedValue: 'h1:2181,h2:2181,h3:2181'
+ },
+ {
+ config: 'templeton.zookeeper.hosts',
+ localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
+ rValue: 'localhost:2181',
+ expectedValue: 'h1:2181,h2:2181,h3:2181'
+ },
+ {
+ config: 'hadoop.registry.zk.quorum',
+ localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
+ rValue: 'localhost:2181',
+ expectedValue: 'h1:2181,h2:2181,h3:2181'
+ },
+ {
+ config: 'hive.cluster.delegation.token.store.zookeeper.connectString',
+ localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
+ rValue: 'localhost:2181',
+ expectedValue: 'h1:2181,h2:2181,h3:2181'
+ },
+ {
+ config: 'instance.zookeeper.host',
+ localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
+ rValue: 'localhost:2181',
+ expectedValue: 'h1:2181,h2:2181,h3:2181'
+ },
+ {
+ config: 'templeton.hive.properties',
+ localDB: getLocalDBForMultipleComponents('HIVE_METASTORE', 2),
+ rValue: 'hive.metastore.local=false,hive.metastore.uris=thrift://localhost:9933,hive.metastore.sasl.enabled=false',
+ dependencies: {
+ 'hive.metastore.uris': 'thrift://localhost:9083'
+ },
+ expectedValue: 'hive.metastore.local=false,hive.metastore.uris=thrift://h1:9083\\,thrift://h2:9083,hive.metastore.sasl.enabled=false'
+ },
+ {
+ config: 'hbase.zookeeper.quorum',
+ m: 'hbase.zookeeper.quorum hbase-site.xml',
+ localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
+ rValue: 'c6401.ambari.apache.org,c6402.ambari.apache.org',
+ expectedValue: 'h1,h2,h3',
+ filename: 'hbase-site.xml'
+ },
+ {
+ config: 'hbase.zookeeper.quorum',
+ m: 'hbase.zookeeper.quorum not-hbase-site.xml',
+ localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
+ rValue: 'localhost',
+ expectedValue: '',
+ expectedRValue: 'localhost',
+ filename: 'not-hbase-site.xml'
+ },
+ {
+ config: 'yarn.resourcemanager.zk-address',
+ localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
+ rValue: 'localhost:2181',
+ dependencies: {
+ 'clientPort': '3333'
+ },
+ expectedValue: 'h1:3333,h2:3333,h3:3333'
+ },
+ {
+ config: 'RANGER_HOST',
+ localDB: getLocalDBForSingleComponent('RANGER_ADMIN'),
+ rValue: 'locahost',
+ expectedValue: 'h1'
+ },
+ {
+ config: 'hive.metastore.uris',
+ localDB: getLocalDBForMultipleComponents('HIVE_METASTORE', 2),
+ dependencies: {
+ 'hive.metastore.uris': 'thrift://localhost:9083'
+ },
+ rValue: 'thrift://localhost:9083',
+ expectedValue: 'thrift://h1:9083,thrift://h2:9083'
+ }
+ ]).forEach(function (test) {
+ it(test.m || test.config, function () {
+ serviceConfigProperty.setProperties({
+ name: test.config,
+ recommendedValue: test.rValue,
+ filename: test.filename
+ });
+ App.ConfigInitializer.initialValue(serviceConfigProperty, test.localDB, test.dependencies);
+ expect(serviceConfigProperty.get('value')).to.eql(test.expectedValue);
+ if (Em.isNone(test.expectedRValue)) {
+ expect(serviceConfigProperty.get('recommendedValue')).to.eql(test.expectedValue);
+ }
+ else {
+ expect(serviceConfigProperty.get('recommendedValue')).to.eql(test.expectedRValue);
+ }
+
+ });
+ });
+
+ });
+
+ describe('#getHiveMetastoreUris', function () {
+
+ var cases = [
+ {
+ hosts: [
+ {
+ hostName: 'h0',
+ component: 'HIVE_SERVER'
+ },
+ {
+ hostName: 'h1',
+ component: 'HIVE_METASTORE'
+ },
+ {
+ hostName: 'h2',
+ component: 'HIVE_METASTORE'
+ }
+ ],
+ recommendedValue: 'thrift://localhost:9083',
+ expected: 'thrift://h1:9083,thrift://h2:9083',
+ title: 'typical case'
+ },
+ {
+ hosts: [
+ {
+ hostName: 'h0',
+ component: 'HIVE_SERVER'
+ }
+ ],
+ recommendedValue: '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'
+ }
+ ],
+ recommendedValue: '',
+ 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(App.ConfigInitializer.getHiveMetastoreUris(item.hosts, item.recommendedValue)).to.equal(item.expected);
+ });
+ });
+
+ });
+
+ describe('config with mount points', function () {
+
+ var localDB = {
+ masterComponentHosts: [
+ {
+ component: 'NAMENODE',
+ hostName: 'h0'
+ },
+ {
+ component: 'SECONDARY_NAMENODE',
+ hostName: 'h4'
+ },
+ {
+ component: 'APP_TIMELINE_SERVER',
+ hostName: 'h0'
+ },
+ {
+ component: 'ZOOKEEPER_SERVER',
+ hostName: 'h0'
+ },
+ {
+ component: 'ZOOKEEPER_SERVER',
+ hostName: 'h1'
+ },
+ {
+ component: 'OOZIE_SERVER',
+ hostName: 'h0'
+ },
+ {
+ component: 'OOZIE_SERVER',
+ hostName: 'h1'
+ },
+ {
+ component: 'NIMBUS',
+ hostName: 'h2'
+ },
+ {
+ component: 'FALCON_SERVER',
+ hostName: 'h3'
+ },
+ {
+ component: 'KAFKA_BROKER',
+ hostName: 'h0'
+ },
+ {
+ component: 'KAFKA_BROKER',
+ hostName: 'h1'
+ }
+ ],
+ slaveComponentHosts: [
+ {
+ componentName: 'DATANODE',
+ hosts: [
+ {
+ hostName: 'h0'
+ },
+ {
+ hostName: 'h1'
+ }
+ ]
+ },
+ {
+ componentName: 'TASKTRACKER',
+ hosts: [
+ {
+ hostName: 'h0'
+ },
+ {
+ hostName: 'h1'
+ }
+ ]
+ },
+ {
+ componentName: 'NODEMANAGER',
+ hosts: [
+ {
+ hostName: 'h0'
+ },
+ {
+ hostName: 'h1'
+ },
+ {
+ hostName: 'h4'
+ }
+ ]
+ },
+ {
+ componentName: 'HBASE_REGIONSERVER',
+ hosts: [
+ {
+ hostName: 'h0'
+ },
+ {
+ hostName: 'h1'
+ }
+ ]
+ },
+ {
+ componentName: 'SUPERVISOR',
+ hosts: [
+ {
+ hostName: 'h0'
+ },
+ {
+ hostName: 'h1'
+ }
+ ]
+ }
+ ],
+ hosts: {
+ h0: {
+ disk_info: [
+ {
+ mountpoint: '/'
+ },
+ {
+ mountpoint: '/home'
+ },
+ {
+ mountpoint: '/boot'
+ },
+ {
+ mountpoint: '/boot/efi'
+ },
+ {
+ mountpoint: '/mnt'
+ },
+ {
+ mountpoint: '/mnt/efi'
+ },
+ {
+ mountpoint: '/media/disk0',
+ available: '100000000'
+ },
+ {
+ mountpoint: '/mount0',
+ available: '100000000'
+ }
+ ]
+ },
+ h4: {
+ disk_info: [
+ {
+ mountpoint: 'c:',
+ available: '100000000'
+ }
+ ]
+ }
+ }
+ },
+ cases = [
+ {
+ name: 'dfs.namenode.name.dir',
+ isOnlyFirstOneNeeded: false,
+ value: '/media/disk0/default\n/mount0/default\n'
+ },
+ {
+ name: 'dfs.name.dir',
+ isOnlyFirstOneNeeded: false,
+ value: '/media/disk0/default\n/mount0/default\n'
+ },
+ {
+ name: 'fs.checkpoint.dir',
+ isOnlyFirstOneNeeded: true,
+ value: 'file:///c:/default\n'
+ },
+ {
+ name: 'dfs.namenode.checkpoint.dir',
+ isOnlyFirstOneNeeded: true,
+ value: 'file:///c:/default\n'
+ },
+ {
+ name: 'dfs.data.dir',
+ isOnlyFirstOneNeeded: false,
+ value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\n'
+ },
+ {
+ name: 'dfs.datanode.data.dir',
+ isOnlyFirstOneNeeded: false,
+ value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\n'
+ },
+ {
+ name: 'mapred.local.dir',
+ isOnlyFirstOneNeeded: false,
+ value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\n'
+ },
+ {
+ name: 'yarn.nodemanager.log-dirs',
+ isOnlyFirstOneNeeded: false,
+ value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\nc:\\default\n'
+ },
+ {
+ name: 'yarn.nodemanager.local-dirs',
+ isOnlyFirstOneNeeded: false,
+ value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\nc:\\default\n'
+ },
+ {
+ name: 'yarn.timeline-service.leveldb-timeline-store.path',
+ isOnlyFirstOneNeeded: true,
+ value: '/media/disk0/default'
+ },
+ {
+ name: 'yarn.timeline-service.leveldb-state-store.path',
+ isOnlyFirstOneNeeded: true,
+ value: '/media/disk0/default'
+ },
+ {
+ name: 'dataDir',
+ isOnlyFirstOneNeeded: true,
+ value: '/media/disk0/default'
+ },
+ {
+ name: 'oozie_data_dir',
+ isOnlyFirstOneNeeded: true,
+ value: '/media/disk0/default'
+ },
+ {
+ name: 'storm.local.dir',
+ isOnlyFirstOneNeeded: true,
+ value: '/media/disk0/default'
+ },
+ {
+ name: '*.falcon.graph.storage.directory',
+ isOnlyFirstOneNeeded: true,
+ value: '/default'
+ },
+ {
+ name: '*.falcon.graph.serialize.path',
+ isOnlyFirstOneNeeded: true,
+ value: '/default'
+ },
+ {
+ name: 'log.dirs',
+ isOnlyFirstOneNeeded: false,
+ value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\n'
+ }
+ ];
+
+ beforeEach(function () {
+ sinon.stub(App.Host, 'find').returns([
+ Em.Object.create({
+ id: 'h1',
+ diskInfo: [
+ {
+ mountpoint: '/media/disk1',
+ type: 'devtmpfs'
+ },
+ {
+ mountpoint: '/media/disk1',
+ type: 'tmpfs'
+ },
+ {
+ mountpoint: '/media/disk1',
+ type: 'vboxsf'
+ },
+ {
+ mountpoint: '/media/disk1',
+ type: 'CDFS'
+ },
+ {
+ mountpoint: '/media/disk1',
+ available: '0'
+ },
+ {
+ mountpoint: '/media/disk1',
+ available: '100000000'
+ },
+ {
+ mountpoint: '/mount1',
+ available: '100000000'
+ }
+ ]
+ }),
+ Em.Object.create({
+ id: 'h2',
+ diskInfo: [
+ {
+ mountpoint: '/'
+ }
+ ]
+ }),
+ Em.Object.create({
+ id: 'h3',
+ diskInfo: []
+ })
+ ]);
+ });
+
+ afterEach(function () {
+ App.Host.find.restore();
+ });
+
+ cases.forEach(function (item) {
+ it(item.name, function () {
+ serviceConfigProperty.setProperties({
+ name: item.name,
+ recommendedValue: '/default'
+ });
+ App.ConfigInitializer.initialValue(serviceConfigProperty, localDB, {});
+ expect(serviceConfigProperty.get('value')).to.equal(item.value);
+ expect(serviceConfigProperty.get('recommendedValue')).to.equal(item.value);
+ });
+ });
+
+ });
+
+ describe('initializerTypes', function () {
+ var types = App.ConfigInitializer.__testGetInitializerTypes();
+ Em.keys(types).forEach(function(type) {
+ it(type, function() {
+ var methodName = types[type].method;
+ expect(methodName).to.be.a.string;
+ expect(methodName).to.have.length.above(0);
+ expect(App.ConfigInitializer[methodName]).to.be.a.function;
+ });
+ });
+ });
+
+ describe('initializers', function () {
+
+ var initializers = App.ConfigInitializer.__testGetInitializers();
+ var types = App.ConfigInitializer.__testGetInitializerTypes();
+ var typeNames = Em.keys(types);
+
+ Em.keys(initializers).forEach(function (configName) {
+ it(configName, function () {
+ var type = initializers[configName].type;
+ expect(typeNames).to.contain(type);
+ });
+ });
+
+ });
+
+ describe('uniqueInitializers', function () {
+
+ var uniqueInitializers = App.ConfigInitializer.__testGetUniqueInitializers();
+ var uniqueInitializersNames = Em.keys(uniqueInitializers).map(function (key) {
+ return uniqueInitializers[key];
+ });
+
+ it('should contains only unique methods', function () {
+ expect(uniqueInitializersNames.length).to.equal(uniqueInitializersNames.uniq().length);
+ });
+
+ uniqueInitializersNames.forEach(function (name) {
+ it(name, function () {
+ expect(App.ConfigInitializer[name]).to.be.a.function;
+ });
+ });
+
+ });
+
+ describe('winReplacersMap', function () {
+
+ var winReplacersMap = App.ConfigInitializer.__testGetWinReplacersMap();
+ var winReplacerNames = Em.keys(winReplacersMap).map(function (key) {
+ return winReplacersMap[key];
+ });
+
+ it('should contains only unique methods', function () {
+ expect(winReplacerNames.length).to.equal(winReplacerNames.uniq().length);
+ });
+
+ winReplacerNames.forEach(function (name) {
+ it(name, function () {
+ expect(App.ConfigInitializer[name]).to.be.a.function;
+ });
+ });
+
+ });
+
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/da8ca2ae/ambari-web/test/utils/configs/config_property_helper_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/configs/config_property_helper_test.js b/ambari-web/test/utils/configs/config_property_helper_test.js
deleted file mode 100644
index 84ebb25..0000000
--- a/ambari-web/test/utils/configs/config_property_helper_test.js
+++ /dev/null
@@ -1,1271 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var App = require('app');
-var configPropertyHelper = require('utils/configs/config_property_helper');
-
-require('models/configs/objects/service_config_property');
-
-var serviceConfig,
- group,
- serviceConfigProperty,
-
- components = [
- {
- name: 'NameNode',
- master: true
- },
- {
- name: 'SNameNode',
- master: true
- },
- {
- name: 'JobTracker',
- master: true
- },
- {
- name: 'HBase Master',
- master: true
- },
- {
- name: 'Oozie Master',
- master: true
- },
- {
- name: 'Hive Metastore',
- master: true
- },
- {
- name: 'WebHCat Server',
- master: true
- },
- {
- name: 'ZooKeeper Server',
- master: true
- },
- {
- name: 'Ganglia',
- master: true
- },
- {
- name: 'DataNode',
- slave: true
- },
- {
- name: 'TaskTracker',
- slave: true
- },
- {
- name: 'RegionServer',
- slave: true
- }
- ],
- masters = components.filterProperty('master'),
- slaves = components.filterProperty('slave');
-
-describe('configPropertyHelper', function () {
-
- beforeEach(function () {
- serviceConfigProperty = App.ServiceConfigProperty.create();
- });
-
- describe('#setRecommendedValue', function () {
- it('should change the recommended value', function () {
- serviceConfigProperty.set('recommendedValue', 'value0');
- configPropertyHelper.setRecommendedValue(serviceConfigProperty, /\d/, '1');
- expect(serviceConfigProperty.get('recommendedValue')).to.equal('value1');
- });
- });
-
- describe('#initialValue', function () {
-
- var cases = {
- 'kafka.ganglia.metrics.host': [
- {
- message: 'kafka.ganglia.metrics.host property should have the value of ganglia hostname when ganglia is selected',
- localDB: {
- masterComponentHosts: [
- {
- component: 'GANGLIA_SERVER',
- hostName: 'c6401'
- }
- ]
- },
- expected: 'c6401'
- },
- {
- message: 'kafka.ganglia.metrics.host property should have the value "localhost" when ganglia is not selected',
- localDB: {
- masterComponentHosts: [
- {
- component: 'NAMENODE',
- hostName: 'c6401'
- }
- ]
- },
- expected: 'localhost'
- }
- ],
- 'hive_database': [
- {
- alwaysEnableManagedMySQLForHive: true,
- currentStateName: '',
- isManagedMySQLForHiveEnabled: false,
- receivedValue: 'New MySQL Database',
- value: 'New MySQL Database',
- options: [
- {
- displayName: 'New MySQL Database'
- }
- ],
- hidden: false
- },
- {
- alwaysEnableManagedMySQLForHive: false,
- currentStateName: 'configs',
- isManagedMySQLForHiveEnabled: false,
- receivedValue: 'New MySQL Database',
- value: 'New MySQL Database',
- options: [
- {
- displayName: 'New MySQL Database'
- }
- ],
- hidden: false
- },
- {
- alwaysEnableManagedMySQLForHive: false,
- currentStateName: '',
- isManagedMySQLForHiveEnabled: true,
- receivedValue: 'New MySQL Database',
- value: 'New MySQL Database',
- options: [
- {
- displayName: 'New MySQL Database'
- }
- ],
- hidden: false
- },
- {
- alwaysEnableManagedMySQLForHive: false,
- currentStateName: '',
- isManagedMySQLForHiveEnabled: false,
- receivedValue: 'New MySQL Database',
- value: 'Existing MySQL Database',
- options: [
- {
- displayName: 'New MySQL Database'
- }
- ],
- hidden: true
- },
- {
- alwaysEnableManagedMySQLForHive: false,
- currentStateName: '',
- isManagedMySQLForHiveEnabled: false,
- receivedValue: 'New PostgreSQL Database',
- value: 'New PostgreSQL Database',
- options: [
- {
- displayName: 'New MySQL Database'
- }
- ],
- hidden: true
- }
- ],
- 'hbase.zookeeper.quorum': [
- {
- filename: 'hbase-site.xml',
- value: 'host0,host1',
- recommendedValue: 'host0,host1',
- title: 'should set ZooKeeper Server hostnames'
- },
- {
- filename: 'ams-hbase-site.xml',
- value: 'localhost',
- recommendedValue: null,
- title: 'should ignore ZooKeeper Server hostnames'
- }
- ],
- 'hivemetastore_host': {
- localDB: {
- masterComponentHosts: [
- {
- component: 'HIVE_METASTORE',
- hostName: 'h0'
- },
- {
- component: 'HIVE_METASTORE',
- hostName: 'h1'
- }
- ]
- },
- value: ['h0', 'h1'],
- title: 'array that contains names of hosts with Hive Metastore'
- },
- 'hive_master_hosts': {
- localDB: {
- masterComponentHosts: [
- {
- component: 'HIVE_SERVER',
- hostName: 'h0'
- },
- {
- component: 'HIVE_METASTORE',
- hostName: 'h0'
- },
- {
- component: 'HIVE_METASTORE',
- hostName: 'h1'
- },
- {
- component: 'WEBHCAT_SERVER',
- hostName: 'h2'
- }
- ]
- },
- 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'
- }
- ]
- },
- dependencies: {
- 'hive.metastore.uris': 'thrift://localhost:9083'
- },
- recommendedValue: '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'
- }
- ]
- },
- dependencies: {
- 'hive.metastore.uris': 'thrift://localhost:9083'
- },
- recommendedValue: 'hive.metastore.local=false,hive.metastore.uris=thrift://localhost:9083,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'
- },
- 'yarn.resourcemanager.zk-address': {
- localDB: {
- masterComponentHosts: [
- {
- component: 'ZOOKEEPER_SERVER',
- hostName: 'h0'
- },
- {
- component: 'ZOOKEEPER_SERVER',
- hostName: 'h1'
- }
- ]
- },
- dependencies: {
- clientPort: '2182'
- },
- recommendedValue: 'localhost:2181',
- value: 'h0:2182,h1:2182',
- title: 'should add ZK host and port dynamically'
- },
- 'oozie_hostname': {
- localDB: {
- masterComponentHosts: [
- {
- component: 'OOZIE_SERVER',
- hostName: 'h0'
- },
- {
- component: 'OOZIE_SERVER',
- hostName: 'h1'
- }
- ]
- },
- value: ['h0', 'h1'],
- title: 'array that contains names of hosts with Oozie Server'
- },
- 'knox_gateway_host': {
- localDB: {
- masterComponentHosts: [
- {
- component: 'KNOX_GATEWAY',
- hostName: 'h0'
- },
- {
- component: 'KNOX_GATEWAY',
- hostName: 'h1'
- }
- ]
- },
- value: ['h0', 'h1'],
- title: 'array that contains names of hosts with Knox Gateway'
- }
- };
-
- cases['kafka.ganglia.metrics.host'].forEach(function (item) {
- it(item.message, function () {
- serviceConfigProperty.setProperties({
- name: 'kafka.ganglia.metrics.host',
- value: 'localhost'
- });
- configPropertyHelper.initialValue(serviceConfigProperty, item.localDB, []);
- expect(serviceConfigProperty.get('value')).to.equal(item.expected);
- });
- });
-
- cases['hive_database'].forEach(function (item) {
- var title = 'hive_database value should be set to {0}';
- it(title.format(item.value), function () {
- sinon.stub(App, 'get')
- .withArgs('supports.alwaysEnableManagedMySQLForHive').returns(item.alwaysEnableManagedMySQLForHive)
- .withArgs('router.currentState.name').returns(item.currentStateName)
- .withArgs('isManagedMySQLForHiveEnabled').returns(item.isManagedMySQLForHiveEnabled);
- serviceConfigProperty.setProperties({
- name: 'hive_database',
- value: item.receivedValue,
- options: item.options
- });
- configPropertyHelper.initialValue(serviceConfigProperty, {}, []);
- expect(serviceConfigProperty.get('value')).to.equal(item.value);
- expect(serviceConfigProperty.get('options').findProperty('displayName', 'New MySQL Database').hidden).to.equal(item.hidden);
- App.get.restore();
- });
- });
-
- cases['hbase.zookeeper.quorum'].forEach(function (item) {
- it(item.title, function () {
- serviceConfigProperty.setProperties({
- name: 'hbase.zookeeper.quorum',
- value: 'localhost',
- 'filename': item.filename
- });
- configPropertyHelper.initialValue(serviceConfigProperty, {
- masterComponentHosts: {
- filterProperty: function () {
- return {
- mapProperty: function () {
- return ['host0', 'host1'];
- }
- };
- }
- }
- }, []);
- expect(serviceConfigProperty.get('value')).to.equal(item.value);
- expect(serviceConfigProperty.get('recommendedValue')).to.equal(item.recommendedValue);
- });
- });
-
- it(cases['hive_master_hosts'].title, function () {
- serviceConfigProperty.set('name', 'hive_master_hosts');
- configPropertyHelper.initialValue(serviceConfigProperty, cases['hive_master_hosts'].localDB, []);
- expect(serviceConfigProperty.get('value')).to.equal(cases['hive_master_hosts'].value);
- });
-
- it(cases['hive.metastore.uris'].title, function () {
- serviceConfigProperty.setProperties({
- name: 'hive.metastore.uris',
- recommendedValue: cases['hive.metastore.uris'].recommendedValue
- });
- configPropertyHelper.initialValue(serviceConfigProperty, cases['hive.metastore.uris'].localDB, {'hive.metastore.uris': cases['hive.metastore.uris'].recommendedValue});
- expect(serviceConfigProperty.get('value')).to.equal(cases['hive.metastore.uris'].value);
- expect(serviceConfigProperty.get('recommendedValue')).to.equal(cases['hive.metastore.uris'].value);
- });
-
- it(cases['templeton.hive.properties'].title, function () {
- serviceConfigProperty.setProperties({
- name: 'templeton.hive.properties',
- recommendedValue: cases['templeton.hive.properties'].recommendedValue,
- value: cases['templeton.hive.properties'].recommendedValue
- });
- configPropertyHelper.initialValue(serviceConfigProperty, cases['templeton.hive.properties'].localDB, {'hive.metastore.uris': cases['templeton.hive.properties'].recommendedValue});
- expect(serviceConfigProperty.get('value')).to.equal(cases['templeton.hive.properties'].value);
- expect(serviceConfigProperty.get('recommendedValue')).to.equal(cases['templeton.hive.properties'].value);
- });
-
- it(cases['yarn.resourcemanager.zk-address'].title, function () {
- serviceConfigProperty.setProperties({
- name: 'yarn.resourcemanager.zk-address',
- recommendedValue: cases['yarn.resourcemanager.zk-address'].recommendedValue
- });
- configPropertyHelper.initialValue(serviceConfigProperty, cases['yarn.resourcemanager.zk-address'].localDB, cases['yarn.resourcemanager.zk-address'].dependencies);
- expect(serviceConfigProperty.get('value')).to.equal(cases['yarn.resourcemanager.zk-address'].value);
- expect(serviceConfigProperty.get('recommendedValue')).to.equal(cases['yarn.resourcemanager.zk-address'].value);
- });
-
- function getLocalDBForSingleComponent(component) {
- return {
- masterComponentHosts: [
- {
- component: component,
- hostName: 'h1'
- },
- {
- component: 'FAKE_COMPONENT',
- hostName: 'FAKE_HOST'
- }
- ]
- };
- }
-
- function getLocalDBForMultipleComponents(component, count) {
- var ret = {
- masterComponentHosts: [{
- component: 'FAKE_COMPONENT',
- hostName: 'FAKE_HOST'
- }]
- };
- for (var i = 1; i <= count; i++) {
- ret.masterComponentHosts.push({
- component: component,
- hostName: 'h' + i
- })
- }
- return ret;
- }
-
- Em.A([
- {
- config: 'dfs.namenode.rpc-address',
- localDB: getLocalDBForSingleComponent('NAMENODE'),
- rValue: 'c6401.ambari.apache.org:8020',
- expectedValue: 'h1:8020'
- },
- {
- config: 'dfs.http.address',
- localDB: getLocalDBForSingleComponent('NAMENODE'),
- rValue: 'c6401.ambari.apache.org:8020',
- expectedValue: 'h1:8020'
- },
- {
- config: 'dfs.namenode.http-address',
- localDB: getLocalDBForSingleComponent('NAMENODE'),
- rValue: 'c6401.ambari.apache.org:8020',
- expectedValue: 'h1:8020'
- },
- {
- config: 'dfs.https.address',
- localDB: getLocalDBForSingleComponent('NAMENODE'),
- rValue: 'c6401.ambari.apache.org:8020',
- expectedValue: 'h1:8020'
- },
- {
- config: 'dfs.namenode.https-address',
- localDB: getLocalDBForSingleComponent('NAMENODE'),
- rValue: 'c6401.ambari.apache.org:8020',
- expectedValue: 'h1:8020'
- },
- {
- config: 'fs.default.name',
- localDB: getLocalDBForSingleComponent('NAMENODE'),
- rValue: 'hdfs://c6401.ambari.apache.org:8020',
- expectedValue: 'hdfs://h1:8020'
- },
- {
- config: 'fs.defaultFS',
- localDB: getLocalDBForSingleComponent('NAMENODE'),
- rValue: 'hdfs://c6401.ambari.apache.org:8020',
- expectedValue: 'hdfs://h1:8020'
- },
- {
- config: 'hbase.rootdir',
- localDB: getLocalDBForSingleComponent('NAMENODE'),
- rValue: 'hdfs://c6401.ambari.apache.org:8020',
- expectedValue: 'hdfs://h1:8020'
- },
- {
- config: 'instance.volumes',
- localDB: getLocalDBForSingleComponent('NAMENODE'),
- rValue: 'hdfs://c6401.ambari.apache.org:8020',
- expectedValue: 'hdfs://h1:8020'
- },
- {
- config: 'dfs.secondary.http.address',
- localDB: getLocalDBForSingleComponent('SECONDARY_NAMENODE'),
- rValue: 'c6401.ambari.apache.org:50090',
- expectedValue: 'h1:50090'
- },
- {
- config: 'dfs.namenode.secondary.http-address',
- localDB: getLocalDBForSingleComponent('SECONDARY_NAMENODE'),
- rValue: 'c6401.ambari.apache.org:50090',
- expectedValue: 'h1:50090'
- },
- {
- config: 'yarn.log.server.url',
- localDB: getLocalDBForSingleComponent('HISTORYSERVER'),
- rValue: 'http://localhost:19888/jobhistory/logs',
- expectedValue: 'http://h1:19888/jobhistory/logs'
- },
- {
- config: 'mapreduce.jobhistory.webapp.address',
- localDB: getLocalDBForSingleComponent('HISTORYSERVER'),
- rValue: 'c6407.ambari.apache.org:19888',
- expectedValue: 'h1:19888'
- },
- {
- config: 'mapreduce.jobhistory.address',
- localDB: getLocalDBForSingleComponent('HISTORYSERVER'),
- rValue: 'c6407.ambari.apache.org:19888',
- expectedValue: 'h1:19888'
- },
- {
- config: 'yarn.resourcemanager.hostname',
- localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
- rValue: 'c6407.ambari.apache.org',
- expectedValue: 'h1'
- },
- {
- config: 'yarn.resourcemanager.resource-tracker.address',
- localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
- rValue: 'c6407.ambari.apache.org:123',
- expectedValue: 'h1:123'
- },
- {
- config: 'yarn.resourcemanager.webapp.https.address',
- localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
- rValue: 'c6407.ambari.apache.org:123',
- expectedValue: 'h1:123'
- },
- {
- config: 'yarn.resourcemanager.webapp.address',
- localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
- rValue: 'c6407.ambari.apache.org:123',
- expectedValue: 'h1:123'
- },
- {
- config: 'yarn.resourcemanager.scheduler.address',
- localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
- rValue: 'c6407.ambari.apache.org:123',
- expectedValue: 'h1:123'
- },
- {
- config: 'yarn.resourcemanager.address',
- localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
- rValue: 'c6407.ambari.apache.org:123',
- expectedValue: 'h1:123'
- },
- {
- config: 'yarn.resourcemanager.admin.address',
- localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
- rValue: 'c6407.ambari.apache.org:123',
- expectedValue: 'h1:123'
- },
- {
- config: 'yarn.timeline-service.webapp.address',
- localDB: getLocalDBForSingleComponent('APP_TIMELINE_SERVER'),
- rValue: 'c6407.ambari.apache.org:432',
- expectedValue: 'h1:432'
- },
- {
- config: 'yarn.timeline-service.address',
- localDB: getLocalDBForSingleComponent('APP_TIMELINE_SERVER'),
- rValue: 'c6407.ambari.apache.org:432',
- expectedValue: 'h1:432'
- },
- {
- config: 'yarn.timeline-service.webapp.https.address',
- localDB: getLocalDBForSingleComponent('APP_TIMELINE_SERVER'),
- rValue: 'c6407.ambari.apache.org:432',
- expectedValue: 'h1:432'
- },
- {
- config: 'mapred.job.tracker',
- localDB: getLocalDBForSingleComponent('JOBTRACKER'),
- rValue: 'c6407.ambari.apache.org:111',
- expectedValue: 'h1:111'
- },
- {
- config: 'mapred.job.tracker.http.address',
- localDB: getLocalDBForSingleComponent('JOBTRACKER'),
- rValue: 'c6407.ambari.apache.org:111',
- expectedValue: 'h1:111'
- },
- {
- config: 'mapreduce.history.server.http.address',
- localDB: getLocalDBForSingleComponent('HISTORYSERVER'),
- rValue: 'c6407.ambari.apache.org:555',
- expectedValue: 'h1:555'
- },
- {
- config: 'hive_hostname',
- localDB: getLocalDBForSingleComponent('HIVE_SERVER'),
- rValue: 'c6407.ambari.apache.org',
- expectedValue: 'h1'
- },
- {
- config: 'oozie_hostname',
- localDB: getLocalDBForSingleComponent('OOZIE_SERVER'),
- rValue: 'c6407.ambari.apache.org',
- expectedValue: 'h1'
- },
- {
- config: 'oozie.base.url',
- localDB: getLocalDBForSingleComponent('OOZIE_SERVER'),
- rValue: 'http://localhost:11000/oozie',
- expectedValue: 'http://h1:11000/oozie'
- },
- {
- config: 'nimbus.host',
- localDB: getLocalDBForSingleComponent('NIMBUS'),
- rValue: 'localhost',
- expectedValue: 'h1'
- },
- {
- config: '*.broker.url',
- localDB: getLocalDBForSingleComponent('FALCON_SERVER'),
- rValue: 'tcp://localhost:61616',
- expectedValue: 'tcp://h1:61616'
- },
- {
- config: 'storm.zookeeper.servers',
- localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
- rValue: "['c6401.ambari.apache.org','c6402.ambari.apache.org']",
- expectedValue: ['h1', 'h2', 'h3']
- },
- {
- config: 'nimbus.seeds',
- localDB: getLocalDBForMultipleComponents('NIMBUS', 3),
- rValue: "['c6401.ambari.apache.org','c6402.ambari.apache.org']",
- expectedValue: ['h1', 'h2', 'h3']
- },
- {
- config: 'hawq_master_address_host',
- localDB: getLocalDBForSingleComponent('HAWQMASTER'),
- rValue: 'localhost',
- expectedValue: 'h1'
- },
- {
- config: 'hawq_standby_address_host',
- localDB: getLocalDBForSingleComponent('HAWQSTANDBY'),
- rValue: 'localhost',
- expectedValue: 'h1'
- },
- {
- config: 'hawq_dfs_url',
- localDB: getLocalDBForSingleComponent('NAMENODE'),
- rValue: 'localhost:8020/hawq_default',
- expectedValue: 'h1:8020/hawq_default'
- },
- {
- config: 'hawq_rm_yarn_address',
- localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
- rValue: 'localhost:8032',
- expectedValue: 'h1:8032'
- },
- {
- config: 'hawq_rm_yarn_scheduler_address',
- localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
- rValue: 'localhost:8030',
- expectedValue: 'h1:8030'
- },
- {
- config: 'hadoop_host',
- localDB: getLocalDBForSingleComponent('NAMENODE'),
- rValue: 'localhost',
- expectedValue: 'h1'
- },
- {
- config: 'hive_master_hosts',
- localDB: getLocalDBForMultipleComponents('HIVE_METASTORE', 3),
- rValue: '',
- expectedValue: 'h1,h2,h3'
- },
- {
- config: 'hive_master_hosts',
- localDB: getLocalDBForMultipleComponents('HIVE_SERVER', 3),
- rValue: '',
- expectedValue: 'h1,h2,h3'
- },
- {
- config: 'zookeeper.connect',
- localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
- rValue: 'localhost:2181',
- expectedValue: 'h1:2181,h2:2181,h3:2181'
- },
- {
- config: 'hive.zookeeper.quorum',
- localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
- rValue: 'localhost:2181',
- expectedValue: 'h1:2181,h2:2181,h3:2181'
- },
- {
- config: 'templeton.zookeeper.hosts',
- localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
- rValue: 'localhost:2181',
- expectedValue: 'h1:2181,h2:2181,h3:2181'
- },
- {
- config: 'hadoop.registry.zk.quorum',
- localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
- rValue: 'localhost:2181',
- expectedValue: 'h1:2181,h2:2181,h3:2181'
- },
- {
- config: 'hive.cluster.delegation.token.store.zookeeper.connectString',
- localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
- rValue: 'localhost:2181',
- expectedValue: 'h1:2181,h2:2181,h3:2181'
- },
- {
- config: 'instance.zookeeper.host',
- localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
- rValue: 'localhost:2181',
- expectedValue: 'h1:2181,h2:2181,h3:2181'
- },
- {
- config: 'templeton.hive.properties',
- localDB: getLocalDBForMultipleComponents('HIVE_METASTORE', 2),
- rValue: 'hive.metastore.local=false,hive.metastore.uris=thrift://localhost:9933,hive.metastore.sasl.enabled=false',
- dependencies: {
- 'hive.metastore.uris': 'thrift://localhost:9083'
- },
- expectedValue: 'hive.metastore.local=false,hive.metastore.uris=thrift://h1:9083\\,thrift://h2:9083,hive.metastore.sasl.enabled=false'
- },
- {
- config: 'hbase.zookeeper.quorum',
- m: 'hbase.zookeeper.quorum hbase-site.xml',
- localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
- rValue: 'c6401.ambari.apache.org,c6402.ambari.apache.org',
- expectedValue: 'h1,h2,h3',
- filename: 'hbase-site.xml'
- },
- {
- config: 'hbase.zookeeper.quorum',
- m: 'hbase.zookeeper.quorum not-hbase-site.xml',
- localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
- rValue: 'localhost',
- expectedValue: '',
- expectedRValue: 'localhost',
- filename: 'not-hbase-site.xml'
- },
- {
- config: 'yarn.resourcemanager.zk-address',
- localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
- rValue: 'localhost:2181',
- dependencies: {
- 'clientPort': '3333'
- },
- expectedValue: 'h1:3333,h2:3333,h3:3333'
- },
- {
- config: 'RANGER_HOST',
- localDB: getLocalDBForSingleComponent('RANGER_ADMIN'),
- rValue: 'locahost',
- expectedValue: 'h1'
- },
- {
- config: 'hive.metastore.uris',
- localDB: getLocalDBForMultipleComponents('HIVE_METASTORE', 2),
- dependencies: {
- 'hive.metastore.uris': 'thrift://localhost:9083'
- },
- rValue: 'thrift://localhost:9083',
- expectedValue: 'thrift://h1:9083,thrift://h2:9083'
- }
- ]).forEach(function (test) {
- it(test.m || test.config, function () {
- serviceConfigProperty.setProperties({
- name: test.config,
- recommendedValue: test.rValue,
- filename: test.filename
- });
- configPropertyHelper.initialValue(serviceConfigProperty, test.localDB, test.dependencies);
- expect(serviceConfigProperty.get('value')).to.eql(test.expectedValue);
- if (Em.isNone(test.expectedRValue)) {
- expect(serviceConfigProperty.get('recommendedValue')).to.eql(test.expectedValue);
- }
- else {
- expect(serviceConfigProperty.get('recommendedValue')).to.eql(test.expectedRValue);
- }
-
- });
- });
-
- });
-
- describe('#getHiveMetastoreUris', function () {
-
- var cases = [
- {
- hosts: [
- {
- hostName: 'h0',
- component: 'HIVE_SERVER'
- },
- {
- hostName: 'h1',
- component: 'HIVE_METASTORE'
- },
- {
- hostName: 'h2',
- component: 'HIVE_METASTORE'
- }
- ],
- recommendedValue: 'thrift://localhost:9083',
- expected: 'thrift://h1:9083,thrift://h2:9083',
- title: 'typical case'
- },
- {
- hosts: [
- {
- hostName: 'h0',
- component: 'HIVE_SERVER'
- }
- ],
- recommendedValue: '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'
- }
- ],
- recommendedValue: '',
- 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(configPropertyHelper.getHiveMetastoreUris(item.hosts, item.recommendedValue)).to.equal(item.expected);
- });
- });
-
- });
-
- describe('config with mount points', function () {
-
- var localDB = {
- masterComponentHosts: [
- {
- component: 'NAMENODE',
- hostName: 'h0'
- },
- {
- component: 'SECONDARY_NAMENODE',
- hostName: 'h4'
- },
- {
- component: 'APP_TIMELINE_SERVER',
- hostName: 'h0'
- },
- {
- component: 'ZOOKEEPER_SERVER',
- hostName: 'h0'
- },
- {
- component: 'ZOOKEEPER_SERVER',
- hostName: 'h1'
- },
- {
- component: 'OOZIE_SERVER',
- hostName: 'h0'
- },
- {
- component: 'OOZIE_SERVER',
- hostName: 'h1'
- },
- {
- component: 'NIMBUS',
- hostName: 'h2'
- },
- {
- component: 'FALCON_SERVER',
- hostName: 'h3'
- },
- {
- component: 'KAFKA_BROKER',
- hostName: 'h0'
- },
- {
- component: 'KAFKA_BROKER',
- hostName: 'h1'
- }
- ],
- slaveComponentHosts: [
- {
- componentName: 'DATANODE',
- hosts: [
- {
- hostName: 'h0'
- },
- {
- hostName: 'h1'
- }
- ]
- },
- {
- componentName: 'TASKTRACKER',
- hosts: [
- {
- hostName: 'h0'
- },
- {
- hostName: 'h1'
- }
- ]
- },
- {
- componentName: 'NODEMANAGER',
- hosts: [
- {
- hostName: 'h0'
- },
- {
- hostName: 'h1'
- },
- {
- hostName: 'h4'
- }
- ]
- },
- {
- componentName: 'HBASE_REGIONSERVER',
- hosts: [
- {
- hostName: 'h0'
- },
- {
- hostName: 'h1'
- }
- ]
- },
- {
- componentName: 'SUPERVISOR',
- hosts: [
- {
- hostName: 'h0'
- },
- {
- hostName: 'h1'
- }
- ]
- }
- ],
- hosts: {
- h0: {
- disk_info: [
- {
- mountpoint: '/'
- },
- {
- mountpoint: '/home'
- },
- {
- mountpoint: '/boot'
- },
- {
- mountpoint: '/boot/efi'
- },
- {
- mountpoint: '/mnt'
- },
- {
- mountpoint: '/mnt/efi'
- },
- {
- mountpoint: '/media/disk0',
- available: '100000000'
- },
- {
- mountpoint: '/mount0',
- available: '100000000'
- }
- ]
- },
- h4: {
- disk_info: [
- {
- mountpoint: 'c:',
- available: '100000000'
- }
- ]
- }
- }
- },
- cases = [
- {
- name: 'dfs.namenode.name.dir',
- isOnlyFirstOneNeeded: false,
- value: '/media/disk0/default\n/mount0/default\n'
- },
- {
- name: 'dfs.name.dir',
- isOnlyFirstOneNeeded: false,
- value: '/media/disk0/default\n/mount0/default\n'
- },
- {
- name: 'fs.checkpoint.dir',
- isOnlyFirstOneNeeded: true,
- value: 'file:///c:/default\n'
- },
- {
- name: 'dfs.namenode.checkpoint.dir',
- isOnlyFirstOneNeeded: true,
- value: 'file:///c:/default\n'
- },
- {
- name: 'dfs.data.dir',
- isOnlyFirstOneNeeded: false,
- value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\n'
- },
- {
- name: 'dfs.datanode.data.dir',
- isOnlyFirstOneNeeded: false,
- value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\n'
- },
- {
- name: 'mapred.local.dir',
- isOnlyFirstOneNeeded: false,
- value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\n'
- },
- {
- name: 'yarn.nodemanager.log-dirs',
- isOnlyFirstOneNeeded: false,
- value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\nc:\\default\n'
- },
- {
- name: 'yarn.nodemanager.local-dirs',
- isOnlyFirstOneNeeded: false,
- value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\nc:\\default\n'
- },
- {
- name: 'yarn.timeline-service.leveldb-timeline-store.path',
- isOnlyFirstOneNeeded: true,
- value: '/media/disk0/default'
- },
- {
- name: 'yarn.timeline-service.leveldb-state-store.path',
- isOnlyFirstOneNeeded: true,
- value: '/media/disk0/default'
- },
- {
- name: 'dataDir',
- isOnlyFirstOneNeeded: true,
- value: '/media/disk0/default'
- },
- {
- name: 'oozie_data_dir',
- isOnlyFirstOneNeeded: true,
- value: '/media/disk0/default'
- },
- {
- name: 'storm.local.dir',
- isOnlyFirstOneNeeded: true,
- value: '/media/disk0/default'
- },
- {
- name: '*.falcon.graph.storage.directory',
- isOnlyFirstOneNeeded: true,
- value: '/default'
- },
- {
- name: '*.falcon.graph.serialize.path',
- isOnlyFirstOneNeeded: true,
- value: '/default'
- },
- {
- name: 'log.dirs',
- isOnlyFirstOneNeeded: false,
- value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\n'
- }
- ];
-
- beforeEach(function () {
- sinon.stub(App.Host, 'find').returns([
- Em.Object.create({
- id: 'h1',
- diskInfo: [
- {
- mountpoint: '/media/disk1',
- type: 'devtmpfs'
- },
- {
- mountpoint: '/media/disk1',
- type: 'tmpfs'
- },
- {
- mountpoint: '/media/disk1',
- type: 'vboxsf'
- },
- {
- mountpoint: '/media/disk1',
- type: 'CDFS'
- },
- {
- mountpoint: '/media/disk1',
- available: '0'
- },
- {
- mountpoint: '/media/disk1',
- available: '100000000'
- },
- {
- mountpoint: '/mount1',
- available: '100000000'
- }
- ]
- }),
- Em.Object.create({
- id: 'h2',
- diskInfo: [
- {
- mountpoint: '/'
- }
- ]
- }),
- Em.Object.create({
- id: 'h3',
- diskInfo: []
- })
- ]);
- });
-
- afterEach(function () {
- App.Host.find.restore();
- });
-
- cases.forEach(function (item) {
- it(item.name, function () {
- serviceConfigProperty.setProperties({
- name: item.name,
- recommendedValue: '/default'
- });
- configPropertyHelper.initialValue(serviceConfigProperty, localDB, {});
- expect(serviceConfigProperty.get('value')).to.equal(item.value);
- expect(serviceConfigProperty.get('recommendedValue')).to.equal(item.value);
- });
- });
-
- });
-
- describe('initializerTypes', function () {
- var types = configPropertyHelper.__testGetInitializerTypes();
- Em.keys(types).forEach(function(type) {
- it(type, function() {
- var methodName = types[type].method;
- expect(methodName).to.be.a.string;
- expect(methodName).to.have.length.above(0);
- expect(configPropertyHelper[methodName]).to.be.a.function;
- });
- });
- });
-
- describe('initializers', function () {
-
- var initializers = configPropertyHelper.__testGetInitializers();
- var types = configPropertyHelper.__testGetInitializerTypes();
- var typeNames = Em.keys(types);
-
- Em.keys(initializers).forEach(function (configName) {
- it(configName, function () {
- var type = initializers[configName].type;
- expect(typeNames).to.contain(type);
- });
- });
-
- });
-
- describe('uniqueInitializers', function () {
-
- var uniqueInitializers = configPropertyHelper.__testGetUniqueInitializers();
- var uniqueInitializersNames = Em.keys(uniqueInitializers).map(function (key) {
- return uniqueInitializers[key];
- });
-
- it('should contains only unique methods', function () {
- expect(uniqueInitializersNames.length).to.equal(uniqueInitializersNames.uniq().length);
- });
-
- uniqueInitializersNames.forEach(function (name) {
- it(name, function () {
- expect(configPropertyHelper[name]).to.be.a.function;
- });
- });
-
- });
-
- describe('winReplacersMap', function () {
-
- var winReplacersMap = configPropertyHelper.__testGetWinReplacersMap();
- var winReplacerNames = Em.keys(winReplacersMap).map(function (key) {
- return winReplacersMap[key];
- });
-
- it('should contains only unique methods', function () {
- expect(winReplacerNames.length).to.equal(winReplacerNames.uniq().length);
- });
-
- winReplacerNames.forEach(function (name) {
- it(name, function () {
- expect(configPropertyHelper[name]).to.be.a.function;
- });
- });
-
- });
-
-});
\ No newline at end of file
[2/2] ambari git commit: AMBARI-13787. Move config_property_helper to
the App.* namespace (onechiporenko)
Posted by on...@apache.org.
AMBARI-13787. Move config_property_helper to the App.* namespace (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/da8ca2ae
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/da8ca2ae
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/da8ca2ae
Branch: refs/heads/trunk
Commit: da8ca2ae386874ba3b8d28f355578c2f340a0d13
Parents: 618d843
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Mon Nov 9 12:07:19 2015 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Mon Nov 9 12:07:19 2015 +0200
----------------------------------------------------------------------
ambari-web/app/assets/test/tests.js | 2 +-
.../wizard/slave_component_groups_controller.js | 5 +-
.../app/controllers/wizard/step7_controller.js | 4 +-
ambari-web/app/initialize.js | 1 +
.../app/utils/configs/config_initializer.js | 908 +++++++++++++
.../app/utils/configs/config_property_helper.js | 905 -------------
.../wizard/slave_component_groups_controller.js | 5 +-
.../objects/service_config_category_test.js | 1 -
.../objects/service_config_property_test.js | 1 -
.../configs/objects/service_config_test.js | 1 -
.../utils/configs/config_initializer_test.js | 1271 ++++++++++++++++++
.../configs/config_property_helper_test.js | 1271 ------------------
12 files changed, 2187 insertions(+), 2188 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/da8ca2ae/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 805d565..71c69db 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -181,7 +181,7 @@ var files = [
'test/utils/ui_effects_test',
'test/utils/updater_test',
'test/utils/configs/database_test',
- 'test/utils/configs/config_property_helper_test',
+ 'test/utils/configs/config_initializer_test',
'test/utils/configs/modification_handlers/modification_handler_test',
'test/utils/configs/modification_handlers/misc_test',
'test/utils/load_timer_test',
http://git-wip-us.apache.org/repos/asf/ambari/blob/da8ca2ae/ambari-web/app/controllers/wizard/slave_component_groups_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/slave_component_groups_controller.js b/ambari-web/app/controllers/wizard/slave_component_groups_controller.js
index 584fdf2..57f1ff5 100644
--- a/ambari-web/app/controllers/wizard/slave_component_groups_controller.js
+++ b/ambari-web/app/controllers/wizard/slave_component_groups_controller.js
@@ -16,7 +16,6 @@
* limitations under the License.
*/
var App = require('app');
-var configPropertyHelper = require('utils/configs/config_property_helper');
/**
* Used to manage slave component config. User could create different settings for separate group
* @type {*}
@@ -102,10 +101,10 @@ App.SlaveComponentGroupsController = Em.ArrayController.extend({
switch(serviceConfigProperty.name){
case 'dfs_data_dir' :
- configPropertyHelper.initialValue(serviceConfigProperty);
+ App.ConfigInitializer.initialValue(serviceConfigProperty);
break;
case 'mapred_local_dir' :
- configPropertyHelper.initialValue(serviceConfigProperty);
+ App.ConfigInitializer.initialValue(serviceConfigProperty);
break;
}
configs.pushObject(serviceConfigProperty);
http://git-wip-us.apache.org/repos/asf/ambari/blob/da8ca2ae/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index c879acc..f5f78ff 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -17,7 +17,7 @@
*/
var App = require('app');
-var configPropertyHelper = require('utils/configs/config_property_helper');
+
/**
* By Step 7, we have the following information stored in App.db and set on this
* controller by the router.
@@ -864,7 +864,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
var serviceConfigProperty = App.ServiceConfigProperty.create(_config);
this.updateHostOverrides(serviceConfigProperty, _config);
if (!storedConfigs && !serviceConfigProperty.get('hasInitialValue')) {
- configPropertyHelper.initialValue(serviceConfigProperty, localDB, dependencies);
+ App.ConfigInitializer.initialValue(serviceConfigProperty, localDB, dependencies);
}
serviceConfigProperty.validate();
configsByService.pushObject(serviceConfigProperty);
http://git-wip-us.apache.org/repos/asf/ambari/blob/da8ca2ae/ambari-web/app/initialize.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/initialize.js b/ambari-web/app/initialize.js
index e4bb171..afcc42c 100644
--- a/ambari-web/app/initialize.js
+++ b/ambari-web/app/initialize.js
@@ -34,6 +34,7 @@ require('utils/base64');
require('utils/db');
require('utils/helper');
require('utils/config');
+require('utils/configs/config_initializer');
require('mixins');
require('models');
require('controllers');
http://git-wip-us.apache.org/repos/asf/ambari/blob/da8ca2ae/ambari-web/app/utils/configs/config_initializer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/config_initializer.js b/ambari-web/app/utils/configs/config_initializer.js
new file mode 100644
index 0000000..34b2a54
--- /dev/null
+++ b/ambari-web/app/utils/configs/config_initializer.js
@@ -0,0 +1,908 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+/**
+ * Regexp for host with port ('hostName:1234')
+ *
+ * @type {string}
+ */
+var hostWithPort = "([\\w|\\.]*)(?=:)";
+
+/**
+ * Regexp for host with port and protocol ('://hostName:1234')
+ *
+ * @type {string}
+ */
+var hostWithPrefix = ":\/\/" + hostWithPort;
+
+/**
+ * Regexp used to determine if mount point is windows-like
+ *
+ * @type {RegExp}
+ */
+var winRegex = /^([a-z]):\\?$/;
+
+/**
+ * Map with initializers types
+ * Doesn't contain unique initializes, only common are included
+ * Key: id
+ * Value: object with method-name (prefer to start method-name with '_init' or '_initAs')
+ * Each method here is called with arguments equal to <code>initialValue</code>-call args
+ * Initializer-settings are added as last argument
+ *
+ * @type {object}
+ */
+var initializerTypes = {
+ host_with_component: {
+ method: '_initAsHostWithComponent'
+ },
+ hosts_with_components: {
+ method: '_initAsHostsWithComponents'
+ },
+ zookeeper_based: {
+ method: '_initAsZookeeperServersList'
+ },
+ single_mountpoint: {
+ method: '_initAsSingleMountPoint'
+ },
+ multiple_mountpoints: {
+ method: '_initAsMultipleMountPoints'
+ }
+};
+
+/**
+ * Map for methods used as value-modifiers for configProperties with values as mount point(s)
+ * Used if mount point is win-like (@see winRegex)
+ * Key: id
+ * Value: method-name
+ *
+ * @type {{default: string, file: string, slashes: string}}
+ */
+var winReplacersMap = {
+ default: '_defaultWinReplace',
+ file: '_winReplaceWithFile',
+ slashes: '_defaultWinReplaceWithAdditionalSlashes'
+};
+
+/**
+ * Settings for <code>host_with_component</code>-initializer
+ * Used for configs with value equal to hostName that has <code>component</code>
+ * Value may be modified with if <code>withModifier</code> is true (it is by default)
+ * <code>hostWithPort</code>-regexp will be used in this case
+ *
+ * @see _initAsHostWithComponent
+ * @param {string} component
+ * @param {boolean} [withModifier=true]
+ * @return {object}
+ */
+function getSimpleComponentConfig(component, withModifier) {
+ if (arguments.length === 1) {
+ withModifier = true;
+ }
+ var config = {
+ type: 'host_with_component',
+ component: component
+ };
+ if (withModifier) {
+ config.modifier = {
+ type: 'regexp',
+ regex: hostWithPort
+ }
+ }
+ return config;
+}
+
+/**
+ * Zookeeper-based configs don't have any customization settings
+ *
+ * @see _initAsZookeeperServersList
+ * @returns {{type: string}}
+ */
+function getZKBasedConfig() {
+ return {
+ type: 'zookeeper_based'
+ };
+}
+
+/**
+ * Almost the same to <code>getSimpleComponentConfig</code>, but with possibility to modify <code>replaceWith</code>-value
+ * <code>prefix</code> is added before it
+ * <code>suffix</code> is added after it
+ * <code>hostWithPrefix</code>-regexp is used
+ *
+ * @see _initAsHostWithComponent
+ * @param {string} component
+ * @param {string} [prefix]
+ * @param {string} [suffix]
+ * @returns {object}
+ */
+function getComponentConfigWithAffixes (component, prefix, suffix) {
+ prefix = prefix || '';
+ suffix = suffix || '';
+ return {
+ type: 'host_with_component',
+ component: component,
+ modifier: {
+ type: 'regexp',
+ regex: hostWithPrefix,
+ prefix: prefix,
+ suffix: suffix
+ }
+ };
+}
+
+/**
+ * Settings for <code>hosts_with_components</code>-initializer
+ * Used for configs with value equal to the hosts list
+ * May set value as array (if <code>asArray</code> is true) or as comma-sepratated string (if <code>asArray</code> is false)
+ *
+ * @see _initAsHostsWithComponents
+ * @param {string|string[]} components
+ * @param {boolean} [asArray=false]
+ * @returns {{type: string, components: string[], asArray: boolean}}
+ */
+function getComponentsHostsConfig(components, asArray) {
+ if (1 === arguments.length) {
+ asArray = false;
+ }
+ return {
+ type: 'hosts_with_components',
+ components: Em.makeArray(components),
+ asArray: asArray
+ };
+}
+
+/**
+ * Settings for <code>single_mountpoint</code>-initializer
+ * Used for configs with value as one of the possible mount points
+ *
+ * @see _initAsSingleMountPoint
+ * @param {string|string[]} components
+ * @param {string} winReplacer
+ * @returns {{components: string[], winReplacer: string, type: string}}
+ */
+function getSingleMountPointConfig(components, winReplacer) {
+ winReplacer = winReplacer || 'default';
+ Em.assert('Invalid `winReplacer` selected - `' + winReplacer + '`! See winReplacersMap for available replacers.', !!winReplacersMap[winReplacer]);
+ return {
+ components: Em.makeArray(components),
+ winReplacer: winReplacersMap[winReplacer],
+ type: 'single_mountpoint'
+ }
+}
+
+/**
+ * Settings for <code>multiple_mountpoints</code>-initializer
+ * Used for configs with value as all of the possible mount points
+ *
+ * @see _initAsMultipleMountPoints
+ * @param {string|string[]} components
+ * @param {string} winReplacer
+ * @returns {{components: string[], winReplacer: string, type: string}}
+ */
+function getMultipleMountPointsConfig(components, winReplacer) {
+ winReplacer = winReplacer || 'default';
+ Em.assert('Invalid `winReplacer` selected - `' + winReplacer + '`! See winReplacersMap for available replacers.', !!winReplacersMap[winReplacer]);
+ return {
+ components: Em.makeArray(components),
+ winReplacer: winReplacersMap[winReplacer],
+ type: 'multiple_mountpoints'
+ }
+}
+
+/**
+ * Map with configurations for config initializers
+ * It's used only for initializers which are common for some configs (if not - use <code>uniqueInitializers</code>-map)
+ * Key {string} configProperty-name
+ * Value {object|object[]} settings for initializer
+ *
+ * @type {object}
+ */
+var initializers = {
+ 'dfs.namenode.rpc-address': getSimpleComponentConfig('NAMENODE'),
+ 'dfs.http.address': getSimpleComponentConfig('NAMENODE'),
+ 'dfs.namenode.http-address': getSimpleComponentConfig('NAMENODE'),
+ 'dfs.https.address': getSimpleComponentConfig('NAMENODE'),
+ 'dfs.namenode.https-address': getSimpleComponentConfig('NAMENODE'),
+ 'dfs.secondary.http.address': getSimpleComponentConfig('SECONDARY_NAMENODE'),
+ 'dfs.namenode.secondary.http-address': getSimpleComponentConfig('SECONDARY_NAMENODE'),
+ 'yarn.resourcemanager.hostname': getSimpleComponentConfig('RESOURCEMANAGER', false),
+ 'yarn.resourcemanager.resource-tracker.address': getSimpleComponentConfig('RESOURCEMANAGER'),
+ 'yarn.resourcemanager.webapp.https.address': getSimpleComponentConfig('RESOURCEMANAGER'),
+ 'yarn.resourcemanager.webapp.address': getSimpleComponentConfig('RESOURCEMANAGER'),
+ 'yarn.resourcemanager.scheduler.address': getSimpleComponentConfig('RESOURCEMANAGER'),
+ 'yarn.resourcemanager.address': getSimpleComponentConfig('RESOURCEMANAGER'),
+ 'yarn.resourcemanager.admin.address': getSimpleComponentConfig('RESOURCEMANAGER'),
+ 'yarn.timeline-service.webapp.address': getSimpleComponentConfig('APP_TIMELINE_SERVER'),
+ 'yarn.timeline-service.webapp.https.address': getSimpleComponentConfig('APP_TIMELINE_SERVER'),
+ 'yarn.timeline-service.address': getSimpleComponentConfig('APP_TIMELINE_SERVER'),
+ 'mapred.job.tracker': getSimpleComponentConfig('JOBTRACKER'),
+ 'mapred.job.tracker.http.address': getSimpleComponentConfig('JOBTRACKER'),
+ 'mapreduce.history.server.http.address': getSimpleComponentConfig('HISTORYSERVER'),
+ 'hive_hostname': getSimpleComponentConfig('HIVE_SERVER', false),
+ 'oozie_hostname': getSimpleComponentConfig('OOZIE_SERVER', false),
+ 'oozie.base.url': getComponentConfigWithAffixes('OOZIE_SERVER', '://'),
+ 'hawq_dfs_url': getSimpleComponentConfig('NAMENODE'),
+ 'hawq_rm_yarn_address': getSimpleComponentConfig('RESOURCEMANAGER'),
+ 'hawq_rm_yarn_scheduler_address': getSimpleComponentConfig('RESOURCEMANAGER'),
+ 'fs.default.name': getComponentConfigWithAffixes('NAMENODE', '://'),
+ 'fs.defaultFS': getComponentConfigWithAffixes('NAMENODE', '://'),
+ 'hbase.rootdir': getComponentConfigWithAffixes('NAMENODE', '://'),
+ 'instance.volumes': getComponentConfigWithAffixes('NAMENODE', '://'),
+ 'yarn.log.server.url': getComponentConfigWithAffixes('HISTORYSERVER', '://'),
+ 'mapreduce.jobhistory.webapp.address': getSimpleComponentConfig('HISTORYSERVER'),
+ 'mapreduce.jobhistory.address': getSimpleComponentConfig('HISTORYSERVER'),
+ 'kafka.ganglia.metrics.host': getSimpleComponentConfig('GANGLIA_SERVER', false),
+ 'hive_master_hosts': getComponentsHostsConfig(['HIVE_METASTORE', 'HIVE_SERVER']),
+ 'hadoop_host': getSimpleComponentConfig('NAMENODE', false),
+ 'nimbus.host': getSimpleComponentConfig('NIMBUS', false),
+ 'nimbus.seeds': getComponentsHostsConfig('NIMBUS', true),
+ 'storm.zookeeper.servers': getComponentsHostsConfig('ZOOKEEPER_SERVER', true),
+ 'hawq_master_address_host': getSimpleComponentConfig('HAWQMASTER', false),
+ 'hawq_standby_address_host': getSimpleComponentConfig('HAWQSTANDBY', false),
+
+ '*.broker.url': {
+ type: 'host_with_component',
+ component: 'FALCON_SERVER',
+ modifier: {
+ type: 'regexp',
+ regex: 'localhost'
+ }
+ },
+
+ 'zookeeper.connect': getZKBasedConfig(),
+ 'hive.zookeeper.quorum': getZKBasedConfig(),
+ 'templeton.zookeeper.hosts': getZKBasedConfig(),
+ 'hadoop.registry.zk.quorum': getZKBasedConfig(),
+ 'hive.cluster.delegation.token.store.zookeeper.connectString': getZKBasedConfig(),
+ 'instance.zookeeper.host': getZKBasedConfig(),
+
+ 'dfs.name.dir': getMultipleMountPointsConfig('NAMENODE', 'file'),
+ 'dfs.namenode.name.dir': getMultipleMountPointsConfig('NAMENODE', 'file'),
+ 'dfs.data.dir': getMultipleMountPointsConfig('DATANODE', 'file'),
+ 'dfs.datanode.data.dir': getMultipleMountPointsConfig('DATANODE', 'file'),
+ 'yarn.nodemanager.local-dirs': getMultipleMountPointsConfig('NODEMANAGER'),
+ 'yarn.nodemanager.log-dirs': getMultipleMountPointsConfig('NODEMANAGER'),
+ 'mapred.local.dir': getMultipleMountPointsConfig(['TASKTRACKER', 'NODEMANAGER']),
+ 'log.dirs': getMultipleMountPointsConfig('KAFKA_BROKER'),
+
+ 'fs.checkpoint.dir': getSingleMountPointConfig('SECONDARY_NAMENODE', 'file'),
+ 'dfs.namenode.checkpoint.dir': getSingleMountPointConfig('SECONDARY_NAMENODE', 'file'),
+ 'yarn.timeline-service.leveldb-timeline-store.path': getSingleMountPointConfig('APP_TIMELINE_SERVER'),
+ 'yarn.timeline-service.leveldb-state-store.path': getSingleMountPointConfig('APP_TIMELINE_SERVER'),
+ 'dataDir': getSingleMountPointConfig('ZOOKEEPER_SERVER'),
+ 'oozie_data_dir': getSingleMountPointConfig('OOZIE_SERVER'),
+ 'storm.local.dir': getSingleMountPointConfig(['NODEMANAGER', 'NIMBUS']),
+ '*.falcon.graph.storage.directory': getSingleMountPointConfig('FALCON_SERVER'),
+ '*.falcon.graph.serialize.path': getSingleMountPointConfig('FALCON_SERVER')
+};
+
+/**
+ * Map with initializers that are used only for one config (are unique)
+ * Key: configProperty-name
+ * Value: method-name
+ * Every method from this map is called with same arguments as <code>initialValue</code> is (prefer to start method-name with '_init' or '_initAs')
+ *
+ * @type {object}
+ */
+var uniqueInitializers = {
+ 'hive_database': '_initHiveDatabaseValue',
+ 'templeton.hive.properties': '_initTempletonHiveProperties',
+ 'hbase.zookeeper.quorum': '_initHBaseZookeeperQuorum',
+ 'yarn.resourcemanager.zk-address': '_initYarnRMzkAddress',
+ 'RANGER_HOST': '_initRangerHost',
+ 'hive.metastore.uris': '_initHiveMetastoreUris'
+};
+
+/**
+ * Helper-object used to set initial value for some configs
+ *
+ * Usage:
+ * <pre>
+ * var configProperty = App.ServiceConfigProperty.create({});
+ * var localDB = {
+ * hosts: [],
+ * masterComponentHosts: [],
+ * slaveComponentHosts: []
+ * };
+ * var dependencies = {};
+ * configPropertyHelper.initialValue(configProperty, localDB, dependencies);
+ * </pre>
+ *
+ * @type {object}
+ */
+App.ConfigInitializer = Em.Object.create({
+
+ /**
+ * Wrapper for common initializers
+ * Execute initializer if it is a function or throw an error otherwise
+ *
+ * @param {App.ServiceConfigProperty} configProperty
+ * @param {topologyLocalDB} localDB
+ * @param {object} dependencies
+ * @returns {App.ServiceConfigProperty}
+ * @private
+ */
+ _defaultInitializer: function (configProperty, localDB, dependencies) {
+ var args = [].slice.call(arguments);
+ var self = this;
+ var initializer = initializers[configProperty.get('name')];
+ if (initializer) {
+ Em.makeArray(initializer).forEach(function (init) {
+ var type = initializerTypes[init.type];
+ // add initializer-settings
+ args.push(init);
+ var methodName = type.method;
+ Em.assert('method-initializer is not a function ' + methodName, 'function' === Em.typeOf(self[methodName]));
+ configProperty = self[methodName].apply(self, args);
+ });
+ }
+ return configProperty;
+ },
+
+ /**
+ * Initializer for configs with value equal to hostName with needed component
+ * Value example: 'hostName'
+ *
+ * @param {App.ServiceConfigProperty} configProperty
+ * @param {topologyLocalDB} localDB
+ * @param {object} dependencies
+ * @param {object} initializer
+ * @returns {App.ServiceConfigProperty}
+ * @private
+ */
+ _initAsHostWithComponent: function (configProperty, localDB, dependencies, initializer) {
+ var component = localDB.masterComponentHosts.findProperty('component', initializer.component);
+ if (!component) {
+ return configProperty;
+ }
+ if (initializer.modifier) {
+ var replaceWith = Em.getWithDefault(initializer.modifier, 'prefix', '')
+ + component.hostName
+ + Em.getWithDefault(initializer.modifier, 'suffix', '');
+ this.setRecommendedValue(configProperty, initializer.modifier.regex, replaceWith);
+ }
+ else {
+ configProperty.setProperties({
+ recommendedValue: component.hostName,
+ value: component.hostName
+ })
+ }
+
+ return configProperty;
+ },
+
+ /**
+ * Initializer for configs with value equal to hostNames with needed components
+ * May be array or comma-separated list
+ * Depends on <code>initializer.asArray</code> (true - array, false - string)
+ * Value example: 'hostName1,hostName2,hostName3' or ['hostName1', 'hostName2', 'hostName3']
+ *
+ * @param {App.ServiceConfigProperty} configProperty
+ * @param {topologyLocalDB} localDB
+ * @param {object} dependencies
+ * @param {object} initializer
+ * @return {App.ServiceConfigProperty}
+ * @private
+ */
+ _initAsHostsWithComponents: function (configProperty, localDB, dependencies, initializer) {
+ var hostNames = localDB.masterComponentHosts.filter(function (masterComponent) {
+ return initializer.components.contains(masterComponent.component);
+ }).mapProperty('hostName');
+ if (!initializer.asArray) {
+ hostNames = hostNames.uniq().join(',');
+ }
+ configProperty.setProperties({
+ value: hostNames,
+ recommendedValue: hostNames
+ });
+ return configProperty;
+ },
+
+ /**
+ * Unique initializer for <code>hive_database</code>-config
+ *
+ * @param {App.ServiceConfigProperty} configProperty
+ * @returns {App.ServiceConfigProperty}
+ * @private
+ */
+ _initHiveDatabaseValue: function (configProperty) {
+ var newMySQLDBOption = configProperty.get('options').findProperty('displayName', 'New MySQL Database');
+ if (newMySQLDBOption) {
+ var isNewMySQLDBOptionHidden = !App.get('supports.alwaysEnableManagedMySQLForHive') && App.get('router.currentState.name') != 'configs' &&
+ !App.get('isManagedMySQLForHiveEnabled');
+ if (isNewMySQLDBOptionHidden && configProperty.get('value') == 'New MySQL Database') {
+ configProperty.set('value', 'Existing MySQL Database');
+ }
+ Em.set(newMySQLDBOption, 'hidden', isNewMySQLDBOptionHidden);
+ }
+ return configProperty;
+ },
+
+ /**
+ * Initializer for configs with value equal to hostNames-list where ZOOKEEPER_SERVER is installed
+ * Value example: 'host1:2020,host2:2020,host3:2020'
+ *
+ * @param {App.ServiceConfigProperty} configProperty
+ * @param {topologyLocalDB} localDB
+ * @returns {App.ServiceConfigProperty}
+ * @private
+ */
+ _initAsZookeeperServersList: function (configProperty, localDB) {
+ var zkHosts = localDB.masterComponentHosts.filterProperty('component', 'ZOOKEEPER_SERVER').mapProperty('hostName');
+ var zkHostPort = zkHosts;
+ var regex = '\\w*:(\\d+)'; //regex to fetch the port
+ var portValue = configProperty.get('recommendedValue') && configProperty.get('recommendedValue').match(new RegExp(regex));
+ if (!portValue) {
+ return configProperty;
+ }
+ if (portValue[1]) {
+ for ( var i = 0; i < zkHosts.length; i++ ) {
+ zkHostPort[i] = zkHosts[i] + ':' + portValue[1];
+ }
+ }
+ this.setRecommendedValue(configProperty, '(.*)', zkHostPort);
+ return configProperty;
+ },
+
+ /**
+ * Unique initializer for <code>templeton.hive.properties</code>
+ *
+ * @param {App.ServiceConfigProperty} configProperty
+ * @param {topologyLocalDB} localDB
+ * @param {object} dependencies
+ * @returns {App.ServiceConfigProperty}
+ * @private
+ */
+ _initTempletonHiveProperties: function (configProperty, localDB, dependencies) {
+ var hiveMSUris = this.getHiveMetastoreUris(localDB.masterComponentHosts, dependencies['hive.metastore.uris']).replace(',', '\\,');
+ if (/\/\/localhost:/g.test(configProperty.get('value'))) {
+ configProperty.set('recommendedValue', configProperty.get('value') + ',hive.metastore.execute.setugi=true');
+ }
+ this.setRecommendedValue(configProperty, "(hive\\.metastore\\.uris=)([^\\,]+)", "$1" + hiveMSUris);
+ return configProperty;
+ },
+
+ /**
+ * Unique initializer for <code>hbase.zookeeper.quorum</code>
+ *
+ * @param {App.ServiceConfigProperty} configProperty
+ * @param {topologyLocalDB} localDB
+ * @returns {App.ServiceConfigProperty}
+ * @private
+ */
+ _initHBaseZookeeperQuorum: function (configProperty, localDB) {
+ if (configProperty.get('filename') == 'hbase-site.xml') {
+ var zkHosts = localDB.masterComponentHosts.filterProperty('component', 'ZOOKEEPER_SERVER').mapProperty('hostName');
+ this.setRecommendedValue(configProperty, "(.*)", zkHosts);
+ }
+ return configProperty;
+ },
+
+ /**
+ * Unique initializer for <code>RANGER_HOST</code>
+ * If RANGER_ADMIN-component isn't installed, this config becomes unneeded (isVisible - false, isRequired - false)
+ * Value example: 'hostName'
+ *
+ * @param {App.ServiceConfigProperty} configProperty
+ * @param {topologyLocalDB} localDB
+ * @returns {App.ServiceConfigProperty}
+ * @private
+ */
+ _initRangerHost: function (configProperty, localDB) {
+ var rangerAdminHost = localDB.masterComponentHosts.findProperty('component', 'RANGER_ADMIN');
+ if(rangerAdminHost) {
+ configProperty.setProperties({
+ value: rangerAdminHost.hostName,
+ recommendedValue: rangerAdminHost.hostName
+ });
+ }
+ else {
+ configProperty.setProperties({
+ isVisible: 'false',
+ isRequired: 'false'
+ });
+ }
+ return configProperty;
+ },
+
+ /**
+ * Unique initializer for <code>yarn.resourcemanager.zk-address</code>
+ * List of hosts where ZOOKEEPER_SERVER is installed
+ * Port is taken from <code>dependencies.clientPort</code>
+ * Value example: 'host1:111,host2:111,host3:111'
+ *
+ * @param {App.ServiceConfigProperty} configProperty
+ * @param {topologyLocalDB} localDB
+ * @param {object} dependencies
+ * @returns {App.ServiceConfigProperty}
+ * @private
+ */
+ _initYarnRMzkAddress: function (configProperty, localDB, dependencies) {
+ var value = localDB.masterComponentHosts.filterProperty('component', 'ZOOKEEPER_SERVER').map(function (component) {
+ return component.hostName + ':' + dependencies.clientPort
+ }).join(',');
+ configProperty.setProperties({
+ value: value,
+ recommendedValue: value
+ });
+ return configProperty;
+ },
+
+ /**
+ * Unique initializer for <code>hive.metastore.uris</code>
+ *
+ * @param {App.ServiceConfigProperty} configProperty
+ * @param {topologyLocalDB} localDB
+ * @param {object} dependencies
+ * @returns {App.ServiceConfigProperty}
+ * @private
+ */
+ _initHiveMetastoreUris: function (configProperty, localDB, dependencies) {
+ var hiveMSUris = this.getHiveMetastoreUris(localDB.masterComponentHosts, dependencies['hive.metastore.uris']);
+ if (hiveMSUris) {
+ this.setRecommendedValue(configProperty, "(.*)", hiveMSUris);
+ }
+ return configProperty;
+ },
+
+ /**
+ * Entry-point for any config's value initializing
+ * Before calling it, be sure that <code>initializers</code> or <code>uniqueInitializers</code>
+ * contains record about needed config
+ *
+ * @param {App.ServiceConfigProperty} configProperty
+ * @param {topologyLocalDB} localDB
+ * @param {object} dependencies
+ * @returns {App.ServiceConfigProperty}
+ */
+ initialValue: function (configProperty, localDB, dependencies) {
+ var configName = configProperty.get('name');
+
+ var initializer = initializers[configName];
+ if (initializer) {
+ return this._defaultInitializer(configProperty, localDB, dependencies);
+ }
+
+ var uniqueInitializer = uniqueInitializers[configName];
+ if (uniqueInitializer) {
+ var args = [].slice.call(arguments);
+ return this[uniqueInitializer].apply(this, args);
+ }
+
+ return configProperty;
+ },
+
+ /**
+ * Get hive.metastore.uris initial value
+ *
+ * @param {object[]} hosts
+ * @param {string} recommendedValue
+ * @returns {string}
+ */
+ getHiveMetastoreUris: function (hosts, recommendedValue) {
+ var hiveMSHosts = hosts.filterProperty('component', 'HIVE_METASTORE').mapProperty('hostName'),
+ hiveMSUris = hiveMSHosts,
+ regex = "\\w*:(\\d+)",
+ portValue = recommendedValue && recommendedValue.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(',');
+ },
+
+ /**
+ * Set <code>value</code> and <code>recommendedValue</code> for <code>configProperty</code>
+ * basing on <code>recommendedValue</code> with replacing <code>regex</code> for <code>replaceWith</code>
+ *
+ * @param {App.ServiceConfigProperty} configProperty
+ * @param {string} regex
+ * @param {string} replaceWith
+ * @return {App.ServiceConfigProperty}
+ */
+ setRecommendedValue: function (configProperty, regex, replaceWith) {
+ var recommendedValue = Em.isNone(configProperty.get('recommendedValue')) ? '' : configProperty.get('recommendedValue');
+ var re = new RegExp(regex);
+ recommendedValue = recommendedValue.replace(re, replaceWith);
+ configProperty.set('recommendedValue', recommendedValue);
+ configProperty.set('value', Em.isNone(configProperty.get('recommendedValue')) ? '' : configProperty.get('recommendedValue'));
+ return configProperty;
+ },
+
+ /**
+ * Initializer for configs with value as one of the possible mount points
+ * Only hosts that contains on the components from <code>initializer.components</code> are processed
+ * Hosts with Windows needs additional processing (@see winReplacersMap)
+ * Value example: '/', '/some/cool/dir'
+ *
+ * @param {App.ServiceConfigProperty} configProperty
+ * @param {topologyLocalDB} localDB
+ * @param {object} dependencies
+ * @param {object} initializer
+ * @return {App.ServiceConfigProperty}
+ */
+ _initAsSingleMountPoint: function (configProperty, localDB, dependencies, initializer) {
+ var hostsInfo = this._updateHostInfo(localDB.hosts);
+ var setOfHostNames = this._getSetOfHostNames(localDB, initializer);
+ // In Add Host Wizard, if we did not select this slave component for any host, then we don't process any further.
+ if (!setOfHostNames.length) {
+ return configProperty;
+ }
+ var allMountPoints = this._getAllMountPoints(setOfHostNames, hostsInfo);
+
+ var mPoint = allMountPoints[0].mountpoint;
+ if (mPoint === "/") {
+ mPoint = configProperty.get('recommendedValue');
+ }
+ else {
+ var mp = mPoint.toLowerCase();
+ if (winRegex.test(mp)) {
+ var methodName = initializer.winReplacer;
+ mPoint = this[methodName].call(this, configProperty, mp);
+ }
+ else {
+ mPoint = mPoint + configProperty.get('recommendedValue');
+ }
+ }
+ configProperty.setProperties({
+ value: mPoint,
+ recommendedValue: mPoint
+ });
+
+ return configProperty;
+ },
+
+ /**
+ * Initializer for configs with value as all of the possible mount points
+ * Only hosts that contains on the components from <code>initializer.components</code> are processed
+ * Hosts with Windows needs additional processing (@see winReplacersMap)
+ * Value example: '/\n/some/cool/dir' (`\n` - is divider)
+ *
+ * @param {App.ServiceConfigProperty} configProperty
+ * @param {topologyLocalDB} localDB
+ * @param {object} dependencies
+ * @param {object} initializer
+ * @return {App.ServiceConfigProperty}
+ */
+ _initAsMultipleMountPoints: function (configProperty, localDB, dependencies, initializer) {
+ var hostsInfo = this._updateHostInfo(localDB.hosts);
+ var self = this;
+ var setOfHostNames = this._getSetOfHostNames(localDB, initializer);
+ // In Add Host Wizard, if we did not select this slave component for any host, then we don't process any further.
+ if (!setOfHostNames.length) {
+ return configProperty;
+ }
+
+ var allMountPoints = this._getAllMountPoints(setOfHostNames, hostsInfo);
+ var mPoint = '';
+
+ allMountPoints.forEach(function (eachDrive) {
+ if (eachDrive.mountpoint === '/') {
+ mPoint += configProperty.get('recommendedValue') + "\n";
+ }
+ else {
+ var mp = eachDrive.mountpoint.toLowerCase();
+ if (winRegex.test(mp)) {
+ var methodName = initializer.winReplacer;
+ mPoint += self[methodName].call(this, configProperty, mp);
+ }
+ else {
+ mPoint += eachDrive.mountpoint + configProperty.get('recommendedValue') + "\n";
+ }
+ }
+ }, this);
+
+ configProperty.setProperties({
+ value: mPoint,
+ recommendedValue: mPoint
+ });
+
+ return configProperty;
+ },
+
+ /**
+ * Replace drive-based windows-path with 'file:///'
+ *
+ * @param {App.ServiceConfigProperty} configProperty
+ * @param {string} mountPoint
+ * @returns {string}
+ * @private
+ */
+ _winReplaceWithFile: function (configProperty, mountPoint) {
+ var winDriveUrl = mountPoint.toLowerCase().replace(winRegex, 'file:///$1:');
+ return winDriveUrl + configProperty.get('recommendedValue') + '\n';
+ },
+
+ /**
+ * Replace drive-based windows-path
+ *
+ * @param {App.ServiceConfigProperty} configProperty
+ * @param {string} mountPoint
+ * @returns {string}
+ * @private
+ */
+ _defaultWinReplace: function (configProperty, mountPoint) {
+ var winDrive = mountPoint.toLowerCase().replace(winRegex, '$1:');
+ var winDir = configProperty.get('recommendedValue').replace(/\//g, '\\');
+ return winDrive + winDir + '\n';
+ },
+
+ /**
+ * Same to <code>_defaultWinReplace</code>, but with extra-slash in the end
+ *
+ * @param {App.ServiceConfigProperty} configProperty
+ * @param {string} mountPoint
+ * @returns {string}
+ * @private
+ */
+ _defaultWinReplaceWithAdditionalSlashes: function (configProperty, mountPoint) {
+ var winDrive = mountPoint.toLowerCase().replace(winRegex, '$1:');
+ var winDir = configProperty.get('recommendedValue').replace(/\//g, '\\\\');
+ return winDrive + winDir + '\n';
+ },
+
+ /**
+ * Update information from localDB using <code>App.Host</code>-model
+ *
+ * @param {object} hostsInfo
+ * @returns {object}
+ * @private
+ */
+ _updateHostInfo: function (hostsInfo) {
+ App.Host.find().forEach(function (item) {
+ if (!hostsInfo[item.get('id')]) {
+ hostsInfo[item.get('id')] = {
+ name: item.get('id'),
+ cpu: item.get('cpu'),
+ memory: item.get('memory'),
+ disk_info: item.get('diskInfo'),
+ bootStatus: "REGISTERED",
+ isInstalled: true
+ };
+ }
+ });
+ return hostsInfo;
+ },
+
+ /**
+ * Determines if mount point is valid
+ * Criterias:
+ * <ul>
+ * <li>Should has available space</li>
+ * <li>Should not be home-dir</li>
+ * <li>Should not be docker-dir</li>
+ * <li>Should not be boot-dir</li>
+ * <li>Should not be dev-dir</li>
+ * </ul>
+ *
+ * @param {{mountpoint: string, available: number}} mPoint
+ * @returns {boolean} true - valid, false - invalid
+ * @private
+ */
+ _filterMountPoint: function (mPoint) {
+ var isAvailable = mPoint.available !== 0;
+ if (!isAvailable) {
+ return false;
+ }
+
+ var notHome = !['/', '/home'].contains(mPoint.mountpoint);
+ var notDocker = !['/etc/resolv.conf', '/etc/hostname', '/etc/hosts'].contains(mPoint.mountpoint);
+ var notBoot = mPoint.mountpoint && !(mPoint.mountpoint.startsWith('/boot') || mPoint.mountpoint.startsWith('/mnt'));
+ var notDev = !(['devtmpfs', 'tmpfs', 'vboxsf', 'CDFS'].contains(mPoint.type));
+
+ return notHome && notDocker && notBoot && notDev;
+ },
+
+ /**
+ * Get list of hostNames from localDB which contains needed components
+ *
+ * @param {topologyLocalDB} localDB
+ * @param {object} initializer
+ * @returns {string[]}
+ * @private
+ */
+ _getSetOfHostNames: function (localDB, initializer) {
+ var masterComponentHostsInDB = localDB.masterComponentHosts;
+ var slaveComponentHostsInDB = localDB.slaveComponentHosts;
+ var hosts = masterComponentHostsInDB.filter(function (master) {
+ return initializer.components.contains(master.component);
+ }).mapProperty('hostName');
+
+ var sHosts = slaveComponentHostsInDB.find(function (slave) {
+ return initializer.components.contains(slave.componentName);
+ });
+ if (sHosts) {
+ hosts = hosts.concat(sHosts.hosts.mapProperty('hostName'));
+ }
+ return hosts;
+ },
+
+ /**
+ * Get list of all unique valid mount points for hosts
+ *
+ * @param {string[]} setOfHostNames
+ * @param {object} hostsInfo
+ * @returns {string[]}
+ * @private
+ */
+ _getAllMountPoints: function (setOfHostNames, hostsInfo) {
+ var allMountPoints = [];
+ for (var i = 0; i < setOfHostNames.length; i++) {
+ var hostname = setOfHostNames[i];
+ var mountPointsPerHost = hostsInfo[hostname].disk_info;
+ var mountPointAsRoot = mountPointsPerHost.findProperty('mountpoint', '/');
+
+ // If Server does not send any host details information then atleast one mountpoint should be presumed as root
+ // This happens in a single container Linux Docker environment.
+ if (!mountPointAsRoot) {
+ mountPointAsRoot = {
+ mountpoint: '/'
+ };
+ }
+
+ mountPointsPerHost.filter(this._filterMountPoint).forEach(function (mPoint) {
+ if( !allMountPoints.findProperty("mountpoint", mPoint.mountpoint)) {
+ allMountPoints.push(mPoint);
+ }
+ }, this);
+ }
+
+ if (!allMountPoints.length) {
+ allMountPoints.push(mountPointAsRoot);
+ }
+ return allMountPoints;
+ },
+
+
+ __testGetInitializers: function () {
+ if ($.mocho) {
+ return initializers;
+ }
+ Em.assert('Available only for testing', false);
+ },
+
+ __testGetUniqueInitializers: function () {
+ if ($.mocho) {
+ return uniqueInitializers;
+ }
+ Em.assert('Available only for testing', false);
+ },
+
+ __testGetInitializerTypes: function () {
+ if ($.mocho) {
+ return initializerTypes;
+ }
+ Em.assert('Available only for testing', false);
+ },
+
+ __testGetWinReplacersMap: function () {
+ if ($.mocho) {
+ return winReplacersMap;
+ }
+ Em.assert('Available only for testing', false);
+ }
+
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/da8ca2ae/ambari-web/app/utils/configs/config_property_helper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/config_property_helper.js b/ambari-web/app/utils/configs/config_property_helper.js
deleted file mode 100644
index 11dddec..0000000
--- a/ambari-web/app/utils/configs/config_property_helper.js
+++ /dev/null
@@ -1,905 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var App = require('app');
-
-/**
- * Regexp for host with port ('hostName:1234')
- *
- * @type {string}
- */
-var hostWithPort = "([\\w|\\.]*)(?=:)";
-
-/**
- * Regexp for host with port and protocol ('://hostName:1234')
- *
- * @type {string}
- */
-var hostWithPrefix = ":\/\/" + hostWithPort;
-
-/**
- * Regexp used to determine if mount point is windows-like
- *
- * @type {RegExp}
- */
-var winRegex = /^([a-z]):\\?$/;
-
-/**
- * Map with initializers types
- * Doesn't contain unique initializes, only common are included
- * Key: id
- * Value: object with method-name (prefer to start method-name with '_init' or '_initAs')
- * Each method here is called with arguments equal to <code>initialValue</code>-call args
- * Initializer-settings are added as last argument
- *
- * @type {object}
- */
-var initializerTypes = {
- host_with_component: {
- method: '_initAsHostWithComponent'
- },
- hosts_with_components: {
- method: '_initAsHostsWithComponents'
- },
- zookeeper_based: {
- method: '_initAsZookeeperServersList'
- },
- single_mountpoint: {
- method: '_initAsSingleMountPoint'
- },
- multiple_mountpoints: {
- method: '_initAsMultipleMountPoints'
- }
-};
-
-/**
- * Map for methods used as value-modifiers for configProperties with values as mount point(s)
- * Used if mount point is win-like (@see winRegex)
- * Key: id
- * Value: method-name
- *
- * @type {{default: string, file: string, slashes: string}}
- */
-var winReplacersMap = {
- default: '_defaultWinReplace',
- file: '_winReplaceWithFile',
- slashes: '_defaultWinReplaceWithAdditionalSlashes'
-};
-
-/**
- * Settings for <code>host_with_component</code>-initializer
- * Used for configs with value equal to hostName that has <code>component</code>
- * Value may be modified with if <code>withModifier</code> is true (it is by default)
- * <code>hostWithPort</code>-regexp will be used in this case
- *
- * @see _initAsHostWithComponent
- * @param {string} component
- * @param {boolean} [withModifier=true]
- * @return {object}
- */
-function getSimpleComponentConfig(component, withModifier) {
- if (arguments.length === 1) {
- withModifier = true;
- }
- var config = {
- type: 'host_with_component',
- component: component
- };
- if (withModifier) {
- config.modifier = {
- type: 'regexp',
- regex: hostWithPort
- }
- }
- return config;
-}
-
-/**
- * Zookeeper-based configs don't have any customization settings
- *
- * @see _initAsZookeeperServersList
- * @returns {{type: string}}
- */
-function getZKBasedConfig() {
- return {
- type: 'zookeeper_based'
- };
-}
-
-/**
- * Almost the same to <code>getSimpleComponentConfig</code>, but with possibility to modify <code>replaceWith</code>-value
- * <code>prefix</code> is added before it
- * <code>suffix</code> is added after it
- * <code>hostWithPrefix</code>-regexp is used
- *
- * @see _initAsHostWithComponent
- * @param {string} component
- * @param {string} [prefix]
- * @param {string} [suffix]
- * @returns {object}
- */
-function getComponentConfigWithAffixes (component, prefix, suffix) {
- prefix = prefix || '';
- suffix = suffix || '';
- return {
- type: 'host_with_component',
- component: component,
- modifier: {
- type: 'regexp',
- regex: hostWithPrefix,
- prefix: prefix,
- suffix: suffix
- }
- };
-}
-
-/**
- * Settings for <code>hosts_with_components</code>-initializer
- * Used for configs with value equal to the hosts list
- * May set value as array (if <code>asArray</code> is true) or as comma-sepratated string (if <code>asArray</code> is false)
- *
- * @see _initAsHostsWithComponents
- * @param {string|string[]} components
- * @param {boolean} [asArray=false]
- * @returns {{type: string, components: string[], asArray: boolean}}
- */
-function getComponentsHostsConfig(components, asArray) {
- if (1 === arguments.length) {
- asArray = false;
- }
- return {
- type: 'hosts_with_components',
- components: Em.makeArray(components),
- asArray: asArray
- };
-}
-
-/**
- * Settings for <code>single_mountpoint</code>-initializer
- * Used for configs with value as one of the possible mount points
- *
- * @see _initAsSingleMountPoint
- * @param {string|string[]} components
- * @param {string} winReplacer
- * @returns {{components: string[], winReplacer: string, type: string}}
- */
-function getSingleMountPointConfig(components, winReplacer) {
- winReplacer = winReplacer || 'default';
- Em.assert('Invalid `winReplacer` selected - `' + winReplacer + '`! See winReplacersMap for available replacers.', !!winReplacersMap[winReplacer]);
- return {
- components: Em.makeArray(components),
- winReplacer: winReplacersMap[winReplacer],
- type: 'single_mountpoint'
- }
-}
-
-/**
- * Settings for <code>multiple_mountpoints</code>-initializer
- * Used for configs with value as all of the possible mount points
- *
- * @see _initAsMultipleMountPoints
- * @param {string|string[]} components
- * @param {string} winReplacer
- * @returns {{components: string[], winReplacer: string, type: string}}
- */
-function getMultipleMountPointsConfig(components, winReplacer) {
- winReplacer = winReplacer || 'default';
- Em.assert('Invalid `winReplacer` selected - `' + winReplacer + '`! See winReplacersMap for available replacers.', !!winReplacersMap[winReplacer]);
- return {
- components: Em.makeArray(components),
- winReplacer: winReplacersMap[winReplacer],
- type: 'multiple_mountpoints'
- }
-}
-
-/**
- * Map with configurations for config initializers
- * It's used only for initializers which are common for some configs (if not - use <code>uniqueInitializers</code>-map)
- * Key {string} configProperty-name
- * Value {object} settings for initializer
- *
- * @type {object}
- */
-var initializers = {
- 'dfs.namenode.rpc-address': getSimpleComponentConfig('NAMENODE'),
- 'dfs.http.address': getSimpleComponentConfig('NAMENODE'),
- 'dfs.namenode.http-address': getSimpleComponentConfig('NAMENODE'),
- 'dfs.https.address': getSimpleComponentConfig('NAMENODE'),
- 'dfs.namenode.https-address': getSimpleComponentConfig('NAMENODE'),
- 'dfs.secondary.http.address': getSimpleComponentConfig('SECONDARY_NAMENODE'),
- 'dfs.namenode.secondary.http-address': getSimpleComponentConfig('SECONDARY_NAMENODE'),
- 'yarn.resourcemanager.hostname': getSimpleComponentConfig('RESOURCEMANAGER', false),
- 'yarn.resourcemanager.resource-tracker.address': getSimpleComponentConfig('RESOURCEMANAGER'),
- 'yarn.resourcemanager.webapp.https.address': getSimpleComponentConfig('RESOURCEMANAGER'),
- 'yarn.resourcemanager.webapp.address': getSimpleComponentConfig('RESOURCEMANAGER'),
- 'yarn.resourcemanager.scheduler.address': getSimpleComponentConfig('RESOURCEMANAGER'),
- 'yarn.resourcemanager.address': getSimpleComponentConfig('RESOURCEMANAGER'),
- 'yarn.resourcemanager.admin.address': getSimpleComponentConfig('RESOURCEMANAGER'),
- 'yarn.timeline-service.webapp.address': getSimpleComponentConfig('APP_TIMELINE_SERVER'),
- 'yarn.timeline-service.webapp.https.address': getSimpleComponentConfig('APP_TIMELINE_SERVER'),
- 'yarn.timeline-service.address': getSimpleComponentConfig('APP_TIMELINE_SERVER'),
- 'mapred.job.tracker': getSimpleComponentConfig('JOBTRACKER'),
- 'mapred.job.tracker.http.address': getSimpleComponentConfig('JOBTRACKER'),
- 'mapreduce.history.server.http.address': getSimpleComponentConfig('HISTORYSERVER'),
- 'hive_hostname': getSimpleComponentConfig('HIVE_SERVER', false),
- 'oozie_hostname': getSimpleComponentConfig('OOZIE_SERVER', false),
- 'oozie.base.url': getComponentConfigWithAffixes('OOZIE_SERVER', '://'),
- 'hawq_dfs_url': getSimpleComponentConfig('NAMENODE'),
- 'hawq_rm_yarn_address': getSimpleComponentConfig('RESOURCEMANAGER'),
- 'hawq_rm_yarn_scheduler_address': getSimpleComponentConfig('RESOURCEMANAGER'),
- 'fs.default.name': getComponentConfigWithAffixes('NAMENODE', '://'),
- 'fs.defaultFS': getComponentConfigWithAffixes('NAMENODE', '://'),
- 'hbase.rootdir': getComponentConfigWithAffixes('NAMENODE', '://'),
- 'instance.volumes': getComponentConfigWithAffixes('NAMENODE', '://'),
- 'yarn.log.server.url': getComponentConfigWithAffixes('HISTORYSERVER', '://'),
- 'mapreduce.jobhistory.webapp.address': getSimpleComponentConfig('HISTORYSERVER'),
- 'mapreduce.jobhistory.address': getSimpleComponentConfig('HISTORYSERVER'),
- 'kafka.ganglia.metrics.host': getSimpleComponentConfig('GANGLIA_SERVER', false),
- 'hive_master_hosts': getComponentsHostsConfig(['HIVE_METASTORE', 'HIVE_SERVER']),
- 'hadoop_host': getSimpleComponentConfig('NAMENODE', false),
- 'nimbus.host': getSimpleComponentConfig('NIMBUS', false),
- 'nimbus.seeds': getComponentsHostsConfig('NIMBUS', true),
- 'storm.zookeeper.servers': getComponentsHostsConfig('ZOOKEEPER_SERVER', true),
- 'hawq_master_address_host': getSimpleComponentConfig('HAWQMASTER', false),
- 'hawq_standby_address_host': getSimpleComponentConfig('HAWQSTANDBY', false),
-
- '*.broker.url': {
- type: 'host_with_component',
- component: 'FALCON_SERVER',
- modifier: {
- type: 'regexp',
- regex: 'localhost'
- }
- },
-
- 'zookeeper.connect': getZKBasedConfig(),
- 'hive.zookeeper.quorum': getZKBasedConfig(),
- 'templeton.zookeeper.hosts': getZKBasedConfig(),
- 'hadoop.registry.zk.quorum': getZKBasedConfig(),
- 'hive.cluster.delegation.token.store.zookeeper.connectString': getZKBasedConfig(),
- 'instance.zookeeper.host': getZKBasedConfig(),
-
- 'dfs.name.dir': getMultipleMountPointsConfig('NAMENODE', 'file'),
- 'dfs.namenode.name.dir': getMultipleMountPointsConfig('NAMENODE', 'file'),
- 'dfs.data.dir': getMultipleMountPointsConfig('DATANODE', 'file'),
- 'dfs.datanode.data.dir': getMultipleMountPointsConfig('DATANODE', 'file'),
- 'yarn.nodemanager.local-dirs': getMultipleMountPointsConfig('NODEMANAGER'),
- 'yarn.nodemanager.log-dirs': getMultipleMountPointsConfig('NODEMANAGER'),
- 'mapred.local.dir': getMultipleMountPointsConfig(['TASKTRACKER', 'NODEMANAGER']),
- 'log.dirs': getMultipleMountPointsConfig('KAFKA_BROKER'),
-
- 'fs.checkpoint.dir': getSingleMountPointConfig('SECONDARY_NAMENODE', 'file'),
- 'dfs.namenode.checkpoint.dir': getSingleMountPointConfig('SECONDARY_NAMENODE', 'file'),
- 'yarn.timeline-service.leveldb-timeline-store.path': getSingleMountPointConfig('APP_TIMELINE_SERVER'),
- 'yarn.timeline-service.leveldb-state-store.path': getSingleMountPointConfig('APP_TIMELINE_SERVER'),
- 'dataDir': getSingleMountPointConfig('ZOOKEEPER_SERVER'),
- 'oozie_data_dir': getSingleMountPointConfig('OOZIE_SERVER'),
- 'storm.local.dir': getSingleMountPointConfig(['NODEMANAGER', 'NIMBUS']),
- '*.falcon.graph.storage.directory': getSingleMountPointConfig('FALCON_SERVER'),
- '*.falcon.graph.serialize.path': getSingleMountPointConfig('FALCON_SERVER')
-};
-
-/**
- * Map with initializers that are used only for one config (are unique)
- * Key: configProperty-name
- * Value: method-name
- * Every method from this map is called with same arguments as <code>initialValue</code> is (prefer to start method-name with '_init' or '_initAs')
- *
- * @type {object}
- */
-var uniqueInitializers = {
- 'hive_database': '_initHiveDatabaseValue',
- 'templeton.hive.properties': '_initTempletonHiveProperties',
- 'hbase.zookeeper.quorum': '_initHBaseZookeeperQuorum',
- 'yarn.resourcemanager.zk-address': '_initYarnRMzkAddress',
- 'RANGER_HOST': '_initRangerHost',
- 'hive.metastore.uris': '_initHiveMetastoreUris'
-};
-
-/**
- * Helper-object used to set initial value for some configs
- *
- * Usage:
- * <pre>
- * var configProperty = App.ServiceConfigProperty.create({});
- * var localDB = {
- * hosts: [],
- * masterComponentHosts: [],
- * slaveComponentHosts: []
- * };
- * var dependencies = {};
- * configPropertyHelper.initialValue(configProperty, localDB, dependencies);
- * </pre>
- *
- * @type {object}
- */
-module.exports = {
-
- /**
- * Wrapper for common initializers
- * Execute initializer if it is a function or throw an error otherwise
- *
- * @param {App.ServiceConfigProperty} configProperty
- * @param {topologyLocalDB} localDB
- * @param {object} dependencies
- * @returns {App.ServiceConfigProperty}
- * @private
- */
- _defaultInitializer: function (configProperty, localDB, dependencies) {
- var args = [].slice.call(arguments);
- var initializer = initializers[configProperty.get('name')];
- if (initializer) {
- var type = initializerTypes[initializer.type];
- // add initializer-settings
- args.push(initializer);
- var methodName = type.method;
- Em.assert('method-initializer is not a function ' + methodName, 'function' === Em.typeOf(this[methodName]));
- configProperty = this[methodName].apply(this, args);
- }
- return configProperty;
- },
-
- /**
- * Initializer for configs with value equal to hostName with needed component
- * Value example: 'hostName'
- *
- * @param {App.ServiceConfigProperty} configProperty
- * @param {topologyLocalDB} localDB
- * @param {object} dependencies
- * @param {object} initializer
- * @returns {App.ServiceConfigProperty}
- * @private
- */
- _initAsHostWithComponent: function (configProperty, localDB, dependencies, initializer) {
- var component = localDB.masterComponentHosts.findProperty('component', initializer.component);
- if (!component) {
- return configProperty;
- }
- if (initializer.modifier) {
- var replaceWith = Em.getWithDefault(initializer.modifier, 'prefix', '')
- + component.hostName
- + Em.getWithDefault(initializer.modifier, 'suffix', '');
- this.setRecommendedValue(configProperty, initializer.modifier.regex, replaceWith);
- }
- else {
- configProperty.setProperties({
- recommendedValue: component.hostName,
- value: component.hostName
- })
- }
-
- return configProperty;
- },
-
- /**
- * Initializer for configs with value equal to hostNames with needed components
- * May be array or comma-separated list
- * Depends on <code>initializer.asArray</code> (true - array, false - string)
- * Value example: 'hostName1,hostName2,hostName3' or ['hostName1', 'hostName2', 'hostName3']
- *
- * @param {App.ServiceConfigProperty} configProperty
- * @param {topologyLocalDB} localDB
- * @param {object} dependencies
- * @param {object} initializer
- * @return {App.ServiceConfigProperty}
- * @private
- */
- _initAsHostsWithComponents: function (configProperty, localDB, dependencies, initializer) {
- var hostNames = localDB.masterComponentHosts.filter(function (masterComponent) {
- return initializer.components.contains(masterComponent.component);
- }).mapProperty('hostName');
- if (!initializer.asArray) {
- hostNames = hostNames.uniq().join(',');
- }
- configProperty.setProperties({
- value: hostNames,
- recommendedValue: hostNames
- });
- return configProperty;
- },
-
- /**
- * Unique initializer for <code>hive_database</code>-config
- *
- * @param {App.ServiceConfigProperty} configProperty
- * @returns {App.ServiceConfigProperty}
- * @private
- */
- _initHiveDatabaseValue: function (configProperty) {
- var newMySQLDBOption = configProperty.get('options').findProperty('displayName', 'New MySQL Database');
- if (newMySQLDBOption) {
- var isNewMySQLDBOptionHidden = !App.get('supports.alwaysEnableManagedMySQLForHive') && App.get('router.currentState.name') != 'configs' &&
- !App.get('isManagedMySQLForHiveEnabled');
- if (isNewMySQLDBOptionHidden && configProperty.get('value') == 'New MySQL Database') {
- configProperty.set('value', 'Existing MySQL Database');
- }
- Em.set(newMySQLDBOption, 'hidden', isNewMySQLDBOptionHidden);
- }
- return configProperty;
- },
-
- /**
- * Initializer for configs with value equal to hostNames-list where ZOOKEEPER_SERVER is installed
- * Value example: 'host1:2020,host2:2020,host3:2020'
- *
- * @param {App.ServiceConfigProperty} configProperty
- * @param {topologyLocalDB} localDB
- * @returns {App.ServiceConfigProperty}
- * @private
- */
- _initAsZookeeperServersList: function (configProperty, localDB) {
- var zkHosts = localDB.masterComponentHosts.filterProperty('component', 'ZOOKEEPER_SERVER').mapProperty('hostName');
- var zkHostPort = zkHosts;
- var regex = '\\w*:(\\d+)'; //regex to fetch the port
- var portValue = configProperty.get('recommendedValue') && configProperty.get('recommendedValue').match(new RegExp(regex));
- if (!portValue) {
- return configProperty;
- }
- if (portValue[1]) {
- for ( var i = 0; i < zkHosts.length; i++ ) {
- zkHostPort[i] = zkHosts[i] + ':' + portValue[1];
- }
- }
- this.setRecommendedValue(configProperty, '(.*)', zkHostPort);
- return configProperty;
- },
-
- /**
- * Unique initializer for <code>templeton.hive.properties</code>
- *
- * @param {App.ServiceConfigProperty} configProperty
- * @param {topologyLocalDB} localDB
- * @param {object} dependencies
- * @returns {App.ServiceConfigProperty}
- * @private
- */
- _initTempletonHiveProperties: function (configProperty, localDB, dependencies) {
- var hiveMSUris = this.getHiveMetastoreUris(localDB.masterComponentHosts, dependencies['hive.metastore.uris']).replace(',', '\\,');
- if (/\/\/localhost:/g.test(configProperty.get('value'))) {
- configProperty.set('recommendedValue', configProperty.get('value') + ',hive.metastore.execute.setugi=true');
- }
- this.setRecommendedValue(configProperty, "(hive\\.metastore\\.uris=)([^\\,]+)", "$1" + hiveMSUris);
- return configProperty;
- },
-
- /**
- * Unique initializer for <code>hbase.zookeeper.quorum</code>
- *
- * @param {App.ServiceConfigProperty} configProperty
- * @param {topologyLocalDB} localDB
- * @returns {App.ServiceConfigProperty}
- * @private
- */
- _initHBaseZookeeperQuorum: function (configProperty, localDB) {
- if (configProperty.get('filename') == 'hbase-site.xml') {
- var zkHosts = localDB.masterComponentHosts.filterProperty('component', 'ZOOKEEPER_SERVER').mapProperty('hostName');
- this.setRecommendedValue(configProperty, "(.*)", zkHosts);
- }
- return configProperty;
- },
-
- /**
- * Unique initializer for <code>RANGER_HOST</code>
- * If RANGER_ADMIN-component isn't installed, this config becomes unneeded (isVisible - false, isRequired - false)
- * Value example: 'hostName'
- *
- * @param {App.ServiceConfigProperty} configProperty
- * @param {topologyLocalDB} localDB
- * @returns {App.ServiceConfigProperty}
- * @private
- */
- _initRangerHost: function (configProperty, localDB) {
- var rangerAdminHost = localDB.masterComponentHosts.findProperty('component', 'RANGER_ADMIN');
- if(rangerAdminHost) {
- configProperty.setProperties({
- value: rangerAdminHost.hostName,
- recommendedValue: rangerAdminHost.hostName
- });
- }
- else {
- configProperty.setProperties({
- isVisible: 'false',
- isRequired: 'false'
- });
- }
- return configProperty;
- },
-
- /**
- * Unique initializer for <code>yarn.resourcemanager.zk-address</code>
- * List of hosts where ZOOKEEPER_SERVER is installed
- * Port is taken from <code>dependencies.clientPort</code>
- * Value example: 'host1:111,host2:111,host3:111'
- *
- * @param {App.ServiceConfigProperty} configProperty
- * @param {topologyLocalDB} localDB
- * @param {object} dependencies
- * @returns {App.ServiceConfigProperty}
- * @private
- */
- _initYarnRMzkAddress: function (configProperty, localDB, dependencies) {
- var value = localDB.masterComponentHosts.filterProperty('component', 'ZOOKEEPER_SERVER').map(function (component) {
- return component.hostName + ':' + dependencies.clientPort
- }).join(',');
- configProperty.setProperties({
- value: value,
- recommendedValue: value
- });
- return configProperty;
- },
-
- /**
- * Unique initializer for <code>hive.metastore.uris</code>
- *
- * @param {App.ServiceConfigProperty} configProperty
- * @param {topologyLocalDB} localDB
- * @param {object} dependencies
- * @returns {App.ServiceConfigProperty}
- * @private
- */
- _initHiveMetastoreUris: function (configProperty, localDB, dependencies) {
- var hiveMSUris = this.getHiveMetastoreUris(localDB.masterComponentHosts, dependencies['hive.metastore.uris']);
- if (hiveMSUris) {
- this.setRecommendedValue(configProperty, "(.*)", hiveMSUris);
- }
- return configProperty;
- },
-
- /**
- * Entry-point for any config's value initializing
- * Before calling it, be sure that <code>initializers</code> or <code>uniqueInitializers</code>
- * contains record about needed config
- *
- * @param {App.ServiceConfigProperty} configProperty
- * @param {topologyLocalDB} localDB
- * @param {object} dependencies
- * @returns {App.ServiceConfigProperty}
- */
- initialValue: function (configProperty, localDB, dependencies) {
- var configName = configProperty.get('name');
-
- var initializer = initializers[configName];
- if (initializer) {
- return this._defaultInitializer(configProperty, localDB, dependencies);
- }
-
- var uniqueInitializer = uniqueInitializers[configName];
- if (uniqueInitializer) {
- var args = [].slice.call(arguments);
- return this[uniqueInitializer].apply(this, args);
- }
-
- return configProperty;
- },
-
- /**
- * Get hive.metastore.uris initial value
- *
- * @param {object[]} hosts
- * @param {string} recommendedValue
- * @returns {string}
- */
- getHiveMetastoreUris: function (hosts, recommendedValue) {
- var hiveMSHosts = hosts.filterProperty('component', 'HIVE_METASTORE').mapProperty('hostName'),
- hiveMSUris = hiveMSHosts,
- regex = "\\w*:(\\d+)",
- portValue = recommendedValue && recommendedValue.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(',');
- },
-
- /**
- * Set <code>value</code> and <code>recommendedValue</code> for <code>configProperty</code>
- * basing on <code>recommendedValue</code> with replacing <code>regex</code> for <code>replaceWith</code>
- *
- * @param {App.ServiceConfigProperty} configProperty
- * @param {string} regex
- * @param {string} replaceWith
- * @return {App.ServiceConfigProperty}
- */
- setRecommendedValue: function (configProperty, regex, replaceWith) {
- var recommendedValue = Em.isNone(configProperty.get('recommendedValue')) ? '' : configProperty.get('recommendedValue');
- var re = new RegExp(regex);
- recommendedValue = recommendedValue.replace(re, replaceWith);
- configProperty.set('recommendedValue', recommendedValue);
- configProperty.set('value', Em.isNone(configProperty.get('recommendedValue')) ? '' : configProperty.get('recommendedValue'));
- return configProperty;
- },
-
- /**
- * Initializer for configs with value as one of the possible mount points
- * Only hosts that contains on the components from <code>initializer.components</code> are processed
- * Hosts with Windows needs additional processing (@see winReplacersMap)
- * Value example: '/', '/some/cool/dir'
- *
- * @param {App.ServiceConfigProperty} configProperty
- * @param {topologyLocalDB} localDB
- * @param {object} dependencies
- * @param {object} initializer
- * @return {App.ServiceConfigProperty}
- */
- _initAsSingleMountPoint: function (configProperty, localDB, dependencies, initializer) {
- var hostsInfo = this._updateHostInfo(localDB.hosts);
- var setOfHostNames = this._getSetOfHostNames(localDB, initializer);
- // In Add Host Wizard, if we did not select this slave component for any host, then we don't process any further.
- if (!setOfHostNames.length) {
- return configProperty;
- }
- var allMountPoints = this._getAllMountPoints(setOfHostNames, hostsInfo);
-
- var mPoint = allMountPoints[0].mountpoint;
- if (mPoint === "/") {
- mPoint = configProperty.get('recommendedValue');
- }
- else {
- var mp = mPoint.toLowerCase();
- if (winRegex.test(mp)) {
- var methodName = initializer.winReplacer;
- mPoint = this[methodName].call(this, configProperty, mp);
- }
- else {
- mPoint = mPoint + configProperty.get('recommendedValue');
- }
- }
- configProperty.setProperties({
- value: mPoint,
- recommendedValue: mPoint
- });
-
- return configProperty;
- },
-
- /**
- * Initializer for configs with value as all of the possible mount points
- * Only hosts that contains on the components from <code>initializer.components</code> are processed
- * Hosts with Windows needs additional processing (@see winReplacersMap)
- * Value example: '/\n/some/cool/dir' (`\n` - is divider)
- *
- * @param {App.ServiceConfigProperty} configProperty
- * @param {topologyLocalDB} localDB
- * @param {object} dependencies
- * @param {object} initializer
- * @return {App.ServiceConfigProperty}
- */
- _initAsMultipleMountPoints: function (configProperty, localDB, dependencies, initializer) {
- var hostsInfo = this._updateHostInfo(localDB.hosts);
- var self = this;
- var setOfHostNames = this._getSetOfHostNames(localDB, initializer);
- // In Add Host Wizard, if we did not select this slave component for any host, then we don't process any further.
- if (!setOfHostNames.length) {
- return configProperty;
- }
-
- var allMountPoints = this._getAllMountPoints(setOfHostNames, hostsInfo);
- var mPoint = '';
-
- allMountPoints.forEach(function (eachDrive) {
- if (eachDrive.mountpoint === '/') {
- mPoint += configProperty.get('recommendedValue') + "\n";
- }
- else {
- var mp = eachDrive.mountpoint.toLowerCase();
- if (winRegex.test(mp)) {
- var methodName = initializer.winReplacer;
- mPoint += self[methodName].call(this, configProperty, mp);
- }
- else {
- mPoint += eachDrive.mountpoint + configProperty.get('recommendedValue') + "\n";
- }
- }
- }, this);
-
- configProperty.setProperties({
- value: mPoint,
- recommendedValue: mPoint
- });
-
- return configProperty;
- },
-
- /**
- * Replace drive-based windows-path with 'file:///'
- *
- * @param {App.ServiceConfigProperty} configProperty
- * @param {string} mountPoint
- * @returns {string}
- * @private
- */
- _winReplaceWithFile: function (configProperty, mountPoint) {
- var winDriveUrl = mountPoint.toLowerCase().replace(winRegex, 'file:///$1:');
- return winDriveUrl + configProperty.get('recommendedValue') + '\n';
- },
-
- /**
- * Replace drive-based windows-path
- *
- * @param {App.ServiceConfigProperty} configProperty
- * @param {string} mountPoint
- * @returns {string}
- * @private
- */
- _defaultWinReplace: function (configProperty, mountPoint) {
- var winDrive = mountPoint.toLowerCase().replace(winRegex, '$1:');
- var winDir = configProperty.get('recommendedValue').replace(/\//g, '\\');
- return winDrive + winDir + '\n';
- },
-
- /**
- * Same to <code>_defaultWinReplace</code>, but with extra-slash in the end
- *
- * @param {App.ServiceConfigProperty} configProperty
- * @param {string} mountPoint
- * @returns {string}
- * @private
- */
- _defaultWinReplaceWithAdditionalSlashes: function (configProperty, mountPoint) {
- var winDrive = mountPoint.toLowerCase().replace(winRegex, '$1:');
- var winDir = configProperty.get('recommendedValue').replace(/\//g, '\\\\');
- return winDrive + winDir + '\n';
- },
-
- /**
- * Update information from localDB using <code>App.Host</code>-model
- *
- * @param {object} hostsInfo
- * @returns {object}
- * @private
- */
- _updateHostInfo: function (hostsInfo) {
- App.Host.find().forEach(function (item) {
- if (!hostsInfo[item.get('id')]) {
- hostsInfo[item.get('id')] = {
- name: item.get('id'),
- cpu: item.get('cpu'),
- memory: item.get('memory'),
- disk_info: item.get('diskInfo'),
- bootStatus: "REGISTERED",
- isInstalled: true
- };
- }
- });
- return hostsInfo;
- },
-
- /**
- * Determines if mount point is valid
- * Criterias:
- * <ul>
- * <li>Should has available space</li>
- * <li>Should not be home-dir</li>
- * <li>Should not be docker-dir</li>
- * <li>Should not be boot-dir</li>
- * <li>Should not be dev-dir</li>
- * </ul>
- *
- * @param {{mountpoint: string, available: number}} mPoint
- * @returns {boolean} true - valid, false - invalid
- * @private
- */
- _filterMountPoint: function (mPoint) {
- var isAvailable = mPoint.available !== 0;
- if (!isAvailable) {
- return false;
- }
-
- var notHome = !['/', '/home'].contains(mPoint.mountpoint);
- var notDocker = !['/etc/resolv.conf', '/etc/hostname', '/etc/hosts'].contains(mPoint.mountpoint);
- var notBoot = mPoint.mountpoint && !(mPoint.mountpoint.startsWith('/boot') || mPoint.mountpoint.startsWith('/mnt'));
- var notDev = !(['devtmpfs', 'tmpfs', 'vboxsf', 'CDFS'].contains(mPoint.type));
-
- return notHome && notDocker && notBoot && notDev;
- },
-
- /**
- * Get list of hostNames from localDB which contains needed components
- *
- * @param {topologyLocalDB} localDB
- * @param {object} initializer
- * @returns {string[]}
- * @private
- */
- _getSetOfHostNames: function (localDB, initializer) {
- var masterComponentHostsInDB = localDB.masterComponentHosts;
- var slaveComponentHostsInDB = localDB.slaveComponentHosts;
- var hosts = masterComponentHostsInDB.filter(function (master) {
- return initializer.components.contains(master.component);
- }).mapProperty('hostName');
-
- var sHosts = slaveComponentHostsInDB.find(function (slave) {
- return initializer.components.contains(slave.componentName);
- });
- if (sHosts) {
- hosts = hosts.concat(sHosts.hosts.mapProperty('hostName'));
- }
- return hosts;
- },
-
- /**
- * Get list of all unique valid mount points for hosts
- *
- * @param {string[]} setOfHostNames
- * @param {object} hostsInfo
- * @returns {string[]}
- * @private
- */
- _getAllMountPoints: function (setOfHostNames, hostsInfo) {
- var allMountPoints = [];
- for (var i = 0; i < setOfHostNames.length; i++) {
- var hostname = setOfHostNames[i];
- var mountPointsPerHost = hostsInfo[hostname].disk_info;
- var mountPointAsRoot = mountPointsPerHost.findProperty('mountpoint', '/');
-
- // If Server does not send any host details information then atleast one mountpoint should be presumed as root
- // This happens in a single container Linux Docker environment.
- if (!mountPointAsRoot) {
- mountPointAsRoot = {
- mountpoint: '/'
- };
- }
-
- mountPointsPerHost.filter(this._filterMountPoint).forEach(function (mPoint) {
- if( !allMountPoints.findProperty("mountpoint", mPoint.mountpoint)) {
- allMountPoints.push(mPoint);
- }
- }, this);
- }
-
- if (!allMountPoints.length) {
- allMountPoints.push(mountPointAsRoot);
- }
- return allMountPoints;
- },
-
-
- __testGetInitializers: function () {
- if ($.mocho) {
- return initializers;
- }
- Em.assert('Available only for testing', false);
- },
-
- __testGetUniqueInitializers: function () {
- if ($.mocho) {
- return uniqueInitializers;
- }
- Em.assert('Available only for testing', false);
- },
-
- __testGetInitializerTypes: function () {
- if ($.mocho) {
- return initializerTypes;
- }
- Em.assert('Available only for testing', false);
- },
-
- __testGetWinReplacersMap: function () {
- if ($.mocho) {
- return winReplacersMap;
- }
- Em.assert('Available only for testing', false);
- }
-
-};
http://git-wip-us.apache.org/repos/asf/ambari/blob/da8ca2ae/ambari-web/test/controllers/wizard/slave_component_groups_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/slave_component_groups_controller.js b/ambari-web/test/controllers/wizard/slave_component_groups_controller.js
index a0bb296..ad1afc0 100644
--- a/ambari-web/test/controllers/wizard/slave_component_groups_controller.js
+++ b/ambari-web/test/controllers/wizard/slave_component_groups_controller.js
@@ -21,7 +21,6 @@ var App = require('app');
require('utils/helper');
require('controllers/wizard/slave_component_groups_controller');
-var configPropertyHelper = require('utils/configs/config_property_helper');
var controller;
describe('App.SlaveComponentGroupsController', function () {
@@ -228,12 +227,12 @@ describe('App.SlaveComponentGroupsController', function () {
});
}
});
- sinon.stub(configPropertyHelper, 'initialValue', Em.K);
+ sinon.stub(App.ConfigInitializer, 'initialValue', Em.K);
});
afterEach(function () {
App.ServiceConfigProperty.create.restore();
App.config.get.restore();
- configPropertyHelper.initialValue.restore();
+ App.ConfigInitializer.initialValue.restore();
});
it('should return created config', function () {
var res = JSON.parse(JSON.stringify(controller.componentProperties('HBASE')));
http://git-wip-us.apache.org/repos/asf/ambari/blob/da8ca2ae/ambari-web/test/models/configs/objects/service_config_category_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/objects/service_config_category_test.js b/ambari-web/test/models/configs/objects/service_config_category_test.js
index 449c874..33521fe 100644
--- a/ambari-web/test/models/configs/objects/service_config_category_test.js
+++ b/ambari-web/test/models/configs/objects/service_config_category_test.js
@@ -18,7 +18,6 @@
*/
var App = require('app');
-var configPropertyHelper = require('utils/configs/config_property_helper');
require('models/configs/objects/service_config_category');
require('models/configs/objects/service_config_property');
http://git-wip-us.apache.org/repos/asf/ambari/blob/da8ca2ae/ambari-web/test/models/configs/objects/service_config_property_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/objects/service_config_property_test.js b/ambari-web/test/models/configs/objects/service_config_property_test.js
index 026006a..638fb0c 100644
--- a/ambari-web/test/models/configs/objects/service_config_property_test.js
+++ b/ambari-web/test/models/configs/objects/service_config_property_test.js
@@ -17,7 +17,6 @@
*/
var App = require('app');
-var configPropertyHelper = require('utils/configs/config_property_helper');
require('models/configs/objects/service_config_category');
require('models/configs/objects/service_config_property');
http://git-wip-us.apache.org/repos/asf/ambari/blob/da8ca2ae/ambari-web/test/models/configs/objects/service_config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/objects/service_config_test.js b/ambari-web/test/models/configs/objects/service_config_test.js
index f223c87..9b5ba2d 100644
--- a/ambari-web/test/models/configs/objects/service_config_test.js
+++ b/ambari-web/test/models/configs/objects/service_config_test.js
@@ -17,7 +17,6 @@
*/
var App = require('app');
-var configPropertyHelper = require('utils/configs/config_property_helper');
require('models/configs/objects/service_config');