|
@@ -152,28 +152,33 @@ public class VersionCheckService extends AbstractPwmService
|
|
|
|
|
|
final VersionCheckInfoCache localCache = cacheHolder.getVersionCheckInfoCache();
|
|
final VersionCheckInfoCache localCache = cacheHolder.getVersionCheckInfoCache();
|
|
|
|
|
|
|
|
+ this.nextScheduledCheck = calculateNextScheduledCheck( localCache, settings );
|
|
|
|
+
|
|
|
|
+ final TimeDuration delayUntilNextExecution = TimeDuration.fromCurrent( this.nextScheduledCheck );
|
|
|
|
+
|
|
|
|
+ getExecutorService().schedule( new PeriodicCheck(), delayUntilNextExecution.asMillis(), TimeUnit.MILLISECONDS );
|
|
|
|
+
|
|
|
|
+ LOGGER.trace( getSessionLabel(), () -> "scheduled next check execution at " + StringUtil.toIsoDate( nextScheduledCheck )
|
|
|
|
+ + " in " + delayUntilNextExecution.asCompactString() );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static Instant calculateNextScheduledCheck( final VersionCheckInfoCache localCache, final VersionCheckSettings settings )
|
|
|
|
+ {
|
|
final TimeDuration idealDurationUntilNextCheck = localCache.getLastError() != null && localCache.getCurrentVersion() == null
|
|
final TimeDuration idealDurationUntilNextCheck = localCache.getLastError() != null && localCache.getCurrentVersion() == null
|
|
? settings.getCheckIntervalError()
|
|
? settings.getCheckIntervalError()
|
|
: settings.getCheckInterval();
|
|
: settings.getCheckInterval();
|
|
|
|
|
|
if ( localCache.getLastCheckTimestamp() == null )
|
|
if ( localCache.getLastCheckTimestamp() == null )
|
|
{
|
|
{
|
|
- this.nextScheduledCheck = Instant.now().plus( 10, ChronoUnit.SECONDS );
|
|
|
|
|
|
+ return Instant.now().plus( 10, ChronoUnit.SECONDS );
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
final Instant nextIdealTimestamp = localCache.getLastCheckTimestamp().plus( idealDurationUntilNextCheck.asDuration() );
|
|
final Instant nextIdealTimestamp = localCache.getLastCheckTimestamp().plus( idealDurationUntilNextCheck.asDuration() );
|
|
- this.nextScheduledCheck = nextIdealTimestamp.isBefore( Instant.now() )
|
|
|
|
|
|
+ return nextIdealTimestamp.isBefore( Instant.now() )
|
|
? Instant.now().plus( 10, ChronoUnit.SECONDS )
|
|
? Instant.now().plus( 10, ChronoUnit.SECONDS )
|
|
: nextIdealTimestamp;
|
|
: nextIdealTimestamp;
|
|
}
|
|
}
|
|
-
|
|
|
|
- final TimeDuration delayUntilNextExecution = TimeDuration.fromCurrent( this.nextScheduledCheck );
|
|
|
|
-
|
|
|
|
- getExecutorService().schedule( new PeriodicCheck(), delayUntilNextExecution.asMillis(), TimeUnit.MILLISECONDS );
|
|
|
|
-
|
|
|
|
- LOGGER.trace( getSessionLabel(), () -> "scheduled next check execution at " + StringUtil.toIsoDate( nextScheduledCheck )
|
|
|
|
- + " in " + delayUntilNextExecution.asCompactString() );
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private class PeriodicCheck implements Runnable
|
|
private class PeriodicCheck implements Runnable
|