public class WSConnectionManager extends Object implements AutoCloseable
| Constructor and Description |
|---|
WSConnectionManager(WSFunction function,
ConnectionParam param,
InFlightRequest inFlightRequest)
Constructs a new WSConnectionManager with the specified parameters.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
authenticateAfterReconnect(Transport transport)
Performs authentication after physical reconnection.
|
void |
balanceConnection(Transport transport)
Balances connections across available endpoints by switching to the least loaded endpoint.
|
void |
checkConnection(int connectTimeout)
Checks and establishes connection to TDengine servers.
|
void |
close()
Closes all connections and releases resources.
|
ConnectionParam |
getConnectionParam()
Gets the connection parameters.
|
WSClient |
getCurrentClient()
Gets the current active WebSocket client.
|
Endpoint |
getCurrentEndpoint()
Gets the current active endpoint.
|
int |
getReconnectCount()
Gets the number of reconnection attempts made.
|
boolean |
isClosed()
Checks if this connection manager is closed.
|
boolean |
isConnected()
Checks if the current connection is open and active.
|
boolean |
isConnectionLost()
Checks if the current connection is closed or lost.
|
void |
performReconnect(boolean isTmq,
Transport transport)
Performs complete reconnection process including physical reconnection and authentication.
|
void |
tmqRethrowConnectionCloseException()
Throws special connection closed exception for TMQ connections.
|
public WSConnectionManager(WSFunction function, ConnectionParam param, InFlightRequest inFlightRequest) throws SQLException
function - the WebSocket function typeparam - the connection parametersinFlightRequest - the in-flight request managerSQLException - if connection initialization failspublic void performReconnect(boolean isTmq,
Transport transport)
throws SQLException
isTmq - whether this is a TMQ connection (TMQ has different reconnection behavior)transport - the transport instance for sending authentication requestsSQLException - if reconnection fails for all endpointspublic boolean authenticateAfterReconnect(Transport transport) throws SQLException
transport - the transport instance for sending authentication requestSQLException - if authentication request failspublic void checkConnection(int connectTimeout)
throws SQLException
connectTimeout - the connection timeout in millisecondsSQLException - if connection cannot be established within timeoutpublic void balanceConnection(Transport transport)
transport - the transport instance for sending authentication during switchpublic WSClient getCurrentClient()
public boolean isConnected()
public boolean isConnectionLost()
public int getReconnectCount()
public ConnectionParam getConnectionParam()
public Endpoint getCurrentEndpoint()
public boolean isClosed()
public void close()
close in interface AutoCloseablepublic void tmqRethrowConnectionCloseException()
throws SQLException
SQLException - always throws TMQ-specific connection closed exceptionCopyright © 2025. All rights reserved.