-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add ingest processor existence helper method #45156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit adds a helper method to the ingest service allowing it to inspect a pipeline by id and verify the existence of a processor in the pipeline. This work exposed a potential bug in that some processors contain inner processors that are passed in at instantiation. These processors needed a common way to expose their inner processors, so the WrappedProcessor was created in order to expose the inner processor.
|
Pinging @elastic/es-core-features |
|
@elasticmachine run elasticsearch-ci/2 |
martijnvg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the comment about hasProcessor(...) method, this PR LGTM.
| } | ||
|
|
||
| for (Processor processor: pipeline.flattenAllProcessors()) { | ||
| if (processor instanceof WrappedProcessor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this method does not work as expected in the following cases:
hasProcessor("_id", ForEachProcessor.class/ConditionalProcessor.class)invocations, because both classes implementedWrappedProcessor, we never end up checking whetherprocessoris assignable fromclazzand straight check the inner processor.- In the case that a wrapped processor is wrapped by another wrapped processor (for example: foreach processor wraps a
conditionalprocessor) then we never check the 2nd wrapped processor or any processor below that.
I think something like the following fixes the above cases:
if (clazz.isAssignableFrom(processor.getClass())) {
return true;
}
while (processor instanceof WrappedProcessor) {
WrappedProcessor wrappedProcessor = (WrappedProcessor) processor;
if (clazz.isAssignableFrom(wrappedProcessor.getInnerProcessor().getClass())) {
return true;
}
processor = wrappedProcessor.getInnerProcessor();
if (wrappedProcessor == processor) {
break;
}
}
(replaces the body of the for loop)
jbaiera
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM, pending the name nitpicks
| * A wrapped processor is one that encapsulates an inner processor, or a processor that the wrapped processor enacts upon. All processors | ||
| * that contain an "inner" processor should implement this interface, such that the actual processor can be obtained. | ||
| */ | ||
| public interface WrappedProcessor extends Processor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think originally we had wanted to call this WrappingProcessor
|
|
||
| import java.util.function.Consumer; | ||
|
|
||
| class WrappedProcessorImpl extends FakeProcessor implements WrappedProcessor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here re: WrappingProcessor vs WrappedProcessor
|
@elasticmachine update branch |
This commit adds a helper method to the ingest service allowing it to inspect a pipeline by id and verify the existence of a processor in the pipeline. This work exposed a potential bug in that some processors contain inner processors that are passed in at instantiation. These processors needed a common way to expose their inner processors, so the WrappingProcessor was created in order to expose the inner processor.
This commit adds a helper method to the ingest service allowing it to
inspect a pipeline by id and verify the existence of a processor in the
pipeline. This work exposed a potential bug in that some processors
contain inner processors that are passed in at instantiation. These
processors needed a common way to expose their inner processors, so the
WrappedProcessor was created in order to expose the inner processor.