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()
LiveViewMultiConnectiongetCurrentConnection in interface LiveViewMultiConnectionpublic List<? extends LiveViewConnectionControl> getConnectionControls()
LiveViewMultiConnectiongetConnectionControls in interface LiveViewMultiConnectionpublic List<Table> listTables() throws LiveViewException
LiveViewConnectionlistTables in interface LiveViewConnectionLiveViewException - if table list cannot be retrievedpublic List<Table> listTables(boolean includeSystemTables) throws LiveViewException
LiveViewConnectionlistTables in interface LiveViewConnectionincludeSystemTables - - if true, system tables are included in the listLiveViewException - if table list cannot be retrievedpublic void registerTableListListener(TableListListener listener, boolean includeSnapshot) throws LiveViewException
LiveViewConnectionregisterTableListListener in interface LiveViewConnectionincludeSnapshot - if true, your listener will get current snapshot data (plus changes); if false, only changes.LiveViewExceptionpublic Table getTable(String name) throws LiveViewException
LiveViewConnectiongetTable in interface LiveViewConnectionname - name of the table to retrieveLiveViewException - if the table does not exists or another server side error occurs.public void close()
LiveViewConnectionclose in interface LiveViewConnectionpublic boolean isConnected()
LiveViewConnectionisConnected in interface LiveViewConnectionpublic <T extends LiveViewServerCapability> boolean hasCapability(Class<T> typeOfCapability)
LiveViewConnectionhasCapability in interface LiveViewConnectiontypeOfCapability - Class that represents a capabilitypublic <T extends LiveViewServerCapability> T getCapability(Class<T> typeOfCapability) throws NoSuchCapabilityException, LiveViewException
LiveViewConnectiongetCapability in interface LiveViewConnectiontypeOfCapability - 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)
LiveViewConnectionQueryConfig 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 LiveViewConnectionconfig - the configuration of the querylistener - specifies the listener that will receive the query eventspublic Query describeQuery(QueryConfig config) throws LiveViewException
LiveViewConnectiondescribeQuery in interface LiveViewConnectionconfig - 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
LiveViewConnectionQueryConfig.
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 LiveViewConnectionconfig - 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
LiveViewConnectionsaveQuery in interface LiveViewConnectionconfig - of the queryLiveViewException - if there is a problem with the query or network issuepublic List<QueryConfig> getQueries(String user) throws LiveViewException
LiveViewConnectiongetQueries in interface LiveViewConnectionuser - nameLiveViewException - if there is a problem with the query or network issuepublic void deleteQuery(Long id) throws LiveViewException
LiveViewConnectiondeleteQuery in interface LiveViewConnectionid - of the query to deleteLiveViewException - if there is a problem with the query or network issuepublic SnapshotResult executeSnapshotQuery(QueryConfig config) throws LiveViewException
LiveViewConnectionLiveViewQueryType 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 LiveViewConnectionconfig - the configuration of the queryLiveViewException - if there is a problem with the query configuration or another server exception occurspublic String getConnectionURI()
LiveViewConnectiongetConnectionURI in interface LiveViewConnectionpublic void setNameValue(String name, String user, String value) throws LiveViewException
LiveViewExceptionpublic List<com.streambase.liveview.internal.protocol.jaxb.Response.GetNameValue.NameValue> getNameValue(String name, String user) throws LiveViewException
LiveViewExceptionpublic com.streambase.liveview.internal.protocol.jaxb.VersionType getVersion()
throws LiveViewException
LiveViewExceptionpublic 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
LiveViewConnectionaddTableProvider in interface LiveViewConnectionid - must be unique on the LiveView server.externalConnectionType - one of CEP_QUERY_TABLES, LIVE_VIEW, CUSTOM_TABLE_PROVIDER ExternalConnectionTypeTypejavaClassName - 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.LiveViewExceptionLiveViewConnection.TableProviderAPIHelperpublic void removeTableProvider(String id) throws LiveViewException
LiveViewConnectionremoveTableProvider in interface LiveViewConnectionid - The exact id of the TableGenerator.LiveViewExceptionpublic List<com.streambase.liveview.internal.protocol.jaxb.AlertRule> getAlertRules(String user) throws LiveViewException
LiveViewExceptionpublic com.streambase.liveview.internal.protocol.jaxb.AlertRule getAlertRule(long alertID)
throws LiveViewException
LiveViewExceptionpublic 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
LiveViewExceptionpublic void deleteAlertRule(Long id) throws LiveViewException
LiveViewExceptionpublic void validateAlertRule(com.streambase.liveview.internal.protocol.jaxb.AlertRule rule)
throws LiveViewException
LiveViewExceptionpublic AlertManager getAlertManager() throws LiveViewException
getAlertManager in interface LiveViewConnectionLiveViewExceptionpublic Tuple sendTupleAction(StreamBaseURI sbUri, String targetInputStreamName, Tuple tuple, String responseOutputStreamName, Schema expectedResponseSchema, long timeout, TimeUnit unit) throws LiveViewException
LiveViewConnectionsendTupleAction in interface LiveViewConnectionsbUri - (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.LiveViewExceptionpublic SendTupleInfo getSendTupleInfo(StreamBaseURI sbUri, String inputStreamName, String outputStreamName) throws LiveViewException
LiveViewConnectiongetSendTupleInfo in interface LiveViewConnectionsbUri - (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 responseLiveViewExceptionpublic boolean checkPermission(LiveViewPermission permission) throws LiveViewException
LiveViewConnectioncheckPermission in interface LiveViewConnectionpermission - a single permission to check forLiveViewExceptionpublic List<Boolean> checkPermissions(List<LiveViewPermission> permissions) throws LiveViewException
LiveViewConnectioncheckPermissions in interface LiveViewConnectionpermissions - a list of permissions to check forLiveViewException