public class Transport extends Object implements AutoCloseable
| Modifier and Type | Field and Description |
|---|---|
static byte[] |
EMPTY_BYTE_ARRAY
Empty byte array constant
|
static String |
ERROR_MSG_CONNECTION_CLOSED
Error message for closed connection
|
static int |
TSDB_CODE_RPC_NETWORK_UNAVAIL
Error code indicating RPC network unavailability
|
static int |
TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED
Error code indicating some nodes are not connected
|
| Modifier | Constructor and Description |
|---|---|
protected |
Transport()
Protected constructor for internal use.
|
|
Transport(WSFunction function,
ConnectionParam param,
InFlightRequest inFlightRequest)
Constructs a new Transport instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
balanceConnection()
Balances connections across available endpoints.
|
void |
checkConnection(int connectTimeout)
Checks and establishes connection to TDengine servers.
|
void |
close()
Closes this transport and releases all resources.
|
ConnectionParam |
getConnectionParam()
Gets the connection parameters.
|
Endpoint |
getCurrentEndpoint()
Gets the current active endpoint.
|
int |
getReconnectCount()
Gets the number of reconnection attempts made.
|
boolean |
isClosed()
Checks if this transport is closed.
|
boolean |
isConnected()
Checks if the current connection is active.
|
boolean |
isConnectionLost()
Checks if the current connection is lost.
|
void |
reconnectTmq()
Performs TMQ-specific reconnection.
|
Response |
send(Request request)
Sends a request with default timeout and retry enabled.
|
Response |
send(Request request,
boolean reSend,
long timeout)
Sends a request with specified timeout and retry configuration.
|
Response |
send(Request request,
long timeout)
Sends a request with specified timeout and retry enabled.
|
Response |
send(String action,
long reqId,
io.netty.buffer.ByteBuf buffer,
boolean resend,
long timeout)
Sends a request with pre-allocated ByteBuf buffer.
|
Response |
send(String action,
long reqId,
long resultId,
long type,
byte[] rawData,
byte[] rawData2,
long timeout)
Sends a binary request with dual data payloads.
|
Response |
send(String action,
long reqId,
long resultId,
long type,
byte[] rawData,
long timeout)
Sends a binary request with single data payload.
|
void |
sendFetchBlockAsync(long reqId,
long resultId)
Sends asynchronous fetch block request.
|
void |
sendWithoutResponse(Request request)
Sends a request without waiting for response.
|
Response |
sendWithoutRetry(Request request,
long timeout)
Sends a request without automatic retry on connection failure.
|
public static final int TSDB_CODE_RPC_NETWORK_UNAVAIL
public static final int TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED
public static final byte[] EMPTY_BYTE_ARRAY
public static final String ERROR_MSG_CONNECTION_CLOSED
protected Transport()
public Transport(WSFunction function, ConnectionParam param, InFlightRequest inFlightRequest) throws SQLException
function - the WebSocket function typeparam - the connection parametersinFlightRequest - the in-flight request managerSQLException - if initialization failspublic Response send(Request request) throws SQLException
request - the request to sendSQLException - if sending fails or timeout occurspublic Response send(Request request, long timeout) throws SQLException
request - the request to sendtimeout - the timeout in millisecondsSQLException - if sending fails or timeout occurspublic Response send(Request request, boolean reSend, long timeout) throws SQLException
request - the request to sendreSend - whether to retry on connection failuretimeout - the timeout in millisecondsSQLException - if sending fails or timeout occurspublic Response send(String action, long reqId, long resultId, long type, byte[] rawData, long timeout) throws SQLException
action - the action typereqId - the request IDresultId - the result IDtype - the message typerawData - the binary data payloadtimeout - the timeout in millisecondsSQLException - if sending fails or timeout occurspublic Response send(String action, long reqId, long resultId, long type, byte[] rawData, byte[] rawData2, long timeout) throws SQLException
action - the action typereqId - the request IDresultId - the result IDtype - the message typerawData - the first binary data payloadrawData2 - the second binary data payloadtimeout - the timeout in millisecondsSQLException - if sending fails or timeout occurspublic void sendFetchBlockAsync(long reqId,
long resultId)
throws SQLException
reqId - the request IDresultId - the result IDSQLException - if sending failspublic Response send(String action, long reqId, io.netty.buffer.ByteBuf buffer, boolean resend, long timeout) throws SQLException
action - the action typereqId - the request IDbuffer - the ByteBuf containing the request dataresend - whether to retry on connection failuretimeout - the timeout in millisecondsSQLException - if sending fails or timeout occurspublic Response sendWithoutRetry(Request request, long timeout) throws SQLException
request - the request to sendtimeout - the timeout in millisecondsSQLException - if sending fails or timeout occurspublic void sendWithoutResponse(Request request) throws SQLException
request - the request to sendSQLException - if sending failspublic boolean isClosed()
public boolean isConnectionLost()
public void close()
close in interface AutoCloseablepublic void checkConnection(int connectTimeout)
throws SQLException
connectTimeout - the connection timeout in millisecondsSQLException - if connection cannot be established within timeoutpublic void reconnectTmq()
throws SQLException
SQLException - if reconnection failspublic int getReconnectCount()
public boolean isConnected()
public final ConnectionParam getConnectionParam()
public final Endpoint getCurrentEndpoint()
public void balanceConnection()
SQLException - if balance operation failsCopyright © 2025. All rights reserved.