forked from I2P_Developers/i2p.i2p
#1069: Deprecated SimpleScheduler and moved functionality into SimpleTimer2
This commit is contained in:
@ -328,7 +328,7 @@ public class I2PSnarkUtil {
|
|||||||
return rv;
|
return rv;
|
||||||
} catch (I2PException ie) {
|
} catch (I2PException ie) {
|
||||||
_banlist.add(dest);
|
_banlist.add(dest);
|
||||||
_context.simpleScheduler().addEvent(new Unbanlist(dest), 10*60*1000);
|
_context.simpleTimer2().addEvent(new Unbanlist(dest), 10*60*1000);
|
||||||
IOException ioe = new IOException("Unable to reach the peer " + peer);
|
IOException ioe = new IOException("Unable to reach the peer " + peer);
|
||||||
ioe.initCause(ie);
|
ioe.initCause(ie);
|
||||||
throw ioe;
|
throw ioe;
|
||||||
|
@ -233,7 +233,7 @@ public class SnarkManager implements CompleteListener {
|
|||||||
// only if default instance
|
// only if default instance
|
||||||
if ("i2psnark".equals(_contextName))
|
if ("i2psnark".equals(_contextName))
|
||||||
// delay until UpdateManager is there
|
// delay until UpdateManager is there
|
||||||
_context.simpleScheduler().addEvent(new Register(), 4*60*1000);
|
_context.simpleTimer2().addEvent(new Register(), 4*60*1000);
|
||||||
// Not required, Jetty has a shutdown hook
|
// Not required, Jetty has a shutdown hook
|
||||||
//_context.addShutdownTask(new SnarkManagerShutdown());
|
//_context.addShutdownTask(new SnarkManagerShutdown());
|
||||||
_idleChecker = new IdleChecker(this, _peerCoordinatorSet);
|
_idleChecker = new IdleChecker(this, _peerCoordinatorSet);
|
||||||
@ -2272,7 +2272,7 @@ public class SnarkManager implements CompleteListener {
|
|||||||
dht.stop();
|
dht.stop();
|
||||||
// Schedule this even for final shutdown, as there's a chance
|
// Schedule this even for final shutdown, as there's a chance
|
||||||
// that it's just this webapp that is stopping.
|
// that it's just this webapp that is stopping.
|
||||||
_context.simpleScheduler().addEvent(new Disconnector(), 60*1000);
|
_context.simpleTimer2().addEvent(new Disconnector(), 60*1000);
|
||||||
addMessage(_("Closing I2P tunnel after notifying trackers."));
|
addMessage(_("Closing I2P tunnel after notifying trackers."));
|
||||||
if (finalShutdown) {
|
if (finalShutdown) {
|
||||||
try { Thread.sleep(5*1000); } catch (InterruptedException ie) {}
|
try { Thread.sleep(5*1000); } catch (InterruptedException ie) {}
|
||||||
|
@ -193,7 +193,7 @@ public class ConsoleUpdateManager implements UpdateManager, RouterApp {
|
|||||||
// handled inside P.U.H. for now
|
// handled inside P.U.H. for now
|
||||||
//register((Updater)puh, PLUGIN, FILE, 0);
|
//register((Updater)puh, PLUGIN, FILE, 0);
|
||||||
new NewsTimerTask(_context, this);
|
new NewsTimerTask(_context, this);
|
||||||
_context.simpleScheduler().addPeriodicEvent(new TaskCleaner(), TASK_CLEANER_TIME);
|
_context.simpleTimer2().addPeriodicEvent(new TaskCleaner(), TASK_CLEANER_TIME);
|
||||||
changeState(RUNNING);
|
changeState(RUNNING);
|
||||||
if (_cmgr != null)
|
if (_cmgr != null)
|
||||||
_cmgr.register(this);
|
_cmgr.register(this);
|
||||||
@ -1397,7 +1397,7 @@ public class ConsoleUpdateManager implements UpdateManager, RouterApp {
|
|||||||
|
|
||||||
private void finishStatus(String msg) {
|
private void finishStatus(String msg) {
|
||||||
updateStatus(msg);
|
updateStatus(msg);
|
||||||
_context.simpleScheduler().addEvent(new StatusCleaner(msg), STATUS_CLEAN_TIME);
|
_context.simpleTimer2().addEvent(new StatusCleaner(msg), STATUS_CLEAN_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class StatusCleaner implements SimpleTimer.TimedEvent {
|
private class StatusCleaner implements SimpleTimer.TimedEvent {
|
||||||
|
@ -38,7 +38,7 @@ class NewsTimerTask implements SimpleTimer.TimedEvent {
|
|||||||
delay += _context.random().nextLong(INITIAL_DELAY);
|
delay += _context.random().nextLong(INITIAL_DELAY);
|
||||||
if (_log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.INFO))
|
||||||
_log.info("Scheduling first news check in " + DataHelper.formatDuration(delay));
|
_log.info("Scheduling first news check in " + DataHelper.formatDuration(delay));
|
||||||
ctx.simpleScheduler().addPeriodicEvent(this, delay, RUN_DELAY);
|
ctx.simpleTimer2().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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import net.i2p.data.Hash;
|
import net.i2p.data.Hash;
|
||||||
import net.i2p.util.ObjectCounter;
|
import net.i2p.util.ObjectCounter;
|
||||||
import net.i2p.util.RandomSource;
|
import net.i2p.util.RandomSource;
|
||||||
import net.i2p.util.SimpleScheduler;
|
|
||||||
import net.i2p.util.SimpleTimer;
|
import net.i2p.util.SimpleTimer;
|
||||||
|
import net.i2p.util.SimpleTimer2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count how often we have received an incoming connection
|
* Count how often we have received an incoming connection
|
||||||
@ -33,7 +33,7 @@ class ConnThrottler {
|
|||||||
// shorten the initial period by a random amount
|
// shorten the initial period by a random amount
|
||||||
// to prevent correlation across destinations
|
// to prevent correlation across destinations
|
||||||
// and identification of router startup time
|
// and identification of router startup time
|
||||||
SimpleScheduler.getInstance().addPeriodicEvent(new Cleaner(),
|
SimpleTimer2.getInstance().addPeriodicEvent(new Cleaner(),
|
||||||
(period / 2) + RandomSource.getInstance().nextLong(period / 2),
|
(period / 2) + RandomSource.getInstance().nextLong(period / 2),
|
||||||
period);
|
period);
|
||||||
}
|
}
|
||||||
|
@ -781,7 +781,7 @@ class Connection {
|
|||||||
private boolean scheduleDisconnectEvent() {
|
private boolean scheduleDisconnectEvent() {
|
||||||
if (!_disconnectScheduledOn.compareAndSet(0, _context.clock().now()))
|
if (!_disconnectScheduledOn.compareAndSet(0, _context.clock().now()))
|
||||||
return false;
|
return false;
|
||||||
_context.simpleScheduler().addEvent(new DisconnectEvent(), DISCONNECT_TIMEOUT);
|
_context.simpleTimer2().addEvent(new DisconnectEvent(), DISCONNECT_TIMEOUT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ class ConnectionPacketHandler {
|
|||||||
final long delay = nextSendTime - now;
|
final long delay = nextSendTime - now;
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("scheduling ack in "+delay);
|
_log.debug("scheduling ack in "+delay);
|
||||||
_context.simpleScheduler().addEvent(new AckDup(con), delay);
|
_context.simpleTimer2().addEvent(new AckDup(con), delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -16,7 +16,7 @@ abstract class SchedulerImpl implements TaskScheduler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void reschedule(long msToWait, Connection con) {
|
protected void reschedule(long msToWait, Connection con) {
|
||||||
_context.simpleScheduler().addEvent(con.getConnectionEvent(), msToWait);
|
_context.simpleTimer2().addEvent(con.getConnectionEvent(), msToWait);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,10 +13,9 @@ import java.awt.Frame;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.util.SimpleScheduler;
|
|
||||||
import net.i2p.util.SimpleTimer;
|
import net.i2p.util.SimpleTimer;
|
||||||
|
import net.i2p.util.SimpleTimer2;
|
||||||
import net.i2p.util.SystemVersion;
|
import net.i2p.util.SystemVersion;
|
||||||
|
|
||||||
import snoozesoft.systray4j.SysTrayMenu;
|
import snoozesoft.systray4j.SysTrayMenu;
|
||||||
import snoozesoft.systray4j.SysTrayMenuEvent;
|
import snoozesoft.systray4j.SysTrayMenuEvent;
|
||||||
import snoozesoft.systray4j.SysTrayMenuIcon;
|
import snoozesoft.systray4j.SysTrayMenuIcon;
|
||||||
@ -66,7 +65,7 @@ public class SysTray implements SysTrayMenuListener {
|
|||||||
private SysTray() {
|
private SysTray() {
|
||||||
_sysTrayMenuIcon.addSysTrayMenuListener(this);
|
_sysTrayMenuIcon.addSysTrayMenuListener(this);
|
||||||
createSysTrayMenu();
|
createSysTrayMenu();
|
||||||
SimpleScheduler.getInstance().addPeriodicEvent(new RefreshDisplayEvent(), REFRESH_DISPLAY_FREQUENCY);
|
SimpleTimer2.getInstance().addPeriodicEvent(new RefreshDisplayEvent(), REFRESH_DISPLAY_FREQUENCY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final long REFRESH_DISPLAY_FREQUENCY = 30*1000;
|
private static final long REFRESH_DISPLAY_FREQUENCY = 30*1000;
|
||||||
|
@ -939,6 +939,7 @@ public class I2PAppContext {
|
|||||||
/**
|
/**
|
||||||
* Use instead of SimpleScheduler.getInstance()
|
* Use instead of SimpleScheduler.getInstance()
|
||||||
* @since 0.9 to replace static instance in the class
|
* @since 0.9 to replace static instance in the class
|
||||||
|
* @deprecated in 0.9.19
|
||||||
*/
|
*/
|
||||||
public SimpleScheduler simpleScheduler() {
|
public SimpleScheduler simpleScheduler() {
|
||||||
if (!_simpleSchedulerInitialized)
|
if (!_simpleSchedulerInitialized)
|
||||||
@ -946,6 +947,9 @@ public class I2PAppContext {
|
|||||||
return _simpleScheduler;
|
return _simpleScheduler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated in 0.9.19
|
||||||
|
*/
|
||||||
private void initializeSimpleScheduler() {
|
private void initializeSimpleScheduler() {
|
||||||
synchronized (_lock18) {
|
synchronized (_lock18) {
|
||||||
if (_simpleScheduler == null)
|
if (_simpleScheduler == null)
|
||||||
|
@ -1353,7 +1353,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
boolean close = Boolean.parseBoolean(_options.getProperty("i2cp.closeOnIdle"));
|
boolean close = Boolean.parseBoolean(_options.getProperty("i2cp.closeOnIdle"));
|
||||||
if (reduce || close) {
|
if (reduce || close) {
|
||||||
updateActivity();
|
updateActivity();
|
||||||
_context.simpleScheduler().addEvent(new SessionIdleTimer(_context, this, reduce, close), SessionIdleTimer.MINIMUM_TIME);
|
_context.simpleTimer2().addEvent(new SessionIdleTimer(_context, this, reduce, close), SessionIdleTimer.MINIMUM_TIME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +118,6 @@ class SessionIdleTimer implements SimpleTimer.TimedEvent {
|
|||||||
} else {
|
} else {
|
||||||
nextDelay = _minimumTime - (now - lastActivity);
|
nextDelay = _minimumTime - (now - lastActivity);
|
||||||
}
|
}
|
||||||
_context.simpleScheduler().addEvent(this, nextDelay);
|
_context.simpleTimer2().addEvent(this, nextDelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ public final class ByteCache {
|
|||||||
_maxCached = maxCachedEntries;
|
_maxCached = maxCachedEntries;
|
||||||
_entrySize = entrySize;
|
_entrySize = entrySize;
|
||||||
_lastOverflow = -1;
|
_lastOverflow = -1;
|
||||||
SimpleScheduler.getInstance().addPeriodicEvent(new Cleanup(), CLEANUP_FREQUENCY + (entrySize % 777)); //stagger
|
SimpleTimer2.getInstance().addPeriodicEvent(new Cleanup(), CLEANUP_FREQUENCY + (entrySize % 777)); //stagger
|
||||||
I2PAppContext.getGlobalContext().statManager().createRateStat("byteCache.memory." + entrySize, "Memory usage (B)", "Router", new long[] { 10*60*1000 });
|
I2PAppContext.getGlobalContext().statManager().createRateStat("byteCache.memory." + entrySize, "Memory usage (B)", "Router", new long[] { 10*60*1000 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ public class SimpleScheduler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* If you have a context, use context.simpleScheduler() instead
|
* If you have a context, use context.simpleScheduler() instead
|
||||||
|
* @deprecated in 0.9.19
|
||||||
*/
|
*/
|
||||||
public static SimpleScheduler getInstance() {
|
public static SimpleScheduler getInstance() {
|
||||||
return I2PAppContext.getGlobalContext().simpleScheduler();
|
return I2PAppContext.getGlobalContext().simpleScheduler();
|
||||||
@ -46,6 +47,7 @@ public class SimpleScheduler {
|
|||||||
/**
|
/**
|
||||||
* To be instantiated by the context.
|
* To be instantiated by the context.
|
||||||
* Others should use context.simpleTimer() instead
|
* Others should use context.simpleTimer() instead
|
||||||
|
* @deprecated in 0.9.19
|
||||||
*/
|
*/
|
||||||
public SimpleScheduler(I2PAppContext context) {
|
public SimpleScheduler(I2PAppContext context) {
|
||||||
this(context, "SimpleScheduler");
|
this(context, "SimpleScheduler");
|
||||||
@ -54,6 +56,7 @@ public class SimpleScheduler {
|
|||||||
/**
|
/**
|
||||||
* To be instantiated by the context.
|
* To be instantiated by the context.
|
||||||
* Others should use context.simpleTimer() instead
|
* Others should use context.simpleTimer() instead
|
||||||
|
* @deprecated in 0.9.19
|
||||||
*/
|
*/
|
||||||
private SimpleScheduler(I2PAppContext context, String name) {
|
private SimpleScheduler(I2PAppContext context, String name) {
|
||||||
_log = context.logManager().getLog(SimpleScheduler.class);
|
_log = context.logManager().getLog(SimpleScheduler.class);
|
||||||
|
@ -125,6 +125,66 @@ public class SimpleTimer2 {
|
|||||||
return _executor.schedule(t, timeoutMs, TimeUnit.MILLISECONDS);
|
return _executor.schedule(t, timeoutMs, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queue up the given event to be fired no sooner than timeoutMs from now.
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
* @param timeoutMs
|
||||||
|
*/
|
||||||
|
public void addEvent(final SimpleTimer.TimedEvent event, long timeoutMs) {
|
||||||
|
if (event == null)
|
||||||
|
throw new IllegalArgumentException("addEvent null");
|
||||||
|
|
||||||
|
new TimedEvent(SimpleTimer2.getInstance(), timeoutMs) {
|
||||||
|
@Override
|
||||||
|
public void timeReached() {
|
||||||
|
event.timeReached();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schedule periodic event
|
||||||
|
*
|
||||||
|
* The TimedEvent must not do its own rescheduling.
|
||||||
|
* As all Exceptions are caught in run(), these will not prevent
|
||||||
|
* subsequent executions (unlike SimpleTimer, where the TimedEvent does
|
||||||
|
* its own rescheduling).
|
||||||
|
*
|
||||||
|
* @param delay run the first iteration of this event after delay ms
|
||||||
|
* @param timeoutMs run subsequent iterations of this event every timeoutMs ms
|
||||||
|
*/
|
||||||
|
public void addPeriodicEvent(final SimpleTimer.TimedEvent event, final long timeoutMs) {
|
||||||
|
|
||||||
|
new PeriodicTimedEvent(SimpleTimer2.getInstance(), timeoutMs) {
|
||||||
|
@Override
|
||||||
|
public void timeReached() {
|
||||||
|
event.timeReached();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schedule periodic event
|
||||||
|
*
|
||||||
|
* The TimedEvent must not do its own rescheduling.
|
||||||
|
* As all Exceptions are caught in run(), these will not prevent
|
||||||
|
* subsequent executions (unlike SimpleTimer, where the TimedEvent does
|
||||||
|
* its own rescheduling).
|
||||||
|
*
|
||||||
|
* @param delay run the first iteration of this event after delay ms
|
||||||
|
* @param timeoutMs run subsequent iterations of this event every timeoutMs ms
|
||||||
|
*/
|
||||||
|
public void addPeriodicEvent(final SimpleTimer.TimedEvent event, final long delay, final long timeoutMs) {
|
||||||
|
|
||||||
|
new PeriodicTimedEvent(SimpleTimer2.getInstance(), delay, timeoutMs) {
|
||||||
|
@Override
|
||||||
|
public void timeReached() {
|
||||||
|
event.timeReached();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* state of a given TimedEvent
|
* state of a given TimedEvent
|
||||||
*
|
*
|
||||||
@ -141,6 +201,7 @@ public class SimpleTimer2 {
|
|||||||
CANCELLED
|
CANCELLED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to SimpleTimer.TimedEvent but users must extend instead of implement,
|
* Similar to SimpleTimer.TimedEvent but users must extend instead of implement,
|
||||||
* and all schedule and cancel methods are through this class rather than SimpleTimer2.
|
* and all schedule and cancel methods are through this class rather than SimpleTimer2.
|
||||||
@ -228,7 +289,6 @@ public class SimpleTimer2 {
|
|||||||
break;
|
break;
|
||||||
case SCHEDULED: // nothing
|
case SCHEDULED: // nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -403,5 +463,36 @@ public class SimpleTimer2 {
|
|||||||
" Completed: " + _executor.getCompletedTaskCount() +
|
" Completed: " + _executor.getCompletedTaskCount() +
|
||||||
" Queued: " + _executor.getQueue().size();
|
" Queued: " + _executor.getQueue().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static abstract class PeriodicTimedEvent extends TimedEvent {
|
||||||
|
private long _timeoutMs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schedule periodic event
|
||||||
|
*
|
||||||
|
* @param timeoutMs run subsequent iterations of this event every timeoutMs ms
|
||||||
|
*/
|
||||||
|
public PeriodicTimedEvent(SimpleTimer2 pool, long timeoutMs) {
|
||||||
|
super(pool, timeoutMs);
|
||||||
|
_timeoutMs = timeoutMs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schedule periodic event
|
||||||
|
*
|
||||||
|
* @param delay run the first iteration of this event after delay ms
|
||||||
|
* @param timeoutMs run subsequent iterations of this event every timeoutMs ms
|
||||||
|
*/
|
||||||
|
public PeriodicTimedEvent(SimpleTimer2 pool, long delay, long timeoutMs) {
|
||||||
|
super(pool, delay);
|
||||||
|
_timeoutMs = timeoutMs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
super.run();
|
||||||
|
schedule(_timeoutMs);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,7 +576,7 @@ public class Router implements RouterClock.ClockShiftListener {
|
|||||||
_context.inNetMessagePool().startup();
|
_context.inNetMessagePool().startup();
|
||||||
startupQueue();
|
startupQueue();
|
||||||
//_context.jobQueue().addJob(new CoalesceStatsJob(_context));
|
//_context.jobQueue().addJob(new CoalesceStatsJob(_context));
|
||||||
_context.simpleScheduler().addPeriodicEvent(new CoalesceStatsEvent(_context), COALESCE_TIME);
|
_context.simpleTimer2().addPeriodicEvent(new CoalesceStatsEvent(_context), COALESCE_TIME);
|
||||||
_context.jobQueue().addJob(new UpdateRoutingKeyModifierJob(_context));
|
_context.jobQueue().addJob(new UpdateRoutingKeyModifierJob(_context));
|
||||||
//_context.adminManager().startup();
|
//_context.adminManager().startup();
|
||||||
_context.blocklist().startup();
|
_context.blocklist().startup();
|
||||||
@ -840,7 +840,7 @@ public class Router implements RouterClock.ClockShiftListener {
|
|||||||
if (blockingRebuild)
|
if (blockingRebuild)
|
||||||
r.timeReached();
|
r.timeReached();
|
||||||
else
|
else
|
||||||
_context.simpleScheduler().addEvent(r, 0);
|
_context.simpleTimer2().addEvent(r, 0);
|
||||||
} catch (DataFormatException dfe) {
|
} catch (DataFormatException dfe) {
|
||||||
_log.log(Log.CRIT, "Internal error - unable to sign our own address?!", dfe);
|
_log.log(Log.CRIT, "Internal error - unable to sign our own address?!", dfe);
|
||||||
}
|
}
|
||||||
@ -1747,7 +1747,7 @@ public class Router implements RouterClock.ClockShiftListener {
|
|||||||
*/
|
*/
|
||||||
private void beginMarkingLiveliness() {
|
private void beginMarkingLiveliness() {
|
||||||
File f = getPingFile();
|
File f = getPingFile();
|
||||||
_context.simpleScheduler().addPeriodicEvent(new MarkLiveliness(this, f), 0, LIVELINESS_DELAY - (5*1000));
|
_context.simpleTimer2().addPeriodicEvent(new MarkLiveliness(this, f), 0, LIVELINESS_DELAY - (5*1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String PROP_BANDWIDTH_SHARE_PERCENTAGE = "router.sharePercentage";
|
public static final String PROP_BANDWIDTH_SHARE_PERCENTAGE = "router.sharePercentage";
|
||||||
|
@ -50,7 +50,7 @@ class RouterThrottleImpl implements RouterThrottle {
|
|||||||
_context = context;
|
_context = context;
|
||||||
_log = context.logManager().getLog(RouterThrottleImpl.class);
|
_log = context.logManager().getLog(RouterThrottleImpl.class);
|
||||||
setTunnelStatus();
|
setTunnelStatus();
|
||||||
_context.simpleScheduler().addEvent(new ResetStatus(), 5*1000 + _context.getProperty(PROP_REJECT_STARTUP_TIME, DEFAULT_REJECT_STARTUP_TIME));
|
_context.simpleTimer2().addEvent(new ResetStatus(), 5*1000 + _context.getProperty(PROP_REJECT_STARTUP_TIME, DEFAULT_REJECT_STARTUP_TIME));
|
||||||
_context.statManager().createRateStat("router.throttleNetworkCause", "How lagged the jobQueue was when an I2NP was throttled", "Throttle", new long[] { 60*1000, 10*60*1000, 60*60*1000, 24*60*60*1000 });
|
_context.statManager().createRateStat("router.throttleNetworkCause", "How lagged the jobQueue was when an I2NP was throttled", "Throttle", new long[] { 60*1000, 10*60*1000, 60*60*1000, 24*60*60*1000 });
|
||||||
//_context.statManager().createRateStat("router.throttleNetDbCause", "How lagged the jobQueue was when a networkDb request was throttled", "Throttle", new long[] { 60*1000, 10*60*1000, 60*60*1000, 24*60*60*1000 });
|
//_context.statManager().createRateStat("router.throttleNetDbCause", "How lagged the jobQueue was when a networkDb request was throttled", "Throttle", new long[] { 60*1000, 10*60*1000, 60*60*1000, 24*60*60*1000 });
|
||||||
_context.statManager().createRateStat("router.throttleTunnelCause", "How lagged the jobQueue was when a tunnel request was throttled", "Throttle", new long[] { 60*1000, 10*60*1000, 60*60*1000, 24*60*60*1000 });
|
_context.statManager().createRateStat("router.throttleTunnelCause", "How lagged the jobQueue was when a tunnel request was throttled", "Throttle", new long[] { 60*1000, 10*60*1000, 60*60*1000, 24*60*60*1000 });
|
||||||
|
@ -557,7 +557,7 @@ class ClientConnectionRunner {
|
|||||||
// theirs is newer
|
// theirs is newer
|
||||||
} else {
|
} else {
|
||||||
// ours is newer, so wait a few secs and retry
|
// ours is newer, so wait a few secs and retry
|
||||||
_context.simpleScheduler().addEvent(new Rerequest(set, expirationTime, onCreateJob, onFailedJob), 3*1000);
|
_context.simpleTimer2().addEvent(new Rerequest(set, expirationTime, onCreateJob, onFailedJob), 3*1000);
|
||||||
}
|
}
|
||||||
// fire onCreated?
|
// fire onCreated?
|
||||||
return; // already requesting
|
return; // already requesting
|
||||||
|
@ -183,7 +183,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
|
|||||||
context.statManager().createRateStat("crypto.sessionTagsExpired", "How many tags/sessions are expired?", "Encryption", new long[] { 10*60*1000, 60*60*1000, 3*60*60*1000 });
|
context.statManager().createRateStat("crypto.sessionTagsExpired", "How many tags/sessions are expired?", "Encryption", new long[] { 10*60*1000, 60*60*1000, 3*60*60*1000 });
|
||||||
context.statManager().createRateStat("crypto.sessionTagsRemaining", "How many tags/sessions are remaining after a cleanup?", "Encryption", new long[] { 10*60*1000, 60*60*1000, 3*60*60*1000 });
|
context.statManager().createRateStat("crypto.sessionTagsRemaining", "How many tags/sessions are remaining after a cleanup?", "Encryption", new long[] { 10*60*1000, 60*60*1000, 3*60*60*1000 });
|
||||||
_alive = true;
|
_alive = true;
|
||||||
_context.simpleScheduler().addEvent(new CleanupEvent(), 60*1000);
|
_context.simpleTimer2().addEvent(new CleanupEvent(), 60*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -205,7 +205,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
|
|||||||
int expired = aggressiveExpire();
|
int expired = aggressiveExpire();
|
||||||
long expireTime = _context.clock().now() - beforeExpire;
|
long expireTime = _context.clock().now() - beforeExpire;
|
||||||
_context.statManager().addRateData("crypto.sessionTagsExpired", expired, expireTime);
|
_context.statManager().addRateData("crypto.sessionTagsExpired", expired, expireTime);
|
||||||
_context.simpleScheduler().addEvent(this, 60*1000);
|
_context.simpleTimer2().addEvent(this, 60*1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ public class OutboundCache {
|
|||||||
|
|
||||||
public OutboundCache(RouterContext ctx) {
|
public OutboundCache(RouterContext ctx) {
|
||||||
_context = ctx;
|
_context = ctx;
|
||||||
_context.simpleScheduler().addPeriodicEvent(new OCMOSJCacheCleaner(), CLEAN_INTERVAL, CLEAN_INTERVAL);
|
_context.simpleTimer2().addPeriodicEvent(new OCMOSJCacheCleaner(), CLEAN_INTERVAL, CLEAN_INTERVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,8 +2,8 @@ package net.i2p.router.networkdb.kademlia;
|
|||||||
|
|
||||||
import net.i2p.data.Hash;
|
import net.i2p.data.Hash;
|
||||||
import net.i2p.util.ObjectCounter;
|
import net.i2p.util.ObjectCounter;
|
||||||
import net.i2p.util.SimpleScheduler;
|
|
||||||
import net.i2p.util.SimpleTimer;
|
import net.i2p.util.SimpleTimer;
|
||||||
|
import net.i2p.util.SimpleTimer2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count how often we have recently flooded a key
|
* Count how often we have recently flooded a key
|
||||||
@ -18,7 +18,7 @@ class FloodThrottler {
|
|||||||
|
|
||||||
FloodThrottler() {
|
FloodThrottler() {
|
||||||
this.counter = new ObjectCounter<Hash>();
|
this.counter = new ObjectCounter<Hash>();
|
||||||
SimpleScheduler.getInstance().addPeriodicEvent(new Cleaner(), CLEAN_TIME);
|
SimpleTimer2.getInstance().addPeriodicEvent(new Cleaner(), CLEAN_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** increments before checking */
|
/** increments before checking */
|
||||||
|
@ -3,8 +3,8 @@ package net.i2p.router.networkdb.kademlia;
|
|||||||
import net.i2p.data.Hash;
|
import net.i2p.data.Hash;
|
||||||
import net.i2p.data.TunnelId;
|
import net.i2p.data.TunnelId;
|
||||||
import net.i2p.util.ObjectCounter;
|
import net.i2p.util.ObjectCounter;
|
||||||
import net.i2p.util.SimpleScheduler;
|
|
||||||
import net.i2p.util.SimpleTimer;
|
import net.i2p.util.SimpleTimer;
|
||||||
|
import net.i2p.util.SimpleTimer2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count how often we have recently received a lookup request with
|
* Count how often we have recently received a lookup request with
|
||||||
@ -25,7 +25,7 @@ class LookupThrottler {
|
|||||||
|
|
||||||
LookupThrottler() {
|
LookupThrottler() {
|
||||||
this.counter = new ObjectCounter<ReplyTunnel>();
|
this.counter = new ObjectCounter<ReplyTunnel>();
|
||||||
SimpleScheduler.getInstance().addPeriodicEvent(new Cleaner(), CLEAN_TIME);
|
SimpleTimer2.getInstance().addPeriodicEvent(new Cleaner(), CLEAN_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package net.i2p.router.networkdb.kademlia;
|
package net.i2p.router.networkdb.kademlia;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.i2p.data.Destination;
|
import net.i2p.data.Destination;
|
||||||
import net.i2p.data.Hash;
|
import net.i2p.data.Hash;
|
||||||
import net.i2p.util.LHMCache;
|
import net.i2p.util.LHMCache;
|
||||||
import net.i2p.util.ObjectCounter;
|
import net.i2p.util.ObjectCounter;
|
||||||
import net.i2p.util.SimpleScheduler;
|
|
||||||
import net.i2p.util.SimpleTimer;
|
import net.i2p.util.SimpleTimer;
|
||||||
|
import net.i2p.util.SimpleTimer2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Track lookup fails
|
* Track lookup fails
|
||||||
@ -24,7 +25,7 @@ class NegativeLookupCache {
|
|||||||
public NegativeLookupCache() {
|
public NegativeLookupCache() {
|
||||||
this.counter = new ObjectCounter<Hash>();
|
this.counter = new ObjectCounter<Hash>();
|
||||||
this.badDests = new LHMCache<Hash, Destination>(MAX_BAD_DESTS);
|
this.badDests = new LHMCache<Hash, Destination>(MAX_BAD_DESTS);
|
||||||
SimpleScheduler.getInstance().addPeriodicEvent(new Cleaner(), CLEAN_TIME);
|
SimpleTimer2.getInstance().addPeriodicEvent(new Cleaner(), CLEAN_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void lookupFailed(Hash h) {
|
public void lookupFailed(Hash h) {
|
||||||
|
@ -184,7 +184,7 @@ public class ReseedChecker {
|
|||||||
*/
|
*/
|
||||||
void done() {
|
void done() {
|
||||||
_inProgress.set(false);
|
_inProgress.set(false);
|
||||||
_context.simpleScheduler().addEvent(new StatusCleaner(_lastStatus, _lastError), STATUS_CLEAN_TIME);
|
_context.simpleTimer2().addEvent(new StatusCleaner(_lastStatus, _lastError), STATUS_CLEAN_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -278,7 +278,7 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
|
|||||||
private static final int LOOKUP_TIME = 30*60*1000;
|
private static final int LOOKUP_TIME = 30*60*1000;
|
||||||
|
|
||||||
private void startGeoIP() {
|
private void startGeoIP() {
|
||||||
_context.simpleScheduler().addEvent(new QueueAll(), START_DELAY);
|
_context.simpleTimer2().addEvent(new QueueAll(), START_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -296,7 +296,7 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
|
|||||||
continue;
|
continue;
|
||||||
_geoIP.add(ip);
|
_geoIP.add(ip);
|
||||||
}
|
}
|
||||||
_context.simpleScheduler().addPeriodicEvent(new Lookup(), 5000, LOOKUP_TIME);
|
_context.simpleTimer2().addPeriodicEvent(new Lookup(), 5000, LOOKUP_TIME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,7 +491,7 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
|
|||||||
|
|
||||||
/** @since 0.7.12 */
|
/** @since 0.7.12 */
|
||||||
private void startTimestamper() {
|
private void startTimestamper() {
|
||||||
_context.simpleScheduler().addPeriodicEvent(new Timestamper(), TIME_START_DELAY, TIME_REPEAT_DELAY);
|
_context.simpleTimer2().addPeriodicEvent(new Timestamper(), TIME_START_DELAY, TIME_REPEAT_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,7 +102,7 @@ public abstract class TransportImpl implements Transport {
|
|||||||
_unreachableEntries = new HashMap<Hash, Long>(32);
|
_unreachableEntries = new HashMap<Hash, Long>(32);
|
||||||
_wasUnreachableEntries = new HashMap<Hash, Long>(32);
|
_wasUnreachableEntries = new HashMap<Hash, Long>(32);
|
||||||
_localAddresses = new ConcurrentHashSet<InetAddress>(4);
|
_localAddresses = new ConcurrentHashSet<InetAddress>(4);
|
||||||
_context.simpleScheduler().addPeriodicEvent(new CleanupUnreachable(), 2 * UNREACHABLE_PERIOD, UNREACHABLE_PERIOD / 2);
|
_context.simpleTimer2().addPeriodicEvent(new CleanupUnreachable(), 2 * UNREACHABLE_PERIOD, UNREACHABLE_PERIOD / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -748,7 +748,7 @@ class EstablishmentManager {
|
|||||||
_transport.send(dsm, peer);
|
_transport.send(dsm, peer);
|
||||||
|
|
||||||
// just do this inline
|
// just do this inline
|
||||||
//_context.simpleScheduler().addEvent(new PublishToNewInbound(peer), 0);
|
//_context.simpleTimer2().addEvent(new PublishToNewInbound(peer), 0);
|
||||||
|
|
||||||
Hash hash = peer.getRemotePeer();
|
Hash hash = peer.getRemotePeer();
|
||||||
if ((hash != null) && (!_context.banlist().isBanlisted(hash)) && (!_transport.isUnreachable(hash))) {
|
if ((hash != null) && (!_context.banlist().isBanlisted(hash)) && (!_transport.isUnreachable(hash))) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package net.i2p.router.transport.udp;
|
package net.i2p.router.transport.udp;
|
||||||
|
|
||||||
import net.i2p.util.ObjectCounter;
|
import net.i2p.util.ObjectCounter;
|
||||||
import net.i2p.util.SimpleScheduler;
|
|
||||||
import net.i2p.util.SimpleTimer;
|
import net.i2p.util.SimpleTimer;
|
||||||
|
import net.i2p.util.SimpleTimer2;
|
||||||
import net.i2p.util.SipHash;
|
import net.i2p.util.SipHash;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,7 +17,7 @@ class IPThrottler {
|
|||||||
public IPThrottler(int max, long time) {
|
public IPThrottler(int max, long time) {
|
||||||
_max = max;
|
_max = max;
|
||||||
_counter = new ObjectCounter<Integer>();
|
_counter = new ObjectCounter<Integer>();
|
||||||
SimpleScheduler.getInstance().addPeriodicEvent(new Cleaner(), time);
|
SimpleTimer2.getInstance().addPeriodicEvent(new Cleaner(), time);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -207,7 +207,7 @@ class PeerTestManager {
|
|||||||
test.incrementPacketsRelayed();
|
test.incrementPacketsRelayed();
|
||||||
sendTestToBob();
|
sendTestToBob();
|
||||||
|
|
||||||
_context.simpleScheduler().addEvent(new ContinueTest(test.getNonce()), RESEND_TIMEOUT);
|
_context.simpleTimer2().addEvent(new ContinueTest(test.getNonce()), RESEND_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ContinueTest implements SimpleTimer.TimedEvent {
|
private class ContinueTest implements SimpleTimer.TimedEvent {
|
||||||
@ -246,7 +246,7 @@ class PeerTestManager {
|
|||||||
sendTestToCharlie();
|
sendTestToCharlie();
|
||||||
}
|
}
|
||||||
// retx at 4, 10, 17, 25 elapsed time
|
// retx at 4, 10, 17, 25 elapsed time
|
||||||
_context.simpleScheduler().addEvent(ContinueTest.this, RESEND_TIMEOUT + (sent*1000));
|
_context.simpleTimer2().addEvent(ContinueTest.this, RESEND_TIMEOUT + (sent*1000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -702,7 +702,7 @@ class PeerTestManager {
|
|||||||
|
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
_activeTests.put(Long.valueOf(nonce), state);
|
_activeTests.put(Long.valueOf(nonce), state);
|
||||||
_context.simpleScheduler().addEvent(new RemoveTest(nonce), MAX_CHARLIE_LIFETIME);
|
_context.simpleTimer2().addEvent(new RemoveTest(nonce), MAX_CHARLIE_LIFETIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
UDPPacket packet = _packetBuilder.buildPeerTestToBob(bobIP, from.getPort(), aliceIP, alicePort,
|
UDPPacket packet = _packetBuilder.buildPeerTestToBob(bobIP, from.getPort(), aliceIP, alicePort,
|
||||||
@ -805,7 +805,7 @@ class PeerTestManager {
|
|||||||
|
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
_activeTests.put(Long.valueOf(nonce), state);
|
_activeTests.put(Long.valueOf(nonce), state);
|
||||||
_context.simpleScheduler().addEvent(new RemoveTest(nonce), MAX_CHARLIE_LIFETIME);
|
_context.simpleTimer2().addEvent(new RemoveTest(nonce), MAX_CHARLIE_LIFETIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
UDPPacket packet = _packetBuilder.buildPeerTestToCharlie(aliceIP, from.getPort(), aliceIntroKey, nonce,
|
UDPPacket packet = _packetBuilder.buildPeerTestToCharlie(aliceIP, from.getPort(), aliceIntroKey, nonce,
|
||||||
|
@ -270,7 +270,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
//_context.statManager().createRateStat("udp.packetAuthTime", "How long it takes to encrypt and MAC a packet for sending", "udp", RATES);
|
//_context.statManager().createRateStat("udp.packetAuthTime", "How long it takes to encrypt and MAC a packet for sending", "udp", RATES);
|
||||||
//_context.statManager().createRateStat("udp.packetAuthTimeSlow", "How long it takes to encrypt and MAC a packet for sending (when its slow)", "udp", RATES);
|
//_context.statManager().createRateStat("udp.packetAuthTimeSlow", "How long it takes to encrypt and MAC a packet for sending (when its slow)", "udp", RATES);
|
||||||
|
|
||||||
_context.simpleScheduler().addPeriodicEvent(new PingIntroducers(), MIN_EXPIRE_TIMEOUT * 3 / 4);
|
_context.simpleTimer2().addPeriodicEvent(new PingIntroducers(), MIN_EXPIRE_TIMEOUT * 3 / 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1235,7 +1235,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
RemoteHostId remote = peer.getRemoteHostId();
|
RemoteHostId remote = peer.getRemoteHostId();
|
||||||
_dropList.add(remote);
|
_dropList.add(remote);
|
||||||
_context.statManager().addRateData("udp.dropPeerDroplist", 1);
|
_context.statManager().addRateData("udp.dropPeerDroplist", 1);
|
||||||
_context.simpleScheduler().addEvent(new RemoveDropList(remote), DROPLIST_PERIOD);
|
_context.simpleTimer2().addEvent(new RemoveDropList(remote), DROPLIST_PERIOD);
|
||||||
}
|
}
|
||||||
markUnreachable(peerHash);
|
markUnreachable(peerHash);
|
||||||
_context.banlist().banlistRouter(peerHash, "Part of the wrong network, version = " + ((RouterInfo) entry).getVersion());
|
_context.banlist().banlistRouter(peerHash, "Part of the wrong network, version = " + ((RouterInfo) entry).getVersion());
|
||||||
|
@ -84,7 +84,7 @@ class TunnelGatewayPumper implements Runnable {
|
|||||||
// in case another packet came in
|
// in case another packet came in
|
||||||
_wantsPumping.remove(gw);
|
_wantsPumping.remove(gw);
|
||||||
if (_backlogged.add(gw))
|
if (_backlogged.add(gw))
|
||||||
_context.simpleScheduler().addEvent(new Requeue(gw), REQUEUE_TIME);
|
_context.simpleTimer2().addEvent(new Requeue(gw), REQUEUE_TIME);
|
||||||
}
|
}
|
||||||
gw = null;
|
gw = null;
|
||||||
if (_wantsPumping.isEmpty()) {
|
if (_wantsPumping.isEmpty()) {
|
||||||
|
@ -41,7 +41,7 @@ class ParticipatingThrottler {
|
|||||||
ParticipatingThrottler(RouterContext ctx) {
|
ParticipatingThrottler(RouterContext ctx) {
|
||||||
this.context = ctx;
|
this.context = ctx;
|
||||||
this.counter = new ObjectCounter<Hash>();
|
this.counter = new ObjectCounter<Hash>();
|
||||||
ctx.simpleScheduler().addPeriodicEvent(new Cleaner(), CLEAN_TIME);
|
ctx.simpleTimer2().addPeriodicEvent(new Cleaner(), CLEAN_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** increments before checking */
|
/** increments before checking */
|
||||||
|
@ -26,7 +26,7 @@ class RequestThrottler {
|
|||||||
RequestThrottler(RouterContext ctx) {
|
RequestThrottler(RouterContext ctx) {
|
||||||
this.context = ctx;
|
this.context = ctx;
|
||||||
this.counter = new ObjectCounter<Hash>();
|
this.counter = new ObjectCounter<Hash>();
|
||||||
ctx.simpleScheduler().addPeriodicEvent(new Cleaner(), CLEAN_TIME);
|
ctx.simpleTimer2().addPeriodicEvent(new Cleaner(), CLEAN_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** increments before checking */
|
/** increments before checking */
|
||||||
|
@ -430,7 +430,7 @@ public class TunnelPoolManager implements TunnelManagerFacade {
|
|||||||
// don't delay the outbound if it already exists, as this opens up a large
|
// don't delay the outbound if it already exists, as this opens up a large
|
||||||
// race window with removeTunnels() below
|
// race window with removeTunnels() below
|
||||||
if (delayOutbound)
|
if (delayOutbound)
|
||||||
_context.simpleScheduler().addEvent(new DelayedStartup(outbound), 1000);
|
_context.simpleTimer2().addEvent(new DelayedStartup(outbound), 1000);
|
||||||
else
|
else
|
||||||
outbound.startup();
|
outbound.startup();
|
||||||
}
|
}
|
||||||
@ -512,7 +512,7 @@ public class TunnelPoolManager implements TunnelManagerFacade {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_inboundExploratory.startup();
|
_inboundExploratory.startup();
|
||||||
_context.simpleScheduler().addEvent(new DelayedStartup(_outboundExploratory), 3*1000);
|
_context.simpleTimer2().addEvent(new DelayedStartup(_outboundExploratory), 3*1000);
|
||||||
|
|
||||||
// try to build up longer tunnels
|
// try to build up longer tunnels
|
||||||
_context.jobQueue().addJob(new BootstrapPool(_context, _inboundExploratory));
|
_context.jobQueue().addJob(new BootstrapPool(_context, _inboundExploratory));
|
||||||
|
Reference in New Issue
Block a user