Skip to content

Conversation

yaauie
Copy link
Member

@yaauie yaauie commented Sep 21, 2022

Release notes

[rn: skip]

What does this PR do?

Simplifies the inheritance hierarchy of our LogStash::JavaPipeline using nearly-entirely-automated code tools. This is a net-zero-change pull-request.

This removes artifacts of the current only-pipeline implementation used by our only-execution engine (previously Java Execution Engine, or JEE) needing to share context with the now-removed LogStash::Pipeline that was integral to the deprecated-and-removed Ruby Execution Engine (REE).

  1. pull all members up from JavaBasePipelineExt into its parent AbstractPipelineExt
    • conflicts: both bring a LOGGER and an identical serialVersionUID, which were manually consolidated
    • restructure: re-arrange method declaration order to group methods that are interacting with similar things
  2. remove our now-useless JavaBasePipelineExt
  • make our ruby-defined LogStash::JavaPipeline inherit directly from our newly-consolidated AbstractPipelineExt
  • move other implementation references from our empty JavaBasePipelineExt to its parent AbstractPipelineExt
  • safe-delete JavaBasePipelineExt, ensuring no dangling code-references to its ruby form LogStash::JavaBasePipeline

Why is it important/What is the impact to the user?

Simplifies our maintenance footprint, and opens the door for future refactors that can further consolidate or clean up the pipeline's implementation.

Prior to this change, our pipeline code was split between three places:

  • ruby-defined LogStash::JavaPipeline
  • which is the only class that inherits from java-defined org.logstash.execution.JavaBasePipelineExt
  • which is the only class that inherits from java-defined org.logstash.execution.AbstractPipelineExt
  • which inherits from jruby-provided org.jruby.RubyBasicObject

After this change, our pipeline code is one step simpler:

  • ruby-defined LogStash::JavaPipeline
  • which is the only class that inherits from java-defined org.logstash.execution.AbstractPipelineExt
  • which inherits from jruby-provided org.jruby.RubyBasicObject

OUT OF SCOPE: the resulting combined AbstractPipelineExt class is certainly convoluted, and contains significant duplication, but is effectively identical to the existing as-composed JavaBasePipeline and resolving the complexity and/or duplication is out of scope.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [ ] I have made corresponding change to the default configuration files (and/or docker env variables)
  • I have added tests that prove my fix is effective or that my feature works
    • this is intended to be net-zero-change, to be validated by the existing tests

How to test this PR locally

As a net-zero-change PR, there is no specific way to validate.

@yaauie
Copy link
Member Author

yaauie commented Sep 21, 2022

Build failed fetching integration resources.

Jenkins test this again please

@yaauie
Copy link
Member Author

yaauie commented Sep 21, 2022

Build will continue to fail until daily snapshots are available for Elasticsearch's newly-cut branch of 8.6, which could be up to 24h. I will follow up tomorrow to kick off CI again.

Copy link
Contributor

@mashhurs mashhurs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put nice to have a doc comment and if we can remove unused params but feel free to merge if we can cover next PRs. Current PR's goal to get rid of JavaBaselinePipeline.

* JRuby extension to provide ancestor class for the ruby-defined {@code LogStash::JavaPipeline} class.
*
* <p>NOTE: Although this class' name implies that it is "abstract", we instantiated it directly
* as a lightweight temporary-scoped pipeline in the ruby-defined {@code LogStash::PipelineAction::Reload}
* */
@JRubyClass(name = "AbstractPipeline")
public class AbstractPipelineExt extends RubyBasicObject {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the effort @yaauie !
+1 for removing JavaBasePipelineExt.java and it seems it even doesn't have any test cases.

Out of scope: how do you think for the long term dividing this class into domains:

  • DLQ features (with its metrics)
  • Stats metrics
  • Pipeline related (reloadable, close, etc...)

We probably need to change the inheritance to include java class if we divide (or extend interface if Ruby/JRuby supports).

I would also argue calling this class abstract (it doesn't in a reality). Maybe candidates: PipelineExtension /PipelineDomain/PipelineService.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am leaning toward BasePipeline, since it is not abstract. After we have a green CI pass here, I will perform another automated-rename in a separate commit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have any specific plans for the cleanup of this class and rearrangement. This PR is one step to remove the hierarchy, and everything else is out of scope.


public AbstractPipelineExt(final Ruby runtime, final RubyClass metaClass) {
super(runtime, metaClass);
}

@JRubyMethod(required = 4)
public AbstractPipelineExt initialize(final ThreadContext context, final IRubyObject[] args)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a documentation for this method? I really confuse whenever I do see at this. We have a caller in reload.rb:L51

LogStash::AbstractPipeline.new(@pipeline_config, nil, logger, nil)

If we do not use args[1] & args[3] as they are nil, why don't we remove?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As stated in the PR, this is a net-zero-change PR, very intentionally designed to change only the hierarchy using automated code tools and as little manual intervention as possible.

I have very little idea what several of these pieces do, and we will have opportunity to refactor and consolidate separately.

@yaauie
Copy link
Member Author

yaauie commented Sep 24, 2022

It looks like we have a Stack 8.6 snapshot now.

Jenkins test this again please

@yaauie yaauie merged commit 228030c into elastic:main Sep 27, 2022
@yaauie yaauie deleted the refactor-pipeline-code branch September 27, 2022 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants