Implement recommendations for vanilla 2.6.0

This patch implements base recommendation provider for vanilla 2.6.0. Also
added new fields in database for cluster and node groups which will allow
to switch off autoconfiguration.

Partial-implements blueprint: recommend-configuration
Change-Id: I9abb6b9c04494f4aed9b72479c06e45fe289c1ff
This commit is contained in:
Vitaly Gridnev 2015-04-24 15:39:25 +03:00
parent 631aada779
commit 3b61a27e4f
4 changed files with 103 additions and 0 deletions

View File

@ -92,3 +92,7 @@ class VanillaProvider(p.ProvisioningPluginBase):
def on_terminate_cluster(self, cluster):
return self._get_version_handler(
cluster.hadoop_version).on_terminate_cluster(cluster)
def recommend_configs(self, cluster):
return self._get_version_handler(
cluster.hadoop_version).recommend_configs(cluster)

View File

@ -594,3 +594,7 @@ class VersionHandler(avm.AbstractVersionHandler):
def on_terminate_cluster(self, cluster):
proxy.delete_proxy_user_for_cluster(cluster)
def recommend_configs(self, cluster):
# We don't support any recommendations in Vanilla 1 plugin
pass

View File

@ -18,6 +18,7 @@ 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
@ -189,3 +190,34 @@ class VersionHandler(avm.AbstractVersionHandler):
def get_open_ports(self, node_group):
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()

View File

@ -0,0 +1,63 @@
# 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.
import mock
import testtools
from sahara.plugins.vanilla.v2_6_0 import versionhandler
CONFIGURATION_SCHEMA = {
'cluster_configs': {
'dfs.replication': ('HDFS', 'dfs.replication')
},
'node_configs': {
'yarn.app.mapreduce.am.command-opts': (
'MapReduce', 'yarn.app.mapreduce.am.command-opts'),
'yarn.scheduler.maximum-allocation-mb': (
'YARN', 'yarn.scheduler.maximum-allocation-mb'),
'yarn.app.mapreduce.am.resource.mb': (
'MapReduce', 'yarn.app.mapreduce.am.resource.mb'),
'yarn.scheduler.minimum-allocation-mb': (
'YARN', 'yarn.scheduler.minimum-allocation-mb'),
'yarn.nodemanager.vmem-check-enabled': (
'YARN', 'yarn.nodemanager.vmem-check-enabled'),
'mapreduce.map.java.opts': (
'MapReduce', 'mapreduce.map.java.opts'),
'mapreduce.reduce.memory.mb': (
'MapReduce', 'mapreduce.reduce.memory.mb'),
'yarn.nodemanager.resource.memory-mb': (
'YARN', 'yarn.nodemanager.resource.memory-mb'),
'mapreduce.reduce.java.opts': (
'MapReduce', 'mapreduce.reduce.java.opts'),
'mapreduce.map.memory.mb': (
'MapReduce', 'mapreduce.map.memory.mb'),
'mapreduce.task.io.sort.mb': (
'MapReduce', 'mapreduce.task.io.sort.mb')
}
}
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):
f_cluster, f_configs = mock.Mock(), mock.Mock()
fake_plugin_configs.return_value = f_configs
versionhandler.VersionHandler().recommend_configs(f_cluster)
self.assertEqual([
mock.call(CONFIGURATION_SCHEMA, f_configs, f_cluster)
], provider.call_args_list)