Yedidyah Bar David has uploaded a new change for review. Change subject: packaging: setup: Make reports heap size configurable ......................................................................
packaging: setup: Make reports 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: I021dbb42139adb99862d26038d2ab3fba7e7fb94 Bug-Url: https://bugzilla.redhat.com/1185411 Signed-off-by: Yedidyah Bar David <[email protected]> --- M packaging/setup/ovirt_engine_setup/reports/constants.py A packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-reports/config/java.py 2 files changed, 144 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-reports refs/changes/00/37500/1 diff --git a/packaging/setup/ovirt_engine_setup/reports/constants.py b/packaging/setup/ovirt_engine_setup/reports/constants.py index b660018..2cbbaac 100644 --- a/packaging/setup/ovirt_engine_setup/reports/constants.py +++ b/packaging/setup/ovirt_engine_setup/reports/constants.py @@ -159,6 +159,10 @@ SERVICE_VARS_D, '10-setup-database.conf' ) + REPORTS_SERVICE_CONFIG_JAVA = os.path.join( + SERVICE_VARS_D, + '10-setup-java.conf' + ) # sync with dwh DWH_SERVICE_VARS_D = '/etc/ovirt-engine-dwh/ovirt-engine-dwhd.conf.d' DWH_SERVICE_CONFIG_DATABASE = os.path.join( @@ -395,6 +399,18 @@ PKI_JBOSS_CSR_FILENAME = 'OVESETUP_REPORTS_CONFIG/pkiJbossCSRFilename' PKI_APACHE_CSR_FILENAME = 'OVESETUP_REPORTS_CONFIG/pkiApacheCSRFilename' + @osetupattrs( + answerfile=True, + ) + def HEAP_MIN(self): + return 'OVESETUP_REPORTS_CONFIG/heapMin' + + @osetupattrs( + answerfile=True, + ) + def HEAP_MAX(self): + return 'OVESETUP_REPORTS_CONFIG/heapMax' + @util.export @util.codegen diff --git a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-reports/config/java.py b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-reports/config/java.py new file mode 100644 index 0000000..ef1133a --- /dev/null +++ b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-reports/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-reports') + + +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.reports import constants as oreportscons + + [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( + oreportscons.ConfigEnv.HEAP_MIN, + None + ) + self.environment.setdefault( + oreportscons.ConfigEnv.HEAP_MAX, + None + ) + self._enabled = False + + @plugin.event( + stage=plugin.Stages.STAGE_CUSTOMIZATION, + after=( + oreportscons.Stages.CORE_ENABLE, + ), + condition=lambda self: self.environment[oreportscons.CoreEnv.ENABLE], + ) + def _customization(self): + config = configfile.ConfigFile([ + oreportscons.FileLocations.SERVICE_VARS, + ]) + + if not ( + config.get('HEAP_MIN') and + config.get('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[ + oreportscons.ConfigEnv.HEAP_MIN + ] is None: + self.environment[ + oreportscons.ConfigEnv.HEAP_MIN + ] = config.get('HEAP_MIN') or calculated_heap_size + + if self.environment[ + oreportscons.ConfigEnv.HEAP_MAX + ] is None: + self.environment[ + oreportscons.ConfigEnv.HEAP_MAX + ] = config.get('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=( + oreportscons.FileLocations.REPORTS_SERVICE_CONFIG_JAVA + ), + content=[ + 'HEAP_MIN="{heap_min}"'.format( + heap_min=self.environment[ + oreportscons.ConfigEnv.HEAP_MIN + ], + ), + 'HEAP_MAX="{heap_max}"'.format( + heap_max=self.environment[ + oreportscons.ConfigEnv.HEAP_MAX + ], + ), + ], + modifiedList=self.environment[ + otopicons.CoreEnv.MODIFIED_FILES + ], + ) + ) + + +# vim: expandtab tabstop=4 shiftwidth=4 -- To view, visit http://gerrit.ovirt.org/37500 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I021dbb42139adb99862d26038d2ab3fba7e7fb94 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-reports Gerrit-Branch: master Gerrit-Owner: Yedidyah Bar David <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
