← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4241: Added system setting for no of cpu cores

 

------------------------------------------------------------
revno: 4241
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-08-02 12:37:13 +0200
message:
  Added system setting for no of cpu cores
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/options/SystemSettingManager.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetSystemSettingsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemSettings.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/options/SystemSettingManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/options/SystemSettingManager.java	2011-05-26 11:45:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/options/SystemSettingManager.java	2011-08-02 10:37:13 +0000
@@ -57,6 +57,7 @@
     final String KEY_PATIENT_EXCEL_TEMPLATE_FILE_NAME = "patientExcelTemplateFileName";
     final String KEY_DATAMART_TASK = "keyDataMartTask";
     final String KEY_DATASETCOMPLETENESS_TASK = "keyDataSetCompletenessTask";
+    final String KEY_CPU_CORES = "keyCpuCores";
     
     final int DEFAULT_MAX_NUMBER_OF_ATTEMPTS = 20;
     final int DEFAULT_TIMEFRAME_MINUTES = 1;
@@ -67,6 +68,7 @@
     final String AGGREGATION_STRATEGY_BATCH = "batch";
     final String DEFAULT_AGGREGATION_STRATEGY = AGGREGATION_STRATEGY_REAL_TIME;
     final int DEFAULT_COMPLETENESS_OFFSET = 15;
+    final int DEFAULT_CPU_CORES = 2;
     
     void saveSystemSetting( String name, Serializable value );
 

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java	2011-07-01 11:27:12 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java	2011-08-02 10:37:13 +0000
@@ -48,6 +48,7 @@
 import org.hisp.dhis.expression.ExpressionService;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.options.SystemSettingManager;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
@@ -58,14 +59,14 @@
 import org.hisp.dhis.system.util.PaginatedList;
 import org.springframework.transaction.annotation.Transactional;
 
+import static org.hisp.dhis.options.SystemSettingManager.*;
+
 /**
  * @author Lars Helge Overland
  */
 public class DefaultDataMartEngine
     implements DataMartEngine
 {
-    private static final int THREAD_NO = 2;
-    
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -147,6 +148,13 @@
         this.organisationUnitService = organisationUnitService;
     }
 
+    private SystemSettingManager systemSettingManager;
+
+    public void setSystemSettingManager( SystemSettingManager systemSettingManager )
+    {
+        this.systemSettingManager = systemSettingManager;
+    }
+
     // -------------------------------------------------------------------------
     // DataMartEngine implementation
     // -------------------------------------------------------------------------
@@ -155,7 +163,9 @@
     public void export( Collection<Integer> dataElementIds, Collection<Integer> indicatorIds,
         Collection<Integer> periodIds, Collection<Integer> organisationUnitIds, boolean useIndexes, ProcessState state )
     {
-        Clock clock = new Clock().startClock().logTime( "Data mart export process started" );
+        final int cpuCores = (Integer) systemSettingManager.getSystemSetting( KEY_CPU_CORES, DEFAULT_CPU_CORES );
+        
+        Clock clock = new Clock().startClock().logTime( "Data mart export process started, number of CPU cores: " + cpuCores );
         
         // ---------------------------------------------------------------------
         // Get objects
@@ -224,7 +234,7 @@
         // Drop potential indexes
         // ---------------------------------------------------------------------
 
-        boolean isIndicators = indicators != null && indicators.size() > 0;
+        final boolean isIndicators = indicators != null && indicators.size() > 0;
         
         aggregatedDataValueService.dropIndex( true, isIndicators );
         
@@ -246,7 +256,7 @@
 
         state.setMessage( "exporting_data_for_data_elements" );
 
-        List<List<Period>> periodPages = new PaginatedList<Period>( periods ).setNumberOfPages( THREAD_NO ).getPages();
+        List<List<Period>> periodPages = new PaginatedList<Period>( periods ).setNumberOfPages( cpuCores ).getPages();
         
         if ( allOperands.size() > 0 )
         {

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml	2011-06-29 15:25:19 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml	2011-08-02 10:37:13 +0000
@@ -34,6 +34,7 @@
     <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
     <property name="expressionService" ref="org.hisp.dhis.expression.ExpressionService" />
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+	<property name="systemSettingManager" ref="org.hisp.dhis.options.SystemSettingManager" />
   </bean>
 
   <bean id="internal-process-DataMart" class="org.hisp.dhis.datamart.DataMartInternalProcess" scope="prototype">

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java	2011-05-05 21:15:45 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java	2011-08-02 10:37:13 +0000
@@ -28,14 +28,6 @@
  */
 
 import static org.hisp.dhis.options.SystemSettingManager.*;
-import static org.hisp.dhis.options.SystemSettingManager.DEFAULT_FACTOR_OF_DEVIATION;
-import static org.hisp.dhis.options.SystemSettingManager.KEY_AGGREGATION_STRATEGY;
-import static org.hisp.dhis.options.SystemSettingManager.KEY_APPLICATION_TITLE;
-import static org.hisp.dhis.options.SystemSettingManager.KEY_DISABLE_DATAENTRYFORM_WHEN_COMPLETED;
-import static org.hisp.dhis.options.SystemSettingManager.KEY_FACTOR_OF_DEVIATION;
-import static org.hisp.dhis.options.SystemSettingManager.KEY_FLAG;
-import static org.hisp.dhis.options.SystemSettingManager.KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART;
-import static org.hisp.dhis.options.SystemSettingManager.KEY_START_MODULE;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -94,6 +86,7 @@
         map.put( KEY_FACTOR_OF_DEVIATION, systemSettingManager.getSystemSetting( KEY_FACTOR_OF_DEVIATION, DEFAULT_FACTOR_OF_DEVIATION ) );
         map.put( KEY_AGGREGATION_STRATEGY, systemSettingManager.getSystemSetting( KEY_AGGREGATION_STRATEGY, DEFAULT_AGGREGATION_STRATEGY ) );
         map.put( KEY_COMPLETENESS_OFFSET, systemSettingManager.getSystemSetting( KEY_COMPLETENESS_OFFSET, DEFAULT_COMPLETENESS_OFFSET ) );
+        map.put( KEY_CPU_CORES, systemSettingManager.getSystemSetting( KEY_CPU_CORES, DEFAULT_CPU_CORES ) );
         
         invocation.getStack().push( map );
         

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetSystemSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetSystemSettingsAction.java	2011-06-10 11:47:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetSystemSettingsAction.java	2011-08-02 10:37:13 +0000
@@ -36,6 +36,7 @@
 import static org.hisp.dhis.options.SystemSettingManager.KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART;
 import static org.hisp.dhis.options.SystemSettingManager.KEY_START_MODULE;
 import static org.hisp.dhis.options.SystemSettingManager.KEY_SYSTEM_IDENTIFIER;
+import static org.hisp.dhis.options.SystemSettingManager.KEY_CPU_CORES;
 
 import org.apache.commons.lang.StringUtils;
 import org.hisp.dhis.configuration.Configuration;
@@ -196,6 +197,13 @@
     {
         this.completenessOffset = completenessOffset;
     }
+    
+    private Integer cpuCores;
+
+    public void setCpuCores( Integer cpuCores )
+    {
+        this.cpuCores = cpuCores;
+    }
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -219,14 +227,13 @@
         systemSettingManager.saveSystemSetting( KEY_APPLICATION_TITLE, applicationTitle );
         systemSettingManager.saveSystemSetting( KEY_FLAG, flag );
         systemSettingManager.saveSystemSetting( KEY_START_MODULE, startModule );
-        systemSettingManager.saveSystemSetting( KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART,
-            omitIndicatorsZeroNumeratorDataMart );
-        systemSettingManager
-            .saveSystemSetting( KEY_DISABLE_DATAENTRYFORM_WHEN_COMPLETED, disableDataEntryWhenCompleted );
+        systemSettingManager.saveSystemSetting( KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART, omitIndicatorsZeroNumeratorDataMart );
+        systemSettingManager.saveSystemSetting( KEY_DISABLE_DATAENTRYFORM_WHEN_COMPLETED, disableDataEntryWhenCompleted );
         systemSettingManager.saveSystemSetting( KEY_FACTOR_OF_DEVIATION, factorDeviation );
         styleManager.setCurrentStyle( currentStyle );
         systemSettingManager.saveSystemSetting( KEY_AGGREGATION_STRATEGY, aggregationStrategy );
         systemSettingManager.saveSystemSetting( KEY_COMPLETENESS_OFFSET, completenessOffset );
+        systemSettingManager.saveSystemSetting( KEY_CPU_CORES, cpuCores );
 
         Configuration configuration = configurationService.getConfiguration();
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties	2011-06-10 11:47:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties	2011-08-02 10:37:13 +0000
@@ -94,4 +94,5 @@
 infrastructural_data_elements = Infrastructural data elements
 infrastructural_period_type = Infrastructural period type
 feedback_recipients = Feedback recipients
-no_feedback_recipients = No message recipients
\ No newline at end of file
+no_feedback_recipients = No message recipients
+no_of_cpu_cores = Number of CPU cores
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemSettings.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemSettings.vm	2011-06-23 16:42:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemSettings.vm	2011-08-02 10:37:13 +0000
@@ -25,6 +25,16 @@
 </select>
 </p>
 
+<h4>$i18n.getString( "no_of_cpu_cores" )</h4>
+
+<p>
+<select name="cpuCores" style="width:30em">
+#foreach( $i in [1..8] )
+<option value="$i"#if( $i == $keyCpuCores ) selected="selected"#end>$i</option>
+#end
+</select>
+</p>
+
 <h4>$i18n.getString( "style" )</h4>
 
 <select style="width:30em" name='currentStyle' id='currentStyle'>