dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32331
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16500: Analytics, introduced system setting for number of cpus on database server. This is useful when d...
------------------------------------------------------------
revno: 16500
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-08-25 13:42:12 +0200
message:
Analytics, introduced system setting for number of cpus on database server. This is useful when deploying dhis database and application on different servers. Currently analytics split tasks in multiple processes and detects number of cpus based on the application server.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java
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/SetGeneralSettingsAction.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/systemGeneralSettings.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/setting/SystemSettingManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java 2014-08-14 21:04:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java 2014-08-25 11:42:12 +0000
@@ -42,7 +42,6 @@
/**
* @author Stian Strandli
- * @version $Id: SystemSettingManager.java 4910 2008-04-15 17:55:02Z larshelg $
*/
public interface SystemSettingManager
{
@@ -99,6 +98,7 @@
final String KEY_CUSTOM_LOGIN_PAGE_LOGO = "keyCustomLoginPageLogo";
final String KEY_CUSTOM_TOP_MENU_LOGO = "keyCustomTopMenuLogo";
final String KEY_ANALYTICS_MAINTENANCE_MODE = "keyAnalyticsMaintenanceMode";
+ final String KEY_DATABASE_SERVER_CPUS = "keyDatabaseServerCpus";
final String KEY_LAST_SUCCESSFUL_DATA_SYNC = "keyLastSuccessfulDataSynch";
final String KEY_LAST_SUCCESSFUL_ANALYTICS_TABLES_UPDATE = "keyLastSuccessfulAnalyticsTablesUpdate";
final String KEY_LAST_SUCCESSFUL_RESOURCE_TABLES_UPDATE = "keyLastSuccessfulResourceTablesUpdate";
@@ -119,6 +119,7 @@
final String DEFAULT_TIME_FOR_SENDING_MESSAGE = "08:00";
final String DEFAULT_CACHE_STRATEGY = "CACHE_6AM_TOMORROW";
final int DEFAULT_ANALYTICS_MAX_LIMIT = 50000;
+ final int DEFAULT_DATABASE_SERVER_CPUS = 0; // Detect automatically
final Map<String, Serializable> DEFAULT_SETTINGS_VALUES = new HashMap<String, Serializable>()
{
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2014-08-25 11:42:12 +0000
@@ -128,6 +128,7 @@
import org.hisp.dhis.period.RelativePeriods;
import org.hisp.dhis.period.comparator.AscendingPeriodEndDateComparator;
import org.hisp.dhis.reporttable.ReportTable;
+import org.hisp.dhis.setting.SystemSettingManager;
import org.hisp.dhis.system.grid.ListGrid;
import org.hisp.dhis.system.util.ConversionUtils;
import org.hisp.dhis.system.util.DebugUtils;
@@ -194,6 +195,9 @@
@Autowired
private DataElementOperandService operandService;
+
+ @Autowired
+ private SystemSettingManager systemSettingManager;
@Autowired
private CurrentUserService currentUserService;
@@ -704,7 +708,7 @@
{
queryPlanner.validateMaintenanceMode();
- int optimalQueries = MathUtils.getWithin( SystemUtils.getCpuCores(), 1, MAX_QUERIES );
+ int optimalQueries = MathUtils.getWithin( getProcessNo(), 1, MAX_QUERIES );
Timer t = new Timer().start();
@@ -1240,4 +1244,16 @@
return metaData;
}
+
+ /**
+ * Gets the number of available cores. Uses explicit number from system
+ * setting if available. Detects number of cores from current server runtime
+ * if not.
+ */
+ private int getProcessNo()
+ {
+ Integer cores = (Integer) systemSettingManager.getSystemSetting( SystemSettingManager.KEY_DATABASE_SERVER_CPUS );
+
+ return ( cores == null || cores == 0 ) ? SystemUtils.getCpuCores() : cores;
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java 2014-08-25 11:42:12 +0000
@@ -47,6 +47,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.resourcetable.ResourceTableService;
import org.hisp.dhis.scheduling.TaskId;
+import org.hisp.dhis.setting.SystemSettingManager;
import org.hisp.dhis.sqlview.SqlViewService;
import org.hisp.dhis.system.notification.Notifier;
import org.hisp.dhis.system.util.Clock;
@@ -86,6 +87,9 @@
@Autowired
private Notifier notifier;
+
+ @Autowired
+ private SystemSettingManager systemSettingManager;
// -------------------------------------------------------------------------
// Implementation
@@ -294,10 +298,18 @@
}
}
+ /**
+ * Gets the number of available cores. Uses explicit number from system
+ * setting if available. Detects number of cores from current server runtime
+ * if not. Subtracts one to the number of cores if greater than two to allow
+ * one core for general system operations.
+ */
private int getProcessNo()
{
- int cores = SystemUtils.getCpuCores();
+ Integer cores = (Integer) systemSettingManager.getSystemSetting( SystemSettingManager.KEY_DATABASE_SERVER_CPUS );
+ cores = ( cores == null || cores == 0 ) ? SystemUtils.getCpuCores() : cores;
+
return cores > 2 ? ( cores - 1 ) : cores;
}
}
=== 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 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java 2014-08-25 11:42:12 +0000
@@ -118,6 +118,7 @@
map.put( KEY_CUSTOM_LOGIN_PAGE_LOGO, systemSettingManager.getSystemSetting( KEY_CUSTOM_LOGIN_PAGE_LOGO, false ) );
map.put( KEY_CUSTOM_TOP_MENU_LOGO, systemSettingManager.getSystemSetting( KEY_CUSTOM_TOP_MENU_LOGO, false ) );
map.put( KEY_ANALYTICS_MAINTENANCE_MODE, systemSettingManager.getSystemSetting( KEY_ANALYTICS_MAINTENANCE_MODE, false ) );
+ map.put( KEY_DATABASE_SERVER_CPUS, systemSettingManager.getSystemSetting( KEY_DATABASE_SERVER_CPUS, DEFAULT_DATABASE_SERVER_CPUS ) );
map.put( SYSPROP_PORTAL, defaultIfEmpty( System.getProperty( SYSPROP_PORTAL ), String.valueOf( false ) ) );
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/SetGeneralSettingsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java 2014-07-10 10:27:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/SetGeneralSettingsAction.java 2014-08-25 11:42:12 +0000
@@ -111,6 +111,13 @@
{
this.analyticsMaxLimit = analyticsMaxLimit;
}
+
+ private Integer databaseServerCpus;
+
+ public void setDatabaseServerCpus( Integer databaseServerCpus )
+ {
+ this.databaseServerCpus = databaseServerCpus;
+ }
private Integer infrastructuralDataElements;
@@ -218,6 +225,7 @@
{
systemSettingManager.saveSystemSetting( KEY_CACHE_STRATEGY, cacheStrategy );
systemSettingManager.saveSystemSetting( KEY_ANALYTICS_MAX_LIMIT, analyticsMaxLimit );
+ systemSettingManager.saveSystemSetting( KEY_DATABASE_SERVER_CPUS, databaseServerCpus );
systemSettingManager.saveSystemSetting( KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART, omitIndicatorsZeroNumeratorDataMart );
systemSettingManager.saveSystemSetting( KEY_FACTOR_OF_DEVIATION, factorDeviation );
systemSettingManager.saveSystemSetting( KEY_PHONE_NUMBER_AREA_CODE, phoneNumberAreaCode );
=== 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 2014-07-11 22:15:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties 2014-08-25 11:42:12 +0000
@@ -116,4 +116,7 @@
put_analytics_in_maintenance_mode=Put analytics in maintenance mode
returns=returns
test_settings=Test settings
-hidden=Hidden
\ No newline at end of file
+hidden=Hidden
+no_of_database_server_cpus=Number of database server CPUs
+automatic=Automatic
+detect_based_on_web_server=detect based on web server
\ 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/systemGeneralSettings.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm 2014-07-10 10:27:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemGeneralSettings.vm 2014-08-25 11:42:12 +0000
@@ -4,6 +4,7 @@
jQuery.postUTF8('setSystemGeneralSettings.action', {
cacheStrategy: getFieldValue('cacheStrategy'),
analyticsMaxLimit: getFieldValue('analyticsMaxLimit'),
+ databaseServerCpus: getFieldValue('databaseServerCpus'),
infrastructuralDataElements: getFieldValue('infrastructuralDataElements'),
infrastructuralPeriodType: getFieldValue('infrastructuralPeriodType'),
feedbackRecipients: getFieldValue('feedbackRecipients'),
@@ -46,6 +47,19 @@
</select>
</div>
+<div class="settingLabel">$i18n.getString( "no_of_database_server_cpus" )</div>
+
+<div class="setting">
+<select id="databaseServerCpus" name="databaseServerCpus">
+ <option value="0">$i18n.getString( "automatic" ) ($i18n.getString( "detect_based_on_web_server" ))</option>
+ <option value="2" #if( $keyDatabaseServerCpus == "2" )selected="selected"#end>2</option>
+ <option value="4" #if( $keyDatabaseServerCpus == "4" )selected="selected"#end>4</option>
+ <option value="8" #if( $keyDatabaseServerCpus == "8" )selected="selected"#end>8</option>
+ <option value="16" #if( $keyDatabaseServerCpus == "16" )selected="selected"#end>16</option>
+ <option value="32" #if( $keyDatabaseServerCpus == "32" )selected="selected"#end>32</option>
+</select>
+</div>
+
<div class="settingLabel">$i18n.getString( "infrastructural_data_elements" )</div>
<div class="setting">