Query tunnel information

Updated at:

Use Tablestore SDK for Java to query the configuration, stage, channel states, and incremental consumption progress of a tunnel.

Prerequisites

Install Tablestore SDK for Java and initialize TunnelClient.

Feature description

Call describeTunnel to query information about a tunnel. The response includes the tunnel configuration, overall incremental consumption point and recovery point objective (RPO), and the state and consumption progress of each channel in the tunnel.

DescribeTunnelResponse describeTunnel(DescribeTunnelRequest request)
        throws TableStoreException, ClientException

The following example queries information about the example_tunnel tunnel of the example_table table and prints the tunnel stage and the state and consumption progress of each channel:

String tableName = "example_table";
String tunnelName = "example_tunnel";

DescribeTunnelRequest request =
        new DescribeTunnelRequest(tableName, tunnelName);
DescribeTunnelResponse response = tunnelClient.describeTunnel(request);

TunnelInfo tunnelInfo = response.getTunnelInfo();
System.out.printf(
        "name=%s, type=%s, stage=%s%n",
        tunnelInfo.getTunnelName(),
        tunnelInfo.getTunnelType(),
        tunnelInfo.getStage());

for (ChannelInfo channelInfo : response.getChannelInfos()) {
    System.out.printf(
            "channelId=%s, type=%s, status=%s, count=%d%n",
            channelInfo.getChannelId(),
            channelInfo.getChannelType(),
            channelInfo.getChannelStatus(),
            channelInfo.getChannelCount());
}

Parameters

request is of the DescribeTunnelRequest type and contains the following parameters:

Name

Type

Description

tableName (required)

String

The name of the table.

tunnelName (required)

String

The name of the tunnel.

Return values

The return value is of the DescribeTunnelResponse type and contains the following fields:

Name

Type

Description

tunnelConsumePoint

Date

The latest incremental consumption point of the tunnel. The value is the consumption point of the slowest channel in the tunnel. Default value: 00:00:00 on January 1, 1970 (UTC). Call getTunnelConsumePoint() to obtain this field.

tunnelRpo

long

The incremental consumption RPO of the tunnel, which is the difference between the current time and the consumption point of the slowest channel. Unit: milliseconds. Call getTunnelRpo() to obtain this field.

tunnelInfo

TunnelInfo

The tunnel information. Call getTunnelInfo() to obtain this field. The fields are the same as those in the TunnelInfo objects returned by List tunnels.

channelInfos

List<ChannelInfo>

The list of channels in the tunnel. If the tunnel has not initialized any channels, an empty list is returned. Call getChannelInfos() to obtain this field.

Note

tunnelConsumePoint and tunnelRpo apply only to incremental consumption. If incremental consumption has not started or the tunnel consumes only full data, tunnelConsumePoint is the default value. In this case, do not use tunnelRpo to determine the consumption latency.

Channel information

Each element in channelInfos[] is of the ChannelInfo type and contains the following fields:

Name

Type

Description

channelId

String

The channel ID.

channelType

ChannelType

The channel type. Valid values: BaseData and Stream, which indicate a full-data channel and an incremental-data channel, respectively.

channelStatus

ChannelStatus

The channel state. Valid values: WAIT, OPEN, CLOSING, CLOSE, and TERMINATED, which indicate waiting, open, closing, closed, and terminated, respectively.

clientId

String

The ID of the client that consumes the channel. This field may be empty if no client is assigned to the channel. The client ID is generated based on TunnelWorkerConfig.clientTag. You can call setClientTag() to customize the client identifier.

channelConsumePoint

Date

The latest incremental consumption point of the channel. Default value: 00:00:00 on January 1, 1970 (UTC). This field does not apply to full-data channels.

channelRpo

long

The incremental consumption RPO of the channel, which is the difference between the current time and channelConsumePoint. Unit: milliseconds. This field does not apply to full-data channels.

channelCount

long

The number of rows synchronized by the channel.