Lindorm Spark Streaming node

Updated at:

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

  1. Log on to the DataWorks console.

  2. In the left-side navigation pane, click Data Development.

  3. On the Data Development page, right-click the target workflow and choose Create Node > Lindorm > Lindorm Spark Streaming.

  4. 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:

    1. Log on to the Lindorm console. In the instance list for the corresponding region, find the Lindorm instance that you created.

    2. Click the instance name to go to the instance details page.

    3. In the left-side navigation pane, click Compute Engine to go to the Compute Engine page.

    4. On the Job Management tab, click Upload Resource to open the upload page.

    5. Click the dashed box area, select the JAR package file, and then click Open.

    6. Click Upload to complete the JAR package upload.

    7. 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: com.example.streaming.KafkaToLindorm.

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 ${var} format.

Configuration Items

Configure Spark runtime parameters. For Streaming tasks, we recommend that you configure parameters such as spark.executor.instances and spark.executor.memory based on the data volume. For more information about Spark properties, see the job configuration instructions. You can also set global Spark parameters when you bind a Lindorm computing resource.

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:

    1. Log on to the Lindorm console. In the instance list for the corresponding region, find the Lindorm instance that you created.

    2. Click the instance name to go to the instance details page.

    3. In the left-side navigation pane, click Compute Engine to go to the Compute Engine page.

    4. On the Job Management tab, click Upload Resource to open the upload page.

    5. Click the dashed box area, select the Python file, and then click Open.

    6. Click Upload to complete the Python file upload.

    7. 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 ${var} format.

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 ${ParameterName} format in the code, specify the parameter name and value here. When the task runs, the variables are dynamically replaced with their actual values.

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.

Note

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 image 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 ${ParameterName} format in the code, specify the parameter name and value here.

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 image icon. The node starts or waits based on the Startup Mode setting.

Related documents