/// <summary>
        /// 查询通道详情
        /// </summary>
        /// <param name="streamName">通道名称 </param>
        /// <param name="startPartitionId">起始分区ID </param>
        /// <param name="limitPartitions">单次请求返回的最大分区数 </param>
        /// <returns></returns>
        public static DescribeStreamResult DescribeStream(string streamName, string startPartitionId, int?limitPartitions)
        {
            DescribeStreamResult response = null;
            var dic     = new DISIngestionClient();
            var request = new DescribeStreamRequest {
                StreamName = streamName
            };

            if (!string.IsNullOrWhiteSpace(startPartitionId))
            {
                //从该分区值开始返回分区列表,返回的分区列表不包括此分区
                request.StartPartitionId = startPartitionId;
            }

            if (limitPartitions != null)
            {
                //单次请求返回的最大分区数
                request.LimitPartitions = limitPartitions.Value;
            }

            response = dic.DescribeStream(request);
            var responseJson = JsonConvert.SerializeObject(response);

            Console.WriteLine(responseJson);
            return(response);
        }
Example #2
0
        /// <summary>
        /// This method waits a maximum of 10 minutes for the specified stream to become active.
        /// <param name="myStreamName">Name of the stream whose active status is waited upon.</param>
        /// </summary>
        private static void WaitForStreamToBecomeAvailable(string myStreamName)
        {
            var deadline = DateTime.UtcNow + TimeSpan.FromMinutes(10);

            while (DateTime.UtcNow < deadline)
            {
                DescribeStreamRequest describeStreamReq = new DescribeStreamRequest();
                describeStreamReq.StreamName = myStreamName;
                DescribeStreamResult describeResult = kinesisClient.DescribeStream(describeStreamReq);
                string streamStatus = describeResult.StreamDescription.StreamStatus;
                Console.Error.WriteLine("  - current state: " + streamStatus);
                if (streamStatus == StreamStatus.ACTIVE)
                {
                    return;
                }
                Thread.Sleep(TimeSpan.FromSeconds(20));
            }

            throw new Exception("Stream " + myStreamName + " never went active.");
        }