Lindorm Spark Streaming node
The Lindorm Spark Streaming node is used to develop and schedule stream processing tasks through DataWorks. It is suitable for scenarios such as real-time data ingestion and stream-based ETL. This topic describes how to create, develop, and debug this type of node.
Background information
Lindorm Spark Streaming is the stream data processing capability provided by the Lindorm compute engine. It is built on the Apache Spark Structured Streaming framework and supports continuously consuming real-time data from data sources such as Kafka, and writing the processed data to Lindorm wide tables, time series engines, and other storage systems. Unlike the Lindorm Spark node that runs batch processing on a schedule, the Lindorm Spark Streaming node runs continuously as a long-running task. It is suitable for real-time data ingestion and stream-based ETL scenarios.
Prerequisites
-
The RAM user for task development has been added to the corresponding DataWorks workspace and granted the Development or Workspace Administrator role, and must have the permission to query job details in the Lindorm console.
-
A Lindorm instance has been created and a Lindorm computing resource is bound to the DataWorks workspace.
-
If you need to consume data from external data sources such as Kafka, the corresponding Lindorm data source has been configured.
Create a Lindorm Spark Streaming node
-
Log on to the DataWorks console.
-
In the left-side navigation pane, click Data Development.
-
On the Data Development page, right-click the target workflow and choose .
-
In the Create Node dialog box, enter the node name, select the storage path, and then click Confirm.
Develop a Lindorm Spark Streaming node
Configure the node to reference the corresponding JAR package or .py file depending on the language type (Java/Scala or Python).
Java/Scala
Prepare JAR resources
You need to prepare the JAR package required by the Spark Streaming task and make it available to the node by using one of the following methods:
-
Method 1: Upload a Lindorm File through DataWorks
In the Main JAR Resource drop-down list on the node editing panel, select a JAR package resource that was uploaded to Lindorm File through DataWorks.
-
Method 2: Upload to Lindorm DFS and enter the absolute path
After you upload the JAR package to LindormDFS, click Enter Absolute Path next to the Main JAR Resource field on the node editing panel and manually enter the absolute DFS path of the JAR package.
Perform the following steps to upload the file:
-
Log on to the Lindorm console. In the instance list for the corresponding region, find the Lindorm instance that you created.
-
Click the instance name to go to the instance details page.
-
In the left-side navigation pane, click Compute Engine to go to the Compute Engine page.
-
On the Job Management tab, click Upload Resource to open the upload page.
-
Click the dashed box area, select the JAR package file, and then click Open.
-
Click Upload to complete the JAR package upload.
-
On the Job Management tab, find the uploaded JAR package. Click the copy icon to the left of the file name to copy the absolute DFS path of the JAR package.
-
Node content
On the Lindorm Spark Streaming node editing panel, configure the following parameters:
|
Parameter |
Description |
|
Main JAR Resource |
Select or enter the JAR package resource path. You can select a Lindorm File uploaded through DataWorks from the drop-down list, or click Enter Absolute Path to manually enter the absolute DFS path of the JAR package in Lindorm DFS. |
|
Main Class |
The main class name of the compiled JAR package. For example: |
|
Files Resource |
(Optional) Select non-JAR file resources that the task depends on at runtime, such as configuration files. |
|
Jars Resource |
(Optional) Select additional JAR package resources that the task depends on at runtime. |
|
Parameters |
Enter the parameters to pass to the code. Separate multiple parameters with spaces. You can configure a dynamic parameter by using the |
|
Configuration Items |
Configure Spark runtime parameters. For Streaming tasks, we recommend that you configure parameters such as |
Python
Prepare Python resources
You need to prepare the Python file required by the PySpark Streaming task and make it available to the node by using one of the following methods:
-
Method 1: Upload a Lindorm File through DataWorks
In the Main Program Package drop-down list on the node editing panel, select the Python file resource that was uploaded to Lindorm File through DataWorks.
-
Method 2: Upload to Lindorm DFS and enter the absolute path
After you upload the Python file to LindormDFS, click Enter Absolute Path next to the Main Program Package field on the node editing panel and manually enter the absolute DFS path of the Python file.
Perform the following steps to upload the file:
-
Log on to the Lindorm console. In the instance list for the corresponding region, find the Lindorm instance that you created.
-
Click the instance name to go to the instance details page.
-
In the left-side navigation pane, click Compute Engine to go to the Compute Engine page.
-
On the Job Management tab, click Upload Resource to open the upload page.
-
Click the dashed box area, select the Python file, and then click Open.
-
Click Upload to complete the Python file upload.
-
On the Job Management tab, find the uploaded file. Click the copy icon to the left of the file name to copy the absolute DFS path of the Python file.
-
Node content
After the Python file is prepared, configure the following parameters on the Lindorm Spark Streaming node editing panel:
|
Parameter |
Description |
|
Main Program Package |
Select or enter the Python file resource path. You can select a Lindorm File uploaded through DataWorks from the drop-down list, or click Enter Absolute Path to manually enter the absolute DFS path of the Python file in Lindorm DFS. |
|
Files Resource |
(Optional) Select additional file resources that the task depends on at runtime. |
|
Jars Resource |
(Optional) Select JAR packages that the PySpark task depends on, such as custom UDFs or connectors. |
|
Parameters |
Enter the parameters to pass to the code. Separate multiple parameters with spaces. You can configure a dynamic parameter by using the |
|
Configuration Items |
Configure Spark runtime parameters. For Streaming tasks, we recommend that you configure checkpoint-related parameters to ensure fault tolerance. For more information about Spark properties, see the Lindorm Spark job configuration instructions. You can also set global Spark parameters when you bind a Lindorm computing resource. |
Run the Lindorm Spark Streaming node
After you configure the node content, click the Run Configuration panel on the right side. Configure the parameters on the following tabs:
|
Tab |
Parameter |
Description |
|
Compute Resource |
Compute Resource |
Select the Lindorm computing resource that is bound to the current workspace. |
|
Lindorm Resource Group |
Select the Lindorm resource group that you specified when you bound the Lindorm computing resource. |
|
|
Resource Group |
Resource Group |
Select the scheduling resource group for which the connectivity test was passed when you bound the Lindorm Spark computing resource. |
|
Script Parameters |
Script Parameters |
If you define dynamic parameters in the |
|
Other Settings |
Duration |
Set the maximum running duration for the Streaming task, in minutes. The task is automatically stopped after the specified duration is reached. |
After you complete the configuration, click Save and then click Run to execute the node.
The Spark Streaming node runs as a long-running task. After the task starts, you can view the job status in Real-time Computing Tasks in Operation Center. To stop the task, you can manually terminate it in Operation Center.
Deploy the Lindorm Spark Streaming node
To deploy the Streaming task to the production environment, click the
icon to deploy the node. Before you deploy the node, click the Real-time Configuration panel on the right side and configure the parameters on the following tabs:
|
Tab |
Parameter |
Description |
|
Compute Resource |
Compute Resource |
Select the Lindorm computing resource that is bound to the current workspace. |
|
Lindorm Resource Group |
Select the Lindorm resource group that you specified when you bound the Lindorm computing resource. |
|
|
Resource Group |
Resource Group |
Select the scheduling resource group for which the connectivity test was passed when you bound the Lindorm Spark computing resource. |
|
Script Parameters |
Script Parameters |
If you define dynamic parameters in the |
|
Time Properties |
Startup Mode |
Select the startup mode after deployment: Start immediately after deployment or Do not start after deployment. |
|
Auto Restart on Failure |
Specifies whether to automatically restart the task after a failure. When enabled, the system automatically restarts the Streaming task when it exits abnormally. |
|
|
Restart Attempts |
The maximum number of automatic restart attempts after a failure. |
|
|
Restart Interval |
The wait time between each restart attempt, in minutes. |
After you complete the configuration, click the
icon. The node starts or waits based on the Startup Mode setting.
Related documents
-
Data Map (Lindorm table data): You can go to Data Map to collect metadata of Lindorm.