NIFI-6889 - Create RulesRecordProcessor #3912
NIFI-6889 - Create RulesRecordProcessor #3912YolandaMDavis wants to merge 2 commits intoapache:masterfrom
Conversation
NIFI-6889 - created RulesRecordProcessor NIFI-6889 - rat check and checkstyle fixes NIFI-6889 - added processor in resources, processor corrections NIFI-6889 - fix issue when transferring original flowfile
| @WritesAttribute(attribute = "mime.type", description = "The MIME Type that the configured Record Writer indicates is appropriate"), | ||
| }) | ||
| @CapabilityDescription("Submits record values to a rules engine and returns actions determined by the engine as records ") | ||
| public class RulesRecordProcessor extends AbstractProcessor { |
There was a problem hiding this comment.
The current convention is to not have Processor in the name of the processor, rather some kind of verb that says what it does. How about EvaluateRulesRecord or something like that?
There was a problem hiding this comment.
I like it, let's go with that 👍
| "fields": [ | ||
| {"name": "type", "type": "string"}, | ||
| {"name": "attributes", "type": {"type": "map", "values": "string"}}, | ||
| {"name": "metrics", "type": {"type": "map", "values": "string"}} |
There was a problem hiding this comment.
Should we have the metrics values be double rather than string? Would make subsequent operations (arithmetic functions via QueryRecord for example) easier and avoids a necessary conversion downstream.
There was a problem hiding this comment.
Technically this should be corrected to say facts and not metrics and those could be either string or numeric value.
nifi-nar-bundles/nifi-rules-bundle/nifi-rules-processors/src/main/resources/schema-actions.avsc
Show resolved
Hide resolved
...fi-rules-processors/src/main/java/org/apache/nifi/rules/processors/RulesRecordProcessor.java
Show resolved
Hide resolved
| static final PropertyDescriptor RULES_ENGINE = new PropertyDescriptor.Builder() | ||
| .name("rules-engine-service") | ||
| .displayName("Rules Engine Service") | ||
| .description("Specifies the Controller Service to use for applying rules to metrics.") |
There was a problem hiding this comment.
Should this read facts instead of metrics? Just want to make sure the terminology is consistent throughout.
There was a problem hiding this comment.
yes it should read facts (same with the schema as mentioned previously)
| static final PropertyDescriptor ACTION_RECORD_WRITER = new PropertyDescriptor.Builder() | ||
| .name("action-record-writer") | ||
| .displayName("Action Record Writer") | ||
| .description("Specifies the Controller Service to use for writing out action records") |
There was a problem hiding this comment.
Perhaps we should mention here that Inherit Schema on the RecordWriter will allow it to use the generated/static schema provided by the processor. The user could still override it (to include/exclude fields) but might be helpful to point out that Inherit Schema wouldn't inherit the reader schema, but the provided one.
| */ | ||
| package org.apache.nifi.rules.processors; | ||
|
|
||
| import com.google.common.collect.Lists; |
There was a problem hiding this comment.
Do we need Guava here? Maybe use Arrays.asList() instead, since I don't think Guava is an explicit dependency of this module (must be transitive)
There was a problem hiding this comment.
@mattyb149 thanks for the review. I'll work on incorporating changes. One other note is the Processor currently will emit records even if there are no actions. I'm thinking I need to add an option for includeZeroResults as well.
|
@mattyb149 I pushed the changes you suggested for your review. Also I was thinking more about excluding empty results and am now rethinking that, especially since even though no actions are returned it still has provenance information associated with it (so technically the flow file may still have value). I'm thinking about leaving it as is but wanted to get your thoughts? |
|
@YolandaMDavis I like the idea of a property to configure whether to send a flowfile on zero results, it's more flexible and supports both use cases. Whichever default value is fine with me. @joewitt The processor takes the "facts" (field values) and runs them through a rules engine which returns a set of actions to take (but it doesn't do the actions, just passes them along). Maybe now that record-based processors are becoming the norm we don't need |
|
Not clear if this is generic enough for community adoption so closing for now. |
NIFI-6889 - reorganizing rules bundle and nar
NIFI-6889 - created RulesRecordProcessor
NIFI-6889 - rat check and checkstyle fixes
NIFI-6889 - added processor in resources, processor corrections
NIFI-6889 - fix issue when transferring original flowfile
Thank you for submitting a contribution to Apache NiFi.
Please provide a short description of the PR here:
Description of PR
Enables X functionality; fixes bug NIFI-YYYY.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
Has your PR been rebased against the latest commit within the target branch (typically
master)?Is your initial contribution a single, squashed commit? Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not
squashor use--forcewhen pushing to allow for clean monitoring of changes.For code changes:
mvn -Pcontrib-check clean installat the rootnififolder?LICENSEfile, including the mainLICENSEfile undernifi-assembly?NOTICEfile, including the mainNOTICEfile found undernifi-assembly?.displayNamein addition to .name (programmatic access) for each of the new properties?For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.