← Back to team overview

dhis2-devs team mailing list archive

Re: Configurable properties?

 

Hi,

thanks for the patch and I think its a good idea and clever solution.

My feeling is that if we are going to introduce a dhis2.properties file we
should make *all* database properties configurable through it, and that
people who adopt it should be able to get rid of hibernate.properties
altogether. Since we are close to release (a moving target at the moment...)
this is not something to include right now and since the next is in a few
months it will give us time to make it more complete... Anyway it might be
time for a dhis2.properties which can be expanded and include things such as
memory available for caching, number of cpu cores available (new datamart
stuff coming up) and so on....

Lars


On Wed, Jun 22, 2011 at 8:55 PM, Jo Størset <storset@xxxxxxxxx> wrote:

> Hi,
>
> in some contexts I've had a recurring problem that they forget to set the
> number of connections in the db pool when they deploy a new war (initially
> the problem was that they didn't know how to set the pool size). Since this
> as of now must be set in beans.xml inside the support-hibernate jar inside
> the war, I can understand why that happens, especially if you are managing
> multiple instances with differing db needs.
>
> A simple solution to this is to introduce a way to let properties like
> these have default values and at the same time make it easy to override per
> instance basis without changing the war. The inlined patch (to make sure it
> gets through) lets properties be optionally overridden in a
> $DHIS_HOME/dhis2.properties file.
>
> We do want most things like this to be in the database and editable in the
> ui, but this solution could also be combined with those solutions. More
> importantly, it can be utilized before any connection with the db has been
> establised, and I think maybe this kind of mechanism would fit better than
> the hibernate configuration file we have today (which I'm still a bit unsure
> exactly how is used).
>
> It's a quick suggestion to ponder, anyway.
>
> Jo
>
>
> === modified file
> 'dhis-2/dhis-support/dhis-support-external/src/main/resources/META-INF/dhis/beans.xml'
> ---
> dhis-2/dhis-support/dhis-support-external/src/main/resources/META-INF/dhis/beans.xml
>        2010-10-29 12:19:15 +0000
> +++
> dhis-2/dhis-support/dhis-support-external/src/main/resources/META-INF/dhis/beans.xml
>        2011-06-22 18:23:50 +0000
> @@ -21,4 +21,27 @@
>     <property name="systemProperty" value="dhis2.home"/>
>   </bean>
>
> +  <!--
> +    Set up DHIS2 to:
> +    1. Load any /META-INF/dhis/default.properties files defined in modules
> +    2. Load the $DHIS2_HOME/dhis2.properties file for optional deployment
> specific overriding of properties.
> +  -->
> +
> +  <bean id="defaultPropsConfigurer"
> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
> +    <property name="locations">
> +      <list>
> +        <value>classpath*:/META-INF/dhis/default.properties</value>
> +        <bean class="org.springframework.core.io.FileSystemResource">
> +          <constructor-arg>
> +            <bean
> class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
> +              <property name="targetObject" ref="locationManager" />
> +              <property name="targetMethod" value="getFileForReading" />
> +              <property name="arguments" value="dhis2.properties" />
> +            </bean>
> +          </constructor-arg>
> +        </bean>
> +      </list>
> +    </property>
> +    <property name="ignoreResourceNotFound" value="true" />
> +
>  </beans>
>
> === modified file
> 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/META-INF/dhis/beans.xml'
> ---
> dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/META-INF/dhis/beans.xml
>       2011-01-28 21:44:54 +0000
> +++
> dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/META-INF/dhis/beans.xml
>       2011-06-22 14:48:11 +0000
> @@ -57,9 +57,9 @@
>     <property name="jdbcUrl" ref="url"/>
>     <property name="user" ref="username"/>
>     <property name="password" ref="password"/>
> -    <property name="acquireIncrement" value="6"/>
> -    <property name="maxPoolSize" value="40"/>
> -    <property name="maxIdleTime" value="7200"/>
> +    <property name="acquireIncrement"
> value="${support.hibernate.aquireIncrement}"/>
> +    <property name="maxPoolSize"
> value="${support.hibernate.maxPoolSize}"/>
> +    <property name="maxIdleTime"
> value="${support.hibernate.maxIdleTime}"/>
>   </bean>
>
>   <bean id="jdbcTemplate"
> class="org.springframework.jdbc.core.JdbcTemplate">
>
> === added file
> 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/META-INF/dhis/default.properties'
> ---
> dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/META-INF/dhis/default.properties
>      1970-01-01 00:00:00 +0000
> +++
> dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/META-INF/dhis/default.properties
>      2011-06-22 14:20:55 +0000
> @@ -0,0 +1,3 @@
> +support.hibernate.maxPoolSize=40
> +support.hibernate.maxIdleTime=7200
> +support.hibernate.aquireIncrement=6
> \ No newline at end of file
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-devs
> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-devs
> More help   : https://help.launchpad.net/ListHelp
>

References