Skip to content

Commit

Permalink
Allow DevelopmentServer testing with internal and external plugins to…
Browse files Browse the repository at this point in the history
…gether

Co-authored-by: Pratham Desai <[email protected]>
  • Loading branch information
xkrogen and phd3 committed Aug 21, 2024
1 parent 6d6ffb7 commit 23a0e5c
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ product-test-reports
.github/bin/redshift/.cluster-identifier
**/dependency-reduced-pom.xml
core/trino-web-ui/src/main/resources/webapp/dist/

# Local plugins added for testing should be excluded
testing/trino-server-dev/etc/plugin/*
!testing/trino-server-dev/etc/plugin/README.md
1 change: 1 addition & 0 deletions testing/trino-server-dev/etc/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ plugin.bundles=\
../../plugin/trino-exchange-hdfs/pom.xml, \
../../plugin/trino-mysql-event-listener/pom.xml

plugin.dir=etc/plugin
node-scheduler.include-coordinator=true
4 changes: 4 additions & 0 deletions testing/trino-server-dev/etc/plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### External Plugins Directory

External plugins can be added to this directory to test with `DevelopmentServer`. Each
plugin should be added as its own subdirectory.
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,44 @@
/*
* 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;

/**
* Supports loading internal and external plugins simultaneously during development.
* The `plugin.dir` value in `config.properties` is relative to `trino-server-dev` module.
*/
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);
serverPluginsProvider.loadPlugins(loader, createClassLoader);
}
}

0 comments on commit 23a0e5c

Please sign in to comment.