* SessionKeyManager:

- More stubs for per-destination managers.
        No functional changes yet.
This commit is contained in:
zzz
2009-05-29 13:57:50 +00:00
parent 0a8cbcbfb6
commit 22609bbfdb
8 changed files with 75 additions and 5 deletions

View File

@ -40,6 +40,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
/** Map allowing us to go from a SessionTag to the containing TagSet */
private Map<SessionTag, TagSet> _inboundTagSets;
protected I2PAppContext _context;
private volatile boolean _alive;
/**
* Let session tags sit around for 10 minutes before expiring them. We can now have such a large
@ -75,19 +76,34 @@ public class TransientSessionKeyManager extends SessionKeyManager {
_inboundTagSets = new HashMap(1024);
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 });
SimpleScheduler.getInstance().addPeriodicEvent(new CleanupEvent(), 60*1000);
_alive = true;
SimpleScheduler.getInstance().addEvent(new CleanupEvent(), 60*1000);
}
private TransientSessionKeyManager() { this(null); }
public void shutdown() {
_alive = false;
synchronized (_inboundTagSets) {
_inboundTagSets.clear();
}
synchronized (_outboundSessions) {
_outboundSessions.clear();
}
}
private class CleanupEvent implements SimpleTimer.TimedEvent {
public void timeReached() {
if (!_alive)
return;
long beforeExpire = _context.clock().now();
int expired = aggressiveExpire();
long expireTime = _context.clock().now() - beforeExpire;
_context.statManager().addRateData("crypto.sessionTagsExpired", expired, expireTime);
SimpleScheduler.getInstance().addEvent(this, 60*1000);
}
}
/** TagSet */
protected Set<TagSet> getInboundTagSets() {
synchronized (_inboundTagSets) {