هذه الصفحة غير متوفرة حاليًا بلغتك المحلية. نحن نعمل جاهدين على إضافة المزيد من اللغات. شاكرين تفهمك ودعمك المستمر لنا.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Application Example

Updated on 2023-06-21 GMT+08:00

Scenarios

DIS provides efficient collection, transmission, and distribution capabilities for real-time data and provides a variety of APIs to help you quickly build real-time data applications.

The following describes how to create a DIS stream by calling the Before You Start API. For details, see Calling APIs.
NOTE:

The token obtained on IAM is valid for only 24 hours. If you want to use one token for authentication, you can cache it to avoid frequent calling.

Involved APIs

If you use a token for authentication, you must obtain the token and add X-Auth-Token to the request header of the API request.

  • API for obtaining a token from IAM
  • API for creating a DIS stream

Prerequisites

You have planned the region where DIS is located and determined the endpoint for calling an API based on the region.

An endpoint is the request address for calling an API. Endpoints vary depending on services and regions. You can obtain endpoints of the service from Endpoints.

Creating a Stream

The following is an example of creating a stream with the simplest configuration.

  1. Obtain the token by following the instructions in Token-based Authentication.
  2. Send POST https://Endpoint of DIS/v2/{project_id}/streams.
  3. Add X-Auth-Token to the request header.
  4. Specify the following parameters in the request body:
    {
    "stream_name": "dis-DLpR",
    "partition_count": 1,
    "stream_type": "COMMON",
    "data_duration": 24
    }
    • stream_name indicates the stream name, which can be customized, for example, newstream.
    • partition_count indicates the number of partitions. A partition is the base throughput unit of a DIS stream. You can specify the number of partitions based on your service throughput requirements.
    • stream_type indicates the stream type. COMMON indicates a common partition. A single partition supports a maximum of 1 MB/s for data writing and a maximum of 2 MB/s for data reading.
    • data_duration indicates the lifecycle of a stream, that is, the duration for storing data in the stream partition.

    If the request is successful, 201 Created is returned.

    If the request fails, an error code and error information are returned. For details, see Error Codes.

Creating a Stream That Supports Auto Scaling

You can also create a stream that supports auto scaling. The number of partitions can be automatically increased or decreased based on the stream traffic. The following is an example configuration:

  1. Obtain the token by following the instructions provided in Token-based Authentication.
  2. Send POST https://Endpoint of DIS/v2/{project_id}/streams.
  3. Add X-Auth-Token to the request header.
  4. Specify the following parameters in the request body:
    {
    "stream_name": "dis-DLpR",
    "partition_count": 1,
    "stream_type": "COMMON",
    "data_duration": 24
    "auto_scale_enabled": true,
    "auto_scale_min_partition_count": 2,
    "auto_scale_max_partition_count": 10
    }

    In this example, a stream that supports auto scaling is created. The number of partitions to scale ranges from 2 to 10. If the stream has 10 partitions, auto scaling-out will not be triggered.

    • auto_scale_enabled specifies whether to enable auto scaling. The value true indicates that auto scaling is enabled.
    • auto_scale_min_partition_count indicates the minimum number of partitions allowed when auto scale-in is enabled. In this example, as there are two partitions, automatic scale-in will not be triggered.
    • auto_scale_max_partition_count indicates the maximum number of partitions allowed when auto scale-out is enabled. In this example, as there are 10 partitions, automatic scale-out will not be triggered.

    If the request is successful, 201 Created is returned.

    If the request fails, an error code and error information are returned. For details, see Error Codes.

Creating a Stream with Data Schemas

You can also configure a schema for the stream. When using DIS to dump data to other services, you can map data based on the schema configured for the stream. The following is an example configuration:

  1. Obtain the token by following the instructions provided in Token-based Authentication.
  2. Send POST https://Endpoint of DIS/v2/{project_id}/streams.
  3. Add X-Auth-Token to the request header.
  4. Specify the following parameters in the request body:
    {
    "stream_name": "dis-DLpR",
    "partition_count": 1,
    "stream_type": "COMMON",
    "data_duration": 24
    "auto_scale_enabled": true,
    "auto_scale_min_partition_count": 1,
    "auto_scale_max_partition_count": 10
    "data_type": "BLOG",
    }

    In this example, a stream whose source data type is JSON and that contains the key1 and key2 attributes is created.

    • data_type indicates the type of source data. The value JSON indicates that the data format in the partition is JSON.
    • data_schema indicates the source data schema, which describes the source data structures in JSON and CSV formats using the Avro Schema syntax.

    If the request is successful, 201 Created is returned.

    If the request fails, an error code and error information are returned. For details, see Error Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback