You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2014/11/02 17:42:12 UTC
git commit: AMBARI-8105 Hide "New MySQL Database" option for Hive in
Install Wizard / Add Service Wizard if OS family is redhat5 or sles11. (Max
Shepel via atkach)
Repository: ambari
Updated Branches:
refs/heads/trunk 96a7e9774 -> 0ac7138fd
AMBARI-8105 Hide "New MySQL Database" option for Hive in Install Wizard / Add Service Wizard if OS family is redhat5 or sles11. (Max Shepel via atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0ac7138f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0ac7138f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0ac7138f
Branch: refs/heads/trunk
Commit: 0ac7138fd53f8be9b6f615f8513dc04a0de459a9
Parents: 96a7e97
Author: atkach <at...@hortonworks.com>
Authored: Sun Nov 2 18:41:42 2014 +0200
Committer: atkach <at...@hortonworks.com>
Committed: Sun Nov 2 18:41:42 2014 +0200
----------------------------------------------------------------------
ambari-web/app/assets/test/tests.js | 1 +
ambari-web/app/config.js | 4 +-
ambari-web/app/controllers/installer.js | 1 +
ambari-web/app/controllers/main.js | 1 +
ambari-web/app/data/HDP2/site_properties.js | 1 +
ambari-web/app/models/service_config.js | 11 +++
ambari-web/app/utils/ajax/ajax.js | 2 +-
ambari-web/app/utils/config.js | 10 +++
ambari-web/app/views/wizard/controls_view.js | 8 +-
ambari-web/test/controllers/installer_test.js | 35 ++++++++
ambari-web/test/controllers/main_test.js | 59 +++++++++++++
ambari-web/test/models/service_config_test.js | 99 +++++++++++++++++++++-
ambari-web/test/utils/config_test.js | 27 ++++++
13 files changed, 254 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/0ac7138f/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 3061733..7376bb5 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -88,6 +88,7 @@ var files = ['test/init_model_test',
'test/controllers/main/alerts_controller_test',
'test/controllers/main/views_controller_test',
'test/controllers/installer_test',
+ 'test/controllers/main_test',
'test/controllers/wizard_test',
'test/controllers/wizard/step0_test',
'test/controllers/wizard/step2_test',
http://git-wip-us.apache.org/repos/asf/ambari/blob/0ac7138f/ambari-web/app/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/config.js b/ambari-web/app/config.js
index c758faa..9370064 100644
--- a/ambari-web/app/config.js
+++ b/ambari-web/app/config.js
@@ -46,6 +46,7 @@ App.healthIconClassGreen = 'icon-ok-sign'; // bootstrap icon class for healthy/s
App.healthIconClassRed = 'icon-warning-sign'; // bootstrap icon class for master down/stopped service/host/host-component
App.healthIconClassOrange = 'icon-minus-sign'; // bootstrap icon class for slave down/decommissioned host/host-component
App.healthIconClassYellow = 'icon-question-sign'; // bootstrap icon class for heartbeat lost service/host/host-component
+App.isManagedMySQLForHiveEnabled = false;
// experimental features are automatically enabled if running on brunch server
App.enableExperimental = false;
@@ -53,7 +54,8 @@ App.enableExperimental = false;
App.supports = {
stackUpgrade: false,
autoRollbackHA: false,
- alerts: false
+ alerts: false,
+ alwaysEnableManagedMySQLForHive: false
};
if (App.enableExperimental) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/0ac7138f/ambari-web/app/controllers/installer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/installer.js b/ambari-web/app/controllers/installer.js
index f0a2146..1fd57b3 100644
--- a/ambari-web/app/controllers/installer.js
+++ b/ambari-web/app/controllers/installer.js
@@ -349,6 +349,7 @@ App.InstallerController = App.WizardController.extend({
} else {
this.set('isServerClientVersionMismatch', false);
}
+ App.set('isManagedMySQLForHiveEnabled', App.config.isManagedMySQLForHiveAllowed(data.RootServiceComponents.properties['server.os_type']));
},
getServerVersionErrorCallback: function () {
console.log('ERROR: Cannot load Ambari server version');
http://git-wip-us.apache.org/repos/asf/ambari/blob/0ac7138f/ambari-web/app/controllers/main.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main.js b/ambari-web/app/controllers/main.js
index 7a54ced..ff2c3d4 100644
--- a/ambari-web/app/controllers/main.js
+++ b/ambari-web/app/controllers/main.js
@@ -150,6 +150,7 @@ App.MainController = Em.Controller.extend({
} else {
this.set('isServerClientVersionMismatch', false);
}
+ App.set('isManagedMySQLForHiveEnabled', App.config.isManagedMySQLForHiveAllowed(data.RootServiceComponents.properties['server.os_type']));
},
getServerVersionErrorCallback: function () {
console.log('ERROR: Cannot load Ambari server version');
http://git-wip-us.apache.org/repos/asf/ambari/blob/0ac7138f/ambari-web/app/data/HDP2/site_properties.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/HDP2/site_properties.js b/ambari-web/app/data/HDP2/site_properties.js
index 0f0b92a..d066cae 100644
--- a/ambari-web/app/data/HDP2/site_properties.js
+++ b/ambari-web/app/data/HDP2/site_properties.js
@@ -2848,6 +2848,7 @@ module.exports =
"radioName": "hive-database",
"isOverridable": false,
"isVisible": true,
+ "isObserved": true,
"serviceName": "HIVE",
"filename": "hive-env.xml",
"category": "HIVE_METASTORE",
http://git-wip-us.apache.org/repos/asf/ambari/blob/0ac7138f/ambari-web/app/models/service_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service_config.js b/ambari-web/app/models/service_config.js
index 88c4127..be5235a 100644
--- a/ambari-web/app/models/service_config.js
+++ b/ambari-web/app/models/service_config.js
@@ -440,6 +440,17 @@ App.ServiceConfigProperty = Ember.Object.extend({
case 'hive_ambari_host':
this.set('value', masterComponentHostsInDB.findProperty('component', 'HIVE_SERVER').hostName);
break;
+ case 'hive_database':
+ var newMySQLDBOption = this.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 && this.get('value') == 'New MySQL Database') {
+ this.set('value', 'Existing MySQL Database');
+ }
+ Em.set(newMySQLDBOption, 'hidden', isNewMySQLDBOptionHidden);
+ }
+ break;
case 'oozieserver_host':
this.set('value', masterComponentHostsInDB.findProperty('component', 'OOZIE_SERVER').hostName);
break;
http://git-wip-us.apache.org/repos/asf/ambari/blob/0ac7138f/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 8bfb193..cb3bc28 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -1464,7 +1464,7 @@ var urls = {
'mock': '/data/requests/host_check/jdk_name.json'
},
'ambari.service.load_server_version': {
- 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/component_version',
+ 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/component_version,RootServiceComponents/properties/server.os_type&minimal_response=true',
'mock': '/data/ambari_components/component_version.json'
},
'ambari.service': {
http://git-wip-us.apache.org/repos/asf/ambari/blob/0ac7138f/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 7b43459..a934cae 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -48,6 +48,16 @@ App.config = Em.Object.create({
},
/**
+ * Check if Hive installation with new MySQL database created via Ambari is allowed
+ * @param osType
+ * @returns {boolean}
+ */
+ isManagedMySQLForHiveAllowed: function (osType) {
+ var osList = ['redhat5', 'sles11'];
+ return !osList.contains(osType);
+ },
+
+ /**
*
* Returns the configuration tagName from supplied filename
*
http://git-wip-us.apache.org/repos/asf/ambari/blob/0ac7138f/ambari-web/app/views/wizard/controls_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/wizard/controls_view.js b/ambari-web/app/views/wizard/controls_view.js
index e607c69..b4e70cb 100644
--- a/ambari-web/app/views/wizard/controls_view.js
+++ b/ambari-web/app/views/wizard/controls_view.js
@@ -216,8 +216,12 @@ App.ServiceConfigRadioButtons = Ember.View.extend({
didInsertElement: function () {
// on page render, automatically populate JDBC URLs only for default database settings
// so as to not lose the user's customizations on these fields
- if (['addServiceController', 'installerController'].contains(App.clusterStatus.wizardControllerName) && ['New PostgreSQL Database', 'New MySQL Database', 'New Derby Database'].contains(this.get('serviceConfig.value'))) {
- this.onOptionsChange();
+ if (['addServiceController', 'installerController'].contains(App.clusterStatus.wizardControllerName)) {
+ if (['New PostgreSQL Database', 'New MySQL Database', 'New Derby Database'].contains(this.get('serviceConfig.value'))) {
+ this.onOptionsChange();
+ } else {
+ this.handleDBConnectionProperty();
+ }
}
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/0ac7138f/ambari-web/test/controllers/installer_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/installer_test.js b/ambari-web/test/controllers/installer_test.js
index 1a2dc7f..7dcf8f0 100644
--- a/ambari-web/test/controllers/installer_test.js
+++ b/ambari-web/test/controllers/installer_test.js
@@ -40,4 +40,39 @@ describe('App.InstallerController', function () {
expect(installerController.get('content.stacks').mapProperty('id')).to.eql(['HDP-2.1','HDP-1.3']);
});
});
+
+ describe('#getServerVersionSuccessCallback', function () {
+
+ var cases = [
+ {
+ osType: 'redhat5',
+ expected: false
+ },
+ {
+ osType: 'redhat6',
+ expected: true
+ },
+ {
+ osType: 'sles11',
+ expected: false
+ }
+ ],
+ title = 'App.isManagedMySQLForHiveEnabled should be {0} for {1}';
+
+ cases.forEach(function (item) {
+ it(title.format(item.expected, item.osType), function () {
+ installerController.getServerVersionSuccessCallback({
+ 'RootServiceComponents': {
+ 'component_version': '',
+ 'properties': {
+ 'server.os_type': item.osType
+ }
+ }
+ });
+ expect(App.get('isManagedMySQLForHiveEnabled')).to.equal(item.expected);
+ });
+ });
+
+ });
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/0ac7138f/ambari-web/test/controllers/main_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main_test.js b/ambari-web/test/controllers/main_test.js
new file mode 100644
index 0000000..186c8f1
--- /dev/null
+++ b/ambari-web/test/controllers/main_test.js
@@ -0,0 +1,59 @@
+/**
+ * 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');
+
+describe('App.InstallerController', function () {
+
+ describe('#getServerVersionSuccessCallback', function () {
+
+ var controller = App.MainController.create(),
+ cases = [
+ {
+ osType: 'redhat5',
+ expected: false
+ },
+ {
+ osType: 'redhat6',
+ expected: true
+ },
+ {
+ osType: 'sles11',
+ expected: false
+ }
+ ],
+ title = 'App.isManagedMySQLForHiveEnabled should be {0} for {1}';
+
+ cases.forEach(function (item) {
+ it(title.format(item.expected, item.osType), function () {
+ controller.getServerVersionSuccessCallback({
+ 'RootServiceComponents': {
+ 'component_version': '',
+ 'properties': {
+ 'server.os_type': item.osType
+ }
+ }
+ });
+ expect(App.get('isManagedMySQLForHiveEnabled')).to.equal(item.expected);
+ });
+ });
+
+ });
+
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/0ac7138f/ambari-web/test/models/service_config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/service_config_test.js b/ambari-web/test/models/service_config_test.js
index a015d82..6929566 100644
--- a/ambari-web/test/models/service_config_test.js
+++ b/ambari-web/test/models/service_config_test.js
@@ -617,7 +617,7 @@ describe('App.ServiceConfigProperty', function () {
});
-describe('initialValue', function () {
+describe('#initialValue - kafka.ganglia.metrics.host', function () {
var tests = [
{
@@ -646,3 +646,100 @@ describe('initialValue', function () {
});
});
});
+
+describe('#initialValue - hive_database', function () {
+
+ var cases = [
+ {
+ 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
+ }
+ ],
+ title = 'value should be set to {0}';
+
+ beforeEach(function () {
+ serviceConfigProperty = App.ServiceConfigProperty.create({
+ name: 'hive_database'
+ });
+ });
+
+ afterEach(function() {
+ App.get.restore();
+ });
+
+ cases.forEach(function (item) {
+ 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.set('value', item.receivedValue);
+ serviceConfigProperty.set('options', item.options);
+ serviceConfigProperty.initialValue({});
+ expect(serviceConfigProperty.get('value')).to.equal(item.value);
+ expect(serviceConfigProperty.get('options').findProperty('displayName', 'New MySQL Database').hidden).to.equal(item.hidden);
+ });
+ });
+
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/0ac7138f/ambari-web/test/utils/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/config_test.js b/ambari-web/test/utils/config_test.js
index 4c68e8b..25b454f 100644
--- a/ambari-web/test/utils/config_test.js
+++ b/ambari-web/test/utils/config_test.js
@@ -476,4 +476,31 @@ describe('App.config', function () {
setups.restoreStackVersion(this);
});
});
+
+ describe('#isManagedMySQLForHiveAllowed', function () {
+
+ var cases = [
+ {
+ osType: 'redhat5',
+ expected: false
+ },
+ {
+ osType: 'redhat6',
+ expected: true
+ },
+ {
+ osType: 'sles11',
+ expected: false
+ }
+ ],
+ title = 'should be {0} for {1}';
+
+ cases.forEach(function (item) {
+ it(title.format(item.expected, item.osType), function () {
+ expect(App.config.isManagedMySQLForHiveAllowed(item.osType)).to.equal(item.expected);
+ });
+ });
+
+ });
+
});