Lindorm Flink Batch node

Updated at:

The Lindorm Flink Batch node of DataWorks submits Flink batch jobs to the Lindorm streaming engine as JAR packages for batch processing of existing data. This topic describes the main workflow for developing tasks with a Lindorm Flink Batch node.

Node introduction

The Lindorm streaming engine is compatible with Flink interfaces and supports submitting Flink jobs as JAR packages. The applicable node type depends on the shape of the job: streaming jobs run persistently and continuously consume data, so use a Lindorm Flink JAR Streaming node; batch jobs exit after the processing is complete and are suitable for batch data processing scenarios, so use a Lindorm Flink Batch node. With a Lindorm Flink Batch node, you can develop, debug, and deploy batch jobs in DataStudio and bring the jobs into the unified scheduling and O&M system of DataWorks.

Limits

  • Resource group limit: A Lindorm Flink Batch node runs only on a serverless resource group, and the resource group must have network connectivity to the Lindorm instance.

  • Job type limit: A Lindorm Flink Batch node supports only Flink jobs that are submitted as compiled JAR packages. SQL and Python jobs are not supported.

Prerequisites

  • A Lindorm instance is created, and a Lindorm computing resource is associated with your DataWorks workspace. The association requires the instance, the database, an access account, and a password, and it must pass the network connectivity test. For more information, see Associate a Lindorm computing resource.

  • The Lindorm streaming engine is enabled for the instance in the Lindorm console, and a Lindorm resource group is created for running Flink jobs.

  • (Optional, required for RAM users) The Resource Access Management (RAM) user who performs the task development is added to the target workspace and holds the Development or Workspace Administrator role. Grant the Workspace Administrator role with care because it carries extensive permissions. For more information about how to add members, see Add members to a workspace.

    Note

    If you use your Alibaba Cloud account, skip this step.

Create a Lindorm Flink Batch node

For the entry point for creating a node, see Data Studio (new version). In the node type list, select Lindorm Flink Batch under the Lindorm group.

Develop a Lindorm Flink Batch node

Development of a Lindorm Flink Batch node mainly includes the following parts: upload the Flink job JAR package as a DataWorks resource file, and configure the submission command and runtime resources of the streaming engine job on the node.

Step 1: Upload the Flink job JAR package as a resource

In Resource Management of DataWorks, create a JAR resource file and upload the compiled Flink job JAR package, for example short-lindorm-flink-batch.jar, so that the node can reference it later. The resource file must be committed and deployed before a task in the production environment can use it.

The following example shows the code of a Flink batch job. The job runs in batch mode, processes one record per second, and processes 20 records in total:

package com.alibaba.lindorm.stream.demo;

import org.apache.flink.api.common.RuntimeExecutionMode;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * Bounded batch job: processes one record per second, 20 records in total.
 */
public class ShortBatchJob {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env =
        StreamExecutionEnvironment.getExecutionEnvironment();

        // Run in batch mode
        env.setRuntimeMode(RuntimeExecutionMode.BATCH);
        env.setParallelism(1);

        env.fromSequence(1, 20)
        .map(new MapFunction<Long, Long>() {
            @Override
            public Long map(Long value) throws Exception {
                Thread.sleep(1000L);
                return value;
            }
        })
        .name("sleep-one-second-per-record")
        .print();

        env.execute("short-lindorm-flink-batch");
    }
}

Step 2: Configure the batch job content

In the code editor of the node, reference the uploaded JAR package resource by using the ##@resource_reference syntax, and use the lstream-cli run command to configure the submission command of the streaming engine job.

Example:

##@resource_reference{"short-lindorm-flink-batch.jar"}
lstream-cli run \
  -D execution.runtime-mode=BATCH \
  --class com.alibaba.lindorm.stream.demo.ShortBatchJob \
  --parallelism 1 \
  short-lindorm-flink-batch.jar

You can configure the node based on the following parameters.

Parameter

Description

-D execution.runtime-mode=BATCH

Required. Sets the Flink execution mode to batch.

--class

Required. The fully qualified name of the main class of the Flink job, namely the class that contains the main method. In the example, the main class is com.alibaba.lindorm.stream.demo.ShortBatchJob. Replace it with the main class of your job.

--parallelism

Optional. The parallelism of the job. If not specified, the default value of the Lindorm streaming engine is used.

JAR package file name

The JAR package file name at the end of the submission command. It must match the file name of the resource referenced by ##@resource_reference.

Debug a Lindorm Flink Batch node

In the configuration pane on the right side of the node editing page, configure the runtime resources of the job. The configuration items currently supported by the Lindorm Flink Batch node are as follows:

Item

Required

Description

Computing Resource

Yes

Select a Lindorm computing resource that is associated with the workspace. Only Lindorm computing resources are supported.

Lindorm Resource Group

Yes

Select a resource group that you created in the Lindorm console. The options load based on the computing resource you selected, so select the computing resource first.

Resource Group

Yes

Select the resource group for scheduling that runs this task. It must have network connectivity to the Lindorm instance.

Script Parameters

No

Add the parameters that the job reads at run time.

After you configure the runtime resources, click Save on the toolbar, and then click Run to debug the node. After the debug run is complete, you can review the submission and execution information of the job in the run log.

Deploy a Lindorm Flink Batch node

After debugging is complete, configure the runtime resources and scheduling properties of the task in the Scheduling Configuration pane on the right side of the node, and then deploy the node to the production environment. After a successful deployment, the task runs in the production environment with the selected scheduling configuration, and you can manage it in Operation Center in a unified manner.

  1. Configure the scheduling configuration.

    Configure the following items in the Scheduling Configuration pane on the right side of the node.

    Item

    Description

    Computing Resource

    On the Scheduling Policy tab, select the Lindorm computing resource associated with your workspace.

    Lindorm Resource Group

    On the Scheduling Policy tab, select the corresponding Lindorm streaming engine resource group.

    Resource Group

    On the Scheduling Policy tab, select a serverless resource group that has passed the network connectivity test.

    Instance generation method

    On the Scheduling Policy tab, select T+1 next-day generation or immediate generation after deployment.

    Scheduling type

    On the Scheduling Policy tab, select normal scheduling, paused scheduling, or dry-run scheduling.

    Maximum number of parallel instances

    On the Scheduling Policy tab, select Unlimited or Limited to set the maximum number of instances that can run concurrently for the task.

    Automatic rerun on failure

    On the Scheduling Policy tab, when enabled, the task is automatically rerun if it fails. You can further set Rerun Count (the maximum number of automatic reruns) and Rerun Interval (the interval between two reruns, in minutes).

  2. Deploy the node.

    After you complete the scheduling configuration, click Deploy on the toolbar to complete deployment package building, production inspector, and deployment to the production environment in sequence. For more information about the deployment process, see Node deployment. After a successful deployment, the task runs in the production environment with the selected scheduling configuration.

Manage batch tasks in Operation Center

After a Lindorm Flink Batch node is deployed to the production environment, you can manage batch jobs in Operation Center in a unified manner:

  • View the running status of batch jobs in Operation Center, perform O&M operations such as stopping and starting tasks, and jump to the job management page of the Lindorm console through the log link.

  • The job status in Operation Center and the Lindorm console is synchronized bidirectionally. When you cancel or start a job in the Lindorm console, Operation Center displays the latest job status (such as Stopped or Running); and vice versa.