diff --git a/sahara/plugins/vanilla/hadoop2/recommendations_utils.py b/sahara/plugins/vanilla/hadoop2/recommendations_utils.py new file mode 100644 index 00000000..6ba4e53e --- /dev/null +++ b/sahara/plugins/vanilla/hadoop2/recommendations_utils.py @@ -0,0 +1,48 @@ +# Copyright (c) 2015 Mirantis Inc. +# +# Licensed 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. + +from sahara.plugins import recommendations_utils as ru + + +def recommend_configs(cluster, plugin_configs): + yarn_configs = [ + 'yarn.nodemanager.resource.memory-mb', + 'yarn.scheduler.minimum-allocation-mb', + 'yarn.scheduler.maximum-allocation-mb', + 'yarn.nodemanager.vmem-check-enabled', + ] + mapred_configs = [ + 'yarn.app.mapreduce.am.resource.mb', + 'yarn.app.mapreduce.am.command-opts', + 'mapreduce.map.memory.mb', + 'mapreduce.reduce.memory.mb', + 'mapreduce.map.java.opts', + 'mapreduce.reduce.java.opts', + 'mapreduce.task.io.sort.mb', + ] + configs_to_configure = { + 'cluster_configs': { + 'dfs.replication': ('HDFS', 'dfs.replication') + }, + 'node_configs': { + } + } + for mapr in mapred_configs: + configs_to_configure['node_configs'][mapr] = ("MapReduce", mapr) + for yarn in yarn_configs: + configs_to_configure['node_configs'][yarn] = ('YARN', yarn) + provider = ru.HadoopAutoConfigsProvider( + configs_to_configure, plugin_configs, cluster) + provider.apply_recommended_configs() diff --git a/sahara/plugins/vanilla/v2_6_0/versionhandler.py b/sahara/plugins/vanilla/v2_6_0/versionhandler.py index ca96820d..dc6b8c60 100644 --- a/sahara/plugins/vanilla/v2_6_0/versionhandler.py +++ b/sahara/plugins/vanilla/v2_6_0/versionhandler.py @@ -18,10 +18,10 @@ from oslo_log import log as logging from sahara import conductor from sahara import context -from sahara.plugins import recommendations_utils as ru from sahara.plugins import utils from sahara.plugins.vanilla import abstractversionhandler as avm from sahara.plugins.vanilla.hadoop2 import config as c +from sahara.plugins.vanilla.hadoop2 import recommendations_utils as ru from sahara.plugins.vanilla.hadoop2 import run_scripts as run from sahara.plugins.vanilla.hadoop2 import scaling as sc from sahara.plugins.vanilla.hadoop2 import validation as vl @@ -192,32 +192,4 @@ class VersionHandler(avm.AbstractVersionHandler): return c.get_open_ports(node_group) def recommend_configs(self, cluster): - yarn_configs = [ - 'yarn.nodemanager.resource.memory-mb', - 'yarn.scheduler.minimum-allocation-mb', - 'yarn.scheduler.maximum-allocation-mb', - 'yarn.nodemanager.vmem-check-enabled', - ] - mapred_configs = [ - 'yarn.app.mapreduce.am.resource.mb', - 'yarn.app.mapreduce.am.command-opts', - 'mapreduce.map.memory.mb', - 'mapreduce.reduce.memory.mb', - 'mapreduce.map.java.opts', - 'mapreduce.reduce.java.opts', - 'mapreduce.task.io.sort.mb', - ] - configs_to_configure = { - 'cluster_configs': { - 'dfs.replication': ('HDFS', 'dfs.replication') - }, - 'node_configs': { - } - } - for mapr in mapred_configs: - configs_to_configure['node_configs'][mapr] = ("MapReduce", mapr) - for yarn in yarn_configs: - configs_to_configure['node_configs'][yarn] = ('YARN', yarn) - provider = ru.HadoopAutoConfigsProvider( - configs_to_configure, self.get_plugin_configs(), cluster) - provider.apply_recommended_configs() + ru.recommend_configs(cluster, self.get_plugin_configs()) diff --git a/sahara/tests/unit/plugins/vanilla/v2_6_0/test_versionhandler.py b/sahara/tests/unit/plugins/vanilla/hadoop2/test_recommendation_utils.py similarity index 85% rename from sahara/tests/unit/plugins/vanilla/v2_6_0/test_versionhandler.py rename to sahara/tests/unit/plugins/vanilla/hadoop2/test_recommendation_utils.py index 673f4ad1..fff665f3 100644 --- a/sahara/tests/unit/plugins/vanilla/v2_6_0/test_versionhandler.py +++ b/sahara/tests/unit/plugins/vanilla/hadoop2/test_recommendation_utils.py @@ -16,7 +16,7 @@ import mock import testtools -from sahara.plugins.vanilla.v2_6_0 import versionhandler +from sahara.plugins.vanilla.hadoop2 import recommendations_utils as ru CONFIGURATION_SCHEMA = { 'cluster_configs': { @@ -52,12 +52,9 @@ CONFIGURATION_SCHEMA = { class TestVersionHandler(testtools.TestCase): @mock.patch('sahara.plugins.recommendations_utils.' 'HadoopAutoConfigsProvider') - @mock.patch('sahara.plugins.vanilla.v2_6_0.versionhandler.VersionHandler.' - 'get_plugin_configs') - def test_recommend_configs(self, fake_plugin_configs, provider): + def test_recommend_configs(self, provider): f_cluster, f_configs = mock.Mock(), mock.Mock() - fake_plugin_configs.return_value = f_configs - versionhandler.VersionHandler().recommend_configs(f_cluster) + ru.recommend_configs(f_cluster, f_configs) self.assertEqual([ mock.call(CONFIGURATION_SCHEMA, f_configs, f_cluster) ], provider.call_args_list)