/** * Caller MUST schedule. */ DecayEvent() { super(_context.simpleTimer2()); }
public Watcher() { super(_context.simpleTimer2(), CHECK_INTERVAL); }
public CheckEvent(I2PAppContext ctx, PeerCheckerTask task) { super(ctx.simpleTimer2()); _task = task; } public void timeReached() {
public Timeout() { super(_context.simpleTimer2(), METAINFO_TIMEOUT); }
public RemoveExpired() { super(_context.simpleTimer2(), REMOVE_EXPIRED_TIME); }
public VerifyUsage() { super(_context.simpleTimer2(), VERIFY_USAGE_TIME); }
/** * If you have a context, use context.simpleTimer2() instead */ public static SimpleTimer2 getInstance() { return I2PAppContext.getGlobalContext().simpleTimer2(); }
public Runner(long delay) { super(_util.getContext().simpleTimer2(), delay); }
public Cleaner() { super(_util.getContext().simpleTimer2()); }
private void startIdleMonitor() { _isReduced = false; boolean reduce = Boolean.parseBoolean(_options.getProperty("i2cp.reduceOnIdle")); boolean close = Boolean.parseBoolean(_options.getProperty("i2cp.closeOnIdle")); if (reduce || close) { updateActivity(); _context.simpleTimer2().addEvent(new SessionIdleTimer(_context, this, reduce, close), SessionIdleTimer.MINIMUM_TIME); } }
/** * Schedules itself. Caller MUST NOT schedule. */ DecayHourlyEvent() { super(_context.simpleTimer2()); schedule(getTimeTillNextHour()); }
/** connect to the given destination */ I2PSocket connect(PeerID peer) throws IOException { I2PSocketManager mgr = _manager; if (mgr == null) throw new IOException("No socket manager"); Destination addr = peer.getAddress(); if (addr == null) throw new IOException("Null address"); if (addr.equals(getMyDestination())) throw new IOException("Attempt to connect to myself"); Hash dest = addr.calculateHash(); if (_banlist.contains(dest)) throw new IOException("Not trying to contact " + dest.toBase64() + ", as they are banlisted"); try { // TODO opts.setPort(xxx); connect(addr, opts) // DHT moved above 6881 in 0.9.9 I2PSocket rv = _manager.connect(addr); if (rv != null) _banlist.remove(dest); return rv; } catch (I2PException ie) { _banlist.add(dest); _context.simpleTimer2().addEvent(new Unbanlist(dest), 10*60*1000); IOException ioe = new IOException("Unable to reach the peer " + peer); ioe.initCause(ie); throw ioe; } }
@Before public void setUp() { when(context.clock()).thenReturn(clock); when(context.simpleTimer2()).thenReturn(timer); scheduler = createScheduler(); }
/** * @param tagsToSend how many to send at a time, may be lower or higher than lowThreshold. 1-128 * @param lowThreshold below this, send more. 1-128 * @since 0.9.2 */ public TransientSessionKeyManager(I2PAppContext context, int tagsToSend, int lowThreshold) { super(context); if (tagsToSend <= 0 || tagsToSend > 128 || lowThreshold <= 0 || lowThreshold > 128) throw new IllegalArgumentException(); _tagsToSend = tagsToSend; _lowThreshold = lowThreshold; _log = context.logManager().getLog(TransientSessionKeyManager.class); _context = context; _outboundSessions = new HashMap<PublicKey, OutboundSession>(64); _inboundTagSets = new HashMap<SessionTag, TagSet>(128); 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 }); _alive = true; _context.simpleTimer2().addEvent(new CleanupEvent(), 60*1000); }
public void timeReached() { if (!_alive) return; long beforeExpire = _context.clock().now(); int expired = aggressiveExpire(); int overage = _inboundTagSets.size() - MAX_INBOUND_SESSION_TAGS; if (overage > 0) clearExcess(overage); long expireTime = _context.clock().now() - beforeExpire; _context.statManager().addRateData("crypto.sessionTagsExpired", expired, expireTime); _context.simpleTimer2().addEvent(this, 60*1000); } }
@Before public void setUp() { _context = I2PAppContext.getGlobalContext(); _st2 = _context.simpleTimer2(); }
/** * Caller must schedule */ public IdleChecker(SnarkManager mgr, PeerCoordinatorSet pcs) { super(mgr.util().getContext().simpleTimer2()); _util = mgr.util(); _log = _util.getContext().logManager().getLog(IdleChecker.class); _mgr = mgr; _pcs = pcs; }
_context.simpleTimer2().addEvent(new Register(), 4*60*1000);
} else { _context.simpleTimer2().addEvent(new Disconnector(), 60*1000);
nextDelay = _minimumTime - (now - lastActivity); _context.simpleTimer2().addEvent(this, nextDelay);