dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13329
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4243: Getting cpu cores from Runtime
------------------------------------------------------------
revno: 4243
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-08-02 13:11:03 +0200
message:
Getting cpu cores from Runtime
modified:
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/SystemUtils.java
--
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-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-08-02 10:55:30 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java 2011-08-02 11:11:03 +0000
@@ -56,6 +56,7 @@
import org.hisp.dhis.system.util.ConcurrentUtils;
import org.hisp.dhis.system.util.ConversionUtils;
import org.hisp.dhis.system.util.PaginatedList;
+import org.hisp.dhis.system.util.SystemUtils;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -63,9 +64,7 @@
*/
public class DefaultDataMartEngine
implements DataMartEngine
-{
- private static final int THREAD_NO = 2;
-
+{
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -155,7 +154,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 = SystemUtils.getCpuCores();
+
+ Clock clock = new Clock().startClock().logTime( "Data mart export process started, number of CPU cores: " + cpuCores );
// ---------------------------------------------------------------------
// Get objects
@@ -224,7 +225,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 +247,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-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/SystemUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/SystemUtils.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/SystemUtils.java 2011-08-02 11:11:03 +0000
@@ -46,4 +46,9 @@
return false;
}
+
+ public static int getCpuCores()
+ {
+ return Runtime.getRuntime().availableProcessors();
+ }
}