dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #35739
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18292: Applied patch from TW. Adds support for 15min interval resource table scheduling
------------------------------------------------------------
revno: 18292
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-02-17 14:27:11 +0100
message:
Applied patch from TW. Adds support for 15min interval resource table scheduling
modified:
dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/SchedulingManager.java
dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/Scheduler.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/scheduling/ScheduleTasksAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.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-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml 2015-02-12 09:28:20 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml 2015-02-17 13:27:11 +0000
@@ -102,5 +102,7 @@
<!-- Scheduled tasks -->
<bean id="resourceTableTask" class="org.hisp.dhis.resourcetable.scheduling.ResourceTableTask" />
-
+
+ <bean id="resourceTable15MinTask" class="org.hisp.dhis.resourcetable.scheduling.ResourceTableTask" />
+
</beans>
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/SchedulingManager.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/SchedulingManager.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/SchedulingManager.java 2015-02-17 13:27:11 +0000
@@ -28,16 +28,17 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.common.ListMap;
+
import java.util.Set;
-import org.hisp.dhis.common.ListMap;
-
/**
* @author Lars Helge Overland
*/
public interface SchedulingManager
{
final String TASK_RESOURCE_TABLE = "resourceTableTask";
+ final String TASK_RESOURCE_TABLE_15_MINS = "resourceTable15MinTask";
final String TASK_DATAMART_LAST_YEAR = "dataMartLastYearTask";
final String TASK_ANALYTICS_ALL = "analyticsAllTask";
final String TASK_ANALYTICS_LAST_3_YEARS = "analyticsLast3YearsTask";
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2014-12-04 06:39:46 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2015-02-17 13:27:11 +0000
@@ -188,6 +188,7 @@
<property name="tasks">
<map>
<entry key="resourceTableTask" value-ref="resourceTableTask" />
+ <entry key="resourceTable15MinTask" value-ref="resourceTable15MinTask" />
<entry key="dataMartLastYearTask" value-ref="dataMartLastYearTask" />
<entry key="analyticsAllTask" value-ref="analyticsAllTask" />
<entry key="analyticsLast3YearsTask" value-ref="analyticsLast3YearsTask" />
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/Scheduler.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/Scheduler.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/Scheduler.java 2015-02-17 13:27:11 +0000
@@ -35,6 +35,7 @@
{
final String CRON_DAILY_0AM = "0 0 0 * * ?";
final String CRON_EVERY_MIN = "0 0/1 * * * ?";
+ final String CRON_EVERY_15MIN = "0 0/15 * * * ?";
final String CRON_TEST = "0 * * * * ?";
final String STATUS_RUNNING = "running";
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/scheduling/ScheduleTasksAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/scheduling/ScheduleTasksAction.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/scheduling/ScheduleTasksAction.java 2015-02-17 13:27:11 +0000
@@ -28,24 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.scheduling.SchedulingManager.TASK_ANALYTICS_ALL;
-import static org.hisp.dhis.scheduling.SchedulingManager.TASK_ANALYTICS_LAST_3_YEARS;
-import static org.hisp.dhis.scheduling.SchedulingManager.TASK_DATAMART_LAST_YEAR;
-import static org.hisp.dhis.scheduling.SchedulingManager.TASK_RESOURCE_TABLE;
-import static org.hisp.dhis.scheduling.SchedulingManager.TASK_MONITORING_LAST_DAY;
-import static org.hisp.dhis.scheduling.SchedulingManager.TASK_DATA_SYNCH;
-import static org.hisp.dhis.setting.SystemSettingManager.*;
-import static org.hisp.dhis.system.scheduling.Scheduler.CRON_DAILY_0AM;
-import static org.hisp.dhis.system.scheduling.Scheduler.CRON_EVERY_MIN;
-import static org.hisp.dhis.system.scheduling.Scheduler.STATUS_RUNNING;
-import static org.hisp.dhis.system.util.CollectionUtils.emptyIfNull;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
+import com.opensymphony.xwork2.Action;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.common.ListMap;
@@ -57,7 +40,31 @@
import org.hisp.dhis.system.scheduling.Scheduler;
import org.springframework.beans.factory.annotation.Autowired;
-import com.opensymphony.xwork2.Action;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.hisp.dhis.scheduling.SchedulingManager.TASK_ANALYTICS_ALL;
+import static org.hisp.dhis.scheduling.SchedulingManager.TASK_ANALYTICS_LAST_3_YEARS;
+import static org.hisp.dhis.scheduling.SchedulingManager.TASK_DATAMART_LAST_YEAR;
+import static org.hisp.dhis.scheduling.SchedulingManager.TASK_DATA_SYNCH;
+import static org.hisp.dhis.scheduling.SchedulingManager.TASK_MONITORING_LAST_DAY;
+import static org.hisp.dhis.scheduling.SchedulingManager.TASK_RESOURCE_TABLE;
+import static org.hisp.dhis.scheduling.SchedulingManager.TASK_RESOURCE_TABLE_15_MINS;
+import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_ORGUNITGROUPSET_AGG_LEVEL;
+import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_SCHEDULED_PERIOD_TYPES;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_LAST_SUCCESSFUL_ANALYTICS_TABLES_UPDATE;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_LAST_SUCCESSFUL_RESOURCE_TABLES_UPDATE;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_ORGUNITGROUPSET_AGG_LEVEL;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULED_PERIOD_TYPES;
+import static org.hisp.dhis.system.scheduling.Scheduler.CRON_DAILY_0AM;
+import static org.hisp.dhis.system.scheduling.Scheduler.CRON_EVERY_15MIN;
+import static org.hisp.dhis.system.scheduling.Scheduler.CRON_EVERY_MIN;
+import static org.hisp.dhis.system.scheduling.Scheduler.STATUS_RUNNING;
+import static org.hisp.dhis.system.util.CollectionUtils.emptyIfNull;
+
/**
* @author Lars Helge Overland
@@ -66,18 +73,19 @@
implements Action
{
private static final String STRATEGY_ALL_DAILY = "allDaily";
+ private static final String STRATEGY_ALL_15_MIN = "allEvery15Min";
private static final String STRATEGY_LAST_3_YEARS_DAILY = "last3YearsDaily";
private static final String STRATEGY_ENABLED = "enabled";
-
+
private static final Log log = LogFactory.getLog( ScheduleTasksAction.class );
-
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@Autowired
private SystemSettingManager systemSettingManager;
-
+
@Autowired
private SchedulingManager schedulingManager;
@@ -90,7 +98,7 @@
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
-
+
private boolean schedule;
public void setSchedule( boolean schedule )
@@ -111,7 +119,7 @@
}
private String analyticsStrategy;
-
+
public String getAnalyticsStrategy()
{
return analyticsStrategy;
@@ -133,9 +141,9 @@
{
this.scheduledPeriodTypes = scheduledPeriodTypes;
}
-
+
private Integer orgUnitGroupSetAggLevel;
-
+
public Integer getOrgUnitGroupSetAggLevel()
{
return orgUnitGroupSetAggLevel;
@@ -157,7 +165,7 @@
{
this.dataMartStrategy = dataMartStrategy;
}
-
+
private String monitoringStrategy;
public String getMonitoringStrategy()
@@ -176,12 +184,12 @@
{
return dataSynchStrategy;
}
-
+
public void setDataSynchStrategy( String dataSynchStrategy )
{
this.dataSynchStrategy = dataSynchStrategy;
}
-
+
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
@@ -199,48 +207,48 @@
{
return running;
}
-
+
private List<OrganisationUnitLevel> levels;
public List<OrganisationUnitLevel> getLevels()
{
return levels;
}
-
+
private Date lastResourceTableSuccess;
public Date getLastResourceTableSuccess()
{
return lastResourceTableSuccess;
}
-
+
private Date lastAnalyticsTableSuccess;
public Date getLastAnalyticsTableSuccess()
{
return lastAnalyticsTableSuccess;
}
-
+
private Date lastDataSyncSuccess;
-
+
public Date getLastDataSyncSuccess()
{
return lastDataSyncSuccess;
}
-
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public String execute()
- {
+ {
if ( schedule )
{
systemSettingManager.saveSystemSetting( KEY_SCHEDULED_PERIOD_TYPES, (HashSet<String>) scheduledPeriodTypes );
systemSettingManager.saveSystemSetting( KEY_ORGUNITGROUPSET_AGG_LEVEL, orgUnitGroupSetAggLevel );
-
+
if ( Scheduler.STATUS_RUNNING.equals( schedulingManager.getTaskStatus() ) )
{
schedulingManager.stopTasks();
@@ -248,7 +256,7 @@
else
{
ListMap<String, String> cronKeyMap = new ListMap<>();
-
+
// -------------------------------------------------------------
// Resource tables
// -------------------------------------------------------------
@@ -257,7 +265,11 @@
{
cronKeyMap.putValue( CRON_DAILY_0AM, TASK_RESOURCE_TABLE );
}
-
+ else if ( STRATEGY_ALL_15_MIN.equals( resourceTableStrategy ) )
+ {
+ cronKeyMap.putValue( CRON_EVERY_15MIN, TASK_RESOURCE_TABLE_15_MINS );
+ }
+
// -------------------------------------------------------------
// Analytics
// -------------------------------------------------------------
@@ -270,11 +282,11 @@
{
cronKeyMap.putValue( CRON_DAILY_0AM, TASK_ANALYTICS_LAST_3_YEARS );
}
-
+
// -------------------------------------------------------------
// Data mart
// -------------------------------------------------------------
-
+
if ( STRATEGY_ALL_DAILY.equals( dataMartStrategy ) )
{
cronKeyMap.putValue( CRON_DAILY_0AM, TASK_DATAMART_LAST_YEAR );
@@ -283,7 +295,7 @@
// -------------------------------------------------------------
// Monitoring
// -------------------------------------------------------------
-
+
if ( STRATEGY_ALL_DAILY.equals( monitoringStrategy ) )
{
cronKeyMap.putValue( CRON_DAILY_0AM, TASK_MONITORING_LAST_DAY );
@@ -292,19 +304,19 @@
// -------------------------------------------------------------
// Data synch
// -------------------------------------------------------------
-
+
if ( STRATEGY_ENABLED.equals( dataSynchStrategy ) )
{
cronKeyMap.putValue( CRON_EVERY_MIN, TASK_DATA_SYNCH );
}
-
+
schedulingManager.scheduleTasks( cronKeyMap );
}
}
else
{
Collection<String> keys = emptyIfNull( schedulingManager.getScheduledKeys() );
-
+
// -----------------------------------------------------------------
// Resource tables
// -----------------------------------------------------------------
@@ -313,7 +325,11 @@
{
resourceTableStrategy = STRATEGY_ALL_DAILY;
}
-
+ else if ( keys.contains( TASK_RESOURCE_TABLE_15_MINS ) )
+ {
+ resourceTableStrategy = STRATEGY_ALL_15_MIN;
+ }
+
// -----------------------------------------------------------------
// Analytics
// -----------------------------------------------------------------
@@ -326,7 +342,7 @@
{
analyticsStrategy = STRATEGY_LAST_3_YEARS_DAILY;
}
-
+
// -----------------------------------------------------------------
// Data mart
// -----------------------------------------------------------------
@@ -339,37 +355,37 @@
// -------------------------------------------------------------
// Monitoring
// -------------------------------------------------------------
-
+
if ( keys.contains( TASK_MONITORING_LAST_DAY ) )
{
monitoringStrategy = STRATEGY_ALL_DAILY;
}
-
+
// -------------------------------------------------------------
// Data synch
// -------------------------------------------------------------
-
+
if ( keys.contains( TASK_DATA_SYNCH ) )
{
dataSynchStrategy = STRATEGY_ENABLED;
- }
+ }
}
-
+
scheduledPeriodTypes = (Set<String>) systemSettingManager.getSystemSetting( KEY_SCHEDULED_PERIOD_TYPES, DEFAULT_SCHEDULED_PERIOD_TYPES );
orgUnitGroupSetAggLevel = (Integer) systemSettingManager.getSystemSetting( KEY_ORGUNITGROUPSET_AGG_LEVEL, DEFAULT_ORGUNITGROUPSET_AGG_LEVEL );
-
- status = schedulingManager.getTaskStatus();
+
+ status = schedulingManager.getTaskStatus();
running = STATUS_RUNNING.equals( status );
-
+
levels = organisationUnitService.getOrganisationUnitLevels();
-
+
lastResourceTableSuccess = (Date) systemSettingManager.getSystemSetting( KEY_LAST_SUCCESSFUL_RESOURCE_TABLES_UPDATE );
lastAnalyticsTableSuccess = (Date) systemSettingManager.getSystemSetting( KEY_LAST_SUCCESSFUL_ANALYTICS_TABLES_UPDATE );
lastDataSyncSuccess = synchronizationManager.getLastSynchSuccess();
log.info( "Status: " + status );
log.info( "Running: " + running );
-
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2015-02-13 15:23:56 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2015-02-17 13:27:11 +0000
@@ -293,6 +293,7 @@
last_2_years_daily=Last 2 years daily
last_3_years_daily=Last 3 years daily
all_daily=All daily
+all_every_15_min=All every 15 minutes
resource_table_task_strategy=Resource tables task strategy
data_mart_task_strategy=Data mart task strategy
never=Never
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.vm 2014-08-05 10:57:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.vm 2015-02-17 13:27:11 +0000
@@ -17,6 +17,7 @@
<select id="resourceTableStrategy" name="resourceTableStrategy" class="scheduling">
<option value="disabled">$i18n.getString( "disabled" )</option>
<option value="allDaily"#if( $resourceTableStrategy && $resourceTableStrategy == "allDaily" ) selected="selected"#end>$i18n.getString( "all_daily" )</option>
+ <option value="allEvery15Min"#if( $resourceTableStrategy && $resourceTableStrategy == "allEvery15Min" ) selected="selected"#end>$i18n.getString( "all_every_15_min" )</option>
</select>
</div>