Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

When the topology starts, the AlertExecutor.init() will be called to populate the map of PolicyEvaluators. The map is updated regularly at one of these methods - init(), onPolicyCreated(), onPolicyChanged() and onPolicyDeleted(). At this point before making any change to the map, we could check for the validity of the policy and then update it accordingly in the HBase tabled against the policyID.


#3 Updating SiddhiRuntime Dynamically

Approach #1

For every change made in the policy end at run time (includes new policy, update existing policy), a new SiddhiRuntime is created (SiddhiPolicyEvaluator.createSiddhiRuntime()) based on the newly available SiddhiPolicyDefinition object and updated accordingly for the PolicyEvaluator in the background (without changing the PolicyEvaluator map available in the AlertExecutor). So at the run time creation, we check if the policy is valid or invalid by SiddhiCompiler.parseQuery() and update the SiddhiRuntime object for that PolicyEvaluator accordingly.

Topology Starting with an existing invalid policy

When a topology is started, we will create a PolicyEvaluator for each of the active policies. A SiddhiRuntime is created for the PolicyEvaluator. At SiddhiPolicyEvalutor.createSiddhiRuntime(), when an invalid policy exists, it fails to create a ExecutionPlanRuntime object and the topology start fails.

We can skip the invalid policy by checking if the policy is valid or not by the above mentioned method and allocate null value to the ExecutionPlanRuntime in the returned SiddhiRuntime object. Also in the SiddhiRuntime, we will add a new boolean field  - markdownEnabled and set it before returning.

With this, we will not be modifying any PE objects in the PE map of AlertExecutor.

 

#4 Avoiding invalid policy at run time to process events

In the SiddhiPolicyEvaluator.evaluate(), we can check for the markdown flag in the SiddhiRuntime object (assigned in the above step) before the existing logic to send dataThe will work on a per PolicyEvaluator basis.