Class StreamBaseMonitor

    • Field Detail

      • STAT_SCHEMA

        public static final Schema STAT_SCHEMA
        The stats schema.
      • STAT_SCHEMA_V3

        public static final Schema STAT_SCHEMA_V3
        The v3 stats schema.
    • Constructor Detail

      • StreamBaseMonitor

        public StreamBaseMonitor​(StreamBaseURI uri)
                          throws StreamBaseException
        Create a monitoring object, which will connect to a server with the given StreamBase URI. The connection will not be made until caller calls run().

        A null StreamBase URI will get the connection information from the streambase.uri property variable, if set. The default server is "sb://localhost:10000".

        Parameters:
        uri - URI of StreamBase server
        Throws:
        StreamBaseException - on error
        See Also:
        StreamBaseURI
      • StreamBaseMonitor

        public StreamBaseMonitor​(StreamBaseClient client)
                          throws StreamBaseException
        Create a monitoring object, which will connect to a server with the given StreamBaseClient object.

        Note: The StreamBaseClient object is passed into this StreamBaseMonitor constructor. Therefore this StreamBaseMonitor does not "own" the StreamBaseClient object. It is the responsibility of the caller to close the StreamBaseClient object.

        Parameters:
        client - an already connected StreamBaseClient
        Throws:
        StreamBaseException - on error
        See Also:
        StreamBaseClient
      • StreamBaseMonitor

        public StreamBaseMonitor​(String uri)
                          throws StreamBaseException
        Create a monitoring object The given uri can either be a StreamBaseURI or a filename. If it is a StreamBaseURI then the monitor will use it to connect to a StreamBaseServer for live monitoring. If a filename the StreamBaseMonitor will read stats from a file. This file is typically made by sbc dequeue system.stats. A empty or null uri will cause the StreamBaseMonitor to get uri information from the environment.

        Parameters:
        uri - A StreamBaseURI or filename.
        Throws:
        StreamBaseException - on error
        See Also:
        StreamBaseURI
    • Method Detail

      • finalize

        protected void finalize()
        Overrides:
        finalize in class Object
      • enableOperatorDetail

        public boolean enableOperatorDetail​(boolean enable)
        Enable or disable operator details in snapshots such as operator type. Must be set before StreamBaseMonitor.run() is called. Setting after run is called has no effect.
        Parameters:
        enable - true: enable collection of Operator details; false: disable collection
        Returns:
        if operator details were previously enabled or disabled.
        Since:
        7.0.2
      • isClosed

        public boolean isClosed()
        Indicates if the StreamBaseMonitor client is closed
        Returns:
        true means this StreamBaseMonitor is moribund.
        Since:
        6.6.9
      • terminate

        public void terminate()
        Ask the monitor to terminate. Termination will occur after the next snapshot, or after the current snapshot if terminate() is invoked from within a MonitorListener's snapshotReceived() method.
      • run

        public void run()
                 throws StreamBaseException
        Read and process monitor snapshots from sbd. This function will block, and will not return until terminate is called or the connection to the StreamBase server is disconnected. Any call to terminate must be either from inside a MonitorListener, or from another thread.
        Throws:
        StreamBaseException - if a connection cannot be established with the server, or an error occurs while receiving a snapshot
      • reportMonitorStatus

        protected void reportMonitorStatus()
        Report GC and memory usage, if log level debug is enabled.
      • isStatsEnabled

        public boolean isStatsEnabled()
        Determine if stats are available
        Returns:
        true=stats are available false=either the server is not available, or stats are disabled on the server
        Since:
        7.0.2
      • addMonitorListener

        public void addMonitorListener​(MonitorListener listener)
                                throws IllegalArgumentException
        Add a listener for snapshot information.

        If the given listener has already been added just return.

        Listeners are called in the order in which they were added.

        Parameters:
        listener - user-implemented MonitorListener to add
        Throws:
        IllegalArgumentException - listener is null
      • removeMonitorListener

        public void removeMonitorListener​(MonitorListener listener)
        Remove a listener that was previously added.
        Parameters:
        listener - user-implemented MonitorListener to remove
      • removeMonitorListeners

        public void removeMonitorListeners()
        Remove all listeners.
      • getStatsStreamName

        public String getStatsStreamName()
        Get the stats stream name
        Returns:
        the stats stream name
      • getStatsSchema

        public Schema getStatsSchema()
        Get the stats schema
        Returns:
        the stats stream schema
      • main

        public static void main​(String[] args)
        Main for testing
        Parameters:
        args - command line arguments