use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.
the class ValidationController method runValidationNotificationsTask.
@RequestMapping(value = "/sendNotifications", method = { RequestMethod.PUT, RequestMethod.POST })
@PreAuthorize("hasRole('ALL') or hasRole('M_dhis-web-app-management')")
@ResponseBody
public WebMessage runValidationNotificationsTask() {
JobConfiguration validationResultNotification = new JobConfiguration("validation result notification from validation controller", JobType.VALIDATION_RESULTS_NOTIFICATION, "", null);
validationResultNotification.setInMemoryJob(true);
validationResultNotification.setUid(CodeGenerator.generateUid());
schedulingManager.executeNow(validationResultNotification);
return ok("Initiated validation result notification");
}
use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.
the class SchedulerStart method checkLeaderElectionJobConfiguration.
private void checkLeaderElectionJobConfiguration(List<JobConfiguration> jobConfigurations) {
Optional<JobConfiguration> maybeLeaderElection = jobConfigurations.stream().filter(configuration -> configuration.getName().equals(SystemJob.LEADER_ELECTION.name)).findFirst();
if (maybeLeaderElection.isPresent()) {
JobConfiguration leaderElection = maybeLeaderElection.get();
leaderElection.setCronExpression(format(LEADER_JOB_CRON_FORMAT, leaderElectionTime));
leaderElection.setEnabled(redisEnabled);
jobConfigurationService.updateJobConfiguration(leaderElection);
}
}
use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.
the class SchedulerStart method addDefaultJobs.
private void addDefaultJobs(List<JobConfiguration> jobConfigurations) {
log.info("Setting up default jobs.");
addDefaultJob(SystemJob.FILE_RESOURCE, jobConfigurations);
addDefaultJob(SystemJob.DATA_STATISTICS, jobConfigurations, config -> portJob(config, SettingKey.LAST_SUCCESSFUL_DATA_STATISTICS));
addDefaultJob(SystemJob.VALIDATION_RESULTS_NOTIFICATION, jobConfigurations);
addDefaultJob(SystemJob.CREDENTIALS_EXPIRY_ALERT, jobConfigurations);
addDefaultJob(SystemJob.ACCOUNT_EXPIRY_ALERT, jobConfigurations);
addDefaultJob(SystemJob.DATA_SET_NOTIFICATION, jobConfigurations);
addDefaultJob(SystemJob.REMOVE_EXPIRED_OR_USED_RESERVED_VALUES, jobConfigurations);
addDefaultJob(SystemJob.SYSTEM_VERSION_UPDATE_CHECK, jobConfigurations);
if (redisEnabled && verifyNoJobExist(SystemJob.LEADER_ELECTION.name, jobConfigurations)) {
JobConfiguration leaderElectionJobConfiguration = new JobConfiguration(SystemJob.LEADER_ELECTION.name, SystemJob.LEADER_ELECTION.type, format(SystemJob.LEADER_ELECTION.cron, leaderElectionTime), null);
leaderElectionJobConfiguration.setLeaderOnlyJob(false);
leaderElectionJobConfiguration.setUid(SystemJob.LEADER_ELECTION.uid);
addAndScheduleJob(leaderElectionJobConfiguration);
} else {
checkLeaderElectionJobConfiguration(jobConfigurations);
}
}
use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.
the class TrackerTrigramIndexingJobTest method testRunJobWithNonIndexableAttributesInJobParameters.
@Test
public void testRunJobWithNonIndexableAttributesInJobParameters() {
when(trackedEntityAttributeService.getAllTrigramIndexableTrackedEntityAttributes()).thenReturn(Collections.singleton(new TrackedEntityAttribute()));
JobConfiguration jobConfiguration = new JobConfiguration();
TrackerTrigramIndexJobParameters jp = new TrackerTrigramIndexJobParameters();
jp.setAttributes(Collections.singleton("aaaa"));
jobConfiguration.setJobParameters(jp);
job.execute(jobConfiguration, NoopJobProgress.INSTANCE);
verify(trackedEntityAttributeTableManager, never()).createTrigramIndex(any());
}
use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.
the class TrackerTrigramIndexingJobTest method testRunJobWithoutAnyAttributesInJobParametersAndWithoutAnyObsolete.
@Test
public void testRunJobWithoutAnyAttributesInJobParametersAndWithoutAnyObsolete() {
JobConfiguration jobConfiguration = new JobConfiguration();
TrackerTrigramIndexJobParameters jp = new TrackerTrigramIndexJobParameters();
jobConfiguration.setJobParameters(jp);
job.execute(jobConfiguration, NoopJobProgress.INSTANCE);
verify(trackedEntityAttributeTableManager, never()).createTrigramIndex(any());
verify(trackedEntityAttributeTableManager, never()).dropTrigramIndex(any());
}
Aggregations