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.

Change-Id: I7ad1b1401d817883d1a26270280e54f1cfa8612b
Bug-Url: https://bugzilla.redhat.com/1185411
Signed-off-by: Yedidyah Bar David <d...@redhat.com>
---
M packaging/setup/ovirt_engine_setup/engine/constants.py
M packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/core/misc.py
2 files changed, 68 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/38/37438/1

diff --git a/packaging/setup/ovirt_engine_setup/engine/constants.py 
b/packaging/setup/ovirt_engine_setup/engine/constants.py
index a2ee32e..9ef4862 100644
--- a/packaging/setup/ovirt_engine_setup/engine/constants.py
+++ b/packaging/setup/ovirt_engine_setup/engine/constants.py
@@ -258,6 +258,10 @@
         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,
         'uninstall.d'
@@ -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/core/misc.py 
b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/core/misc.py
index be5791f..6d338918 100644
--- a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/core/misc.py
+++ b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/core/misc.py
@@ -43,6 +43,8 @@
     def __init__(self, context):
         super(Plugin, self).__init__(context=context)
         self._engine_fqdn = None
+        self._engine_heap_min = None
+        self._engine_heap_max = None
 
     @plugin.event(
         stage=plugin.Stages.STAGE_INIT,
@@ -59,6 +61,10 @@
         ])
         if config.get('ENGINE_FQDN'):
             self._engine_fqdn = config.get('ENGINE_FQDN')
+        if config.get('ENGINE_HEAP_MIN'):
+            self._engine_heap_min = config.get('ENGINE_HEAP_MIN')
+        if config.get('ENGINE_HEAP_MAX'):
+            self._engine_heap_max = config.get('ENGINE_HEAP_MAX')
 
     @plugin.event(
         stage=plugin.Stages.STAGE_CUSTOMIZATION,
@@ -92,6 +98,52 @@
             )
         if self.environment[oenginecons.CoreEnv.ENABLE]:
             self.environment[oengcommcons.ApacheEnv.ENABLE] = True
+            if self.environment[
+                oenginecons.ConfigEnv.ENGINE_HEAP_MIN
+            ] is None:
+                self.environment[
+                    oenginecons.ConfigEnv.ENGINE_HEAP_MIN
+                ] = max(
+                    1024,
+                    self.environment[osetupcons.ConfigEnv.TOTAL_MEMORY_MB] / 4
+                )
+            if self.environment[
+                oenginecons.ConfigEnv.ENGINE_HEAP_MAX
+            ] is None:
+                self.environment[
+                    oenginecons.ConfigEnv.ENGINE_HEAP_MAX
+                ] = max(
+                    1024,
+                    self.environment[osetupcons.ConfigEnv.TOTAL_MEMORY_MB] / 4
+                )
 
+    @plugin.event(
+        stage=plugin.Stages.STAGE_MISC,
+        condition=lambda self: self.environment[oenginecons.CoreEnv.ENABLE],
+    )
+    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}M"'.format(
+                            heap_min=self.environment[
+                                oenginecons.ConfigEnv.ENGINE_HEAP_MIN
+                            ],
+                        ),
+                        'ENGINE_HEAP_MAX="{heap_max}M"'.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/37438
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7ad1b1401d817883d1a26270280e54f1cfa8612b
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Yedidyah Bar David <d...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to