Operation on Rule

It has five services for performing operation on CEP rule :-

  1. Start the rule

  2. Stop the rule

  3. Update the rule

  4. Delete the rule

Start the rule

It starts a rule based on a rule id given by user. User can start the rule with or without oldData by setting optional “WithOldData” query parameter.By default it is set to false

Rule can also be scaled both horizontally and vertically while starting the rule by specifying number of cores,executors and memory per executor.Scaling is optional and user can start the rule without giving these values.Then rule will be started with default values of these parmeters

Following is the URL to start a rule in CEP :-

POST http://<domain name>/cep/v2.0/rules/{ruleId}/start

here ruleId is the id of created CEP rule which need to be started.

Stop the rule

It stops a rule based on a rule id given by user.

Following is the URL to stop a rule in CEP :-

POST http://<domain name>/cep/v2.0/rules/{ruleId}/stop

here ruleId is the id of created CEP rule which need to be stopped.

Update the rule

This API facilitates to update rule based on a json format given by user. User needs to stop the rule before update if it is in running state and then need to start the rule

Following is the URL for describing a routing rule by ID in CEP :-

PUT http://<domain name>/cep/v2.0/rules/{ruleId}

Template for update rule remain the same as of create rule. Following is the sample CEP rule to be updated with the given template :-

{
     "ruleName": "JoiningSample1",
     "selectClause": "s1.temp as currtemp,s2.humidity as currhumidity,s1.feature as feature,s1.starttime as s1time,s2.starttime as s2time",
     "joinClause": "(s1.feature = s2.feature) AND abs(s1.starttime - s2.starttime) <= 30",
"whereClause": "currtemp > 20 AND currhumidity > 80",
     "groupByField": "",
     "triggerInterval": "30",
     "windowDuration": "",
     "input": [{
                     "alias": "s1",
                     "topic": "test1",
                     "properties": [
                             "temp"
                     ]
             },
             {
                     "alias": "s2",
                     "topic": "test2",
                     "properties": [
                             "humidity"
                     ]
             }
     ],
     "output": "outputjoin4"
}

Note

If user needs to update a running rule then the rule is to be stopped,then it is to be updated and started again.

Delete a rule

It deletes a rule based on a rule id given by user :-

Following is the URL for deleting a rule by ID in CEP :-

DELETE http://<domain name>/cep/v2.0/rules/{ruleId}