forked from I2P_Developers/i2p.i2p
NewsFetcher: Delay news fetch on new installs (ticket #1153)
This commit is contained in:
@ -25,15 +25,20 @@ class NewsTimerTask implements SimpleTimer.TimedEvent {
|
|||||||
private volatile boolean _firstRun = true;
|
private volatile boolean _firstRun = true;
|
||||||
|
|
||||||
private static final long INITIAL_DELAY = 5*60*1000;
|
private static final long INITIAL_DELAY = 5*60*1000;
|
||||||
|
private static final long NEW_INSTALL_DELAY = 25*60*1000;
|
||||||
private static final long RUN_DELAY = 10*60*1000;
|
private static final long RUN_DELAY = 10*60*1000;
|
||||||
|
|
||||||
public NewsTimerTask(RouterContext ctx, ConsoleUpdateManager mgr) {
|
public NewsTimerTask(RouterContext ctx, ConsoleUpdateManager mgr) {
|
||||||
_context = ctx;
|
_context = ctx;
|
||||||
_log = ctx.logManager().getLog(NewsTimerTask.class);
|
_log = ctx.logManager().getLog(NewsTimerTask.class);
|
||||||
_mgr = mgr;
|
_mgr = mgr;
|
||||||
ctx.simpleScheduler().addPeriodicEvent(this,
|
long installed = ctx.getProperty("router.firstInstalled", 0L);
|
||||||
INITIAL_DELAY + _context.random().nextLong(INITIAL_DELAY),
|
boolean isNew = (ctx.clock().now() - installed) < 30*60*1000L;
|
||||||
RUN_DELAY);
|
long delay = isNew ? NEW_INSTALL_DELAY : INITIAL_DELAY;
|
||||||
|
delay += _context.random().nextLong(INITIAL_DELAY);
|
||||||
|
if (_log.shouldLog(Log.INFO))
|
||||||
|
_log.info("Scheduling first news check in " + DataHelper.formatDuration(delay));
|
||||||
|
ctx.simpleScheduler().addPeriodicEvent(this, delay, RUN_DELAY);
|
||||||
// UpdateManager calls NewsFetcher to check the existing news at startup
|
// UpdateManager calls NewsFetcher to check the existing news at startup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user