Package com.streambase.sb.client
Class StreamBaseAdminClient
- java.lang.Object
-
- com.streambase.sb.client.StreamBaseAdminClient
-
- All Implemented Interfaces:
AutoCloseable
public class StreamBaseAdminClient extends Object
This class is used to send administrative commands to the StreamBase Server
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StreamBaseAdminClient.ListConnectionArgument
Valid arguments for the listConnection command
-
Field Summary
Fields Modifier and Type Field Description protected com.streambase.sb.client.Admin
_admin
static int
VARIABLE_RESPONSE
Used to signal that a command will return a variable number of responses
-
Constructor Summary
Constructors Constructor Description StreamBaseAdminClient()
Create a StreamBaseAdminClient.StreamBaseAdminClient(StreamBaseURI uri)
Create a StreamBaseAdminClient, connecting to the server at the provided URI.StreamBaseAdminClient(String uri)
Create a StreamBaseAdminClient.StreamBaseAdminClient(List<StreamBaseURI> uris)
Create a StreamBaseAdminClient.StreamBaseAdminClient(List<StreamBaseURI> uris, ClientSettings settings)
Create a StreamBaseAdminClient.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description String[]
addContainer(String containerName, byte[] application, List<String> options)
Add the given application to the given container in the StreamBase serverString[]
addContainer(String containerName, File application, List<String> options)
Add the given application to the given container in the StreamBase serverString[]
addContainer(String containerName, String applicationText, List<String> options)
Add the given application to the given container in the StreamBase serverString[]
addDeploy(byte[] deployText, String... args)
Deprecated.Replaced with application fragments and HOCON configurationString[]
addDeploy(File deployFile, String... options)
Deprecated.Replaced with application fragments and HOCON configurationString[]
addDeploy(String deployText, String... args)
Deprecated.Replaced with application fragments and HOCON configurationString
clearEvalCache(String containerName)
Clear evaluation cachevoid
close()
Close/shutdown the connection to the StreamBase server.void
drain()
Drain a StreamBase Server Has no effect if the server is not runningvoid
drain(String containerName)
Drain a container within a StreamBase Server Has no effect if the server is not runningvoid
fastForwardTime(String msecs)
Fast forward timeString
getEvalCacheContent(String containerName)
Get evaluation cache contentString
getMapperCacheContent(String containerName)
Get mapper cache contentsString[]
getOperatorProperties(String operatorName)
For the given Operator, return its set of properties and their values.String
getOperatorProperty(String operatorName, String propertyName)
Return the value of the given property on the given Operator.ClientSettings
getSettings()
Return the settings for this clientString
getTargetTime()
Get target timeStreamBaseURI
getURI()
Return the URI used by this Client.List<StreamBaseURI>
getURIs()
get all of the URI's for this clientprotected boolean
haModeOn()
is HA mode onString[]
killAllConnections()
Kill all of the connections on the serverString[]
killConnection(byte[] connectionId)
Kill the connection with the given connectionIdString[]
listConnections(StreamBaseAdminClient.ListConnectionArgument... args)
Return an array of client connectionsString[]
listEntities(String entityType, int flags)
Return an array of entity names for the given entity typeString[]
manageJdbcConnections(List<String> args)
Manage JDBC connections: count [name]Count the open JDBC connections to the named data source (or all data sources if ommitted) close [name]Close any open JDBC connections to the named data source (or all data sources if ommitted)String[]
modifyContainer(String containerName, List<String> options)
Modifies the given container.String[]
operatorStatus(String containerName)
Return the status of all the operators in the specified containerString[]
removeContainer(String containerName, String... args)
Remove the given container in the StreamBase serverString[]
restartContainer(String containerName)
Restart a containervoid
restartOperators(List<String> operatorNames)
Restart the given Operators on the StreamBase server.void
resume(String containerName)
Resume a container in a StreamBase servervoid
resumeOperators(List<String> operatorNames)
Resume the given Operators on the StreamBase servervoid
setOperatorProperty(String operatorName, String propertyName, String value)
On the given Operator, set the given property to the given value.void
setRuntimeParam(String paramName, String paramValue, String operator)
Set a runtime parameter on one, or all, operators.String
shutdown()
Shutdown a StreamBase serverString
shutdown(String containerName)
Shutdown a container within a StreamBase servervoid
shutdownOperators(List<String> operatorNames)
Shut down the given Operators on the StreamBase server.String[]
status()
Return the status of the StreamBase ServerString[]
status(boolean verbose)
Return the status of the StreamBase Servervoid
suspend(String name)
Suspend (pause) a container or operator within a StreamBase Servervoid
suspendOperators(List<String> operatorNames)
Suspend (pause) the given Operators on the StreamBase Server
-
-
-
Field Detail
-
VARIABLE_RESPONSE
public static final int VARIABLE_RESPONSE
Used to signal that a command will return a variable number of responses- See Also:
- Constant Field Values
-
_admin
protected final com.streambase.sb.client.Admin _admin
-
-
Constructor Detail
-
StreamBaseAdminClient
public StreamBaseAdminClient() throws StreamBaseException
Create a StreamBaseAdminClient. Uses the value of the "streambase.uri" property as the URI, orStreamBaseURI.DEFAULT_URI
if this property is undefined.- Throws:
StreamBaseException
- on connect error, malformed URI, etc.- See Also:
StreamBaseURI
-
StreamBaseAdminClient
public StreamBaseAdminClient(StreamBaseURI uri) throws StreamBaseException
Create a StreamBaseAdminClient, connecting to the server at the provided URI.- Parameters:
uri
- server address- Throws:
StreamBaseException
- on connect error- See Also:
StreamBaseURI
-
StreamBaseAdminClient
public StreamBaseAdminClient(String uri) throws StreamBaseException
Create a StreamBaseAdminClient.- Parameters:
uri
- The uri to use of the form: sb://address:port. SeeStreamBaseURI
- Throws:
StreamBaseException
- on connect error, malformed URI, etc.- See Also:
StreamBaseURI
-
StreamBaseAdminClient
public StreamBaseAdminClient(List<StreamBaseURI> uris) throws StreamBaseException
Create a StreamBaseAdminClient.- Parameters:
uris
- a list of StreamBaseURIs. Note: The StreamBaseAdminClient only supports one URI in the list.- Throws:
StreamBaseException
- on connect error, malformed URI, etc.- See Also:
StreamBaseURI
-
StreamBaseAdminClient
public StreamBaseAdminClient(List<StreamBaseURI> uris, ClientSettings settings) throws StreamBaseException
Create a StreamBaseAdminClient.- Parameters:
uris
- a list of StreamBaseURIs. Note: The StreamBaseAdminClient only supports one URI in the list.settings
- client settings- Throws:
StreamBaseException
- on connect error, malformed URI, etc.- Since:
- 7.1
- See Also:
StreamBaseURI
-
-
Method Detail
-
close
public void close()
Close/shutdown the connection to the StreamBase server.- Specified by:
close
in interfaceAutoCloseable
-
addDeploy
@Deprecated public String[] addDeploy(String deployText, String... args) throws StreamBaseException
Deprecated.Replaced with application fragments and HOCON configurationAdd the given deployment file to the server given the text of the file- Parameters:
deployText
- String contents of a deployment configuration file (.sbdeploy
file)args
- a list of options for the command. Valid options include:- [--verbose]
- returns a string indicating a succesful operation
sbadmin
command and the documentation for additional details- Returns:
- array of informational results from the server or empty array if no results
- Throws:
StreamBaseException
- deployment file error- Since:
- 7.0
- See Also:
addDeploy(File, String...)
-
addDeploy
@Deprecated public String[] addDeploy(byte[] deployText, String... args) throws StreamBaseException
Deprecated.Replaced with application fragments and HOCON configurationAdd the given deployment file to the server given the byte content of the file.- Parameters:
deployText
- byte contents of a file that specifies a deployment configuration: a.sbdeploy
(StreamBase Deployment) file or a.sbar
(StreamBase Archive) file. If it is a StreamBase Archive file, the file must have been created by runningsbargen
on an.sbdeploy
file.args
- a list of options for the command. Valid options include:- [--verbose]
- returns a string indicating a succesful operation
sbadmin
command and the documentation for additional details- Returns:
- array of informational results from the server or empty array if no results
- Throws:
StreamBaseException
- error adding deploy file- Since:
- 7.0
- See Also:
addDeploy(File, String...)
-
addDeploy
@Deprecated public String[] addDeploy(File deployFile, String... options) throws StreamBaseException
Deprecated.Replaced with application fragments and HOCON configurationAdds applications and containers defined in the given deployment or archive file to the StreamBase server.- Parameters:
deployFile
- File that specifies a deployment configuration: a.sbdeploy
(StreamBase Deployment) file or a.sbar
(StreamBase Archive) file. If it is a StreamBase Archive file, the file must have been created by runningsbargen
on an.sbdeploy
file.options
- a list of options for the added command. Valid options include:- [--verbose]
- returns a string indicating a succesful operation
sbadmin
command and the documentation for additional details- Returns:
- array of informational results from the server or empty array if no results
- Throws:
StreamBaseException
- if the deployment file is invalid, any of the containers that would be added is invalid, or there is a name collision that prevents a container from being added.- Since:
- 7.0
-
addContainer
public String[] addContainer(String containerName, String applicationText, List<String> options) throws StreamBaseException
Add the given application to the given container in the StreamBase server- Parameters:
containerName
- the container name to add the application underapplicationText
- contents of an application: xml from an EventFlow application, or StreamSQL text. The character set is assumed UTF-8.options
- List of options for the added container. SeeaddContainer(String, byte[], List)
for details.- Returns:
- array of informational results from the server or empty array if no results
- Throws:
StreamBaseException
- thrown on typecheck and other errors- Since:
- 6.4 --parameter
-
addContainer
public String[] addContainer(String containerName, byte[] application, List<String> options) throws StreamBaseException
Add the given application to the given container in the StreamBase server- Parameters:
containerName
- the container name to add the application underapplication
- contents of an application: binary content from a.sbar
file, xml from an EventFlow application, or StreamSQL text. The character set is assumed UTF-8.options
- a list of options for the added container. Valid options include:- newContainer.newStream=oldContainer.oldStream
- sets up a cross-container connection. You may specify more than one of this option.
- --parameter=paramName=paramValue
- sets a module parameter (or overrides a default value) for this container's top level application. You may specify more than one of this option.
- --suspend
- sets the container to the suspended state when added
- --enqueue=STREAMSTATUS, --dequeue=STREAMSTATUS
- sets the enqueue or dequeue status for this container. STREAMSTATUS is one of ENABLED, DISABLED, DROP_TUPLES. You may specify each option at most once.
- --moduleSearch=DIR
- adds a directory for the server to locate modules in while adding this container. You may specify more than one of this option.
- --datadir=DIR
- sets the data directory for this container. You may specify this option only once.
- --traceStreamPattern=pattern, --traceFileBase=basefilename, --traceCompress, --traceOverwrite
- sets options for runtime tracing for this container. Please see the documentation for details on how to enable and configure runtime tracing
- [--verbose]
- returns a string indicating a successsful operation
sbadmin
command and the documentation for additional details on container options.- Returns:
- array of informational results from the server or empty array if no results
- Throws:
StreamBaseException
- thrown on typecheck and other errors- Since:
- 6.4 added additional tracing options, and the ability to set module parameters for the top-level container application
-
addContainer
public String[] addContainer(String containerName, File application, List<String> options) throws StreamBaseException
Add the given application to the given container in the StreamBase server- Parameters:
containerName
- the container name to add the application underapplication
- File that specifies an application: a.sbar
file, an EventFlow application, or a StreamSQL application text.options
- List of options for the added container. SeeaddContainer(String, byte[], List)
for details- Returns:
- array of informational results from the server or empty array if no results
- Throws:
StreamBaseException
- thrown on typecheck and other errors- Since:
- 6.2
-
getOperatorProperties
public String[] getOperatorProperties(String operatorName) throws StreamBaseException
For the given Operator, return its set of properties and their values.- Parameters:
operatorName
- The operator whose properties are retrieved.- Returns:
- array of results or empty array if no results
- Throws:
StreamBaseException
- error getting properties
-
getOperatorProperty
public String getOperatorProperty(String operatorName, String propertyName) throws StreamBaseException
Return the value of the given property on the given Operator.- Parameters:
operatorName
- The operator whose property value is retrieved.propertyName
- The property whose value is retrieved.- Returns:
- the value of the operator property
- Throws:
StreamBaseException
- error getting properties
-
setOperatorProperty
public void setOperatorProperty(String operatorName, String propertyName, String value) throws StreamBaseException
On the given Operator, set the given property to the given value.- Parameters:
operatorName
- The operator whose property value is set.propertyName
- The property whose value is set.value
- The value set.- Throws:
StreamBaseException
- error setting properties
-
removeContainer
public String[] removeContainer(String containerName, String... args) throws StreamBaseException
Remove the given container in the StreamBase server- Parameters:
containerName
- the containerNameargs
- a list of options for the command. Valid options include:- [--verbose]
- returns a string indicating a succesful operation
sbadmin
command and the documentation for additional details- Returns:
- array of informational results from the server or empty array if no results
- Throws:
StreamBaseException
- thrown on error
-
restartOperators
public void restartOperators(List<String> operatorNames) throws StreamBaseException
Restart the given Operators on the StreamBase server. The Operators must currently be shut down.- Parameters:
operatorNames
- names of operators to restart- Throws:
StreamBaseException
- error restarting operators
-
restartContainer
public String[] restartContainer(String containerName) throws StreamBaseException
Restart a container- Parameters:
containerName
- Container name- Returns:
- Results if any
- Throws:
StreamBaseException
- Error restarting container
-
fastForwardTime
public void fastForwardTime(String msecs) throws StreamBaseException
Fast forward time- Parameters:
msecs
- Forward by this number of milliseconds- Throws:
StreamBaseException
- Error fast forwarding time
-
getTargetTime
public String getTargetTime() throws StreamBaseException
Get target time- Returns:
- Target time value
- Throws:
StreamBaseException
- Error getting target time
-
getEvalCacheContent
public String getEvalCacheContent(String containerName) throws StreamBaseException
Get evaluation cache content- Parameters:
containerName
- Container name- Returns:
- Cache contents
- Throws:
StreamBaseException
- Error accessing evaluation cache
-
clearEvalCache
public String clearEvalCache(String containerName) throws StreamBaseException
Clear evaluation cache- Parameters:
containerName
- Container name- Returns:
- Results if any
- Throws:
StreamBaseException
- Error clearing evaluation cache
-
getMapperCacheContent
public String getMapperCacheContent(String containerName) throws StreamBaseException
Get mapper cache contents- Parameters:
containerName
- Container name- Returns:
- Cache contents
- Throws:
StreamBaseException
- Error accessing cache
-
resumeOperators
public void resumeOperators(List<String> operatorNames) throws StreamBaseException
Resume the given Operators on the StreamBase server- Parameters:
operatorNames
- names of operators to resume- Throws:
StreamBaseException
- error resuming operators
-
resume
public void resume(String containerName) throws StreamBaseException
Resume a container in a StreamBase server- Parameters:
containerName
- the name of the container- Throws:
StreamBaseException
- error resuming container
-
shutdown
public String shutdown() throws StreamBaseException
Shutdown a StreamBase server- Returns:
- a message describing the outcome
- Throws:
StreamBaseException
- thrown on network or other errors
-
shutdown
public String shutdown(String containerName) throws StreamBaseException
Shutdown a container within a StreamBase server- Parameters:
containerName
- the name of the container- Returns:
- a message describing the outcome
- Throws:
StreamBaseException
- thrown on network or other errors
-
shutdownOperators
public void shutdownOperators(List<String> operatorNames) throws StreamBaseException
Shut down the given Operators on the StreamBase server.- Parameters:
operatorNames
- name of operators to shut down- Throws:
StreamBaseException
- error shutting down operators
-
suspendOperators
public void suspendOperators(List<String> operatorNames) throws StreamBaseException
Suspend (pause) the given Operators on the StreamBase Server- Parameters:
operatorNames
- names of operators to suspend- Throws:
StreamBaseException
- thrown on network or other errors
-
suspend
public void suspend(String name) throws StreamBaseException
Suspend (pause) a container or operator within a StreamBase Server- Parameters:
name
- the name of the container or operator- Throws:
StreamBaseException
- thrown on network or other errors
-
drain
public void drain() throws StreamBaseException
Drain a StreamBase Server Has no effect if the server is not running- Throws:
StreamBaseException
- thrown on network or other errors
-
drain
public void drain(String containerName) throws StreamBaseException
Drain a container within a StreamBase Server Has no effect if the server is not running- Parameters:
containerName
- the name of the container- Throws:
StreamBaseException
- thrown on network or other errors
-
listConnections
public String[] listConnections(StreamBaseAdminClient.ListConnectionArgument... args) throws StreamBaseException
Return an array of client connections- Parameters:
args
- arguments for the command- Returns:
- an array of client connections
- Throws:
StreamBaseException
- thrown on network or other errors
-
listEntities
public String[] listEntities(String entityType, int flags) throws StreamBaseException
Return an array of entity names for the given entity type- Parameters:
entityType
- the entity type to do the lookupflags
- FULLY_QUALIFIED_NAMES and INCLUDE_MODULES flags- Returns:
- an array of entity names for the given entity type
- Throws:
StreamBaseException
- thrown on network or other errors
-
killAllConnections
public String[] killAllConnections() throws StreamBaseException
Kill all of the connections on the server- Returns:
- status of kill command
- Throws:
StreamBaseException
- error killing connections
-
killConnection
public String[] killConnection(byte[] connectionId) throws StreamBaseException
Kill the connection with the given connectionId- Parameters:
connectionId
- connection identifier- Returns:
- status of kill command
- Throws:
StreamBaseException
- error killing connection
-
manageJdbcConnections
public String[] manageJdbcConnections(List<String> args) throws StreamBaseException
Manage JDBC connections:- count [name]
- Count the open JDBC connections to the named data source (or all data sources if ommitted)
- close [name]
- Close any open JDBC connections to the named data source (or all data sources if ommitted)
- Parameters:
args
- a list that must contain at least one command string (close
orcount
), and may contain an optional second argument string (the name of a data source). When no argument string is given, the command will apply to all data sources.- Returns:
- for
close
, one string containing the number of connections closed. forcount
, one string containing the number of open connections - Throws:
StreamBaseException
- throw on network or other errors- Since:
- 7.2
-
setRuntimeParam
public void setRuntimeParam(String paramName, String paramValue, String operator) throws StreamBaseException
Set a runtime parameter on one, or all, operators. If the operator name is null, the parameter is changed on all operators.- Parameters:
paramName
- the runtime parameter name to modifyparamValue
- the new valueoperator
- the target operator to notify for this parameter change, or null to notify all operators- Throws:
StreamBaseException
- thrown on network or other errors
-
modifyContainer
public String[] modifyContainer(String containerName, List<String> options) throws StreamBaseException
Modifies the given container. Only one command may be issued per method invocation.- Parameters:
containerName
- the container name to modifyoptions
- a modify command String as the first entry, and any arguments required by that command as subsequent String entries. Valid modify commands and arguments are:- [addConnection|removeConnection] destinationContainer.destinationStream=sourceContainer.sourceStream
- adds or removes an asynchronous container connection specified by this command's argument
- [addConnection|removeConnection] destinationContainer.destinationStream:=sourceContainer.sourceStream
- adds or removes a synchronous container connection specified by this command's argument
- [--enqueue=STREAMSTATUS|--dequeue=STREAMSTATUS]
- sets the enqueue or dequeue status for this container. STREAMSTATUS is one of ENABLED, DISABLED, DROP_TUPLES. You may only specify one option per invocation of this method.
- trace [--traceStreamPattern=pattern] [--traceFileBase=baseFilename] [--traceOverwrite] [--traceCompress] [true|false]
- Enables runtime tracing using the provided tracing options, or disable tracing for this container. The last argument must be one of
true
orfalse
. - --traceFileBase=basefilename
- Changes the trace filename prefix
- [--traceOverwrite|--traceCompress] [true|false]
- Enables or disables overwriting and compressing of trace files
- [--verbose]
- reports a successful modifyContainer call
sbadmin
command and the documentation for additional details on container options.- Returns:
- array of informational results from the server or empty array if no results
- Throws:
StreamBaseException
- thrown on errors- Since:
- 6.4 added tracing options
-
haModeOn
protected boolean haModeOn()
is HA mode on- Returns:
- if HA mode is on
-
getSettings
public ClientSettings getSettings()
Return the settings for this client- Returns:
- settings for this client
-
status
public String[] status() throws StreamBaseException
Return the status of the StreamBase Server- Returns:
- the status
- Throws:
StreamBaseException
- thrown on network and other errors
-
status
public String[] status(boolean verbose) throws StreamBaseException
Return the status of the StreamBase Server- Parameters:
verbose
- return a verbose status- Returns:
- the status
- Throws:
StreamBaseException
- thrown on network and other errors
-
operatorStatus
public String[] operatorStatus(String containerName) throws StreamBaseException
Return the status of all the operators in the specified container- Parameters:
containerName
- the name of the container- Returns:
- an array of strings of the form "operatorname=status"
- Throws:
StreamBaseException
- error getting status
-
getURI
public StreamBaseURI getURI()
Return the URI used by this Client. In HA mode this just returns the 1st URI for the client- Returns:
- the uri for this client
-
getURIs
public List<StreamBaseURI> getURIs()
get all of the URI's for this client- Returns:
- all of the URI's for this client
-
-