Skip to content

Add support in plugins for a separate spi classloader #76288

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

Merged
merged 5 commits into from
Aug 11, 2021

Conversation

rjernst
Copy link
Member

@rjernst rjernst commented Aug 10, 2021

SPI is how plugins provide extension points for other plugins to
customize their behavior. Plugins may have a separate SPI jar, so as not
to expose the internals of the plugin implementation. In essense, this
system was built as a stopgap for Java modules, where implementation can
be protected in the same jar. However, currently the plugins service
loads both spi and plugin implementations into the same classloader.
This means that although another plugin may only compile against spi,
they could still get jar hell from a duplicate dependency.

This commit adds support for plugins to contain an "spi" subdirectory
which is loaded into a separate classloader. This spi classloader is a
parent to the plugin implementation, as well as any other plugins which
have extended it. Additionally as a demonstration of how this works in
practice, lang-painless is setup as the first plugin to provide an spi
jar, and sql's dependence on painless is changed to only spi, so that
it now has an independent version of antlr.

closes #74448

SPI is how plugins provide extension points for other plugins to
customize their behavior. Plugins may have a separate SPI jar, so as not
to expose the internals of the plugin implementation. In essense, this
system was built as a stopgap for Java modules, where implementation can
be protected in the same jar. However, currently the plugins service
loads both spi and plugin implementations into the same classloader.
This means that although another plugin may only compile against spi,
they could still get jar hell from a duplicate dependency.

This commit adds support for plugins to contain an "spi" subdirectory
which is loaded into a separate classloader. This spi classloader is a
parent to the plugin implementation, as well as any other plugins which
have extended it. Additionally as a demonstration of how this works in
practice, lang-painless is setup as the first plugin to provide an spi
jar, and sql's dependence on painless is changed to only spi, so that
it now has an independent version of antlr.

closes elastic#74448
@rjernst rjernst added >enhancement :Core/Infra/Plugins Plugin API and infrastructure labels Aug 10, 2021
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Aug 10, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@rjernst
Copy link
Member Author

rjernst commented Aug 10, 2021

@elasticmachine run elasticsearch-ci/packaging-tests-windows-sample

Copy link
Contributor

@colings86 colings86 left a comment

Choose a reason for hiding this comment

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

LGTM

@rjernst rjernst added auto-backport Automatically create backport pull requests when merged auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) and removed auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) labels Aug 11, 2021
@@ -58,7 +63,7 @@ tasks.named("yamlRestCompatTest").configure {
* Painless plugin */
tasks.register("apiJavadoc", Javadoc) {
source = sourceSets.main.allJava
classpath = sourceSets.main.runtimeClasspath
classpath = sourceSets.main.runtimeClasspath + configurations.named("spi").classpath
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can simplify this by just using configurations.spi here

Copy link
Contributor

@breskeby breskeby left a comment

Choose a reason for hiding this comment

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

lgtm. just minor style remark

@rjernst rjernst added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Aug 11, 2021
@elasticsearchmachine elasticsearchmachine merged commit 35980c8 into elastic:master Aug 11, 2021
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
7.x Commit could not be cherrypicked due to conflicts

To backport manually run backport --upstream elastic/elasticsearch --pr 76288

costin added a commit to costin/elasticsearch that referenced this pull request Aug 11, 2021
Following elastic#76288, upgrade ANTLR library to benefit from the various
improvements made in most recent releases in particular better
performance and error messages.

Looking at the changelog, since version 4.7.2 most changes in ANTLR seem
to have occurred in non-Java targets however this commit upgrades to
ANTLR 4.9.2 to benefit from the dependency updates (such as
StringTemplate).

Additionally move the library into QL to consolidate its use across QL
projects.

Relates elastic#74448
Fix elastic#76354
@rjernst rjernst deleted the plugin/spi_separation branch August 11, 2021 15:01
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Aug 11, 2021
SPI is how plugins provide extension points for other plugins to
customize their behavior. Plugins may have a separate SPI jar, so as not
to expose the internals of the plugin implementation. In essense, this
system was built as a stopgap for Java modules, where implementation can
be protected in the same jar. However, currently the plugins service
loads both spi and plugin implementations into the same classloader.
This means that although another plugin may only compile against spi,
they could still get jar hell from a duplicate dependency.

This commit adds support for plugins to contain an "spi" subdirectory
which is loaded into a separate classloader. This spi classloader is a
parent to the plugin implementation, as well as any other plugins which
have extended it. Additionally as a demonstration of how this works in
practice, lang-painless is setup as the first plugin to provide an spi
jar, and sql's dependence on painless is changed to only spi, so that
it now has an independent version of antlr.

closes elastic#74448
elasticsearchmachine pushed a commit that referenced this pull request Aug 11, 2021
SPI is how plugins provide extension points for other plugins to
customize their behavior. Plugins may have a separate SPI jar, so as not
to expose the internals of the plugin implementation. In essense, this
system was built as a stopgap for Java modules, where implementation can
be protected in the same jar. However, currently the plugins service
loads both spi and plugin implementations into the same classloader.
This means that although another plugin may only compile against spi,
they could still get jar hell from a duplicate dependency.

This commit adds support for plugins to contain an "spi" subdirectory
which is loaded into a separate classloader. This spi classloader is a
parent to the plugin implementation, as well as any other plugins which
have extended it. Additionally as a demonstration of how this works in
practice, lang-painless is setup as the first plugin to provide an spi
jar, and sql's dependence on painless is changed to only spi, so that
it now has an independent version of antlr.

closes #74448
@nik9000 nik9000 mentioned this pull request Aug 11, 2021
elasticsearchmachine pushed a commit that referenced this pull request Aug 11, 2021
* QL: Upgrade ANTLR and move it into QL

Following #76288, upgrade ANTLR library to benefit from the various
improvements made in most recent releases in particular better
performance and error messages.

Looking at the changelog, since version 4.7.2 most changes in ANTLR seem
to have occurred in non-Java targets however this commit upgrades to
ANTLR 4.9.2 to benefit from the dependency updates (such as
StringTemplate).

Additionally move the library into QL to consolidate its use across QL
projects.

Relates #74448
Fix #76354

* Fix matching on error message

Co-authored-by: Elastic Machine <[email protected]>
costin added a commit to costin/elasticsearch that referenced this pull request Aug 11, 2021
* QL: Upgrade ANTLR and move it into QL

Following elastic#76288, upgrade ANTLR library to benefit from the various
improvements made in most recent releases in particular better
performance and error messages.

Looking at the changelog, since version 4.7.2 most changes in ANTLR seem
to have occurred in non-Java targets however this commit upgrades to
ANTLR 4.9.2 to benefit from the dependency updates (such as
StringTemplate).

Additionally move the library into QL to consolidate its use across QL
projects.

Relates elastic#74448
Fix elastic#76354

* Fix matching on error message

Co-authored-by: Elastic Machine <[email protected]>
elasticsearchmachine pushed a commit that referenced this pull request Aug 12, 2021
* QL: Upgrade ANTLR and move it into QL

Following #76288, upgrade ANTLR library to benefit from the various
improvements made in most recent releases in particular better
performance and error messages.

Looking at the changelog, since version 4.7.2 most changes in ANTLR seem
to have occurred in non-Java targets however this commit upgrades to
ANTLR 4.9.2 to benefit from the dependency updates (such as
StringTemplate).

Additionally move the library into QL to consolidate its use across QL
projects.

Relates #74448
Fix #76354

* Fix matching on error message

Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :Core/Infra/Plugins Plugin API and infrastructure >enhancement Team:Core/Infra Meta label for core/infra team v7.15.0 v8.0.0-alpha2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ANTLR library update
6 participants