Package com.seeq.link.sdk
Class BaseConnection
java.lang.Object
com.seeq.link.sdk.BaseConnection
- All Implemented Interfaces:
Connection
- Direct Known Subclasses:
DatasourceConnectionV2Host
Facilitates a consistent approach external connection establishment and monitoring. External connections can be
connector datasources or the Seeq Server.
Once connected, a monitoring thread will periodically call the abstract monitor() function that must be implemented
in derived classes.
If the monitor function() discovers a dead connection and sets the state to Disconnected, the monitoring thread will
attempt reconnection at intervals that exponentially increase (to avoid flooding the log).
See
Connection
for more documentation on the interface.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.seeq.link.sdk.interfaces.Connection
Connection.ConnectionState, Connection.StateChangedEventArgs
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
connect()
Connect to the server (implemented by derived classes).abstract void
destroy()
Disconnects from external systems and kills the monitoring thread.void
disable()
Disable connections to the server.protected abstract void
Disconnect from the server (implemented by derived classes).void
enable()
Enable connections to the server and attempt to make a connection.protected abstract String
The connection ID used to connect to the server.A summary of the connection status, including any connection failure reason.The last exception that has occurred on the connection.Maximum time to delay a reconnect attempt.Time to wait, default is 5 seconds.Time between testing of the connection vitality.getState()
The current state of the connection.Event for state changes of the connection.protected void
handleConnectionMonitorException
(String methodName, Exception exception) abstract void
Initializes a connection, attempting to connect if enabled.protected abstract void
monitor()
A connector-specific test to ensure the connection is alive (implemented by derived classes).void
setMaxReconnectDelay
(Duration value) Maximum time to delay a reconnect attempt.void
setMinReconnectDelay
(Duration value) Time to wait before reconnecting.void
setMonitorPeriod
(Duration value) Time between testing of the connection vitality.protected void
setState
(Connection.ConnectionState newState, String message) Set the current state of the connection.
-
Field Details
-
lastException
-
-
Constructor Details
-
BaseConnection
public BaseConnection()
-
-
Method Details
-
initialize
public abstract void initialize()Description copied from interface:Connection
Initializes a connection, attempting to connect if enabled.- Specified by:
initialize
in interfaceConnection
-
destroy
public abstract void destroy()Description copied from interface:Connection
Disconnects from external systems and kills the monitoring thread.- Specified by:
destroy
in interfaceConnection
-
getState
Description copied from interface:Connection
The current state of the connection.- Specified by:
getState
in interfaceConnection
- Returns:
- state of the connection
-
getConnectionMessage
Description copied from interface:Connection
A summary of the connection status, including any connection failure reason.- Specified by:
getConnectionMessage
in interfaceConnection
- Returns:
- summary of the connection status, including any connection failure reason.
-
getLastException
The last exception that has occurred on the connection.- Returns:
- the last exception
-
getStateChangedEvent
Description copied from interface:Connection
Event for state changes of the connection.- Specified by:
getStateChangedEvent
in interfaceConnection
- Returns:
- the state changed event
-
getConnectionId
The connection ID used to connect to the server.- Returns:
- the connection ID
-
setState
Set the current state of the connection. If the new state is Disconnected and automaticallyReconnect is true, an attempt will be made to reconnect within the ReconnectDelay.- Parameters:
newState
- The new state for the connection.message
- A message that indicates the status of the connection.
-
handleConnectionMonitorException
-
getMinReconnectDelay
Time to wait, default is 5 seconds. Connectors use an exponential backoff algorithm to reduce the noise in the log files when a connection is down.- Specified by:
getMinReconnectDelay
in interfaceConnection
- Returns:
- minimum reconnect delay
-
setMinReconnectDelay
Description copied from interface:Connection
Time to wait before reconnecting. Default is 5 seconds. There is an "exponential backoff" algorithm at play that will increase the reconnect delay as repeated attempts fail. That's why this is the minimum delay.- Specified by:
setMinReconnectDelay
in interfaceConnection
- Parameters:
value
- minimum reconnect delay
-
getMaxReconnectDelay
Description copied from interface:Connection
Maximum time to delay a reconnect attempt. Default is 5 minutes. There is an "exponential backoff" algorithm at play that will increase the reconnect delay as repeated attempts fail.- Specified by:
getMaxReconnectDelay
in interfaceConnection
- Returns:
- maximum reconnect delay
-
setMaxReconnectDelay
Description copied from interface:Connection
Maximum time to delay a reconnect attempt. Default is 5 minutes. There is an "exponential backoff" algorithm at play that will increase the reconnect delay as repeated attempts fail.- Specified by:
setMaxReconnectDelay
in interfaceConnection
- Parameters:
value
- maximum reconnect delay
-
getMonitorPeriod
Description copied from interface:Connection
Time between testing of the connection vitality. Default should be 5 seconds.- Specified by:
getMonitorPeriod
in interfaceConnection
- Returns:
- the monitor period
-
setMonitorPeriod
Description copied from interface:Connection
Time between testing of the connection vitality. Default should be 5 seconds.- Specified by:
setMonitorPeriod
in interfaceConnection
- Parameters:
value
- - the new monitor period
-
getBackgroundThreads
-
enable
public void enable()Enable connections to the server and attempt to make a connection. This calls the connect method in the derived class.- Specified by:
enable
in interfaceConnection
-
disable
public void disable()Disable connections to the server. This calls the disconnect method in the derived class.- Specified by:
disable
in interfaceConnection
-
connect
protected abstract void connect()Connect to the server (implemented by derived classes). -
monitor
protected abstract void monitor()A connector-specific test to ensure the connection is alive (implemented by derived classes). -
disconnect
protected abstract void disconnect()Disconnect from the server (implemented by derived classes).
-