public class OutboundCache extends Object
This class maintains several caches to optimize outbound message routing and delivery:
All caches use ConcurrentHashMap with tuned initial capacity, load factor, and concurrency level to allow safe concurrent access and high throughput with low contention. Tunnel caches have been converted from HashMaps with explicit synchronization to ConcurrentHashMaps for consistent concurrency management without external locking.
Cache cleaning occurs periodically with a configurable interval, removing expired entries to balance memory use and cache freshness.
| Modifier and Type | Class and Description |
|---|---|
(package private) static class | OutboundCache.HashPairComposite key for caches, combining source and destination Hashes. |
| Modifier and Type | Field and Description |
|---|---|
(package private) ConcurrentHashMap<OutboundCache.HashPair,TunnelInfo> | backloggedTunnelCacheCache for backlogged tunnels per source-destination pair. |
(package private) ConcurrentHashMap<OutboundCache.HashPair,Long> | lastReplyRequestCacheCache to track the last reply request time per source-destination pair. |
(package private) ConcurrentHashMap<OutboundCache.HashPair,Lease> | leaseCacheLease cache keyed by source-destination pairs. |
(package private) ConcurrentHashMap<OutboundCache.HashPair,LeaseSet> | leaseSetCacheLeaseSet cache keyed by source-destination pairs. |
ConcurrentHashMap<Hash,LeaseSet> | multihomedCacheCache for LeaseSets associated with multihomed routers or hosted destinations. |
(package private) ConcurrentHashMap<OutboundCache.HashPair,TunnelInfo> | tunnelCacheCache for outbound tunnels per source-destination pair. |
(package private) ConcurrentHashMap<OutboundCache.HashPair,Long> | tunnelStartTimeTracks when each tunnel was first selected for a source-destination pair,
to prevent rapid tunnel switching that causes out-of-order delivery
and unnecessary NACKs in the streaming layer. |
| Constructor and Description |
|---|
OutboundCache(RouterContext ctx)Creates an OutboundCache instance and schedules periodic cache cleanup. |
| Modifier and Type | Method and Description |
|---|---|
void | clearAllCaches()Clears all caches managed by this instance. |
(package private) void | clearCaches(OutboundCache.HashPair hashPair,
Lease lease,
TunnelInfo inTunnel,
TunnelInfo outTunnel)Clears cache entries related to the provided key and elements upon failure,
allowing retries with fresh associations. |
final ConcurrentHashMap<OutboundCache.HashPair,TunnelInfo> backloggedTunnelCache
final ConcurrentHashMap<OutboundCache.HashPair,Long> lastReplyRequestCache
final ConcurrentHashMap<OutboundCache.HashPair,Lease> leaseCache
final ConcurrentHashMap<OutboundCache.HashPair,LeaseSet> leaseSetCache
public final ConcurrentHashMap<Hash,LeaseSet> multihomedCache
final ConcurrentHashMap<OutboundCache.HashPair,TunnelInfo> tunnelCache
final ConcurrentHashMap<OutboundCache.HashPair,Long> tunnelStartTime
public OutboundCache(RouterContext ctx)
ctx - the router context providing environment and utilities.public void clearAllCaches()
void clearCaches(OutboundCache.HashPair hashPair, Lease lease, TunnelInfo inTunnel, TunnelInfo outTunnel)
hashPair - the source-destination key for caches.lease - lease to clear from leaseCache, may be null.inTunnel - inbound tunnel to check for leaseSetCache invalidation, may be null.outTunnel - outbound tunnel to clear from tunnel caches, may be null.