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.HashPair
Composite key for caches, combining source and destination Hashes.
|
| Modifier and Type | Field and Description |
|---|---|
(package private) ConcurrentHashMap<OutboundCache.HashPair,TunnelInfo> |
backloggedTunnelCache
Cache for backlogged tunnels per source-destination pair.
|
(package private) ConcurrentHashMap<OutboundCache.HashPair,Long> |
lastReplyRequestCache
Cache to track the last reply request time per source-destination pair.
|
(package private) ConcurrentHashMap<OutboundCache.HashPair,Lease> |
leaseCache
Lease cache keyed by source-destination pairs.
|
(package private) ConcurrentHashMap<OutboundCache.HashPair,LeaseSet> |
leaseSetCache
LeaseSet cache keyed by source-destination pairs.
|
ConcurrentHashMap<Hash,LeaseSet> |
multihomedCache
Cache for LeaseSets associated with multihomed routers or hosted destinations.
|
(package private) ConcurrentHashMap<OutboundCache.HashPair,TunnelInfo> |
tunnelCache
Cache for outbound tunnels per source-destination pair.
|
| 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
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.