- All Implemented Interfaces:
Runnable
This event runs every minute to collect, aggregate, and coalesce router performance statistics. It gathers metrics from all major router components and updates the statistics framework for monitoring and analysis.
Statistics Collected:
- Network metrics - peer counts, bandwidth usage
- System resources - memory usage, CPU load, thread count
- Tunnel performance - build success rates, participation
- Router health - job queue lag, processing times
- Communication system - send/receive rates, error counts
Features:
- Automatic cache clearing when memory is low
- Rate calculation and rolling averages
- Performance trend monitoring
- Data available via /stats.jsp and /graphs.jsp
This data is essential for router performance monitoring, troubleshooting, and capacity planning. The statistics are used by the router console to display real-time performance graphs and historical trends.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RouterContextThe router whose stats are coalesced.private longCumulative GC pause time, in ms, observed at the previous coalesce cycle, used to derive per-minute GC latency; -1 means uninitialized.private final LogLogger for this class.private final longHeap the JVM will use, in bytes.private static final longFree heap that counts as low: 5 MB.Fields inherited from class SimpleTimer2.TimedEvent
_state, DEFAULT_FUZZModifier and TypeFieldDescriptionprotected SimpleTimer2.TimedEventStateState of the current event.protected static final intDefault fuzz threshold in milliseconds.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionprivate static final StringMark a string for extraction by xgettext and translation.private voidGather this cycle's statistics and coalesce them into the Rates.private static longCumulative GC pause time (ms) across all collectors since JVM start.private longGC pause time (ms) elapsed since the previous coalesce cycle.voidCollect and coalesce router statistics.Methods inherited from class SimpleTimer2.TimedEvent
cancel, forceReschedule, reschedule, reschedule, run, schedule, setFuzz, setPool, toStringModifier and TypeMethodDescriptionbooleancancel()Cancel the timed event.voidforceReschedule(long timeoutMs) Always use the new time - ignores fuzz.voidreschedule(long timeoutMs) Use the earliest of the new time and the old time May be called from within timeReached(), but schedule() is better there.voidreschedule(long timeoutMs, boolean useEarliestTime) May be called from within timeReached(), but schedule() is better there.voidrun()voidschedule(long timeoutMs) Schedule this event.voidsetFuzz(int fuzz) Reschedule threshold in ms.voidsetPool(SimpleTimer2 pool) Timer pool for this event.toString()Timer summary for log messages.
Field Details
_ctx
The router whose stats are coalesced._maxMemory
private final long _maxMemoryHeap the JVM will use, in bytes.LOW_MEMORY_THRESHOLD
private static final long LOW_MEMORY_THRESHOLDFree heap that counts as low: 5 MB.- See Also:
_log
Logger for this class._lastGcPauseTime
private long _lastGcPauseTimeCumulative GC pause time, in ms, observed at the previous coalesce cycle, used to derive per-minute GC latency; -1 means uninitialized.
Constructor Details
CoalesceStatsEvent
Create a new stats coalescence event. Initializes all required rate statistics for monitoring router performance.- Parameters:
ctx- the router context for accessing statistics manager
Method Details
timeReached
public void timeReached()Collect and coalesce router statistics.This method is called periodically to gather various router metrics including network statistics, peer counts, memory usage, and tunnel performance. The collected data is used for monitoring and performance analysis.
Statistics collected include:
- Peer counts (known, active, fast, high capacity, etc.)
- Bandwidth usage (send/receive rates)
- Memory usage and CPU load
- Tunnel performance metrics
- Thread counts and system resources
- Specified by:
timeReachedin classSimpleTimer2.TimedEvent
collectStats
private void collectStats()Gather this cycle's statistics and coalesce them into the Rates.Called every Router.COALESCE_TIME by
timeReached(), which guarantees the reschedule and contains any exception this throws, so nothing here needs its own try/catch._x
getCumulativeGcPauseTime
private static long getCumulativeGcPauseTime()Cumulative GC pause time (ms) across all collectors since JVM start. Returns -1 if GC beans are unavailable.- Returns:
- the cumulative gc pause time
getGcPauseTime
private long getGcPauseTime()GC pause time (ms) elapsed since the previous coalesce cycle. Returns -1 on the first call (no baseline) or if GC data is unavailable.- Returns:
- the gc pause time