Skip to content
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

Allow DevelopmentServer testing with internal and external plugins together #23100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ product-test-reports
**/dependency-reduced-pom.xml
core/trino-web-ui/src/main/resources/webapp/dist/
.node

# Local plugins added for testing should be excluded
testing/trino-server-dev/etc/plugin/*
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this redundant with testing/trino-server-dev/etc/plugin/.gitignore?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes! This was added before I added the nested .gitignore. Thanks for catching it.

!testing/trino-server-dev/etc/plugin/README.md
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ IntelliJ, using `$MODULE_DIR$` accomplishes this automatically.
If `VM options` doesn't exist in the dialog, you need to select `Modify options`
and enable `Add VM options`.

To adjust which internal plugins are enabled for the development server, adjust the value of
`plugin.bundles` in `config.properties`. External plugins can also be added to the server
by copying them into the `testing/trino-server-dev/etc/plugin` directory.
Each plugin must be added as its own subdirectory containing all necessary dependencies.
If you want to expose a custom plugin as a catalog, you'll need to also add a corresponding
`<catalog_name>.properties` file to `testing/trino-server-dev/etc/catalog`.

### Running the CLI

Start the CLI to connect to the server and run SQL queries:
Expand Down
2 changes: 2 additions & 0 deletions testing/trino-server-dev/etc/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,6 @@ plugin.bundles=\
../../plugin/trino-exchange-hdfs/pom.xml, \
../../plugin/trino-mysql-event-listener/pom.xml

# This can be configured to any path, whether absolute or relative to the working directory
plugin.dir=etc/plugin
mosabua marked this conversation as resolved.
Show resolved Hide resolved
node-scheduler.include-coordinator=true
5 changes: 5 additions & 0 deletions testing/trino-server-dev/etc/plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Keep this placeholder directory as a place to add plugins.
# Ignore everything in this directory ...
*
# ... except this file
!.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ protected Iterable<? extends Module> getAdditionalModules()
{
return ImmutableList.of(binder -> {
newOptionalBinder(binder, PluginsProvider.class).setBinding()
.to(DevelopmentPluginsProvider.class).in(Scopes.SINGLETON);
.to(HybridDevelopmentPluginsProvider.class).in(Scopes.SINGLETON);
binder.bind(DevelopmentPluginsProvider.class).in(Scopes.SINGLETON);
binder.bind(ServerPluginsProvider.class).in(Scopes.SINGLETON);
configBinder(binder).bindConfig(DevelopmentLoaderConfig.class);
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.trino.server;

import com.google.inject.Inject;
import io.trino.server.PluginManager.PluginsProvider;

import static java.util.Objects.requireNonNull;

public class HybridDevelopmentPluginsProvider
implements PluginsProvider
{
private final DevelopmentPluginsProvider developmentPluginsProvider;
private final ServerPluginsProvider serverPluginsProvider;

@Inject
public HybridDevelopmentPluginsProvider(DevelopmentPluginsProvider developmentPluginsProvider, ServerPluginsProvider serverPluginsProvider)
{
this.developmentPluginsProvider = requireNonNull(developmentPluginsProvider, "developmentPluginsProvider is null");
this.serverPluginsProvider = requireNonNull(serverPluginsProvider, "serverPluginsProvider is null");
}

@Override
public void loadPlugins(Loader loader, ClassLoaderFactory createClassLoader)
{
developmentPluginsProvider.loadPlugins(loader, createClassLoader);
Copy link
Member

Choose a reason for hiding this comment

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

This looks ok to me, but I wonder if we can improve the developer experience here. Coping plugins is one extra step that could be avoided - if the DevelopmentPluginsProvider was able to load a plugin from a directory, then we could add directories to the plugin.bundles list.

Copy link
Member Author

@xkrogen xkrogen Nov 5, 2024

Choose a reason for hiding this comment

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

Hm I see what you're saying. Currently, plugins.bundle supports pom.xml/*.pom files as well as Maven coordinates, and we could also add support for directories. It's a good idea! I can take a look at this.

serverPluginsProvider.loadPlugins(loader, createClassLoader);
}
}
Loading