public class KdbConnection extends Object implements AutoCloseable
Class provides connect / disconnect / reconnect functionality on top
of the default c class.
NOTE: By default this class exposes no send / receive functionality. This is left up to extension classes to provide these features.
(c) 2014 - 2015 Sport Trades Ltd| Modifier and Type | Field and Description |
|---|---|
private c |
connection
The current active connection to the kdb process
|
private static Integer |
DEFAULT_RECONNECT_INTERVAL_MS
The default reconnection interval in milliseconds
|
private static org.slf4j.Logger |
log |
private KdbProcess |
process
The details of the process to connect to
|
protected Integer |
reconnectIntervalMs
The amount of time in milliseconds to wait between connection attempts
|
| Constructor and Description |
|---|
KdbConnection(KdbProcess process)
Creates a new kdb connection object with the reconnection interval set as the default
(as defined by
DEFAULT_RECONNECT_INTERVAL_MS. |
KdbConnection(KdbProcess process,
Integer reconnectIntervalMs)
Creates a new kdb connection object with the specified reconnection interval.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
connect()
Performs the connection to the KDB process
|
void |
disconnect()
Disconnects from the KDB process (by closing the underlying socket)
|
c |
getConnection() |
KdbProcess |
getRemoteProcess() |
boolean |
isConnected() |
void |
reconnect()
Provides the ability to reconnect to the target KDB process if necessary (generally after an
IOException). |
private static final org.slf4j.Logger log
private static final Integer DEFAULT_RECONNECT_INTERVAL_MS
protected final Integer reconnectIntervalMs
private final KdbProcess process
private c connection
public KdbConnection(KdbProcess process)
DEFAULT_RECONNECT_INTERVAL_MS. NOTE: Calling this constructor will
not initiate the connection. This must be done manually by calling connect().process - The kdb process to connect toKdbConnection(KdbProcess, Integer)public KdbConnection(KdbProcess process, Integer reconnectIntervalMs)
connect().process - The kdb process to connect toreconnectIntervalMs - The reconnect interval (in milliseconds) in case the connection is lostpublic void connect()
throws KdbTargetProcessUnavailableException
KdbTargetProcessUnavailableException - If the target KDB process is unavailablereconnect()public void disconnect()
public boolean isConnected()
False if either the connection object or the connection Socket is
null. NOTE: These are the only two circumstances where false
will be returned. True will be returned in all other cases.public c getConnection()
public KdbProcess getRemoteProcess()
public void reconnect()
Provides the ability to reconnect to the target KDB process if necessary (generally after an IOException).
Function will also force a disconnect of the underlying Socket, just to be sure.
NOTE: This function will block in a retry loop if the kdb process is unavailable when attempting to connect.
reconnectIntervalMspublic void close()
close in interface AutoCloseableCopyright © 2017. All rights reserved.