Program listings in the disclosure of this patent document contain material that is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or the patent disclosure, as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever.
The present invention relates generally to computer systems and software, and specifically to tools and methods for programming the response of a computer system to specified events.
There are many applications in which a computer must detect, evaluate and respond to events. Such events may include substantially any occurrence of interest that is detected by the computer, such as a change in the price of a stock, the beginning of a banking transaction, change of an entry in a database, or a suspected fault in a computer or communication system. The timing, sequence and content of these events are generally not known in advance. Various tools have been developed in order to allow events and their attendant reactions to be specified in a general, flexible way.
For example, U.S. Pat. No. 6,604,093 describes a situation awareness system. The system uses a language that enables complex events to be defined as the composition of multiple simple events, such as successive withdrawals from one or more bank accounts. In addition, a particular order and other timing constraints on the component events may be specified. Once the complex event has been detected, there may be one or more conditions that qualify the event, for example, that the amounts of the withdrawals be greater than a specified threshold. If the conditions are satisfied, then an action is triggered, such as alerting the bank's security manager of a possible fraud.
Aspects of the situation management system described in U.S. Pat. No. 6,604,093 are implemented in IBM Active Middleware Technology™ (formerly known as AMiT), a situation management tool developed at IBM Haifa Research Laboratory (Haifa, Israel). This tool is described in an article by Adi and Etzion entitled, “AMiT—the Situation Manager,” VLDB Journal 13(2) (Springer-Verlag, May, 2004), pages 177-203.
Some event-processing systems have real-time performance requirements that cannot always be met by conventional, general-purpose processing engines such as the one provided by IBM Active Middleware Technology. In telecommunications applications, for example, a variety of adjunct switching services such as debit-based billing, number mapping, call forwarding, and local-number portability involve event processing during the critical call-connection phase of a telephone call. To meet the real-time requirements of the network, the service time for such events generally must not exceed a few milliseconds. These limitations have led to the use of custom database systems for many high-performance real-time event processing applications.
As an alternative, U.S. Pat. No. 6,496,831 describes a general-purpose real-time event processing system (EPS), which is said to avoid the problems associated with custom systems. The EPS uses one or more real-time analysis engines (RAEs), operating in conjunction with a main-memory storage manager as its underlying database system. The main-memory storage manager offers transactional access to persistent data, but at the speed of a main-memory system. The EPS may implement a parallel arrangement of RAEs for scalability as workload and resources increase. Other real-time event processing systems are described in U.S. Pat. No. 6,449,618, U.S. Pat. No. 6,502,133, U.S. Pat. No. 6,681,230, and U.S. Pat. No. 6,968,552.
A disclosed embodiment of the present invention provides a method for information processing. Respective execution times are determined for a plurality of operations on a selected computing platform. A rule is defined as including a complex event and an action to be performed upon occurrence of the complex event. Software code is automatically generated to implement the rule on the selected computing platform. The code invokes a sequence of the operations responsively to the occurrence of the complex event. A worst-case estimate of a duration of execution of the software code is computed based on the respective execution times of the operations in the sequence. When the worst-case estimate is no greater than a predetermined limit, the software code may be run on the selected computing platform so as to cause the action to be performed when the rule is satisfied.
Other embodiments of the invention provide apparatus and computer software products.
The present invention will be more fully understood from the following detailed description of the embodiments thereof, taken together with the drawings in which:
The term “real-time processing” can have different meanings in different applications. In the field of event processing, the term generally means that the event-processing system completes its handling of a given event within a short time of the occurrence of the event. Even “short” in this context is not well defined, since some real-time applications may require that events be processed within a few milliseconds of occurrence (or even less), while others require that processing be completed within seconds or even minutes of the event. What is common, however, to all of these “real-time” applications is that there is a specified time limit that the event-processing software must reliably meet. General-purpose event-processing engines, such as the above-mentioned IBM Active Middleware Technology engine, can be configured flexibly to perform a wide range of event-processing tasks, but they do not generally offer this sort of real-time performance predictability.
Embodiments of the present invention, on the other hand, provide methods and systems for automatic generation of software code for real-time event processing in which processing time for specified complex events is guaranteed to be no greater than a specified limit. This sort of system, as described in detail hereinbelow, generates code to implement declarative definitions of event processing rules that are input by a user. By analyzing the operations that the code will have to perform in processing a given rule, the code generation system is able to compute in advance a worst-case estimate of the duration of execution of the code on a given computing platform. The user can thus determine with high confidence that the real-time performance of the code will be adequate, or take corrective measures if the worst-case estimate is too high.
For each rule that is defined by user 24, processor 22 determines the sequence of processing operations that will have to be performed by the corresponding software code, and then looks up the worst-case execution time for each operation in a data repository 30, such as a database. Typically, these execution times are measured in advance for each type of operation by running benchmark execution tests on a test platform 32, using methods of benchmarking that are known in the art. The execution time for each type of operation depends, of course, on the computing platform on which the software is to execute. Therefore, for each type of operation, repository 30 may contain worst-case estimates with respect to a number of different platforms. Processor 22 may thus compute and inform user 24 of the worst-case execution times for a given rule on two or more different platforms, thus enabling the user to choose a more powerful platform if necessary to meet the real-time system requirements.
Processor 22 generates real-time software code to implement rules 27 that are input by user 24. In an exemplary embodiment, which is described in greater detail hereinbelow, the user inputs the rules in the form of declarative statements. Processor 22 translates these statements into corresponding software classes, which inherit from a predefined set of abstract classes. The rule syntax and abstract classes may be designed specifically for efficient, predictable execution, by limiting the number and/or lifespans of events that may be included in a rule, for example, and limiting access to non-real-time external resources, such as large databases.
When code generation is complete, and user 24 has determined that the worst-case execution time is within acceptable limits, the run-time code is compiled and loaded into an execution platform 34. This platform typically comprises a general- or special-purpose computer, with an interface for receiving indications of events from a source or set of sources 36. (Sources 36 are represented in
The sample code above defines a “situation,” which is a complex event, defined as a composition of other simple or complex events together with conditions attached to these events. The situation in this case, called AlertTrack, is an “all” situation over two component events, TrackData and AlertTrigger, meaning that both of the component events must occur in order for the situation (and the corresponding rule) to be triggered. The two events in the situation use an arbitrary quantifier, referred to as “first,” and have the “retain” attribute set to “false,” meaning that the events are not to be retained by execution platform 34 after situation detection.
Processor 22 parses the rules defined by the user and generates corresponding run-time software code, at a code generation step 52. The processor also evaluates the worst-case execution duration for the code and presents the result to user 24, at an execution time computation step 54. For the sake of convenience and clarity of explanation, step 54 is shown in the figure and described hereinbelow as following step 52 (since the total execution duration depends on the benchmarked times that will be required to perform each of the operations in the run-time code). In practice, however, as will be explained below, each element of the situation expressed in the declarative language corresponds to certain operations in predefined abstract software classes. Thus, processor 22 may alternatively associate respective execution times with the expressions in the declarative language, and may use these execution times in computing the worst-case execution duration directly, independently of code generation.
Processor 22 also generates a container 80 for holding sets of instances of each operator, which inherits from an abstract container class 78. Container 80 holds all active lifespans relating to the situation defined by the corresponding concrete class, and routes incoming events to the appropriate situation objects. For this purpose, for example, if the AlertTrackAll situation may be keyed using an ID attribute, it will ensure that the relevant incoming events are routed to an AlertTrackAll object with matching ID.
Events 84 are likewise defined as concrete classes, which implement an interface inherited from an abstract IEvent class 82.
The chain of inheritance of AlertTrackAll is shown by way of example in Tables II, III and IV in the Appendix below. The sample programs shown are written in the Java™ language, but the principles of the present invention may similarly be implemented in other suitable programming languages, as will be apparent to those skilled in the art. AlertTrackAll in Table IV inherits from AbstractAll in Table III, which in turn inherits from AbstractOperator in Table II. These classes import other classes for operations such as adding, composing and consuming events, which are omitted here for the sake of brevity. Such operations are commonly used in event processing, and their implementation will be apparent to those skilled in the art.
Processor 22 maps the expressions in the declarative rule definition in Table I above to corresponding operations in AlertTrackAll. Since the AlertTrack situation is an “all” situation over two event types, the AlertTrackAll class extends AbstractAll, as explained above, and the “candidates” field in AltertTrackAll is an array of size 2, with two add methods, one for each event type. Because the two events in Table I use the “first” quantifier (an arbitrary attribute, used here for the sake of illustration), the corresponding adder and composer code objects are of the type FirstEventAdder and FirstEventComposer, which mimic the behavior of the “first” quantifier. An EventConsumer is included in the generated code to delete the events that were used to detect the situation, since the retain=“false” attribute indicates that the events are not to be retained after situation detection.
Returning now to
To derive the worst-case time estimate, processor 22 analyzes the basic behavior of the operators in the run-time code, such as the “compose” method in AbstractAll, and the “consume” method in AbstractOperator, as shown in Tables II and III below. The execution times of these operators will depend, in turn on the number of candidate events that are kept in memory, as well as on the execution times of the various event adders (such as FirstEventAdder), composers (such as FirstEventComposer), and consumers. These execution times may all be benchmarked in advance.
In addition, processor 22 analyzes the execution times of rule-specific operations, such as the “createNotification” method in the AlertTrackAll class in Table IV. The createNotification method, for example, is composed of low-level Java primitives (array access, expression evaluation, etc.), which are also benchmarked in advance. The processor uses these benchmarks in computing the worst-case estimate for the specific method.
After having broken down the code (or possibly the corresponding declarative expressions, as explained above) into primitives and other operations that have been benchmarked in advance, processor 22 adds up the worst-case benchmark execution times for these primitives and operations to get the total execution duration for the entire rule. For instance the createNotification method in AlertTrackAll (Table IV) consists of two array access operations, creation of a new object, and setting the values of three variables. The worst-case execution times of these primitives are summed to give the worst-case time that will be required to create a notification of a detected situation. Worst-case execution times for the other operations in AlertTrackAll may be determined in like manner.
The processor typically presents the result of the execution duration computation to the user on output device 26, at an acceptance step 56. If the user determines that the worst-case duration is within the acceptable limit to meet the real-time requirements of the application in question, the user approves the code. In this case, processor 22 outputs the code to run on platform 34 (typically after having compiled the source code into byte code or other executable form).
Alternatively, if the execution duration is longer than acceptable, user 24 may make appropriate changes in order to meet real-time requirements. For example, the user may simplify or otherwise revise the rules for faster operation, at a rule revision step 60. Processor 22 receives the revised rules at step 50 and repeats steps 52-56 in order to present the user with the new execution duration. As another alternative, the user may instruct the processor to repeat the computation of execution duration for a more powerful real-time platform, which will presumably run the code faster. Once the user has reached an acceptable result, the processor outputs the code at step 58.
Although the embodiments described above relate specifically to event processing, the principles of the present invention may similarly be applied in real-time applications of other types. It will thus be appreciated that the embodiments described above are cited by way of example, and that the present invention is not limited to what has been particularly shown and described hereinabove. Rather, the scope of the present invention includes both combinations and subcombinations of the various features described hereinabove, as well as variations and modifications thereof which would occur to persons skilled in the art upon reading the foregoing description and which are not disclosed in the prior art.