Package com.streambase.sb.monitor
Class StreamBaseMonitor
java.lang.Object
com.streambase.sb.monitor.StreamBaseMonitor
- All Implemented Interfaces:
Closeable
,AutoCloseable
Monitors a StreamBase Server, and gathers statistics. Periodically sends
Snapshot objects to all registered MonitorListeners.
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionStreamBaseMonitor
(StreamBaseClient client) Create a monitoring object, which will connect to a server with the given StreamBaseClient object.StreamBaseMonitor
(StreamBaseClient sbClient, String streamName) ConstructorCreate a monitoring object, which will connect to a server with the given StreamBase URI.StreamBaseMonitor
(String uri) Create a monitoring object The given uri can either be a StreamBaseURI or a filename. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMonitorListener
(MonitorListener listener) Add a listener for snapshot information.void
close()
boolean
enableOperatorDetail
(boolean enable) Enable or disable operator details in snapshots such as operator type.protected void
finalize()
Get theStreamBaseClient
that this monitor is usingGet the stats schemaGet the stats stream nameboolean
isClosed()
Indicates if the StreamBaseMonitor client is closedboolean
Determine if stats are availablevoid
removeMonitorListener
(MonitorListener listener) Remove a listener that was previously added.void
Remove all listeners.protected void
Report GC and memory usage, if log level debug is enabled.void
run()
Read and process monitor snapshots from sbd.void
Ask the monitor to terminate.
-
Field Details
-
STAT_SCHEMA
The stats schema. -
STAT_SCHEMA_V3
The v3 stats schema. -
streamTagNames
Total number of tuples passed through a stream -
sysTags
System tags -
opTags
Operation tags -
thrTags
Thread tags -
modTags
Module tags -
streamTags
Stream tags -
decisionTableTags
Decision table tags
-
-
Constructor Details
-
StreamBaseMonitor
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:
-
StreamBaseMonitor
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:
-
StreamBaseMonitor
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:
-
StreamBaseMonitor
Constructor- Parameters:
sbClient
- StreamBase ClientstreamName
- Stream name- Throws:
StreamBaseException
- Error creating monitor
-
-
Method Details
-
finalize
protected void finalize() -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
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
Read and process monitor snapshots from sbd. This function will block, and will not return untilterminate
is called or the connection to the StreamBase server is disconnected. Any call toterminate
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
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
Remove a listener that was previously added.If listener was not previously added this method quietly does nothing
- Parameters:
listener
- user-implemented MonitorListener to remove
-
removeMonitorListeners
public void removeMonitorListeners()Remove all listeners. -
getStatsStreamName
Get the stats stream name- Returns:
- the stats stream name
-
getStatsSchema
Get the stats schema- Returns:
- the stats stream schema
-
getClient
Get theStreamBaseClient
that this monitor is using- Returns:
StreamBaseClient
in use by this monitor
-