@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 ); }
@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() ) ); }
@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() ) ); }
.logTime( String.format( "Starting update: %s, processes: %d, org unit levels: %d", tableType.getTableName(), processNo, orgUnitLevelNo ) ); clock.logTime( "Table updated aborted, no table or partitions found" ); notifier.notify( jobId, "Table updated aborted, no table or partitions found" ); return; clock.logTime( "Table update start: " + tableType.getTableName() + ", earliest: " + earliest + ", parameters: " + params.toString() ); notifier.notify( jobId, "Performing pre-create table work, org unit levels: " + orgUnitLevelNo ); clock.logTime( "Performed pre-create table work" ); notifier.notify( jobId, "Dropping temp tables" ); clock.logTime( "Dropped temp tables" ); notifier.notify( jobId, "Creating analytics tables" ); clock.logTime( "Created analytics tables" ); notifier.notify( jobId, "Populating analytics tables" ); clock.logTime( "Populated analytics tables" ); notifier.notify( jobId, "Invoking analytics table hooks" ); clock.logTime( "Invoked analytics table hooks" ); notifier.notify( jobId, "Applying aggregation levels" ); clock.logTime( "Applied aggregation levels" ); clock.logTime( "Tables vacuumed" ); clock.logTime( "Created indexes" );
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."); }
final Clock clock = new Clock( log ).startClock().logTime( "Starting anonymous event program data synchronization job." ); final int objectsToSynchronize = eventService.getAnonymousEventReadyForSynchronizationCount(); clock.logTime( "SUCCESS! Events sync was successfully done! It took " ); return SynchronizationResult.newSuccessResultWithMessage( "Events synchronization done. It took " + clock.getTime() + " ms." );
final Clock clock = new Clock( log ).startClock().logTime( "Starting Tracker program data synchronization job." ); clock.logTime( "SUCCESS! Tracker synchronization was successfully done! It took " ); return SynchronizationResult.newSuccessResultWithMessage( "Tracker synchronization done. It took " + clock.getTime() + " ms." );
clock.logTime( "Analytics tables updated" );
final Clock clock = new Clock( log ).startClock().logTime( "Starting DataValueSynchronization job" ); final Date lastSuccessTime = getLastDataSynchSuccessFallback(); final int objectsToSynchronize = dataValueService.getDataValueCountLastUpdatedAfter( lastSuccessTime, true ); clock.logTime( "SUCCESS! DataValueSynchronization job is done. It took" ); setLastDataValueSynchronizationSuccess( new Date( clock.getStartTime() ) ); return SynchronizationResult.newSuccessResultWithMessage( "DataValueSynchronization done. It took " + clock.getTime() + " ms." );
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; }
clock.logTime( "Import done" );
.logTime( "Starting complete data set registration import, options: " + importOptions ); notifier.clear( id ).notify( id, "Process started" ); clock.logTime( String.format( "Complete data set registration import done, total: %d, imported: %d, updated: %d, deleted: %d", totalCount, count.getImported(), count.getUpdated(), count.getDeleted() ) );
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" ); clock.logTime( "Validated outer meta-data" ); notifier.notify( id, notificationLevel, "Importing data values" ); summary.setDescription( "Import process completed successfully" ); clock.logTime( "Data value import done, total: " + totalCount + ", import: " + importCount + ", update: " + updateCount + ", delete: " + deleteCount ); notifier.notify( id, notificationLevel, "Import done", true ).addJobSummary( id, notificationLevel, summary, ImportSummary.class );