Creating a Stream
Initialize a DIS client as instructed in Initializing a DIS SDK Client Instance.
When you use the DIS SDK to create a DIS stream, specify the stream name, number of partitions in the stream, and stream type.
COMMON indicates a common stream, and ADVANCED indicates an advanced stream.
Creating a Stream That Has No Dump Tasks
//Stream name.
string streamName = "XXX";
//Partition quantity.
int partitionCount = XXX;
CreateStreamRequest request = new CreateStreamRequest
{
//Stream name.
StreamName =streamName,
//Stream type (COMMON and ADVANCED).
StreamType = "XXX",
//Partition quantity.
PartitionCount =partitionCount,
//Source data type: BLOB, JSON, CSV, and file.
DataType = "XXX",
//Data retention. Value: N x 24. N is an integer ranging from 1 to 7.
DataDuration = 7 * 24,
};
After configuring CreateStreamRequest, you can create the stream by calling createStream.
ResponseResult response = dic.CreateStream(request); Console.WriteLine(response);
Viewing Execution Results
Press Ctrl+F5. If information similar to the following is displayed on the console, the stream is created successfully:
ResponseResult{status_code='201 Created', content='', errorCode='', message=''}
|
Parameter |
Type |
Description |
|---|---|---|
|
content |
String |
Response body. |
|
errorCode |
String |
Error code. |
|
message |
String |
Error response body. |
|
status_code |
String |
Status code. |
Creating a Stream That Has Periodic OBS Dump Tasks
//Stream name.
string streamName = "XXX";
//Partition quantity.
int partitionCount = XXX;
var dic = new DISIngestionClient();
var request = new CreateStreamRequest
{
StreamName = streamName,
//Stream type (COMMON and ADVANCED).
StreamType = "XXX",
PartitionCount = partitionCount,
//Source data type: BLOB, JSON, CSV, and file.
DataType = "XXX",
//Data retention. Value: N x 24. N is an integer ranging from 1 to 7.
DataDuration = 7 * 24,
};
List<ObsDestinationDescriptorEntity> obsDestinationDescriptorEntitys = new List<ObsDestinationDescriptorEntity>();
var obsDestinationDescriptorEntity = new ObsDestinationDescriptorEntity
{
//IAM agency name.
AgencyName = "XXX",
//Bucket name.
ObsBucketPath = "XXX",
//Custom file
FilePrefix = "XXX",
//Time when data is imported to OBS
DeliverTimeInterval =XXX,
//Directory level in the OBS bucket.
PartitionFormat = "XXX",
//Delimiter.
RecordDelimiter = "XXX"
};
obsDestinationDescriptorEntitys.Add(obsDestinationDescriptorEntity);
request.ObsDestinationDescriptor = obsDestinationDescriptorEntitys;
After configuring CreateStreamRequest, you can create a stream by calling createStream.
ResponseResult response = dic.CreateStream(request); Console.WriteLine(response);
Viewing Execution Results
Press Ctrl+F5. If information similar to the following is displayed on the console, the stream is created successfully:
ResponseResult{status_code='201 Created', content='', errorCode='', message=''}
|
Parameter |
Type |
Description |
|---|---|---|
|
content |
String |
Response body. |
|
errorCode |
String |
Error code. |
|
message |
String |
Error response body. |
|
status_code |
String |
Status code. |
Creating a DIS Stream That Has Custom OBS Dump Tasks
//Stream name.
string streamName = "XXX";
//Partition quantity.
int partitionCount = XXX;
var dic = new DISIngestionClient();
var request = new CreateStreamRequest
{
StreamName = streamName,
PartitionCount = partitionCount,
//Data retention. Value: N x 24. N is an integer ranging from 1 to 7.
DataDuration = 7 * 24,
//Stream type (COMMON and ADVANCED).
StreamType = "XXX",
};
List<ObsDestinationDescriptorEntity> obsDestinationDescriptorEntitys = new List<ObsDestinationDescriptorEntity>();
var obsDestinationDescriptorEntity = new ObsDestinationDescriptorEntity
{
//IAM agency name.
AgencyName = "XXX",
//Bucket name.
ObsBucketPath = "XXX",
//Specify this parameter when Data Dump Type is Custom Dump. Default value: file_stream.
DeliverDataType = "XXX",
};
obsDestinationDescriptorEntitys.Add(obsDestinationDescriptorEntity);
request.ObsDestinationDescriptor = obsDestinationDescriptorEntitys;
After configuring CreateStreamRequest, you can create a stream by calling createStream.
ResponseResult response = dic.CreateStream(request); Console.WriteLine(response);
Viewing Execution Results
Press Ctrl+F5. If information similar to the following is displayed on the console, the stream is created successfully:
ResponseResult{status_code='201 Created', content='', errorCode='', message=''}
|
Parameter |
Type |
Description |
|---|---|---|
|
content |
String |
Response body. |
|
errorCode |
String |
Error code. |
|
message |
String |
Error response body. |
|
status_code |
String |
Status code. |
Last Article: Initializing a DIS SDK Client Instance
Next Article: Deleting a Stream
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.