After you create a tunnel, you can call the ListTunnel operation to query information about all tunnels of a table, including the tunnel name, type, ID, and stage, and whether the data is expired.
Prerequisites
A TunnelClient instance is initialized.
A tunnel is created for the data table. For more information, see Create a tunnel.
Parameters
Request parameters
Parameter | Description |
TableName | The name of the data table whose tunnel information you want to query. |
Response parameters
Parameter | Description |
List<TunnelInfo> | The information about the tunnels. The following information is included in the response:
|
RequestId | The ID of the request. |
Examples
The following sample code provides an example on how to query information about all tunnels of a table:
private static void listTunnel(TunnelClient client, String tableName) {
ListTunnelRequest request = new ListTunnelRequest(tableName);
ListTunnelResponse resp = client.listTunnel(request);
System.out.println("RequestId: " + resp.getRequestId());
for (TunnelInfo info : resp.getTunnelInfos()) {
System.out.println("TunnelInfo::::::");
System.out.println("\tTunnelName: " + info.getTunnelName());
System.out.println("\tTunnelId: " + info.getTunnelId());
// The type of the tunnel. Valid values: BaseData, Stream, and BaseAndStream.
System.out.println("\tTunnelType: " + info.getTunnelType());
System.out.println("\tTableName: " + info.getTableName());
System.out.println("\tInstanceName: " + info.getInstanceName());
// The stage of the tunnel. Valid values: InitBaseDataAndStreamShard, ProcessBaseData, and ProcessStream.
System.out.println("\tStage: " + info.getStage());
// Indicate whether the data is expired. If true is returned, contact Tablestore technical support by using DingTalk at the earliest opportunity.
System.out.println("\tExpired: " + info.isExpired());
}
}
References
For information about the API operation that you can call to query information about all tunnels of a data table, see ListTunnel.
If you want to quickly use Tunnel Service to consume data, see Getting started.
You can query information about a tunnel. For more information, see Query information about a tunnel.
You can delete a tunnel that you no longer require. For more information, see Delete a tunnel.