A Flink automatic integration method and system

The template engine automatically generates Flink core code and realizes automatic deployment, which solves the problems of cumbersome operations and version dependence in existing technologies, realizes automatic deployment and dynamic code generation of Flink projects, and improves configuration efficiency and deployment flexibility.

CN113805851BActive Publication Date: 2024-10-01SHANGHAI DEFINESYS INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110991764.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-27
Publication Date
2024-10-01
Estimated Expiration
2041-08-27

AI Technical Summary

Technical Problem

The existing Flink integration solution is cumbersome to operate, over-reliant on versions, and cannot implement Restful interfaces, resulting in inconvenient upgrades and inconvenient interfaces provided by other platforms.

Method used

It uses a template engine to automatically generate Flink core code and dynamically generates code through the Restful interface to achieve automatic deployment and reduce the risk of human errors. It supports remote push and is independent of version control. The code is pushed through a combination of Java and SSH commands and packaged as a Jar package using Maven. .

Benefits of technology

It realizes the automated deployment of Flink projects, reduces the complexity of manual writing and deployment, supports dynamic code generation, improves configuration efficiency, supports deployment of any target server, is not subject to version control, and simplifies code management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113805851B_ABST
    Figure CN113805851B_ABST
Patent Text Reader

Abstract

The present invention relates to a Flink automatic integration method and system, the method includes obtaining a Flink configuration request body, parsing the Flink configuration request body, automatically generating the core code of Flink in a preset template engine; pushing the core code to a designated server; pushing the core code to a designated path through the server, and generating a running record script file; packaging and pushing the core code to the Flink platform through the server for pipeline control, and executing the running record script file to obtain real-time log and process status information; the template engine is provided with an environment initialization template, a source data source template, a target data source template, a business interception logic template, a data replacement logic template and a target execution logic template, and the core code of Flink is generated by integrating the data generated by each template. Compared with the prior art, the present invention has the advantages of automatically generating code, reducing the risk of human error, supporting remote push, and not being subject to version control.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Flink integration technology, and in particular to a Flink automatic integration method and system. Background Art

[0002] Currently, most Flink integration solutions use SpringBoot to directly write project programs for specific needs, integrate all requirements into one project, and then manually package them into Jar packages and publish them to the Flink platform for pipeline control.

[0003] For example, the invention disclosed in the authorization announcement number CN111752545B discloses a stream computing method that supports data replay, and its main scheme includes: step 1, defining the backup and preservation mechanism of the task task and the snapshot backup and recovery interface SnapShotInterface that the task task needs to implement in the stream platform; step 2, the user writes the implementation class of SnapShotInterface in the implementation of the task task, and the final form is a packaged jar package; step 3, submitting the jar package to the stream platform for processing, and the stream computing platform periodically calls the backup method of the implementation class to save the backed-up data to hdfs; step 4, when the task task fails to execute, when restarting the task task, the stream processing platform executes the recover method of the implementation class of SnapShotInterface to read the save point file from hdfs and restore the data, and then re-executes the task task.

[0004] This method also requires the user to write the implementation class of SnapShotInterface in the implementation of the task. The final form is a packaged jar package, that is, a manual processing method is adopted. Currently, these solutions have the following disadvantages:

[0005] 1. The operation is cumbersome. Whenever new requirements are added, the code needs to be rewritten, and then debugging and docking are performed.

[0006] 2. Over-reliance on Flink versions makes upgrades inconvenient and requires modifying all related codes in the project before upgrading.

[0007] 3. Unable to implement Restful interface and provide convenient interface for other platforms. Summary of the invention

[0008] The purpose of the present invention is to provide a Flink automatic integration method and system in order to overcome the defects of the above-mentioned prior art, such as cumbersome operation and excessive dependence on the Flink version.

[0009] The purpose of the present invention can be achieved by the following technical solutions:

[0010] A Flink automatic integration method includes the following steps:

[0011] S1: Obtain the Flink configuration request body, parse the Flink configuration request body, and automatically generate the Flink core code in the preset template engine;

[0012] S2: Push the core code to a designated server;

[0013] S3: Pushing the core code to a specified path through the server;

[0014] S4: The core code is packaged and pushed to the Flink platform through the server for pipeline control.

[0015] Furthermore, the template engine is provided with an environment initialization template, a source data source template, a target data source template, a business interception logic template, a data replacement logic template and a target execution logic template.

[0016] The environment initialization template is used to generate the code of the Flink basic environment;

[0017] The source data source template is used to generate the object configuration of the Flink pipeline source data source;

[0018] The target data source template is used to generate the object configuration of the Flink pipeline synchronization target data source;

[0019] The business interception logic template is used to generate the code of the relevant interception logic in the Flink pipeline;

[0020] The data replacement logic template is used to generate the code for replacing related fields in the Flink pipeline;

[0021] The target execution logic template is used to generate Flink pipeline execution code;

[0022] The template engine also integrates the data generated by each template to generate the core code of Flink.

[0023] Furthermore, the code of the Flink basic environment includes the code of EnvironmentSettings, TableEnvironment and Pipeline;

[0024] The object configuration of the Flink pipeline source data source includes: source database connection information, user name, password, synchronization field information and Kafka information;

[0025] The object configuration of the Flink pipeline synchronization target data source includes: connection information, user name, password, and synchronization field information of the target database;

[0026] The code of the relevant interception logic in the Flink pipeline includes: greater than logic, less than logic, inclusion logic, and not equal to logic;

[0027] The Flink pipeline execution code includes an insert operation, a delete operation, and a modify operation.

[0028] Furthermore, step S3 also includes: generating a running record script file in the server, and step S4 also includes: after the core code is packaged and pushed to the Flink platform, executing the running record script file to obtain real-time log and process status information.

[0029] Furthermore, an automation script file is pre-deployed in the specified server, and the automation script file is used to push the core code to a specified path, generate the operation record script file, and package the core code and push it to the Flink platform.

[0030] Furthermore, step S2 is specifically as follows: pushing the core code to a designated server by combining Java commands with SSH commands.

[0031] Furthermore, in step S4, the core code is packaged into a Jar package by Maven.

[0032] Furthermore, the Flink configuration request body is generated through a Restful interface.

[0033] The present invention also provides a Flink automatic integration system, including a memory and a processor, wherein the memory stores a computer program, and the processor calls the computer program to execute the steps of the above method.

[0034] Compared with the prior art, the present invention has the following advantages:

[0035] (1) The present invention proposes to use a template engine to automatically generate Flink's core code according to Flink pipeline configuration information, and then push it to the server to implement automatic packaging and publishing of the code in the server, which has the following advantages:

[0036] Flink code can be dynamically generated and automatically deployed through the Restful interface;

[0037] Automatically generate code to reduce the risk of human error in manual writing and manual server deployment;

[0038] Support remote push, and deploy Flink projects to any target server;

[0039] Not subject to version control, all programs can be modified by simply modifying the template file.

[0040] (2) The principle of dynamic code generation in the present invention focuses on the Freemarker template specification, which divides the Flink source code into six parts: environment initialization template, source data source template, target data source template, business interception logic template, data replacement logic template, and target execution logic template, which is convenient for targeted modification and more efficient and convenient configuration of the core code. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 The figure is a flowchart of a Flink automatic integration method provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0042] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0043] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0044] Example 1

[0045] This embodiment provides a Flink automatic integration method, including the following steps:

[0046] S1: Obtain the Flink configuration request body, parse the Flink configuration request body, and automatically generate the Flink core code in the preset template engine;

[0047] S2: Push the core code to the specified server;

[0048] S3: Push the core code to the specified path through the server;

[0049] S4: The core code is packaged and pushed to the Flink platform through the server for pipeline control.

[0050] The template engine has environment initialization template, source data source template, target data source template, business interception logic template, data replacement logic template and target execution logic template.

[0051] Environment initialization template, used to generate the code for the Flink basic environment, including: source database connection information, user name, password, synchronization field information, and Kafka information;

[0052] Source data source template, used to generate the object configuration of the source data source of the Flink pipeline, including the connection information, user name, password, synchronization field information, Kafka information, etc. of the source database;

[0053] The target data source template is used to generate the object configuration of the Flink pipeline synchronization target data source, including the connection information, user name, password, synchronization field information, etc. of the target database;

[0054] Business interception logic template, used to generate code for related interception logic in Flink pipeline, including greater than, less than, included, and not equal to logic;

[0055] Data replacement logic template, used to generate code for related field replacement in Flink pipeline, including field replacement;

[0056] Target execution logic template, used to generate Flink pipeline execution code, including insert operations, delete operations, and modify operations;

[0057] The template engine also integrates the data generated by each template to generate the core code of Flink.

[0058] Preferably, to obtain Flink operation information, step S3 further includes: generating an operation record script file in the server, and step S4 further includes: after the core code is packaged and pushed to the Flink platform, executing the operation record script file to obtain real-time log and process status information.

[0059] An automation script file is pre-deployed in the specified server. The automation script file is used to push the core code to the specified path, generate a running record script file, and package the core code and push it to the Flink platform.

[0060] In this embodiment, step S2 specifically includes: pushing the core code to the designated server by combining Java commands with SSH commands.

[0061] In step S4, the core code is packaged into a Jar package using Maven.

[0062] The following is a detailed introduction to the specific implementation process of this Flink automatic integration method.

[0063] Flink automatic integration method, which uses dynamic code generation. The front end transmits the configuration request plus the ExecuteId execution identifier. First, Freemarker+Java is used to generate the core code of Flink. Then, the core code is pushed to the specified server through Java local commands combined with SSH. Then, the core code is pushed to the specified path through the Python3 script file on the server and an executable Bash script (ExecuteId.sh) is generated. Finally, the Bash script is automatically run. The Flink project code is packaged into a Jar package through Maven, and then pushed to the Flink platform, and the log is written to the ExecuteId.log file. The specific steps include:

[0064] Step 1: Pass the execution identifier ExecuteId and Flink configuration request body to the backend through the Restful interface, and then execute step 2;

[0065] Step 2: The backend uses algorithms and Freemarker to parse the Flink configuration request body, and then executes step 3;

[0066] Step 3: Save the parsed Flink core code as a String and proceed to step 4.

[0067] Step 4: Use Java command calls combined with SSH commands to encapsulate the Flink core code and push it to the target server, and then proceed to step 5.

[0068] Step 5: The automated deployment script file flink.py needs to be written in advance on the server, and then proceed to step 6;

[0069] Step 6: The server automatically executes the command 'python3 flink.py Flink core code', and then executes steps 7 and 8;

[0070] Step 7: Generate an executable script file ExecuteId.sh according to ExecuteId, and proceed to step 11;

[0071] Step 8: The flink.py script will automatically push the Flink core code to the specified location, and then execute steps 9 and 10.

[0072] Steps 9 and 10: The flink.py script will automatically use the Maven tool to package the Flink project code. Then proceed to step 11.

[0073] Step 11: When all the above steps are completed successfully, the flink.py script will execute the final command 'nohup bash ExecuteId.sh>>ExecuteId.log'. In subsequent operations, the front end can directly query the running log content through ExecuteId again, and use the command 'ps-eo pid,command|grep bashExecuteId.sh' to query the entire life cycle of the Flink pipeline in real time.

[0074] This embodiment further provides a Flink automatic integration system, including a memory and a processor, wherein the memory stores a computer program, and the processor calls the computer program to execute the steps of the Flink automatic integration method as described above.

[0075] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.

Claims

1. A Flink automatic integration method, characterized in that: The following steps are involved: S1: Obtain the Flink configuration request body, parse the Flink configuration request body, and automatically generate the Flink core code in the preset template engine; S2: Push the core code to a designated server; S3: Pushing the core code to a specified path through the server; S4: The core code is packaged and pushed to the Flink platform through the server for pipeline control; The template engine is provided with an environment initialization template, a source data source template, a target data source template, a business interception logic template, a data replacement logic template and a target execution logic template. The environment initialization template is used to generate the code of the Flink basic environment; The source data source template is used to generate the object configuration of the Flink pipeline source data source; The target data source template is used to generate the object configuration of the Flink pipeline synchronization target data source; The business interception logic template is used to generate the code of the relevant interception logic in the Flink pipeline; The data replacement logic template is used to generate the code for replacing related fields in the Flink pipeline; The target execution logic template is used to generate Flink pipeline execution code; The template engine also integrates the data generated by each template to generate the core code of Flink; The Flink basic environment code includes EnvironmentSettings, TableEnvironment, and Pipeline codes; The object configuration of the Flink pipeline source data source includes: source database connection information, user name, password, synchronization field information and Kafka information; The object configuration of the Flink pipeline synchronization target data source includes: connection information, user name, password, and synchronization field information of the target database; The code of the relevant interception logic in the Flink pipeline includes: greater than logic, less than logic, inclusion logic, and not equal to logic; The Flink pipeline execution code includes insert operation, delete operation, and modify operation; Step S3 also includes: generating a running record script file in the server, and step S4 also includes: after the core code is packaged and pushed to the Flink platform, executing the running record script file to obtain real-time log and process status information; An automation script file is pre-deployed in the specified server, and the automation script file is used to push the core code to a specified path, generate the operation record script file, and package the core code and push it to the Flink platform.

2. A Flink automatic integration method according to claim 1, characterized in that: Step S2 specifically includes: pushing the core code to a designated server by combining Java commands with SSH commands.

3. A Flink automatic integration method according to claim 1, characterized in that: In step S4, the core code is packaged into a Jar package by Maven.

4. A Flink automatic integration method according to claim 1, characterized in that: The Flink configuration request body is generated through a Restful interface.

5. A Flink automatic integration system, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and the processor calls the computer program to execute the steps of any one of the methods according to claims 1 to 4.