Querying Stream Details

Use the DIS SDK to query the details about a specified stream.

char *streamName = "myStream"; 
char *projectId = "d575b0b740e54221aeb9a165653b103d";
char *region = "southchina";
int ret = 0;
int i = 0;
DISResponseInfo RspInfo = { 0 };
DISDescribeStream streamDetail = { 0 };
streamDetail.streamName = streamName;
//streamDetail.startPartitionId="";
//streamDetail.limitPartitionNum=10;
printf("===================%s Begin=======================\n", __FUNCTION__);
ret = DescribeStream(host, projectId, region, &streamDetail, &RspInfo);
if (ret != 0)
{
printf("List Error: %d\r\n", ret);
printf("HttpResponseCode: %ld\r\n", RspInfo.HttpResponseCode);
printf("ErrorCode: %s\r\n", RspInfo.ErrorCode);
printf("ErrorDetail: %s\r\n", RspInfo.ErrorDetail);
return;
}
printf("HttpResponseCode: %ld\r\n", RspInfo.HttpResponseCode);
printf("streamId:%s\n", streamDetail.streamInfo.streamId);
printf("streamName:%s\n", streamDetail.streamInfo.streamName);
printf("createTime:%ld\n", streamDetail.streamInfo.createTime);
printf("lastModifyTime:%ld\n", streamDetail.streamInfo.lastModifyTime);
printf("retentionPeriod:%ld\n", streamDetail.streamInfo.retentionPeriod);
printf("dataType:%s\n", streamDetail.streamInfo.dataType == DISDataTypeBlob ? "BLOB"
: (streamDetail.streamInfo.dataType == DISDataTypeJson) ? "JSON"
: (streamDetail.streamInfo.dataType == DISDataTypeCsv) ? "CSV"
: "FILE");
printf("streamStatus:%s\n", streamDetail.streamInfo.streamStatus == DISStreamStatusCreating ? "CREATING"
: (streamDetail.streamInfo.streamStatus == DISStreamStatusRunning) ? "RUNNING"
: (streamDetail.streamInfo.streamStatus == DISStreamStatusTerminating) ? "TERMINATING"
: "FROZEN");
printf("streamType:%s\n", streamDetail.streamInfo.streamType == DISStreamTypeCommon ? "Common" : "Advanced");
printf("hasMorepartition:%s\n", streamDetail.streamInfo.hasMorepartition == 0 ? "false" : "true");
printf("currentNumber:%ld\n", streamDetail.streamInfo.currentNumber);
for (i = 0; i < streamDetail.streamInfo.currentNumber; i++)
{
printf("loop %d partitionStatus:%s\n", i, streamDetail.streamInfo.partitionList[i].partitionStatus == DISPartitionStatusCreating ? "CREATING"
: (streamDetail.streamInfo.partitionList[i].partitionStatus == DISPartitionStatusActive) ? "ACTIVE"
: (streamDetail.streamInfo.partitionList[i].partitionStatus == DISPartitionStatusDeleted) ? "DELETED"
: "EXPIRED");
printf("loop %d partitionId:%s\n", i, streamDetail.streamInfo.partitionList[i].partitionId);
printf("loop %d hashRange:%s\n", i, streamDetail.streamInfo.partitionList[i].hashRange);
printf("loop %d sequenceNumberRange:%s\n", i, streamDetail.streamInfo.partitionList[i].sequenceNumberRange);
}
printf("===================%s End=======================\n", __FUNCTION__);

Table 1 DISDescribeStream parameter description

Parameter

Mandatory

Type

Description

streamName

Yes

Char *

Stream to be queried.

startPartitionId

No

Char *

Name of the partition to start the partition list with. The returned partition list does not contain this partition.

limitPartitionNum

No

long

Max. number of partitions to list in a single API call.

Value range: 1-1000

Default value: 100

The returned stream details are as follows:

HttpResponseCode: 200
streamId:fXdsj6XzvxKJVLQoplg
streamName: myStream
createTime:1536546556151
lastModifyTime:1536546557001
retentionPeriod:72
dataType:FILE
streamStatus:RUNNING
streamType:Advanced
hasMorepartition:false
currentNumber:2
loop 0 partitionStatus:ACTIVE
loop 0 partitionId:shardId-0000000000
loop 0 hashRange:[0 : 4611686018427387902]
loop 0 sequenceNumberRange:[0 : 0]
loop 1 partitionStatus:ACTIVE
loop 1 partitionId:shardId-0000000001
loop 1 hashRange:[4611686018427387903 : 9223372036854775807]
loop 1 sequenceNumberRange:[0 : 0]
Table 2 DISDescribeStream parameter description

Parameter

Type

Description

streamInfo

DISStreamDetailInfo

Stream details obtained through response.

Table 3 DISStreamDetailInfo parameter description

Parameter

Type

Description

streamName

Char *

Name of the DIS stream to be created.

streamId

Char *

Unique identifier of the stream.

createTime

Long

Timestamp at which the stream was created.

lastModifyTime

Long

Timestamp at which the stream was most recently modified.

retentionPeriod

Long

Period of time for which data is retained in the stream.

streamStatus

DISStreamStatus

Current status of the stream. Possible values:

  • DISStreamStatusCreating
  • DISStreamStatusRunning
  • DISStreamStatusTerminating
  • DISStreamStatusFrozen

streamType

DISStreamType

Stream type.

  • DISStreamTypeCommon
  • DISStreamTypeAdvanced

hasMorepartition

long

Specify whether there are more matching partitions of the DIS stream to list.

  • 1: yes
  • 0: no

dataType

DISDataType

Source Data Type

  • DISDataTypeBlob
  • DISDataTypeJson
  • DISDataTypeCsv
  • DISDataTypeFile

currentNumber

long

Number of partitions.

partitionList

DISPartitionDetailInfo[100]

Partition list of the stream

Table 4 DISPartitionDetailInfo parameter description

Parameter

Type

Description

partitionStatus

DISPartitionStatus

Current status of the partition. Possible values:

  • DISPartitionStatusCreating
  • DISPartitionStatusActive
  • DISPartitionStatusDeleted
  • DISPartitionStatusExpired

partitionId

Char [128]

Unique identifier of the partition.

hashRange

Char [128]

Possible value range of the hash key used by the partition.

sequenceNumberRange

Char [128]

Sequence number range of the partition.