Class LiveTransferRegistry
java.lang.Object
ecmwf.ecpds.master.LiveTransferRegistry
The Class LiveTransferRegistry.
In-memory, MasterServer-side registry of the latest
LiveTransferSample received from every DataMover. Acts as
the single "source of truth" for the "Live ECPDS Earth" globe visualisation: DataMovers push samples in here (via
MasterInterface.updateLiveTransferStatistics(LiveTransferSample[])), and any number of
listeners (e.g. a WebSocket broadcaster, added in a later phase) can subscribe to be notified in real-time, and/or
poll getActiveTransfers() for the current snapshot.
Kept intentionally simple (no full history/replay persistence) since it only ever needs to reflect "what is happening
right now"; the only persisted piece of state is the rolling 24h transferred-bytes total's underlying per-minute
buckets (see snapshotBucketsForPersistence()/restoreBucketsFromPersistence(String)), periodically
saved to the SYS_CONFIG table by the MasterServer so that figure survives a restart. Detailed
historical/replay data is expected to be handled separately (e.g. a periodic rollup written to the database), not by
this class.-
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(Consumer<LiveTransferSample> listener) Register a listener notified for every sample update (active or terminal).Gets a snapshot of every currently active transfer known to the registry.longGets the total number of bytes transferred (across every Mover/ProxyHost) over the last rolling 24 hours.longgetBytesLast24h(String direction) Gets the total number of bytes transferred (across every Mover/ProxyHost) over the last rolling 24 hours, for a single direction.static LiveTransferRegistryGets the singleton instance.booleanWhether the registry currently has at least one interested listener (e.g. an open globe WebSocket).voidremoveListener(Consumer<LiveTransferSample> listener) Remove a previously registered listener.voidRepopulates the per-minute buckets from a string previously produced bysnapshotBucketsForPersistence(), e.g. on MasterServer startup, so the rolling 24h total does not simply reset to zero after a restart.voidsetEnabled(boolean enabled) Force-enable the registry (e.g. via a configuration flag), regardless of listener count.Serializes every currently non-empty, non-stale (i.e. within the last 24h) per-minute bucket into a compactminute:dissBytes:acqBytestriples string, suitable for storage in a singleSYS_CONFIGrow.voidtouch()Records that a remote consumer (the Monitor plugin's globe WebSocket broadcaster, polling viaManagementInterface.getLiveTransfers()) is actively interested right now.voidupdate(LiveTransferSample[] samples) Update the registry with a freshly received batch of samples from a DataMover, and notify listeners.
-
Method Details
-
getInstance
-
update
Update the registry with a freshly received batch of samples from a DataMover, and notify listeners.- Parameters:
samples- the samples
-
getBytesLast24h
public long getBytesLast24h()Gets the total number of bytes transferred (across every Mover/ProxyHost) over the last rolling 24 hours. This is a single, MasterServer-side, always-on counter (unlike the per-connection "session" figure a globe client used to keep locally), so every open globe page - and every Monitor plugin instance - sees the exact same value, and it survives page reloads/reconnects. The underlying per-minute buckets are also periodically persisted to theSYS_CONFIGtable (seesnapshotBucketsForPersistence()/restoreBucketsFromPersistence(String)), so a normal MasterServer restart only loses at most a few minutes of history instead of the full 24 hours.- Returns:
- the total bytes transferred in the last 24 hours
-
getBytesLast24h
Gets the total number of bytes transferred (across every Mover/ProxyHost) over the last rolling 24 hours, for a single direction. Same semantics/persistence asgetBytesLast24h(), just filtered to one ofLiveTransferSample.DIRECTION_DISSEMINATIONorLiveTransferSample.DIRECTION_ACQUISITION, so the globe UI's "Transferred (24h)" KPI can match whichever of Dissemination/Acquisition/Both is currently selected.- Parameters:
direction- one ofLiveTransferSample.DIRECTION_DISSEMINATIONorLiveTransferSample.DIRECTION_ACQUISITION- Returns:
- the total bytes transferred in the last 24 hours for that direction
-
snapshotBucketsForPersistence
Serializes every currently non-empty, non-stale (i.e. within the last 24h) per-minute bucket into a compactminute:dissBytes:acqBytestriples string, suitable for storage in a singleSYS_CONFIGrow. Meant to be called periodically (e.g. every few minutes) by the MasterServer, so a restart only loses the handful of minutes since the last save rather than the full rolling 24h window.- Returns:
- the serialized snapshot, or an empty string if there is nothing (yet) to persist
-
restoreBucketsFromPersistence
Repopulates the per-minute buckets from a string previously produced bysnapshotBucketsForPersistence(), e.g. on MasterServer startup, so the rolling 24h total does not simply reset to zero after a restart. Entries for minutes already outside the current rolling 24h window (i.e. the MasterServer was down for a while) are silently skipped, exactly as they would eventually age out of the live buckets anyway. Accepts both the currentminute:dissBytes:acqBytesformat and the legacyminute:bytesformat (from before the Dissemination/Acquisition split), treating a legacy entry's single value as Dissemination bytes so upgrading a running MasterServer does not lose its rolling 24h total.- Parameters:
data- the previously persisted snapshot, as produced bysnapshotBucketsForPersistence()
-
getActiveTransfers
Gets a snapshot of every currently active transfer known to the registry.- Returns:
- the active transfers
-
addListener
Register a listener notified for every sample update (active or terminal).- Parameters:
listener- the listener
-
removeListener
Remove a previously registered listener.- Parameters:
listener- the listener
-
isEnabled
public boolean isEnabled()Whether the registry currently has at least one interested listener (e.g. an open globe WebSocket). Used by DataMovers to decide whether it is worth sampling/pushing live statistics at all.- Returns:
- true, if is enabled
-
touch
public void touch()Records that a remote consumer (the Monitor plugin's globe WebSocket broadcaster, polling viaManagementInterface.getLiveTransfers()) is actively interested right now. Used to extendisEnabled()forPOLL_ENABLE_WINDOW_MSbeyond each poll. -
setEnabled
public void setEnabled(boolean enabled) Force-enable the registry (e.g. via a configuration flag), regardless of listener count.- Parameters:
enabled- the enabled
-