A complex event rule description method and compilation system based on Flink
By introducing a textual complex event rule description method into the Flink CEP framework, the difficulty of rule definition and management is solved, ease of use for non-programming users and dynamic loading of rules are achieved, and the flexibility and clarity of the system are improved.
Patent Information
- Application Number
- CN202410662396.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2044-05-27
AI Technical Summary
The existing Flink CEP framework lacks a textual description method for complex event rules, which makes rule definition and management difficult. It also makes it difficult for non-programming users to use its interface to edit complex event rules, resulting in low flexibility.
This paper provides a Flink-based complex event rule description method and compilation system. Complex events and their processing methods are defined in a textual language, including rule description texts for single patterns and pattern groups. The rule description texts are compiled into patterns or pattern groups in Flink using parsing units and compilation units, and then output in dictionary form through an output module.
It reduces the difficulty of operation, improves the universality of use for non-programming users, realizes the dynamic loading of rules and the clarity of the system, and enhances the readability and management efficiency of rules.
Smart Images

Figure CN118778949B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of event processing rules, and in particular to a FlinkCEP-based event rule description method and a compilation system thereof. Background Art
[0002] Complex Event Processing (CEP) refers to the process of analyzing and processing large amounts of event data in real time to identify meaningful patterns and associations, thereby making quick decisions or triggering corresponding actions. Existing complex event processing systems typically use event stream models and rule engines to process events, such as the Flink framework. The Flink framework is a distributed processing engine that can process both unbounded and bounded data streams and perform stateful computations. Flink CEP, a submodule of the framework, enables the application of complex event processing techniques based on stateful data stream computations. It uses user-defined complex event rules from the data stream to obtain the desired data, that is, output complex events that meet the rules. Although Flink provides methods for complex event processing, it does not provide a textual language to describe this method. Complex events can only be defined at the code level, and rules cannot be dynamically loaded during program execution. This makes the definition and management of complex event rules difficult, and programs written using this method are less flexible. Furthermore, for users without programming experience, editing complex event rules using the interface provided by Flink CEP is quite difficult.
[0003] In order to solve the problem that complex event rules in related technologies do not provide a textual description method and cannot be dynamically loaded, the present invention proposes a complex event rule description method and compilation system based on Flink. Summary of the Invention
[0004] To address these issues, the present invention provides a Flink-based complex event rule description method and compilation system. This system uses a textual language to define complex events and their processing methods, reducing user experience. Users without programming experience can also edit complex event rules using the interface provided by Flink CEP, increasing their universality. Furthermore, the textual description method enables dynamic rule loading.
[0005] To achieve the above object, the technical solution adopted by the present invention is:
[0006] A method for describing event rules based on FlinkCEP, including:
[0007] Compile a rule description text for a single pattern or a pattern group, an input module of the compilation system reads the rule description text, determines whether the rule description text belongs to a single pattern rule description text or a pattern group rule description text, calls a first compilation module for the single pattern or a second compilation module for the pattern group, and calls a first parsing unit for the single pattern or a second parsing unit for the pattern group;
[0008] After receiving the corresponding rule description text, the first parsing unit or the second parsing unit checks whether the corresponding rule description text conforms to the corresponding format. If it conforms to the format, the first parsing unit or the second parsing unit segments the corresponding rule description text and extracts components, and transmits the components to the first compiling unit or the second compiling unit.
[0009] The first compilation unit or the second compilation unit compiles the components into a single pattern or pattern group in Flink using an interface provided by Flink, and transmits the single pattern or pattern group to an output module of the compilation system;
[0010] After receiving the single pattern or pattern group, the output module outputs the single pattern or pattern group in the form of a dictionary.
[0011] Preferably, the single pattern rule description text includes a rule name, an event type, a matching condition, a continuity identifier, a quantifier, a greedy identifier, a specified identifier, and a termination condition. The expression of the single pattern rule description text is:
[0012] "Rule name": <event type> [matching condition] continuity identifier (quantifier, specified identifier greedy identifier) _ [termination condition].
[0013] Preferably, the matching conditions include simple conditions and complex conditions, the simple conditions are composed of a binary logical expression, the binary logical expression includes a left operand, a right operand and an operator, and the complex conditions are composed of multiple simple conditions, and the multiple simple conditions are connected by logical operators.
[0014] Preferably, the continuity identifier includes a strict continuity identifier, a loose continuity identifier and an uncertain loose continuity identifier.
[0015] Preferably, the quantifier includes three expressions: a specified number of times, a specified range of times, and greater than a specified number of times.
[0016] Preferably, the pattern group rule description text includes pattern elements and connectors, and the expression of the pattern group rule description text is:
[0017] [schema element]connector[schema element]connector…[schema element].
[0018] Preferably, the mode element includes a single mode name and a skip strategy.
[0019] A compilation system applied to the above-mentioned FlinkCEP-based event rule description method includes an input module, a first compilation module, a second compilation module and an output module.
[0020] Preferably, the first compilation module includes the first parsing unit and the first compilation unit, the first parsing unit is used to parse the input single pattern rule description text into a single pattern rule component text, and the first compilation unit is used to compile the single pattern rule component text into a single pattern in Flink.
[0021] Preferably, the second compilation module includes a second parsing unit and the second compilation unit, the second parsing unit is used to parse the pattern group rule description text into pattern group rule component text, and the second compilation unit is used to compile the pattern group rule component text into a pattern group in Flink.
[0022] The beneficial effects of the present invention are:
[0023] 1. The present invention writes a rule description text for a single pattern or a pattern group. The first parsing unit or the second parsing unit segments the rule description text that conforms to the format and extracts its components. The components are then output to the first compilation unit or the second compilation unit. The first compilation unit or the second compilation unit uses the interface provided by Flink to compile the components into a single pattern or pattern group in Flink, and passes the single pattern or pattern group to the output module of the compilation system. Complex events and their processing methods are defined in a rule text language, which reduces the operator's usage and management difficulty. Even users without programming knowledge can use the interface provided by Flink CEP to edit complex event rules, which improves the universality of use. In addition, the provision of a textual description method enables dynamic loading of rules.
[0024] 2. In complex event processing, dividing rule descriptions into individual patterns and pattern groups can improve system clarity and readability. By breaking down complex rule descriptions into individual patterns, each focused on handling a specific simple event or sequence of events, the rules become clearer and more concise. Pattern groups, meanwhile, logically group these individual patterns, helping to understand and organize the entire rule set at a high level. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 This is a flowchart of a method for describing complex event rules in a specific embodiment of the present application;
[0026] Figure 2 This is a workflow diagram for compiling a single pattern rule description text in a specific embodiment of this application;
[0027] Figure 3 A workflow diagram for compiling rule description texts of a pattern group in a specific embodiment of the present application;
[0028] Figure 4 This is a workflow diagram of the compilation system in a specific embodiment of this application. DETAILED DESCRIPTION
[0029] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0030] See also Figures 1-4 As shown, the present invention relates to a complex event rule description method and compilation system based on Flink.
[0031] A complex event is composed of a series of simple events, interconnected by specific relationships and patterns. In the context of complex event processing (CEP), a complex event typically refers to a sequence or combination of events identified in a data stream based on specific rules and conditions. These events are not just independent data points, but represent higher-level, meaningful business contexts or behavioral patterns.
[0032] Complex Event Processing (CEP): A technology for processing, analyzing, and responding to patterns and relationships in event streams.
[0033] Complex event processing rules are logical expressions used to identify specific patterns and relationships in event streams. These rules define patterns based on event attributes, sequence, time windows, and other conditions. When the sequence of events in the data stream matches the pattern defined by the rules, the CEP system triggers corresponding actions or generates alerts. The design and application of rules are the core of CEP systems, enabling them to extract valuable information from large amounts of real-time data and respond quickly. Complex event processing rules are also called event patterns in Flink.
[0034] Flink: An open-source stream processing framework designed to handle large-scale data streams, it provides high throughput, low latency, and high reliability in real-time data stream processing. Flink has a wide range of applications, including but not limited to real-time data analysis, online advertising, financial market monitoring, and IoT data processing. Due to its powerful functionality and flexibility, Flink has become a key tool in the field of big data processing.
[0035] Flink Complex Event Processing (CEP): A component of the Apache Flink stream processing framework, CEP is specifically designed to identify and process complex event patterns in real-time data streams. CEP defines a set of event patterns, enabling users to detect complex event sequences occurring in data streams that may indicate specific business logic or anomalous behavior.
[0036] Example 1
[0037] A method for describing event rules based on FlinkCEP, including:
[0038] Write the rule description text for a single pattern or pattern group;
[0039] An input module of the compilation system reads the rule description text, determines whether the rule description text belongs to a single pattern rule description text or a pattern group rule description text, calls a first compilation module for the single pattern or a second compilation module for the pattern group, and calls a first parsing unit for the single pattern or a second parsing unit for the pattern group;
[0040] After receiving the corresponding rule description text, the first parsing unit or the second parsing unit checks whether the corresponding rule description text conforms to the corresponding format. If it conforms to the format, the first parsing unit or the second parsing unit segments the corresponding rule description text and extracts components, and transmits the components to the first compilation unit or the second compilation unit.
[0041] The first compilation unit or the second compilation unit compiles the components into a single pattern or pattern group in Flink using an interface provided by Flink, and transmits the single pattern or pattern group to an output module of the compilation system;
[0042] After receiving the single pattern or pattern group, the output module outputs the single pattern or pattern group in the form of a dictionary.
[0043] The expression of the rule description text of a single pattern is:
[0044] "Rule name": <event type> [matching condition] continuity identifier (quantifier, specified identifier greedy identifier) _ [termination condition], where the symbols """, "<>", "[]", "()", and "_[]" are identifiers used by the compilation system to extract the corresponding text language components.
[0045] Rule name, which is used to describe the name of the rule in a single pattern rule description statement. This part is a required part of the description statement and can be set according to user needs.
[0046] Event type, used in a rule description statement to describe the event type matched by the rule.
[0047] Matching conditions are used to describe the matching conditions in the rule description statement.
[0048] Continuity identifier: The part used in the rule description statement to describe the continuity of the rule.
[0049] Quantifier, used in the rule description statement to describe the number of times the rule is repeated.
[0050] Greedy identifier, used in rule descriptions to indicate whether the rule matches greedily. In rule descriptions, it is represented by the letter g.
[0051] Specifies an identifier used in rule descriptions to indicate whether a rule is optional. It is represented by the letter o in rule descriptions.
[0052] The termination condition is the part of the rule description statement used to describe the termination condition of the rule. This part starts with the symbol "_" and is followed by the above-mentioned matching condition to indicate the termination condition.
[0053] A simple condition consists of a binary logical expression, which includes a left operand, a right operand, and an operator. The left and right operands can be constants or attributes of instances generated by the event type specified by the rule, and the operator can be “>(greater than)”, “<(less than)”, “=(equal to)”, “>=(greater than or equal to)”, “<=(less than or equal to)”, or “!=(not equal to)”.
[0054] A compound condition is composed of multiple simple conditions and is represented by connecting them using the "∨ (or)" and "∧ (and)" logical operators.
[0055] The continuity identifier can be of the following three types:
[0056] Strict continuity is indicated by “·” in the rule description statement.
[0057] Loose continuity is indicated by “~” in the rule description statement.
[0058] Uncertain loose continuity is represented by “~~” in the rule description statement.
[0059] There are three forms of quantifiers:
[0060] Specify the number of matches. Specify a constant n in the rule description statement so that the number of matches for the rule described is n.
[0061] To specify a match range, specify two constants n and m in the rule description statement so that the match count of the rule described is between n and m.
[0062] Greater than the specified number of times: Specify a constant n in the rule description statement and add a ":" symbol after the number to make the number of matches of the described rule greater than n.
[0063] In Flink CEP, there is no direct interface for expressing a count less than a specified number. However, you can express a count less than a specified number by specifying a count range (0, n).
[0064] It also includes the pattern group rule description text, which is used to describe the sentence of the pattern group rule and consists of several pattern elements and several connectors. Its complete form is as follows: [pattern element] connector [pattern element] connector…[pattern element];
[0065] The pattern element is used to indicate the position of a single pattern in the pattern group and its skipping strategy in the pattern group rule description statement;
[0066] A connector is used to describe how the single pattern after the connector is connected to the pattern group before the single pattern.
[0067] Example 2
[0068] refer to Figure 2 As shown, this embodiment is the compilation workflow of the single pattern rule description text described in the above embodiment 1, and the steps are as follows:
[0069] Step S201: The compiling module starts running and waits for data input;
[0070] Step S202: Read in a text list of rule descriptions for a single pattern. The text list is user-defined and stores rule descriptions for multiple single patterns of complex conditions.
[0071] Step S203: Create an empty pattern list for storing successfully compiled patterns in subsequent steps;
[0072] Step S204, checking whether the rule description text list is empty, if it is empty, skipping the compilation process directly until output step S226, otherwise entering the compilation step S205;
[0073] Step S205, check whether a rule text can be parsed from the list, if it can be parsed, jump to S206, otherwise jump to output step S226;
[0074] Step S206, parse the first rule description text from the list;
[0075] Step S207, check whether the parsed rule description text has format errors. If there are errors, skip parsing of the rule and jump to S208. Otherwise, continue the compilation process and jump to S209. Whether the format is incorrect specifically refers to:
[0076] "Rule Name" and "Event Type" are required parts of the description statement. If these parts are not present, the statement is incorrect.
[0077] "Continuity identifier" and "quantifier" are optional components and must exist at the same time, and the existence of "matching condition" is a prerequisite, so the statement is incorrect;
[0078] Step S208, discarding the rule description text that failed to compile;
[0079] Step S209: extract the "rule name" from the rule description text, remove the extracted part from the original rule description text, use it as the processed rule description text, and pass the processed rule text downward;
[0080] In step S210, the "event type" is extracted from the rule description text obtained in S209, and the "event type" is removed from the rule description text. The removed rule description text is then passed down. At this point, the rule initialization conditions are met. The relevant Flink pattern definition statement is called to obtain an initialized pattern, which is then passed down. The initialization uses the "event type" to set the pattern generic type and the "rule name" to set the pattern name.
[0081] Step S211: Extract the text describing the "matching condition" from the rule description text obtained in S210. The "matching condition" may be a "complex condition", that is, the "matching condition" is composed of n "simple conditions" and n-1 "∨ (or)" and "∧ (and)" alternatingly. Remove the "matching condition" from the rule description text, and pass the text describing the "matching condition" and the rule description text without the "matching condition" to step S212.
[0082] Step S212, checking whether a "simple condition" can be extracted from the text describing the current "matching condition", if so, jumping to step S213, otherwise jumping to step S215 and passing the current mode to step S215;
[0083] Step S213, extracting a "simple condition" from the text describing the "matching condition", removing the "simple condition" from the text describing the "matching condition", and passing the "simple condition" and the text describing the "matching condition" to S214;
[0084] Step S214: Compile the "simple condition" and add the compiled "simple condition" to the previous pattern, update the pattern, and pass the pattern to step S212. Specifically, the compilation process is to parse the "simple condition" into a left operand, a right operand, and an operator, and use it as a binary logical operation function to enable it to produce a Boolean value type result. This function is passed to the simpleCondition class in Flink to obtain an instance. The "∨ (or)" and "∧ (and)" operators before the "matching condition" determine the connection method between the instance and the previous pattern. That is, if the "∨ (or)" is used, "or()" is used for connection; if the "∧ (and)" is used, "where()" is used for connection.
[0085] Step S215, check whether the rule description text obtained from S212 has a "continuity identifier", if yes, jump to S216, if not, pass the pattern and rule description text downward, jump to S218;
[0086] Step S216: Obtain the "continuity identifier", remove the "continuity identifier" from the rule description text, and pass the rule description text after removing the "continuity identifier" downward;
[0087] Step S217, compile the "continuity identifier", add continuity to the pattern obtained in step S215, and pass the pattern to step S218. The compilation is based on the specific type of the continuity identifier. If it is "·", the "consecutive()" method of the pattern is called to add strict continuity. If it is "~~", the "allowCombinations()" method of the pattern is called to add uncertain loose continuity. If it is "~", it means using the default loose continuity and no operation is required.
[0088] Step S218, check whether the rule description text obtained from S215 contains "quantifier", "greedy identifier" and "optional identifier". If yes, jump to S219, otherwise jump to S221 and pass the pattern and rule description text to 221;
[0089] Step S219: parse out the "quantifier", "greedy identifier", and "optional identifier" in the rule description text, and remove the "quantifier", "greedy identifier", and "optional identifier" from the rule description text, and pass the pattern and the rule description text after removal to step S220;
[0090] Step S220, based on the contents of the "quantifier", "greedy identifier" and "optional identifier", the pattern is updated, and the pattern and rule description text are passed to step S221. The update, i.e., based on the type of the "quantifier", the quantifier, greedy identifier and optional identifier of the current rule are set. If it is "specified number of times" or "specified number range", the "times()" method is called based on the original pattern. If it is "greater than the specified number of times", the "timesOrMore()" method is called based on the pattern of S215, and the pattern is updated. Based on the presence or absence of the "greedy identifier", it is decided whether to call the "greedy() method" based on the updated pattern, and the pattern is updated. Based on the presence or absence of the "optional identifier", it is decided whether to call the "optional()" method, and the pattern is updated.
[0091] Step S221, check whether the passed rule description text has a "termination condition", if so, jump to step S222, pass the pattern and rule description text to step S222, otherwise jump to step S224, pass the pattern and rule description text to step S224;
[0092] Step S222: Obtain the "termination condition" from the passed rule description text, parse the "termination condition" text, remove the "termination condition" from the rule description text, update the rule description text, and pass the updated rule description text, the parsed "termination condition" text, and the pattern to S223;
[0093] Step S223 sets the termination condition for the current rule and calls the until() method of the pattern, passing the compiled condition in. The pattern is updated, and the updated pattern and rule description text are passed to step S224. The compilation parses the "simple condition" in the termination condition into a left operand, a right operand, and an operator, treating it as a binary logical operation function that produces a Boolean result. This function is passed to the simpleCondition class in Flink to obtain an instance, which is then passed to the until() method.
[0094] Step S224, adding the current rule to the list created in step S203;
[0095] Step S225, outputting a compiled singleton pattern list;
[0096] Step S226, end the compilation process.
[0097] Example 3
[0098] refer to Figure 3 As shown, this embodiment is the compilation workflow of the pattern group rule description text described in the above embodiment 1, and the steps are as follows:
[0099] Step S301: The compiling module starts running and waits for data input;
[0100] Step S302: Input a complex event pattern group rule description text and a compiled singleton pattern list, wherein the complex event pattern group rule description text is defined by the user and may contain multiple complex event pattern group rules, and the compiled singleton pattern list is the output of the text compilation module of the description method for a single pattern;
[0101] Step S303: Check the complex event pattern group rule description text or the compiled singleton pattern list. If the complex event pattern group rule description text is empty, it means that no compilation operation is required. If the compiled singleton pattern list is empty, it means that no singleton pattern can be provided for subsequent compilation operations. If either of the above is empty, jump to step S317; otherwise, enter the compilation process and jump to step S304;
[0102] Step S304: Create an empty pattern group list to store the results of the pattern group compilation module;
[0103] Step S305, checking whether the complex event pattern group rule description text contains the next pattern group rule, if so, jump to step S306, otherwise jump to step S316;
[0104] Step S306, taking out a pattern group rule from the complex event pattern group rule description text, removing the pattern group rule from the complex event pattern group rule description text, updating the complex event pattern group rule description text, and transferring the complex event pattern group rule description text and the pattern group rule in step S307;
[0105] Step S307: Check whether the extracted pattern group rules have format errors. If so, jump to step S308; otherwise, jump to step S309 and pass the complex event pattern group rule description text and pattern group rules to step S309. The format error means that the pattern group rule cannot start with a connector and must be organized in the form of "[pattern name of a single pattern, skip strategy] connector [pattern name of a single pattern, skip strategy] connector ... [pattern name of a single pattern, skip strategy]";
[0106] Step S308: discarding rules with format errors;
[0107] Step S309: Initialize the pattern group. The pattern group is now an empty pattern group, so that content can be added to the pattern group in subsequent steps.
[0108] Step S310, checking whether the pattern group rule text begins with a connector. If it does, it means that the currently processed pattern group is not compiled from the beginning but is being compiled. Jump to step S311 and pass the complex event pattern group rule description text and pattern group to step S311. Otherwise, jump to step S312 and pass the complex event pattern group rule description text and pattern group to step S313.
[0109] Step S311: Select the “connection mode” to connect the subsequent pattern elements according to the connector. The “connection mode” refers to:
[0110] Strictly continuous connection: The event matched by the pattern defined after this connection mode must directly follow the previously matched event (strictly continuous);
[0111] Loose continuation: The pattern defined after this connector can have other events appearing between the matched event and the previously matched event (loose continuation).
[0112] Uncertain loose continuation connection: The pattern defined after this connector can have other events appearing between the matched event and the previously matched event. Each optional matching event will be output as an optional matching result (uncertain loose continuation);
[0113] Anti-strict continuous connection: the (negated) event of the pattern matching defined after this connector must directly follow the previously matched event (strict continuity) to discard these partial matches;
[0114] Anti-loose continuation: The pattern defined after this connector will discard partially matched event sequences (loose continuation) even if other events occur between the matched (negated) event and the previously matched event.
[0115] Step S312, check whether the pattern group rule text at this time begins with a pattern element, if not, jump to step S318, otherwise jump to step S313,
[0116] Step S313: Parse the pattern element to obtain the string variable "pattern name of single pattern" and the string variable "skip strategy". If the pattern element does not contain "skip strategy", the "skip strategy" is empty.
[0117] Step S314, check whether there is a "skip strategy" in the pattern element, that is, whether the skip strategy is empty. If so, jump to step S315 and pass the connection mode, complex event pattern group rule description text and pattern group to step S315; otherwise, jump to step S316 and pass the connection mode, complex event pattern group rule description text and pattern group rules to step S316;
[0118] Step S315, add a "skip strategy" for the current single pattern, and pass the "skip strategy", "pattern name of the single pattern", "skip strategy", "connection mode", complex event pattern group rule description text and pattern group to step S316. The skip strategy includes:
[0119] NO_SKIP: Each successful match is output and is indicated by "NS" in the description method for the pattern group.
[0120] SKIP_TO_NEXT: Discard all partial matches that start with the same event, indicated by "S2N" in the description method for pattern groups.
[0121] SKIP_PAST_LAST_EVENT: Discard all partial matches starting between the start and end of this match, indicated by "SPLE" in the description method for the pattern group.
[0122] SKIP_TO_FIRST: Discard all partial matches between the start of this match and the first occurrence of a single pattern name, indicated by "S2F" in the description method for pattern groups.
[0123] SKIP_TO_LAST: Discard all partial matches between the start of this match and the last occurrence of a single pattern name, represented by "STL" in the description method for pattern groups.
[0124] Step S316, add the current pattern element to the current pattern group, obtain the singleton pattern from the compiled singleton pattern list through the "pattern name of the single pattern", add the singleton pattern to the current pattern group, and pass the complex event pattern group rule description text and pattern group to S317;
[0125] Step S317, removing the currently parsed content from the rule description text, that is, removing the currently parsed content from the "pattern group rule description text" so that parsing can continue in the next cycle;
[0126] Step S318, adding the compiled pattern group to the pattern group list for output;
[0127] Step S319: Output the compiled pattern group list to the outside of the compilation module;
[0128] Step S320, end the compilation process.
[0129] Example 4
[0130] The above-mentioned embodiment 2 and embodiment 3 are combined to realize the function of expressing complex event processing rules in Flink through text language. The collaborative workflow of the two modules is shown in the following figure: Figure 4 As shown, the steps are as follows:
[0131] Step S401, the system starts running and waits for input;
[0132] Step S402: input a pattern rule description statement, which may be a description statement for a single pattern or a description statement for a pattern group;
[0133] Step S403, check whether the statement can be compiled into a singleton mode, if yes, jump to S404, if not, jump to S405;
[0134] Step S404, running the compilation module of the description method for a single mode;
[0135] Step S405, running the compilation module of the description method for the pattern group;
[0136] Step S406: Integrate and output the outputs of the two modules;
[0137] Step S407, end the system operation.
[0138] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0139] The above embodiments are merely descriptions of preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary engineering technicians in this field should fall within the scope of protection determined by the claims of the present invention.
Claims
1. A method for describing event rules based on FlinkCEP, characterized in that: include: Compile a rule description text for a single pattern or a pattern group, an input module of the compilation system reads the rule description text, determines whether the rule description text belongs to a single pattern rule description text or a pattern group rule description text, and calls a first parsing unit for the single pattern or a second parsing unit for the pattern group; After receiving the corresponding rule description text, the first parsing unit or the second parsing unit checks whether the corresponding rule description text conforms to the corresponding format. If it conforms to the format, the first parsing unit or the second parsing unit segments the corresponding rule description text and extracts components, and transmits the components to the first compilation unit or the second compilation unit. The first compilation unit or the second compilation unit compiles the components into a single pattern or pattern group in Flink using an interface provided by Flink, and transmits the single pattern or pattern group to an output module of the compilation system; After receiving the single pattern or pattern group, the output module outputs the single pattern or pattern group in the form of a dictionary; The single pattern rule description text includes a rule name, an event type, a matching condition, a continuity identifier, a quantifier, a greedy identifier, a specified identifier, and a termination condition. The expression of the single pattern rule description text is: "Rule name": <event type> [matching condition] continuity identifier (quantifier, specified identifier greedy identifier) _ [termination condition]; The pattern group rule description text includes pattern elements and connectors. The expression of the pattern group rule description text is: [schema element] connector [schema element] connector ... [schema element]; The first parsing unit is used to parse the input single pattern rule description text into a single pattern rule component text, and the first compiling unit is used to compile the single pattern rule component text into a single pattern in Flink; The second parsing unit is used to parse the pattern group rule description text into pattern group rule component texts, and the second compiling unit is used to compile the pattern group rule component texts into a pattern group in Flink; Among them, the quantifier is the part used to describe the number of times the rule is repeated in the rule description statement; The greedy identifier is used in the rule description statement to describe whether the rule is greedy matching; Specifies the identifier used in the rule description statement to describe whether the rule is optional; The termination condition is the part in the rule description statement used to describe the termination condition of the rule; Simple conditions are composed of binary logical expressions, which include left operand, right operand and operator. A complex condition is composed of multiple simple conditions connected by logical operators; Wherein, according to the connector, select the connection mode to connect the subsequent pattern elements, and the connection mode includes: Strict continuous connection, loose continuous connection, uncertain loose continuous connection, anti-strict continuous connection and anti-loose continuous connection.
2. The event rule description method based on FlinkCEP according to claim 1 is characterized in that: The matching conditions include simple conditions and complex conditions.
3. The event rule description method based on FlinkCEP according to claim 1 is characterized in that: The continuity identifier includes a strict continuity identifier, a loose continuity identifier and an indeterminate loose continuity identifier.
4. The event rule description method based on FlinkCEP according to claim 1 is characterized in that: The quantifier includes three forms of expression: a specified number of times, a specified range of times, and greater than a specified number of times.
5. The event rule description method based on FlinkCEP according to claim 1 is characterized in that: The pattern element includes a single pattern name and a skip strategy.
6. A compilation system applied to the FlinkCEP-based event rule description method according to any one of claims 1 to 5, characterized in that: It includes an input module, a first compiling module, a second compiling module and an output module.
7. The compilation system of the event rule description method based on FlinkCEP according to claim 6, characterized in that: The first compilation module includes the first parsing unit and the first compilation unit.
8. The compilation system of the event rule description method based on FlinkCEP according to claim 6, characterized in that: The second compilation module includes a second parsing unit and the second compilation unit.
Citation Information
Patent Citations
Event processing method and system, electronic equipment and computer readable medium
CN116049234A
Event processing method and device, electronic equipment and storage medium
CN117009039A