public class StreamBaseMonitor
extends java.lang.Object
implements java.io.Closeable
Snapshot
,
MonitorListener
Modifier and Type | Field and Description |
---|---|
static Schema |
STAT_SCHEMA
The stats schema.
|
static Schema |
STAT_SCHEMA_V3
The v3 stats schema.
|
Constructor and Description |
---|
StreamBaseMonitor(StreamBaseClient client)
Create a monitoring object, which will connect to a server with the given
StreamBaseClient object.
|
StreamBaseMonitor(StreamBaseClient sbClient,
java.lang.String streamName) |
StreamBaseMonitor(StreamBaseURI uri)
Create a monitoring object, which will connect to a server with the given
StreamBase URI.
|
StreamBaseMonitor(java.lang.String uri)
Create a monitoring object
The given uri can either be a StreamBaseURI or a filename.
|
Modifier and Type | Method and Description |
---|---|
void |
addMonitorListener(MonitorListener listener)
Add a listener for snapshot information.
|
void |
close()
close this monitor
|
boolean |
enableOperatorDetail(boolean enable)
Enable or disable operator details in snapshots such as operator type.
|
protected void |
finalize() |
StreamBaseClient |
getClient()
Get the StreamBaseClient that this monitor is using
|
Schema |
getStatsSchema()
Get the stats schema
|
java.lang.String |
getStatsStreamName()
Get the stats stream name
|
boolean |
isClosed()
Indicates if the StreamBaseMonitor client is closed
|
boolean |
isStatsEnabled()
Determine if stats are available
|
static void |
main(java.lang.String[] args)
Main for testing
|
void |
removeMonitorListener(MonitorListener listener)
Remove a listener that was previously added.
|
void |
removeMonitorListeners()
Remove all listeners.
|
protected void |
reportMonitorStatus()
Report GC and memory usage, if log level debug is enabled.
|
void |
run()
Read and process monitor snapshots from sbd.
|
void |
terminate()
Ask the monitor to terminate.
|
public static final Schema STAT_SCHEMA
public static final Schema STAT_SCHEMA_V3
public StreamBaseMonitor(StreamBaseURI uri) throws StreamBaseException
A null StreamBase URI will get the connection information from the streambase.uri property variable, if set. The default server is "sb://localhost:10000".
uri
- URI of StreamBase serverStreamBaseException
- on errorStreamBaseURI
public StreamBaseMonitor(StreamBaseClient client) throws StreamBaseException
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.
client
- an already connected StreamBaseClientStreamBaseException
- on errorStreamBaseClient
public StreamBaseMonitor(java.lang.String uri) throws StreamBaseException
uri
- A StreamBaseURI or filename.StreamBaseException
- on errorStreamBaseURI
public StreamBaseMonitor(StreamBaseClient sbClient, java.lang.String streamName) throws StreamBaseException
StreamBaseException
protected void finalize()
finalize
in class java.lang.Object
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public boolean enableOperatorDetail(boolean enable)
enable
- true: enable collection of Operator details; false: disable collectionpublic boolean isClosed()
public void terminate()
public void run() throws StreamBaseException
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.StreamBaseException
- if a connection cannot be established with the server, or an error occurs while receiving a snapshotprotected void reportMonitorStatus()
public boolean isStatsEnabled()
public void addMonitorListener(MonitorListener listener)
If the given listener has already been added just return.
Listeners are called in the order in which they were added.
listener
- user-implemented MonitorListener to addpublic void removeMonitorListener(MonitorListener listener)
listener
- user-implemented MonitorListener to removepublic void removeMonitorListeners()
public java.lang.String getStatsStreamName()
public Schema getStatsSchema()
public StreamBaseClient getClient()
public static void main(java.lang.String[] args)
args
- command line arguments