public class LiveViewMultiConnectionImpl extends Object implements LiveViewMultiConnection
Modifier and Type | Class and Description |
---|---|
class |
LiveViewMultiConnectionImpl.DummyMultiConnectionListener |
LiveViewConnection.TableProviderAPIHelper
Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
logger |
CQS_INTERNAL_ID
Constructor and Description |
---|
LiveViewMultiConnectionImpl(MultiConnectionConfig config) |
Modifier and Type | Method and Description |
---|---|
void |
addTableProvider(String id,
com.streambase.liveview.internal.protocol.jaxb.ExternalConnectionTypeType externalConnectionType,
String javaClassName,
com.streambase.liveview.internal.protocol.jaxb.ExternalServerConnectionType.Parameters parameters,
com.streambase.liveview.internal.protocol.jaxb.ExternalServerConnectionType.Mappings mappings,
int maxFailAttempts,
int waitSeconds)
Connect to a TableProvider, which then allows for remote connections as if they were LiveView Tables.
|
boolean |
checkPermission(LiveViewPermission permission)
Checks whether the authenticated user has the specified permission.
|
List<Boolean> |
checkPermissions(List<LiveViewPermission> permissions)
Checks whether the authenticated user has the specified permissions.
|
void |
close()
Closes all queries and open resources with the server.
|
com.streambase.liveview.internal.protocol.jaxb.AlertRule |
createAlertRule() |
void |
deleteAlertRule(Long id) |
void |
deleteQuery(Long id)
deletes a QueryConfig on the server.
|
void |
deleteRows(QueryConfig config)
Delete rows based on the supplied
QueryConfig . |
Query |
describeQuery(QueryConfig config)
Get information about a query, such as its result schema, without actually running it
|
SnapshotResult |
executeSnapshotQuery(QueryConfig config)
This method makes it easy to run a snapshot-only query where the results come back
in an object that can be iterated over to retrieve the snapshot tuples.
|
AlertManager |
getAlertManager() |
com.streambase.liveview.internal.protocol.jaxb.AlertRule |
getAlertRule(long alertID) |
List<com.streambase.liveview.internal.protocol.jaxb.AlertRule> |
getAlertRules(String user) |
<T extends LiveViewServerCapability> |
getCapability(Class<T> typeOfCapability)
Returns the object that represents a capability of the connected server,
or throws NoSuchCapabilityException if the type of capability is not
supported by the server.
|
List<? extends LiveViewConnectionControl> |
getConnectionControls()
This list will have a one-for-one correspondence with the list of ConnectionConfigs or the list of URIs that were
used to create this LiveViewMultiConnection.
|
String |
getConnectionURI()
Retrieves the URI that was used to connect to the server
|
LiveViewConnectionControl |
getCurrentConnection()
LiveViewConnectionControl of the "current" connection, if there is one.
|
MultiConnectionListener |
getListener() |
List<com.streambase.liveview.internal.protocol.jaxb.Response.GetNameValue.NameValue> |
getNameValue(String name,
String user) |
short |
getNextQueryId()
Get the next one sequentially.
|
List<QueryConfig> |
getQueries(String user)
Lists all QueryConfigs for the given user.
|
long |
getRetryIntervalMillis() |
SendTupleInfo |
getSendTupleInfo(StreamBaseURI sbUri,
String inputStreamName,
String outputStreamName)
Gets the schemas associated with streams, for the purposes of using SendTupleAction.
|
Table |
getTable(String name)
Retrieve a specific table from the server
|
long |
getTimeout() |
com.streambase.liveview.internal.protocol.jaxb.VersionType |
getVersion() |
<T extends LiveViewServerCapability> |
hasCapability(Class<T> typeOfCapability)
Returns true if the connected server supports the given type of capability.
|
boolean |
isConnected()
A polling method to check if the connection with the server is still valid.
|
List<Table> |
listTables()
Lists the available tables for querying
|
List<Table> |
listTables(boolean includeSystemTables)
List the available tables for querying
|
Query |
registerQuery(QueryConfig config,
QueryListener listener)
Registers a new query on the server based on the
QueryConfig and sends query events
to the specified QueryListener . |
void |
registerTableListListener(TableListListener listener,
boolean includeSnapshot)
If you want to be informed of changes to the Table List, then register a Listener with this
method.
|
void |
removeTableProvider(String id)
Disconnect a previously-connected TableGenerator
|
long |
saveQuery(QueryConfig config)
Saves a QueryConfig on the server.
|
Tuple |
sendTupleAction(StreamBaseURI sbUri,
String targetInputStreamName,
Tuple tuple,
String responseOutputStreamName,
Schema expectedResponseSchema,
long timeout,
TimeUnit unit)
Sends a tuple to an existing StreamBase application.
|
com.streambase.liveview.internal.protocol.jaxb.AlertRule |
setAlertRule(com.streambase.liveview.internal.protocol.jaxb.AlertRule rule) |
void |
setNameValue(String name,
String user,
String value) |
void |
validateAlertRule(com.streambase.liveview.internal.protocol.jaxb.AlertRule rule) |
public LiveViewMultiConnectionImpl(MultiConnectionConfig config)
config
- public short getNextQueryId()
public long getRetryIntervalMillis()
public long getTimeout()
public MultiConnectionListener getListener()
public LiveViewConnectionControl getCurrentConnection()
LiveViewMultiConnection
getCurrentConnection
in interface LiveViewMultiConnection
public List<? extends LiveViewConnectionControl> getConnectionControls()
LiveViewMultiConnection
getConnectionControls
in interface LiveViewMultiConnection
public List<Table> listTables() throws LiveViewException
LiveViewConnection
listTables
in interface LiveViewConnection
LiveViewException
- if table list cannot be retrievedpublic List<Table> listTables(boolean includeSystemTables) throws LiveViewException
LiveViewConnection
listTables
in interface LiveViewConnection
includeSystemTables
- - if true, system tables are included in the listLiveViewException
- if table list cannot be retrievedpublic void registerTableListListener(TableListListener listener, boolean includeSnapshot) throws LiveViewException
LiveViewConnection
registerTableListListener
in interface LiveViewConnection
includeSnapshot
- if true, your listener will get current snapshot data (plus changes); if false, only changes.LiveViewException
public Table getTable(String name) throws LiveViewException
LiveViewConnection
getTable
in interface LiveViewConnection
name
- name of the table to retrieveLiveViewException
- if the table does not exists or another server side error occurs.public void close()
LiveViewConnection
close
in interface LiveViewConnection
public boolean isConnected()
LiveViewConnection
isConnected
in interface LiveViewConnection
public <T extends LiveViewServerCapability> boolean hasCapability(Class<T> typeOfCapability)
LiveViewConnection
hasCapability
in interface LiveViewConnection
typeOfCapability
- Class that represents a capabilitypublic <T extends LiveViewServerCapability> T getCapability(Class<T> typeOfCapability) throws NoSuchCapabilityException, LiveViewException
LiveViewConnection
getCapability
in interface LiveViewConnection
typeOfCapability
- Class that represents a capabilityNoSuchCapabilityException
- if the type of capability is not supported by the serverLiveViewException
- if the LiveViewConnection is not currently connected.public Query registerQuery(QueryConfig config, QueryListener listener)
LiveViewConnection
QueryConfig
and sends query events
to the specified QueryListener
.
Depending on the query configuration the server will return snapshot only data
or snapshot followed by continuous updates.registerQuery
in interface LiveViewConnection
config
- the configuration of the querylistener
- specifies the listener that will receive the query eventspublic Query describeQuery(QueryConfig config) throws LiveViewException
LiveViewConnection
describeQuery
in interface LiveViewConnection
config
- the configuration of queryQuery
with information about the given configuration. The query is already closed; callers
do not need to call Query.close()
on the return value.LiveViewException
- if there is a problem with the query configuration or another server exception occurspublic void deleteRows(QueryConfig config) throws LiveViewException
LiveViewConnection
QueryConfig
.
The issuer of this delete does not know how many rows were removed,
or when the delete completes. Only a subset of the QueryConfig
options are valid for deleteRows, you may set:
deleteRows is effectively a snapshot query where the results of the
query is the data to be deleted.deleteRows
in interface LiveViewConnection
config
- the configuration of the queryLiveViewException
- if there is a problem with the query configuration or another server exception occurspublic long saveQuery(QueryConfig config) throws LiveViewException
LiveViewConnection
saveQuery
in interface LiveViewConnection
config
- of the queryLiveViewException
- if there is a problem with the query or network issuepublic List<QueryConfig> getQueries(String user) throws LiveViewException
LiveViewConnection
getQueries
in interface LiveViewConnection
user
- nameLiveViewException
- if there is a problem with the query or network issuepublic void deleteQuery(Long id) throws LiveViewException
LiveViewConnection
deleteQuery
in interface LiveViewConnection
id
- of the query to deleteLiveViewException
- if there is a problem with the query or network issuepublic SnapshotResult executeSnapshotQuery(QueryConfig config) throws LiveViewException
LiveViewConnection
LiveViewQueryType
setting in QueryConfig will be ignored because this method is always
LiveViewQueryType.SNAPSHOT
This method returns as soon as the query is successfully regiestered, but before the data has arrived.
However, the SnapshotResult that is returned will block appropriately in its next and hasNext methods,
so you can immediately start using it as if it were an iterator.executeSnapshotQuery
in interface LiveViewConnection
config
- the configuration of the queryLiveViewException
- if there is a problem with the query configuration or another server exception occurspublic String getConnectionURI()
LiveViewConnection
getConnectionURI
in interface LiveViewConnection
public void setNameValue(String name, String user, String value) throws LiveViewException
LiveViewException
public List<com.streambase.liveview.internal.protocol.jaxb.Response.GetNameValue.NameValue> getNameValue(String name, String user) throws LiveViewException
LiveViewException
public com.streambase.liveview.internal.protocol.jaxb.VersionType getVersion() throws LiveViewException
LiveViewException
public void addTableProvider(String id, com.streambase.liveview.internal.protocol.jaxb.ExternalConnectionTypeType externalConnectionType, String javaClassName, com.streambase.liveview.internal.protocol.jaxb.ExternalServerConnectionType.Parameters parameters, com.streambase.liveview.internal.protocol.jaxb.ExternalServerConnectionType.Mappings mappings, int maxFailAttempts, int waitSeconds) throws LiveViewException
LiveViewConnection
addTableProvider
in interface LiveViewConnection
id
- must be unique on the LiveView server.externalConnectionType
- one of CEP_QUERY_TABLES, LIVE_VIEW, CUSTOM_TABLE_PROVIDER ExternalConnectionTypeType
javaClassName
- The className of a class which implements com.streambase.liveview.server.table.TableProvider. Only used if type is CUSTOM_TABLE_PROVIDER.parameters
- key-value pairs that are specific to your TableGenerator. Use utility function TableProviderAPIHelper#addMapping(Mappings, String, String)
to create and extend.mappings
- Table name selector and mapping definitions. Use utility function TableProviderAPIHelper#addParameter(Parameters, String, String)
to create and extend.maxFailAttempts
- Maximum failures before giving up. Anything < 1 for infinite attemptswaitSeconds
- Time to wait after a failure before trying. Anything < 1 becomes the default of 120 seconds.LiveViewException
LiveViewConnection.TableProviderAPIHelper
public void removeTableProvider(String id) throws LiveViewException
LiveViewConnection
removeTableProvider
in interface LiveViewConnection
id
- The exact id of the TableGenerator.LiveViewException
public List<com.streambase.liveview.internal.protocol.jaxb.AlertRule> getAlertRules(String user) throws LiveViewException
LiveViewException
public com.streambase.liveview.internal.protocol.jaxb.AlertRule getAlertRule(long alertID) throws LiveViewException
LiveViewException
public com.streambase.liveview.internal.protocol.jaxb.AlertRule createAlertRule()
public com.streambase.liveview.internal.protocol.jaxb.AlertRule setAlertRule(com.streambase.liveview.internal.protocol.jaxb.AlertRule rule) throws LiveViewException
LiveViewException
public void deleteAlertRule(Long id) throws LiveViewException
LiveViewException
public void validateAlertRule(com.streambase.liveview.internal.protocol.jaxb.AlertRule rule) throws LiveViewException
LiveViewException
public AlertManager getAlertManager() throws LiveViewException
getAlertManager
in interface LiveViewConnection
LiveViewException
public Tuple sendTupleAction(StreamBaseURI sbUri, String targetInputStreamName, Tuple tuple, String responseOutputStreamName, Schema expectedResponseSchema, long timeout, TimeUnit unit) throws LiveViewException
LiveViewConnection
sendTupleAction
in interface LiveViewConnection
sbUri
- (Optional) URI of the StreamBase server. The LV server's current SB server will be used if null.targetInputStreamName
- The pathname of the input stream to which to send the tupletuple
- The tuple to sendresponseOutputStreamName
- (Optional) pathname of OutputStream to listen for a responseexpectedResponseSchema
- (Optional) The schema that the response is expected to have, likely retrieved via getSendTupleInfotimeout
- Maximum time to wait for response. Valid range is 50 - 120000 MILLISECONDSunit
- (Optional) units for the timeout. If null, TimeUnit.MILLISECONDS
will be assumed.LiveViewException
public SendTupleInfo getSendTupleInfo(StreamBaseURI sbUri, String inputStreamName, String outputStreamName) throws LiveViewException
LiveViewConnection
getSendTupleInfo
in interface LiveViewConnection
sbUri
- (Optional) URI of the StreamBase server. The LV server's current SB server will be used if null.inputStreamName
- The pathname of the input stream to which to send the tupleoutputStreamName
- (Optional) pathname of OutputStream to listen for a responseLiveViewException
public boolean checkPermission(LiveViewPermission permission) throws LiveViewException
LiveViewConnection
checkPermission
in interface LiveViewConnection
permission
- a single permission to check forLiveViewException
public List<Boolean> checkPermissions(List<LiveViewPermission> permissions) throws LiveViewException
LiveViewConnection
checkPermissions
in interface LiveViewConnection
permissions
- a list of permissions to check forLiveViewException