All Products
Search
Document Center

Tablestore:Query information about a tunnel

Last Updated:Jul 05, 2024

After you create a tunnel, you can call the DescribeTunnel operation to query information about the tunnel, such as information about channels in the tunnel.

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.

TunnelName

The name of the tunnel.

Response parameters

Parameter

Description

TunnelConsumePoint

The most recent time when the tunnel is used to consume incremental data. The time is the point in time when the slowest channel in the tunnel is used to consume data. Default value: January 1, 1970 (UTC).

TunnelInfo

The information about the tunnel. The following information is included in the response:

  • TunnelId: the ID of the tunnel.

  • TunnelType: the type of the tunnel. Valid values: BaseData, Stream, and BaseAndStream. The BaseData type indicates that the tunnel is used to consume full data of the data table. The Stream type indicates that the tunnel is used to consume incremental data of the data table. The BaseAndStream type indicates that the tunnel is used to consume differential data of the data table.

  • TableName: the name of the data table for which the tunnel is created.

  • InstanceName: the name of the instance in which the tunnel is located.

  • Stage: the stage of the tunnel. Valid values: InitBaseDataAndStreamShard, ProcessBaseData, and ProcessStream. The InitBaseDataAndStreamShard stage indicates that the tunnel is being initialized. The ProcessBaseData stage indicates that the tunnel is being used to consume full data. The ProcessStream stage indicates that the tunnel is being used to consume incremental data.

  • Expired: indicates whether the data is expired.

    If true is returned, contact Tablestore technical support by using DingTalk at the earliest opportunity.

List<ChannelInfo>

The information about the channels in the tunnel. The following information is included in the response:

  • ChannelId: the ID of the channel.

  • ChannelType: the type of the channel. Valid values: BaseData and Stream.

  • ChannelStatus: the status of the channel. Valid values: WAIT, OPEN, CLOSING, CLOSE, and TERMINATED.

  • ClientId: the ID of the tunnel client. By default, the client ID concatenates the hostname of the client and a random string. The client hostname can be specified by using TunnelWorkerConfig.

  • ChannelConsumePoint: the most recent time when the channel is used to consume incremental data. Default value: January 1, 1970 (UTC). This parameter does not take effect for channels of the BaseData type.

  • ChannelCount: the number of data entries that the channel synchronizes.

RequestId

The ID of the request.

Examples

The following sample code provides an example on how to query information about a tunnel, including the most recent time when the tunnel is used to consume incremental data and the information about the channels in the tunnel:

// The most recent time when the tunnel is used to consume incremental data and the recovery point objective (RPO) take effect only if the tunnel is of the Stream type. 
// Stream tunnel: The Stage parameter in TunnelInfo is ProcessStream. Stream channel: The ChannelType parameter in ChannelInfo is Stream. 
private static void describeTunnel(TunnelClient client, String tableName, String tunnelName) {
    DescribeTunnelRequest request = new DescribeTunnelRequest(tableName, tunnelName);
    DescribeTunnelResponse resp = client.describeTunnel(request);
    System.out.println("RequestId: " + resp.getRequestId());
    // The most recent time when the tunnel is used to consume incremental data. The time is the point in time when the slowest channel in the tunnel is used to consume data. Default value: January 1, 1970 (UTC). 
    System.out.println("TunnelConsumePoint: " + resp.getTunnelConsumePoint());
    System.out.println("TunnelInfo: " + resp.getTunnelInfo());
    for (ChannelInfo ci : resp.getChannelInfos()) {
        System.out.println("ChannelInfo::::::");
        System.out.println("\tChannelId: " + ci.getChannelId());
        // The type of the channel. Valid values: BaseData and Stream. 
        System.out.println("\tChannelType: " + ci.getChannelType());
        // The ID of the tunnel client. By default, the client ID concatenates the hostname of the client and a random string. 
        System.out.println("\tClientId: " + ci.getClientId());
        // The most recent time when the channel is used to consume incremental data. 
        System.out.println("\tChannelConsumePoint: " + ci.getChannelConsumePoint());
        // The number of data entries that the channel synchronizes. 
        System.out.println("\tChannelCount: " + ci.getChannelCount());
    }
}

References