Skip to content
Snippets Groups Projects
Commit 8021fba8 authored by srosse's avatar srosse
Browse files

Merge OpenOLAT 9.4 to OpenOLAT default branch with 4c389cd34793f2b66c3713818ef61b0872092eab

parents d14c1e3c bf0304cd
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,11 @@ ...@@ -24,6 +24,11 @@
*/ */
package org.olat.core.commons.persistence; package org.olat.core.commons.persistence;
import static org.hibernate.cfg.AvailableSettings.QUERY_PLAN_CACHE_MAX_SIZE;
import static org.hibernate.cfg.AvailableSettings.QUERY_PLAN_CACHE_PARAMETER_METADATA_MAX_SIZE;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
...@@ -38,26 +43,15 @@ import java.util.Properties; ...@@ -38,26 +43,15 @@ import java.util.Properties;
*/ */
public class DBVendorHibernatePropertiesSimplification extends Properties { public class DBVendorHibernatePropertiesSimplification extends Properties {
private static final long serialVersionUID = 2191563335029326588L;
/**
*
*/
private static final long serialVersionUID = 1L;
/**
*
*/
public DBVendorHibernatePropertiesSimplification() {
super();
}
/** /**
* First added key valu pairs, which are eventually overwritten by values added during a {@link #setMoreProperties(Map)} call. * First added key value pairs, which are eventually overwritten by values added during a {@link #setMoreProperties(Map)} call.
* @param firstKeyValues * @param firstKeyValues
*/ */
public DBVendorHibernatePropertiesSimplification(Properties firstKeyValues) { public DBVendorHibernatePropertiesSimplification(Properties firstKeyValues) {
super(); super();
optimizeForEnvironment(firstKeyValues);
putAll(firstKeyValues); putAll(firstKeyValues);
} }
...@@ -65,8 +59,50 @@ public class DBVendorHibernatePropertiesSimplification extends Properties { ...@@ -65,8 +59,50 @@ public class DBVendorHibernatePropertiesSimplification extends Properties {
* add more key value pairs * add more key value pairs
* @param more * @param more
*/ */
public void setAddMoreProperties(Map<String,String> more){ public void setAddMoreProperties(Properties more) {
optimizeForEnvironment(more);
putAll(more); putAll(more);
} }
private void optimizeForEnvironment(Properties more) {
List<Object> keys = new ArrayList<>(more.keySet());
for(Object key:keys) {
optimizeForEnvironment(key, more);
}
}
private void optimizeForEnvironment(Object key, Properties properties) {
if(QUERY_PLAN_CACHE_MAX_SIZE.equals(key)) {
MemorySize mem = getMaxMemoryAvailable();
if(mem == MemorySize.small) {
properties.put(QUERY_PLAN_CACHE_MAX_SIZE, "512");
} else if(mem == MemorySize.medium) {
properties.put(QUERY_PLAN_CACHE_MAX_SIZE, "1024");
}
} else if(QUERY_PLAN_CACHE_PARAMETER_METADATA_MAX_SIZE.equals(key)) {
MemorySize mem = getMaxMemoryAvailable();
if(mem == MemorySize.small) {
properties.put(QUERY_PLAN_CACHE_PARAMETER_METADATA_MAX_SIZE, "32");
} else if(mem == MemorySize.medium) {
properties.put(QUERY_PLAN_CACHE_PARAMETER_METADATA_MAX_SIZE, "64");
}
}
}
private MemorySize getMaxMemoryAvailable() {
long maxMem = Runtime.getRuntime().maxMemory();
if(maxMem < 550000000l) {
return MemorySize.small;
} else if(maxMem < 1048000000l) {
return MemorySize.medium;
}
return MemorySize.large;
}
private enum MemorySize {
small,
medium,
large
}
} }
...@@ -147,6 +147,9 @@ ...@@ -147,6 +147,9 @@
olat works only with level 2; the database must support level 2 olat works only with level 2; the database must support level 2
--> -->
<prop key="hibernate.connection.isolation">2</prop> <prop key="hibernate.connection.isolation">2</prop>
<!-- The 2 options below are automatically reduced if not enough memory is available -->
<prop key="hibernate.query.plan_cache_max_size">2048</prop>
<prop key="hibernate.query.plan_parameter_metadata_max_size">128</prop>
<prop key="javax.persistence.lock.timeout">30000</prop> <prop key="javax.persistence.lock.timeout">30000</prop>
</props> </props>
</constructor-arg> </constructor-arg>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment