@Transactional @Override public void sendScheduledNotifications() { Clock clock = new Clock( log ).startClock() .logTime( "Processing ProgramStageNotification messages scheduled by program rules" ); List<ProgramNotificationInstance> templates = identifiableObjectManager.getAll( ProgramNotificationInstance.class ).stream() .filter( IS_SCHEDULED_BY_PROGRAM_RULE ).collect( Collectors.toList() ); if ( templates.isEmpty() ) { return; } int totalMessageCount = 0; List<MessageBatch> batches = templates.stream().filter( ProgramNotificationInstance::hasProgramInstance ) .map( t -> createProgramInstanceMessageBatch( t.getProgramNotificationTemplate(), Arrays.asList( t.getProgramInstance() ) ) ) .collect( Collectors.toList() ); batches.addAll( templates.stream().filter( ProgramNotificationInstance::hasProgramStageInstance ) .map( t -> createProgramStageInstanceMessageBatch( t.getProgramNotificationTemplate(), Arrays.asList( t.getProgramStageInstance() ) ) ) .collect( Collectors.toList() ) ); batches.stream().forEach( this::sendAll ); totalMessageCount = batches.stream().mapToInt( MessageBatch::messageCount ).sum(); clock.logTime( String.format( "Created and sent %d messages in %s", totalMessageCount, clock.time() ) ); }
Clock clock = new Clock( log ).startClock() .logTime( String.format( "Creating notifications for %d validation results", validationResults.size() ) );
@Transactional @Override public void sendScheduledNotificationsForDay( Date notificationDate ) { Clock clock = new Clock( log ).startClock() .logTime( "Processing ProgramStageNotification messages" ); List<ProgramNotificationTemplate> scheduledTemplates = getScheduledTemplates(); int totalMessageCount = 0; for ( ProgramNotificationTemplate template : scheduledTemplates ) { MessageBatch batch = createScheduledMessageBatchForDay( template, notificationDate ); sendAll( batch ); totalMessageCount += batch.messageCount(); } clock.logTime( String.format( "Created and sent %d messages in %s", totalMessageCount, clock.time() ) ); }
public void generateResourceTable( ResourceTable<?> resourceTable ) final Clock clock = new Clock().startClock(); final String createTableSql = resourceTable.getCreateTempTableStatement(); final Optional<String> populateTableSql = resourceTable.getPopulateTempTableStatement();
@Override public void execute( JobConfiguration jobConfiguration ) { final Clock clock = new Clock().startClock(); notifier.notify( jobConfiguration, "Generating and sending scheduled program notifications" ); try { runInternal(); notifier.notify( jobConfiguration, NotificationLevel.INFO, "Generated and sent scheduled program notifications: " + clock.time(), true ); } catch ( RuntimeException ex ) { notifier.notify( jobConfiguration, NotificationLevel.ERROR, "Process failed: " + ex.getMessage(), true ); messageService.sendSystemErrorNotification( "Generating and sending scheduled program notifications failed", ex ); throw ex; } }
@Override public void generateResourceTables( JobConfiguration jobId ) { final Clock clock = new Clock().startClock(); notifier.notify( jobId, "Generating resource tables" ); try { generateResourceTables(); notifier.notify( jobId, INFO, "Resource tables generated: " + clock.time(), true ); } catch ( RuntimeException ex ) { notifier.notify( jobId, ERROR, "Process failed: " + ex.getMessage(), true ); messageService.sendSystemErrorNotification( "Resource table process failed", ex ); throw ex; } }
@Override public void execute( JobConfiguration jobConfiguration ) { final Clock clock = new Clock().startClock(); notifier.notify( jobConfiguration, "Sending new validation result notifications" ); try { runInternal(); notifier.notify( jobConfiguration, NotificationLevel.INFO, "Sent validation result notifications: " + clock.time(), true ); } catch ( RuntimeException ex ) { notifier.notify( jobConfiguration, NotificationLevel.ERROR, "Process failed: " + ex.getMessage(), true ); messageService .sendSystemErrorNotification( "Sending validation result notifications failed", ex ); throw ex; } }
@Override public void execute( JobConfiguration jobConfiguration ) throws Exception { final Clock clock = new Clock().startClock(); notifier.notify( jobConfiguration, "Sending scheduled dataset notifications" ); try { send(); notifier.notify( jobConfiguration, NotificationLevel.INFO, "Sent scheduled dataset notifications: " + clock.time(), true ); } catch ( RuntimeException ex ) { notifier.notify( jobConfiguration, NotificationLevel.ERROR, "Process failed: " + ex.getMessage(), true ); messageService.sendSystemErrorNotification( "Scheduled dataset notifications failed", ex ); throw ex; } }
@Override public void generateTables( AnalyticsTableUpdateParams params ) final Clock clock = new Clock( log ).startClock(); final JobConfiguration jobId = params.getJobId(); final Set<AnalyticsTableType> skipTypes = CollectionUtils.emptyIfNull( params.getSkipTableTypes() );
final Clock clock = new Clock( log ).startClock().logTime( "Starting anonymous event program data synchronization job." ); final int objectsToSynchronize = eventService.getAnonymousEventReadyForSynchronizationCount();
final Clock clock = new Clock( log ).startClock().logTime( "Starting Tracker program data synchronization job." );
public SynchronizationResult syncCompleteness() { if ( !SyncUtils.testServerAvailability( systemSettingManager, restTemplate ).isAvailable() ) { return SynchronizationResult.newFailureResultWithMessage( "Completeness Synchronisation failed. Remote " + "server is unavailable." ); } final Clock clock = new Clock( log ) .startClock() .logTime( "Starting Completeness Synchronisation job." ); // --------------------------------------------------------------------- // Set time for last success to start of process to make data saved // subsequently part of next synch process without being ignored // --------------------------------------------------------------------- ImportSummary importSummary; try { importSummary = synchronizationManager.executeDataSetCompletenessPush(); if ( checkSummaryStatus( importSummary, SyncEndpoint.COMPLETE_DATA_SET_REGISTRATIONS ) ) { clock.logTime( "SUCCESS! Completeness Synchronisation job is done. It took" ); setLastDataValueSynchronizationSuccess( new Date( clock.getStartTime() ) ); return SynchronizationResult.newSuccessResultWithMessage( "Completeness Synchronisation done. It took " + clock.getTime() + " ms." ); } } catch ( Exception ex ) { log.error( "Exception happened while trying to completeness push " + ex.getMessage(), ex ); } return SynchronizationResult.newFailureResultWithMessage( "Completeness Synchronisation failed."); }
@Override public void execute( JobConfiguration jobConfiguration ) { final int cpuCores = SystemUtils.getCpuCores(); Clock clock = new Clock().startClock().logTime( "Aggregate process started, number of CPU cores: " + cpuCores + ", " + SystemUtils.getMemoryString() ); clock.logTime( "Starting to send messages in outbound" ); notifier.notify( jobConfiguration, INFO, "Start to send messages in outbound", true ); sendMessages(); clock.logTime( "Sending messages in outbound completed" ); notifier.notify( jobConfiguration, INFO, "Sending messages in outbound completed", true ); }
final Clock clock = new Clock( log ).startClock().logTime( "Starting DataValueSynchronization job" ); final Date lastSuccessTime = getLastDataSynchSuccessFallback(); final int objectsToSynchronize = dataValueService.getDataValueCountLastUpdatedAfter( lastSuccessTime, true );
Clock clock = new Clock( log ).startClock();
final Clock clock = new Clock().startClock(); try
public Collection<ValidationResult> validationAnalysis( ValidationAnalysisParams parameters) { Clock clock = new Clock( log ).startClock().logTime( "Starting validation analysis" + ( parameters.getOrgUnit() == null ? "" : " for orgUnit " + parameters.getOrgUnit().getUid() + ( parameters.isIncludeOrgUnitDescendants() ? " with descendants" : "" ) ) + ", " + ( parameters.getPeriods().size() == 1 ? "period " + Iterables.getOnlyElement( parameters.getPeriods() ).getIsoDate() : parameters.getPeriods().size() + " periods" ) + ", " + parameters.getRules().size() + " rules" + ( parameters.isPersistResults() ? ", persisting results" : "" ) + ( parameters.isSendNotifications() ? ", sending notifications" : "" ) ); ValidationRunContext context = getValidationContext( parameters ); clock.logTime( "Initialized validation analysis" ); Collection<ValidationResult> results = Validator.validate( context, applicationContext, analyticsService ); if ( context.isPersistResults() ) { validationResultService.saveValidationResults( context.getValidationResults() ); } clock.logTime( "Finished validation analysis, " + context.getValidationResults().size() + " results").stop(); if ( context.isSendNotifications() ) { notificationService.sendNotifications( Sets.newHashSet( results ) ); } return results; }
private ImportSummary saveCompleteDataSetRegistrations( ImportOptions importOptions, JobConfiguration id, CompleteDataSetRegistrations completeRegistrations ) Clock clock = new Clock( log ).startClock() .logTime( "Starting complete data set registration import, options: " + importOptions ); notifier.clear( id ).notify( id, "Process started" );
.startClock() .logTime( String.format( "Starting update: %s, processes: %d, org unit levels: %d", tableType.getTableName(), processNo, orgUnitLevelNo ) );
Clock clock = new Clock( log ).startClock().logTime( "Starting data value import, options: " + importOptions ); NotificationLevel notificationLevel = importOptions.getNotificationLevel( INFO ); notifier.clear( id ).notify( id, notificationLevel, "Process started" );