@Override public void terminate(final boolean error) { this.executor.shutdown(); if (!error) { long shutdownDelaySecondsFromNow = TimeUnit.SECONDS.convert( (this.latestSchedulingTime - this.timer.getCurrentTime(this.timeunit)) + this.shutdownDelay, this.timeunit); if (shutdownDelaySecondsFromNow < 0) { shutdownDelaySecondsFromNow = 0; } shutdownDelaySecondsFromNow += 2; // Add a buffer for the timeout. Having exactly the second for the last // event is unnecessarily tight. try { this.logger.info("Awaiting termination delay of {} seconds ...", shutdownDelaySecondsFromNow); if (!this.executor.awaitTermination(shutdownDelaySecondsFromNow, TimeUnit.SECONDS)) { this.logger.error("Termination delay triggerred before all scheduled records sent"); } } catch (final InterruptedException e) { this.logger.error("Interrupted while awaiting termination delay", e); } } }
IMonitoringRecord.class }, description = "Receives the records to be delayed") public final void inputRecord(final IMonitoringRecord monitoringRecord) { final long currentTime = this.timer.getCurrentTime(this.timeunit);
final long currentTime = this.timer.getCurrentTime(this.timeunit);
@Override public void terminate(final boolean error) { this.executor.shutdown(); if (!error) { long shutdownDelaySecondsFromNow = TimeUnit.SECONDS.convert((this.latestSchedulingTime - this.timer.getCurrentTime(this.timeunit)) + this.shutdownDelay, this.timeunit); if (shutdownDelaySecondsFromNow < 0) { shutdownDelaySecondsFromNow = 0; } shutdownDelaySecondsFromNow += 2; // Add a buffer for the timeout. Having exactly the second for the last event is unnecessarily tight. try { this.log.info("Awaiting termination delay of " + shutdownDelaySecondsFromNow + " seconds ..."); if (!this.executor.awaitTermination(shutdownDelaySecondsFromNow, TimeUnit.SECONDS)) { this.log.error("Termination delay triggerred before all scheduled records sent"); } } catch (final InterruptedException e) { this.log.error("Interrupted while awaiting termination delay", e); } } }