Class GlobeWebSocket

java.lang.Object
ecmwf.ecpds.master.plugin.http.GlobeWebSocket
All Implemented Interfaces:
org.eclipse.jetty.ee8.websocket.api.WebSocketConnectionListener, org.eclipse.jetty.ee8.websocket.api.WebSocketListener

public class GlobeWebSocket extends Object implements org.eclipse.jetty.ee8.websocket.api.WebSocketListener
WebSocket endpoint streaming live data-transfer events to the "Live ECPDS Earth" globe visualisation.

The Monitor plugin (where this class runs) is a separate JVM/process from the MasterServer, connected only over RMI (see MasterManager), so it cannot read the MasterServer-side LiveTransferRegistry singleton directly - a shared, JVM-wide poller (started lazily on the first connection, stopped once the last one closes) periodically calls ManagementInterface.getLiveTransfers() and ManagementInterface.getLiveTransferOrigin() over RMI and fans the resulting snapshot out to every currently connected client as a "snapshot" message (which the frontend uses to fully replace its current transfer set, so no client-side diffing is needed). Polling only happens while at least one globe page is open, which is also what keeps DataMovers sampling (see LiveTransferRegistry.touch()). Geolocation of Host/Mover names is likewise always resolved on the MasterServer side, via ManagementInterface.getGeoLocations(String[]) - the Monitor JVM never needs its own copy of the GeoIP2 database.

Implements the (legacy/"ee8") WebSocketListener interface directly rather than relying on the annotation-based API, since the endpoint is registered through JettyWebSocketServletContainerInitializer, whose frame-handler factory only recognises org.eclipse.jetty.ee8.websocket.api.annotations.* annotations (not the similarly named ones in org.eclipse.jetty.websocket.api.annotations), so implementing the interface avoids that ambiguity.

  • Constructor Details

    • GlobeWebSocket

      public GlobeWebSocket()
  • Method Details

    • onWebSocketConnect

      public void onWebSocketConnect(org.eclipse.jetty.ee8.websocket.api.Session session)
      Called when the WebSocket is connected. Registers this connection for broadcast, starts the shared poller if it is not already running, and sends an initial "hello" (origin location) and "snapshot" (currently active transfers) message.
      Specified by:
      onWebSocketConnect in interface org.eclipse.jetty.ee8.websocket.api.WebSocketConnectionListener
      Parameters:
      session - the connected WebSocket session
    • onWebSocketText

      public void onWebSocketText(String message)
      Called when a message is received from the client. No client-initiated commands are currently supported; this is a read-only stream, so any incoming message is simply ignored.
      Specified by:
      onWebSocketText in interface org.eclipse.jetty.ee8.websocket.api.WebSocketListener
      Parameters:
      message - the raw message from the client
    • onWebSocketClose

      public void onWebSocketClose(int statusCode, String reason)
      Called when the WebSocket is closed. Unregisters this connection from the broadcast set, and stops the shared poller if it was the last one.
      Specified by:
      onWebSocketClose in interface org.eclipse.jetty.ee8.websocket.api.WebSocketConnectionListener
      Parameters:
      statusCode - the close status code
      reason - the reason for closure
    • onWebSocketError

      public void onWebSocketError(Throwable error)
      Called on WebSocket error. Unregisters this connection from the broadcast set.
      Specified by:
      onWebSocketError in interface org.eclipse.jetty.ee8.websocket.api.WebSocketConnectionListener
      Parameters:
      error - the thrown error