forked from I2P_Developers/i2p.i2p
* SimpleScheduler: New replacement for SimpleTimer when events
will not be rescheduled or cancelled, to reduce SimpleTimer
lock contention
This commit is contained in:
@@ -43,6 +43,7 @@ import net.i2p.stat.StatManager;
|
||||
import net.i2p.util.FileUtil;
|
||||
import net.i2p.util.I2PThread;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.SimpleScheduler;
|
||||
import net.i2p.util.SimpleTimer;
|
||||
|
||||
/**
|
||||
@@ -257,7 +258,7 @@ public class Router {
|
||||
_context.inNetMessagePool().startup();
|
||||
startupQueue();
|
||||
//_context.jobQueue().addJob(new CoalesceStatsJob(_context));
|
||||
SimpleTimer.getInstance().addEvent(new CoalesceStatsEvent(_context), 0);
|
||||
SimpleScheduler.getInstance().addPeriodicEvent(new CoalesceStatsEvent(_context), 20*1000);
|
||||
_context.jobQueue().addJob(new UpdateRoutingKeyModifierJob(_context));
|
||||
warmupCrypto();
|
||||
_sessionKeyPersistenceHelper.startup();
|
||||
@@ -346,7 +347,7 @@ public class Router {
|
||||
if (blockingRebuild)
|
||||
r.timeReached();
|
||||
else
|
||||
SimpleTimer.getInstance().addEvent(r, 0);
|
||||
SimpleScheduler.getInstance().addEvent(r, 0);
|
||||
} catch (DataFormatException dfe) {
|
||||
_log.log(Log.CRIT, "Internal error - unable to sign our own address?!", dfe);
|
||||
}
|
||||
@@ -1261,8 +1262,6 @@ class CoalesceStatsEvent implements SimpleTimer.TimedEvent {
|
||||
getContext().statManager().addRateData("bw.sendBps", (long)KBps, 60*1000);
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTimer.getInstance().addEvent(this, 20*1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import net.i2p.router.RouterContext;
|
||||
import net.i2p.util.I2PThread;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.RandomSource;
|
||||
import net.i2p.util.SimpleScheduler;
|
||||
import net.i2p.util.SimpleTimer;
|
||||
|
||||
/**
|
||||
@@ -419,7 +420,7 @@ public class ClientConnectionRunner {
|
||||
// theirs is newer
|
||||
} else {
|
||||
// ours is newer, so wait a few secs and retry
|
||||
SimpleTimer.getInstance().addEvent(new Rerequest(set, expirationTime, onCreateJob, onFailedJob), 3*1000);
|
||||
SimpleScheduler.getInstance().addEvent(new Rerequest(set, expirationTime, onCreateJob, onFailedJob), 3*1000);
|
||||
}
|
||||
// fire onCreated?
|
||||
return; // already requesting
|
||||
|
||||
@@ -24,6 +24,7 @@ import net.i2p.router.PeerSelectionCriteria;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.SimpleScheduler;
|
||||
import net.i2p.util.SimpleTimer;
|
||||
|
||||
/**
|
||||
@@ -50,7 +51,7 @@ class PeerManager {
|
||||
_peersByCapability[i] = new ArrayList(64);
|
||||
loadProfiles();
|
||||
////_context.jobQueue().addJob(new EvaluateProfilesJob(_context));
|
||||
SimpleTimer.getInstance().addEvent(new Reorg(), 0);
|
||||
SimpleScheduler.getInstance().addPeriodicEvent(new Reorg(), 0, 30*1000);
|
||||
//_context.jobQueue().addJob(new PersistProfilesJob(_context, this));
|
||||
}
|
||||
|
||||
@@ -60,8 +61,6 @@ class PeerManager {
|
||||
_organizer.reorganize(true);
|
||||
} catch (Throwable t) {
|
||||
_log.log(Log.CRIT, "Error evaluating profiles", t);
|
||||
} finally {
|
||||
SimpleTimer.getInstance().addEvent(Reorg.this, 30*1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import net.i2p.router.Router;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.util.I2PThread;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.SimpleScheduler;
|
||||
import net.i2p.util.SimpleTimer;
|
||||
|
||||
/**
|
||||
@@ -184,7 +185,7 @@ public class EstablishmentManager {
|
||||
msg.getTarget().getIdentity(),
|
||||
new SessionKey(addr.getIntroKey()), addr);
|
||||
_outboundStates.put(to, state);
|
||||
SimpleTimer.getInstance().addEvent(new Expire(to, state), 10*1000);
|
||||
SimpleScheduler.getInstance().addEvent(new Expire(to, state), 10*1000);
|
||||
}
|
||||
}
|
||||
if (state != null) {
|
||||
@@ -394,7 +395,7 @@ public class EstablishmentManager {
|
||||
msg.getTarget().getIdentity(),
|
||||
new SessionKey(addr.getIntroKey()), addr);
|
||||
_outboundStates.put(to, qstate);
|
||||
SimpleTimer.getInstance().addEvent(new Expire(to, qstate), 10*1000);
|
||||
SimpleScheduler.getInstance().addEvent(new Expire(to, qstate), 10*1000);
|
||||
|
||||
for (int i = 0; i < queued.size(); i++) {
|
||||
OutNetMessage m = (OutNetMessage)queued.get(i);
|
||||
@@ -477,7 +478,7 @@ public class EstablishmentManager {
|
||||
dsm.setMessageExpiration(_context.clock().now()+10*1000);
|
||||
dsm.setMessageId(_context.random().nextLong(I2NPMessage.MAX_ID_VALUE));
|
||||
_transport.send(dsm, peer);
|
||||
SimpleTimer.getInstance().addEvent(new PublishToNewInbound(peer), 0);
|
||||
SimpleScheduler.getInstance().addEvent(new PublishToNewInbound(peer), 0);
|
||||
}
|
||||
private class PublishToNewInbound implements SimpleTimer.TimedEvent {
|
||||
private PeerState _peer;
|
||||
@@ -629,7 +630,7 @@ public class EstablishmentManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
SimpleTimer.getInstance().addEvent(new FailIntroduction(state, nonce), INTRO_ATTEMPT_TIMEOUT);
|
||||
SimpleScheduler.getInstance().addEvent(new FailIntroduction(state, nonce), INTRO_ATTEMPT_TIMEOUT);
|
||||
state.setIntroNonce(nonce);
|
||||
_context.statManager().addRateData("udp.sendIntroRelayRequest", 1, 0);
|
||||
UDPPacket requests[] = _builder.buildRelayRequest(_transport, state, _transport.getIntroKey());
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.i2p.data.SessionKey;
|
||||
import net.i2p.router.CommSystemFacade;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.SimpleScheduler;
|
||||
import net.i2p.util.SimpleTimer;
|
||||
|
||||
/**
|
||||
@@ -79,7 +80,7 @@ class PeerTestManager {
|
||||
|
||||
sendTestToBob();
|
||||
|
||||
SimpleTimer.getInstance().addEvent(new ContinueTest(), RESEND_TIMEOUT);
|
||||
SimpleScheduler.getInstance().addEvent(new ContinueTest(), RESEND_TIMEOUT);
|
||||
}
|
||||
|
||||
private class ContinueTest implements SimpleTimer.TimedEvent {
|
||||
@@ -103,7 +104,7 @@ class PeerTestManager {
|
||||
// second message from Charlie yet
|
||||
sendTestToCharlie();
|
||||
}
|
||||
SimpleTimer.getInstance().addEvent(ContinueTest.this, RESEND_TIMEOUT);
|
||||
SimpleScheduler.getInstance().addEvent(ContinueTest.this, RESEND_TIMEOUT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -430,7 +431,7 @@ class PeerTestManager {
|
||||
synchronized (_activeTests) {
|
||||
_activeTests.put(new Long(nonce), state);
|
||||
}
|
||||
SimpleTimer.getInstance().addEvent(new RemoveTest(nonce), MAX_CHARLIE_LIFETIME);
|
||||
SimpleScheduler.getInstance().addEvent(new RemoveTest(nonce), MAX_CHARLIE_LIFETIME);
|
||||
}
|
||||
|
||||
UDPPacket packet = _packetBuilder.buildPeerTestToBob(bobIP, from.getPort(), aliceIP, alicePort, aliceIntroKey, nonce, state.getBobCipherKey(), state.getBobMACKey());
|
||||
@@ -511,7 +512,7 @@ class PeerTestManager {
|
||||
synchronized (_activeTests) {
|
||||
_activeTests.put(new Long(nonce), state);
|
||||
}
|
||||
SimpleTimer.getInstance().addEvent(new RemoveTest(nonce), MAX_CHARLIE_LIFETIME);
|
||||
SimpleScheduler.getInstance().addEvent(new RemoveTest(nonce), MAX_CHARLIE_LIFETIME);
|
||||
}
|
||||
|
||||
UDPPacket packet = _packetBuilder.buildPeerTestToCharlie(aliceIP, from.getPort(), aliceIntroKey, nonce,
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.i2p.router.RouterContext;
|
||||
import net.i2p.router.transport.FIFOBandwidthLimiter;
|
||||
import net.i2p.util.I2PThread;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.SimpleScheduler;
|
||||
import net.i2p.util.SimpleTimer;
|
||||
|
||||
/**
|
||||
@@ -115,7 +116,7 @@ public class UDPReceiver {
|
||||
long delay = ARTIFICIAL_DELAY_BASE + _context.random().nextInt(ARTIFICIAL_DELAY);
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Delay packet " + packet + " for " + delay);
|
||||
SimpleTimer.getInstance().addEvent(new ArtificiallyDelayedReceive(packet), delay);
|
||||
SimpleScheduler.getInstance().addEvent(new ArtificiallyDelayedReceive(packet), delay);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import net.i2p.router.transport.Transport;
|
||||
import net.i2p.router.transport.TransportBid;
|
||||
import net.i2p.router.transport.TransportImpl;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.SimpleScheduler;
|
||||
import net.i2p.util.SimpleTimer;
|
||||
|
||||
/**
|
||||
@@ -631,7 +632,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
}
|
||||
if (added) {
|
||||
_context.statManager().addRateData("udp.dropPeerDroplist", droplistSize, 0);
|
||||
SimpleTimer.getInstance().addEvent(new RemoveDropList(remote), DROPLIST_PERIOD);
|
||||
SimpleScheduler.getInstance().addEvent(new RemoveDropList(remote), DROPLIST_PERIOD);
|
||||
}
|
||||
}
|
||||
markUnreachable(peerHash);
|
||||
|
||||
Reference in New Issue
Block a user