Creating a Flink Edge SQL Job
This section describes how to create a Flink streaming SQL edge job. The Flink streaming SQL edge job analyzes and processes data near where data is generated when a large amount of data is generated on edge devices, which reduces the amount of data to be migrated to the cloud and improves real-time data processing.
This job combines DLI with IEF. By deploying the stream computing application provided by the system on edge nodes, the Flink computing capability is extended from the cloud to the edge. Then, DLI edits Flink jobs and delivers them to the edge for execution, helping you quickly and accurately analyze and process streaming data in real time at the edge.
Prerequisites
- IEF has been enabled.
- Edge nodes have been created and successfully managed. For details, see section Edge Nodes in the Intelligent EdgeFabric User Guide.
- The edge stream computing application has been deployed. For details, see Application Deployment in the Intelligent EdgeFabric User Guide.
- Only users with the Tenant Administrator permission can run jobs of IEF.
- Before creating a Flink SQL edge job, purchase an edge authentication code. For details about how to purchase and use an edge authentication code, see Buying an Edge Authentication Code.
Precautions
When deploying edge applications, pay attention to the following points:
- If you deploy an application using a system template, ensure that the container specification is not less than the default value. Otherwise, the instance deployment fails.
- The application name must be prefixed with edge-dli- to ensure that DLI can obtain the edge node information.
- You need to specify the environment variable PROJECT_ID. The value of PROJECT_ID is the project ID of the user account, which can be obtained from the My Credentials page in the upper right corner of the console.
- Mount the /opt/flink/edgecsa directory of the container to the local directory of the terminal node and grant the read and write permissions to ensure that the system can automatically start the Flink job when the container restarts abnormally.
- The Mosquitto software needs to be deployed on edge nodes to ensure that containers can properly send and receive messages. To download Mosquitto, visit https://mosquitto.org/download/.
- During application deployment, click Container Network, set Network to Host network to ensure that the containerized application can access Mosquitto properly.
- The current version supports only the professional edition IEF instances. The platinum edition will be supported in later versions.
During the deployment of edge stream computing applications, some Flink parameters can be customized using container environment variables. The following table lists the supported parameters.
| Parameter | Description |
|---|---|
| JobManagerHeapSize | Heap memory size of Jobmanager. The default value is 1024 MB. |
| TaskManagerMemoryProcessSize | Memory size of the TaskManager process. The default value is 2048 MB. |
| TaskManagerMemoryMetaSize | Memory size of the TaskManager metaspace. The default value is 256 MB. |
| TaskManagerNetworkBufferNum | Number of TaskManager network caches. The default value is 2048. |
| NumberOfTaskSlots | Number of TaskManager task slots. The default value is 1. |
| RestartStrategy | Specifies the restart policy. The default value is fixed-delay. |
| RestartAttemptsNum | Number of restart times. The default value is 3. |
| RestartInterval | Specifies the restart interval. The default value is 10s. |
| TimeZone | Specifies the time zone. The value is in the standard format of the Linux system. The default value is Asia/Shanghai. |
Creating a Flink Edge SQL Job
- In the left navigation pane of the DLI management console, choose > . The Flink Jobs page is displayed.
- In the upper right corner of the Flink Jobs page, click Create Job. Figure 1 Creating a Flink edge SQL job
- Specify job parameters.
Table 2 Job configuration information Parameter
Description
Type
Set Type to Flink Edge SQL. You will need to start jobs by compiling SQL statements.
Name
Name of a job. Enter 1 to 57 characters. Only letters, digits, hyphens (-), and underscores (_) are allowed.
NOTE:The job name must be globally unique.
Description
Description of a job. It can be up to 512 characters long.
Template Name
This parameter is only used when Editor is set to SQL Editor.
You can select a sample template or a custom job template. For details about the template, see Flink Template Management.
Tags
Tags are used to identify cloud resources. A tag pair includes the Tag Key and Tag Value. If you want to use the same tag to identify multiple cloud resources, that is, to select the same tag from the drop-down list box for all services, you are advised to create predefined tags on the Tag Management Service (TMS). For details, see the Tag Management Service User Guide.
NOTE:- A maximum of 10 tags can be added.
- Only one tag value can be added to a tag key.
- Tag Key: Enter a tag key name in the text box. NOTE:
- A tag key contains a maximum of 36 characters. The first and last characters cannot be spaces. The following characters are not allowed: =*,<>\|/
- If there are predefined tags, you can select a tag from the drop-down list box.
- Tag Value: Enter a tag value in the text box. NOTE:
- A tag value contains a maximum of 43 characters. The first and last characters cannot be spaces. The following characters are not allowed: =*,<>\|/
- If there are predefined tags, you can select a tag from the drop-down list box.
- Click OK to enter the page.
- Edit the job.
Edit the Flink streaming SQL edge job as required to process data generated on edge devices.
Currently, the following DDLs are supported:
- Input and output streams: edgehub (user-defined)
- Dimension table: RDS (MySQL and GaussDB 100)
For details about SQL statements, see the Data Lake Insight SQL Syntax Reference.
Example: Export the names and scores of students whose scores are greater than or equal to 80.
create source stream student_scores(name string, score int) with ( type = "edgehub", topic = "abc", encode = "json", json_config = "score = student.score; name=student.name" ); create sink stream excellent_students(name string, score int) with ( type = "edgehub", topic = "abcd", encode = "csv", field_delimiter = "," ); insert into excellent_students select name, score from student_scores where score >= 80; - Click Check Semantics.
- You can only Debug, Submit, or Start a job after semantic verification succeeds.
- If verification is successful, the message "The SQL semantic verification is complete. No error." will be displayed.
- If verification fails, a red "X" mark will be displayed in front of each SQL statement that produced an error. You can move the cursor to the "X" mark to view error details and change the SQL statement as prompted.
- Set job running parameters. Figure 2 Setting running parameters of the Flink streaming SQL edge job
Table 3 Running parameters Parameter
Description
CUs
Sum of the number of compute units and job manager CUs of DLI. CU is also the billing unit of DLI. One CU equals one vCPU and 4 GB.
Job Manager CUs
Number of CUs of the management unit.
Max Concurrent Jobs
Maximum number of Flink jobs that run at the same time.
NOTE:The value must not exceed four times of (Number of CUs – 1).
Edge Node to Which the Job Belongs
Select the edge node that the job belongs to.
- Your own edge computing devices serve as the edge nodes run edge applications, process your data, and work with cloud applications securely and conveniently. An edge application is a functional module that runs on an edge node.
- DLI allows you to deploy jobs on multiple edge nodes. By binding the edge nodes to which the jobs belong, DLI combines Flink jobs with IEF.
IEF Message Channel
The channel is used to create an IEF side cloud message.
UDF Jar
User-defined UDF files can be uploaded to DLI using the Package Management function.
- Click Create to create an IEF message channel.
- Click Save.
- Click Submit. On the displayed Job Configurations page, click OK to submit and start the job.
After the job is submitted, the system automatically switches to the page, and the created job is displayed in the job list. You can view the job status in the column. After a job is successfully submitted, the job status will change from to . When the task is complete, Completed is displayed.
If the job status is or , the job submission failed or the job did not execute successfully. In this case, you can move the cursor over the status icon in the column of the job list to view the error details. You can click
to copy these details. After handling the fault based on the provided information, resubmit the job.
Other buttons are as follows:
- Debug: indicates to perform job debugging. For details, see Debugging a Job.
- Format SQL: indicates to format the SQL statement. After clicking Format SQL, you need to edit SQL statements again.
- More > Modify Name and Description: indicates to modify the job name and description.
- More > Save As: indicates to save the created job as a new job.
- More > Set as Template: indicates to set the created job as a job template.
- More > Theme Settings: indicates to set the theme related parameters, including Font Size, Wrap, and Page Style.
- More > Help: The help center provides SQL syntax reference for users.
Verifying Job Running
- On IEF, log in to any node that must interwork with edge nodes.
- You can use the following command to send data to edge nodes.
mosquitto_pub -h Edge node IP address -t abc -m '{"student":{"score":90,"name":"1bc2"}}';In the command, abc refers to the topic name defined in the job.
- Open a new window and run related commands to monitor the output. Enter the following command to query the names and scores of students whose scores are greater than or equal to 80.
mosquitto_sub -h Edge node IP address -t abcd
In the command, abcd refers to the topic name defined in the job.
Last Article: Creating a Flink OpenSource SQL Job
Next Article: Managing Edge Authentication Codes
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.