Halaman ini belum tersedia dalam bahasa lokal Anda. Kami berusaha keras untuk menambahkan lebih banyak versi bahasa. Terima kasih atas dukungan Anda.

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

Customizing a Flink Streaming Job

Updated on 2024-03-05 GMT+08:00

Obtaining a DIS Flink Connector Demo

  1. Obtain the dis-flink-connector-X.X.X.zip package from https://dis-publish.obs-website.cn-north-1.myhuaweicloud.com/. Decompress the dis-flink-connector-X.X.X.zip package to obtain the following directory that contains a Maven project sample:

    • huaweicloud-dis-flink-connector-demo which contains a sample Maven project

Importing the Demo Project on Intellij IDEA

The following uses the IntelliJ IDEA community version as an example to describe how to compile a Flink job. Make sure that the following components have been configured on IDEA.

  • JDK 1.8+
  • Scala-sdk-2.11
  • Maven 3.3.*
  1. Open IntelliJIDEA and choose File > New > Project from Existing Sources.... Select the huaweicloud-dis-flink-connector-demo directory and click OK.

  2. Select a Maven project, retain the default settings, and click Next until the New Project dialog box is displayed.

  3. Click New Window to open the project in a new window.

  4. Right-click pom.xml and choose Maven > Reimport from the shortcut menu to import the maven dependency library again.

Verifying the Flink Streaming Source Job

This section describes how to test a Flink Streaming job in the local IDE to understand the basic usage of the SDK. In a real-world scenario, the Flink Streaming job needs to run on a Flink cluster. After the test is complete, you can create clusters (such as MRS clusters) and submit a job for verification.

  1. Use the account to log in to the DIS console.
  2. Click in the upper left corner of the page and select a region and project.
  3. Create a DIS stream by referring to Step 1: Creating a DIS Stream and continuously upload data to the newly created DIS stream. In this example, the content to be uploaded is hello world.
  4. Open the pom.xml file, press Ctrl+/ to comment out the <scope>provided</scope> row, and save the setting.

  5. Right-click pom.xml and choose Maven > Reimport from the shortcut menu to import the dependency package again.

  6. Right-click in the DISFlinkStreamingSourceJavaExample file and choose Create 'DISFlinkStreamingSourceJavaExample' from the shortcut menu.

  7. On the configuration page that is displayed, set Program arguments in the following format:

    DIS gateway address + Region name + AK + SK + Project ID + Stream name + Start position + Consumer ID
     
    https://dis.${region}.myhuaweicloud.com ${region} YOU_AK YOU_SK YOU_PROJECTID YOU_STREAM_NAME latest GROUP_ID

    The parameter sequence and meaning are available in the sample code. For details, see the following information:

    //DIS endpoint.
            String endpoint;
    //ID of the region where DIS resides.
            String region;
    //AK of the user.
            String ak;
    //SK of the user.
            String sk;
    //Project ID of the user.
            String projectId;
    //DIS stream name.
            String streamName;
    //Consumption policy. This policy is used only when the partition has no checkpoint or the checkpoint has expired. If a valid checkpoint exists, the consumption continues from this checkpoint.
    //When the policy is set to LATEST, the consumption starts from the latest data. This policy will ignore the existing data in the stream.
    //When the policy is set to Earliest, the consumption starts from the earliest data. This policy will obtain all valid data in the stream.
            String startingOffsets;
    //Consumer group ID. Different clients in the same consumer group can consume the same stream at the same time.
            String groupId;
    NOTE:
    • A checkpoint must be specified or a consumption point is automatically marked as follows:

    disConfig.put(DisConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "true");

    disConfig.put(DisConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG, "1000");

    disConfig.put(DisConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "LATEST"); //LATEST indicates that the consumption starts from the latest data.

    • If none of them is set, the consumption starts from the latest by default.

    The final configurations of the IDEA are shown in the following figure. After confirming that all configurations are correct, click OK to close the window.

  8. Right-click in the DISFlinkStreamingSourceJavaExample file and choose Run 'DISFlinkStreamingSourceJavaExample' from the shortcut menu to start the job.

  9. If no error occurs, data is read from DIS and output to the console. The following is an example:

    2> hello world
    2> hello world
    2> hello world

  10. After verifying that the job can run locally without error, remove the comment tag from the <scope>provided</scope> row in pom.xml to prevent the Flink dependency from being packaged. Then stop the data upload program.

Verifying the Flink Streaming Sink Job

This section describes how to test a Flink job in the local IDE to understand the basic usage of the SDK. In a real-world scenario, the Flink job needs to run on a Flink cluster. After the test is complete, you can create clusters (such as MRS clusters) and submit a job for verification.

  1. Use the account to log in to the DIS console.
  2. Click in the upper left corner of the page and select a region and project.
  3. Enable DIS by referring to Step 1: Creating a DIS Stream.
  4. Open the pom.xml file, press Ctrl+/ to comment out the <scope>provided</scope> row, and save the setting.

  5. Right-click pom.xml and choose Maven > Reimport from the shortcut menu to import the dependency package again.

  6. Right-click in the DISFlinkStreamingSinkJavaExample file and choose Create 'DISFlinkStreamingSinkJavaExample' from the shortcut menu.

  7. On the configuration page that is displayed, set Program arguments in the following format:

    DIS gateway address + Region name + AK + SK + Project ID + Stream name
    https://dis.${region}.myhuaweicloud.com ${region} YOU_AK YOU_SK YOU_PROJECTID YOU_STREAM_NAME

    The parameter sequence and meaning are available in the sample code. For details, see the following information:

    //DIS endpoint.
            String endpoint;
    //ID of the region where DIS resides.
            String region;
    //AK of the user.
            String ak;
    //SK of the user.
            String sk;
    //Project ID of the user.
            String projectId;
    //DIS stream name.
            String streamName;

    The final configurations of the IDEA are shown in the following figure. After confirming that all configurations are correct, click OK to close the window.

  8. Right-click in the DISFlinkStreamingSinkJavaExample file and choose Run 'DISFlinkStreamingSinkJavaExample' from the shortcut menu to start the job.

  9. Check whether the data is successfully uploaded on the stream monitoring page of the DIS console.
  10. After verifying that the job can run locally without error, remove the comment tag from the <scope>provided</scope> row in pom.xml to prevent the Flink dependency from being packaged. Then stop the data upload program.

Kami menggunakan cookie untuk meningkatkan kualitas situs kami dan pengalaman Anda. Dengan melanjutkan penelusuran di situs kami berarti Anda menerima kebijakan cookie kami. Cari tahu selengkapnya

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback