Package net.i2p.router.message
Class OutboundCache
java.lang.Object
net.i2p.router.message.OutboundCache
public class OutboundCache extends Object
Helper for OCMOSJ
This is the place where we make I2P go fast.
We have five static caches.
- The LeaseSet cache is used to decide whether to bundle our own leaseset,
which minimizes overhead.
- The Lease cache is used to persistently send to the same lease for the destination,
which keeps the streaming lib happy by minimizing out-of-order delivery.
- The Tunnel and BackloggedTunnel caches are used to persistently use the same outbound tunnel
for the same destination,
which keeps the streaming lib happy by minimizing out-of-order delivery.
- The last reply requested cache ensures that a reply is requested every so often,
so that failed tunnels are recognized.
- Since:
- 0.9 moved out of OCMOSJ
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
OutboundCache.HashPair
Key used to cache things with based on source + dest -
Field Summary
Fields Modifier and Type Field Description (package private) Map<OutboundCache.HashPair,TunnelInfo>
backloggedTunnelCache
(package private) Map<OutboundCache.HashPair,Long>
lastReplyRequestCache
This cache is used to ensure that we request a reply every so often.(package private) ConcurrentHashMap<OutboundCache.HashPair,Lease>
leaseCache
Use the same inbound tunnel (i.e.(package private) ConcurrentHashMap<OutboundCache.HashPair,LeaseSet>
leaseSetCache
Returns the reply lease set if forced to do so, or if configured to do so, or if a certain percentage of the time if configured to do so, or if our lease set has changed since we last talked to them, or 10% of the time anyway so they don't forget us (disabled for now), or null otherwise.(package private) Map<OutboundCache.HashPair,TunnelInfo>
tunnelCache
Use the same outbound tunnel as we did for the same destination previously, if possible, to keep the streaming lib happy Use two caches - although a cache of a list of tunnels per dest might be more elegant. -
Constructor Summary
Constructors Constructor Description OutboundCache(RouterContext ctx)
-
Method Summary
Modifier and Type Method Description void
clearAllCaches()
(package private) void
clearCaches(OutboundCache.HashPair hashPair, Lease lease, TunnelInfo inTunnel, TunnelInfo outTunnel)
Called on failure to give us a better chance of success next time.
-
Field Details
-
tunnelCache
Use the same outbound tunnel as we did for the same destination previously, if possible, to keep the streaming lib happy Use two caches - although a cache of a list of tunnels per dest might be more elegant. Key the caches on the source+dest pair. NOT concurrent. -
backloggedTunnelCache
-
leaseSetCache
Returns the reply lease set if forced to do so, or if configured to do so, or if a certain percentage of the time if configured to do so, or if our lease set has changed since we last talked to them, or 10% of the time anyway so they don't forget us (disabled for now), or null otherwise. Note that wantACK randomly forces us another 5% of the time. We don't want to do this too often as a typical 2-lease leaseset in a DatabaseStoreMessage is 861+37=898 bytes - when added to garlic it's a 1056-byte addition total, which is huge. Key the cache on the source+dest pair. Concurrent. -
leaseCache
Use the same inbound tunnel (i.e. lease) as we did for the same destination previously, if possible, to keep the streaming lib happy Key the caches on the source+dest pair. We're going to use the lease until it expires, as long as it remains in the current leaseSet. If not found, fetch the next lease that we should try sending through, randomly chosen from within the sorted leaseSet (NOT sorted by # of failures through each lease). Concurrent. -
lastReplyRequestCache
This cache is used to ensure that we request a reply every so often. Hopefully this allows the router to recognize a failed tunnel and switch, before upper layers like streaming lib fail, even for low-bandwidth connections like IRC. Concurrent.
-
-
Constructor Details
-
Method Details
-
clearCaches
void clearCaches(OutboundCache.HashPair hashPair, Lease lease, TunnelInfo inTunnel, TunnelInfo outTunnel)Called on failure to give us a better chance of success next time. Of course this is probably 60s too late. And we could pick the bad ones at random again. Or remove entries that were sent and succeeded after this was sent but before this failed. But it's a start.- Parameters:
lease
- may be nullinTunnel
- may be nulloutTunnel
- may be null
-
clearAllCaches
public void clearAllCaches()- Since:
- 0.8.8
-