Yedidyah Bar David has uploaded a new change for review. Change subject: packaging: setup: Make engine heap size configurable ......................................................................
packaging: setup: Make engine heap size configurable Set heap min/max by default to max(1GB, 25% of RAM). Allow configuring by env. Existing conf - by setup on upgrades or manually by user - is kept as-is. Change-Id: I7ad1b1401d817883d1a26270280e54f1cfa8612b Bug-Url: https://bugzilla.redhat.com/1185411 Signed-off-by: Yedidyah Bar David <[email protected]> (cherry picked from commit 6523310897bc131ddc0f34631c6a34a58c52d6c6) --- M packaging/setup/ovirt_engine_setup/engine/constants.py M packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/__init__.py A packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/java.py 3 files changed, 148 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/76/37576/1 diff --git a/packaging/setup/ovirt_engine_setup/engine/constants.py b/packaging/setup/ovirt_engine_setup/engine/constants.py index a2ee32e..acc1841 100644 --- a/packaging/setup/ovirt_engine_setup/engine/constants.py +++ b/packaging/setup/ovirt_engine_setup/engine/constants.py @@ -1,6 +1,6 @@ # # ovirt-engine-setup -- ovirt engine setup -# Copyright (C) 2014 Red Hat, Inc. +# Copyright (C) 2014-2015 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -257,6 +257,10 @@ OVIRT_ENGINE_NOTIFIER_SERVICE_CONFIG_JBOSS = os.path.join( OVIRT_ENGINE_NOTIFIER_SERVICE_CONFIGD, '10-setup-jboss.conf', + ) + OVIRT_ENGINE_SERVICE_CONFIG_JAVA = os.path.join( + OVIRT_ENGINE_SERVICE_CONFIGD, + '10-setup-java.conf', ) OVIRT_ENGINE_UNINSTALL_DIR = os.path.join( OVIRT_ENGINE_SYSCONFDIR, @@ -597,6 +601,18 @@ ENGINE_FQDN = 'OVESETUP_ENGINE_CONFIG/fqdn' + @osetupattrs( + answerfile=True, + ) + def ENGINE_HEAP_MIN(self): + return 'OVESETUP_CONFIG/engineHeapMin' + + @osetupattrs( + answerfile=True, + ) + def ENGINE_HEAP_MAX(self): + return 'OVESETUP_CONFIG/engineHeapMax' + @util.export @util.codegen diff --git a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/__init__.py b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/__init__.py index 0860452..d050699 100644 --- a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/__init__.py +++ b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/__init__.py @@ -1,6 +1,6 @@ # # ovirt-engine-setup -- ovirt engine setup -# Copyright (C) 2013 Red Hat, Inc. +# Copyright (C) 2013-2015 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ from . import jboss +from . import java from . import database from . import protocols from . import appmode @@ -39,6 +40,7 @@ @util.export def createPlugins(context): jboss.Plugin(context=context) + java.Plugin(context=context) database.Plugin(context=context) protocols.Plugin(context=context) appmode.Plugin(context=context) diff --git a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/java.py b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/java.py new file mode 100644 index 0000000..182c15f --- /dev/null +++ b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/java.py @@ -0,0 +1,128 @@ +# +# ovirt-engine-setup -- ovirt engine setup +# Copyright (C) 2015 Red Hat, 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. +# + + +"""Java plugin.""" + + +import gettext +_ = lambda m: gettext.dgettext(message=m, domain='ovirt-engine-setup') + + +from otopi import util +from otopi import plugin +from otopi import constants as otopicons +from otopi import filetransaction + + +from ovirt_engine import configfile + + +from ovirt_engine_setup import constants as osetupcons +from ovirt_engine_setup.engine import constants as oenginecons + + [email protected] +class Plugin(plugin.PluginBase): + """Misc plugin.""" + + def __init__(self, context): + super(Plugin, self).__init__(context=context) + + @plugin.event( + stage=plugin.Stages.STAGE_INIT, + ) + def _init(self): + self.environment.setdefault( + oenginecons.ConfigEnv.ENGINE_HEAP_MIN, + None + ) + self.environment.setdefault( + oenginecons.ConfigEnv.ENGINE_HEAP_MAX, + None + ) + self._enabled = False + + @plugin.event( + stage=plugin.Stages.STAGE_CUSTOMIZATION, + after=( + oenginecons.Stages.CORE_ENABLE, + ), + condition=lambda self: self.environment[oenginecons.CoreEnv.ENABLE], + ) + def _customization(self): + config = configfile.ConfigFile([ + oenginecons.FileLocations.OVIRT_ENGINE_SERVICE_CONFIG, + ]) + + if not ( + config.get('ENGINE_HEAP_MIN') and + config.get('ENGINE_HEAP_MAX') + ): + self._enabled = True + + calculated_heap_size = '{sizemb}M'.format( + sizemb=max( + 1024, + self.environment[osetupcons.ConfigEnv.TOTAL_MEMORY_MB] / 4 + ) + ) + + if self.environment[ + oenginecons.ConfigEnv.ENGINE_HEAP_MIN + ] is None: + self.environment[ + oenginecons.ConfigEnv.ENGINE_HEAP_MIN + ] = config.get('ENGINE_HEAP_MIN') or calculated_heap_size + + if self.environment[ + oenginecons.ConfigEnv.ENGINE_HEAP_MAX + ] is None: + self.environment[ + oenginecons.ConfigEnv.ENGINE_HEAP_MAX + ] = config.get('ENGINE_HEAP_MAX') or calculated_heap_size + + @plugin.event( + stage=plugin.Stages.STAGE_MISC, + condition=lambda self: self._enabled, + ) + def _misc(self): + self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append( + filetransaction.FileTransaction( + name=( + oenginecons.FileLocations.OVIRT_ENGINE_SERVICE_CONFIG_JAVA + ), + content=[ + 'ENGINE_HEAP_MIN="{heap_min}"'.format( + heap_min=self.environment[ + oenginecons.ConfigEnv.ENGINE_HEAP_MIN + ], + ), + 'ENGINE_HEAP_MAX="{heap_max}"'.format( + heap_max=self.environment[ + oenginecons.ConfigEnv.ENGINE_HEAP_MAX + ], + ), + ], + modifiedList=self.environment[ + otopicons.CoreEnv.MODIFIED_FILES + ], + ) + ) + + +# vim: expandtab tabstop=4 shiftwidth=4 -- To view, visit http://gerrit.ovirt.org/37576 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7ad1b1401d817883d1a26270280e54f1cfa8612b Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Yedidyah Bar David <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
