Versions Compared

Key

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

...

You can check out the source code from ONAP gerritThere are two sub modules, rulemgt-standalone and rulemgtrulemgt-standalone is for packaging the application packaging rulemgt into a Docker image, while rulemgt has all the business logic.

...

It is required that env variable HOSTNAME is provided. Rule Management service host and port are obtained from Consul by passing in HOSTNAME (in org.onap.holmes.common.config.MicroServiceConfig.getMicroServiceIpAndPort()):
http://{CONSUL_HOST}:8500/v1/catalog/service/{HOSTNAME} ,
where CONSUL_HOST is defined in env as well.

Host and port are then submitted to MSB, along with: (in RuleActiveApp)

msinfo.setServiceName("holmes-rule-mgmt");
msinfo.setVersion("v1");
msinfo.setUrl("/api/holmes-rule-mgmt/v1");
msinfo.setProtocol("REST");
msinfo.setVisualRange("0|1");
msinfo.setEnable_ssl(true);

...

A thread is forked using JDK Executors.newSingleThreadScheduledExecutor(), and the forked task, org.onap.holmes.rulemgt.dcae.DcaeConfigurationPolling, runs at an interval of 30 seconds. In DcaeConfigurationPolling: (In RuleActiveApp)

Config Binding Service (CBS) endpoint is obtained from DCAE Consul: (In org.onap.holmes.common.config.MicroServiceConfig)
http://{CONSUL_HOST}:8500/v1/catalog/service/{CONFIG_BINDING_SERVICE}

From CBS, configuration info on HOSTNAME is obtained through: (In MicroServiceConfig.getServiceConfigInfoFromCBS())
http://{CBS ServiceAddress}:{CBS ServicePort}/service_component/{HOSTNAME}
(In MicroServiceConfig.getServiceConfigInfoFromCBS())

The configuration data from CBS is in JSON format, and is parsed by DcaeConfigurationParser. The result is a DcaeConfigurations object, which contains rules, DMaaP Publisher topics, and DMaaP Subscriber topics. (In DcaeConfigurationParser.parse())

If the DcaeConfigurations has update (by checking its MD5 against the previous version), all existing rules are wiped out, and one rule is generated for each rule in DcaeConfigurations. All  All the rule operations are done through the RESTful APIs discussed in the next section.  (In DcaeConfigurationPolling.run())

Rule Management REST API

Like Spring Boot Controllers, Dropwizard Jersey resources are the entrance points of web services. EngineResources  RuleMgtResources is a such a resource that provides all engine Rule Management REST APIs, and has the following services: 

  1. Creating a Rule
    Save
    This service saves a rule into the database; deploy , and deploys it to the Drools engine if it is enabled. The HTTP request should be in such format:

    PUT /api/holmes-rule-mgmt/v1/rule
    {

    "ruleName": "Alarm Compression",

    "loopControlName": "Control Loop Name",

    "description"(optional): "This is the description of the rule.",

    "content": "template header\n ruleId\n package packageName...",

    "enabled": 0|1

    }

    This request is handled by RuleMgtResources.addCorrelationRule(), where the “content” in the HTTP body is used as a rule. The rule is save to database table APLUS_RULE, and is deployed to Doorls rule engine via Holmes Engine Management Restful APIREST API, and is saved to database table APLUS_RULE. On successfully deploying the rule, the rule ID is returned to the client. Note that if a rule with the same name already exists in database, the rule id deployment will fail, and an error message "A rule with the same name already exists." is returned to the client.

  2. Modifying a Rule
    Update
    This service updates an existing rule; deploy , and deploys it to the Drools engine if it is enabled. The HTTP request should be in such format:

    POST /api/holmes-rule-mgmt/v1/rule
    {

    “ruleId": "ruleid0937261",

    "loopControlName": "Control Loop Name",

    "description"(optional): "This is the description of the rule.",

    "content": "template header\n ruleId\n package packageName...",

    "enabled": 0|1

    }

    This request is handled by RuleMgtResources.updateCorrelationRule(), where the “content” in the HTTP body is used as a rule. The rule is updated in database table APLUS_RULE, and is deployed to Doorls rule engine via Holmes Engine Management Restful API. On successfully updating the rule, the rule id is returned to the client.

  3. Deleting a Rule 


    rulemgt/src/main/resources/swagger.json is the OpenAPI Specification (OAS) file that describes all the above APIs. This wiki page has the complete spec of these REST APIs.