Skip to content
Merged
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
21 changes: 21 additions & 0 deletions core/trino-main/src/main/java/io/trino/server/PluginInstaller.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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 io.trino.spi.Plugin;

public interface PluginInstaller
{
void installPlugin(Plugin plugin);
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public class PluginManager
private final BlockEncodingManager blockEncodingManager;
Comment thread
skrzypo987 marked this conversation as resolved.
Outdated
private final HandleResolver handleResolver;
private final AtomicBoolean pluginsLoading = new AtomicBoolean();
private final Set<PluginInstaller> pluginInstallers;

@Inject
public PluginManager(
Expand All @@ -108,7 +109,8 @@ public PluginManager(
TypeRegistry typeRegistry,
BlockEncodingManager blockEncodingManager,
HandleResolver handleResolver,
ExchangeManagerRegistry exchangeManagerRegistry)
ExchangeManagerRegistry exchangeManagerRegistry,
Set<PluginInstaller> pluginInstallers)
{
this.pluginsProvider = requireNonNull(pluginsProvider, "pluginsProvider is null");
this.connectorFactory = requireNonNull(connectorFactory, "connectorFactory is null");
Expand All @@ -125,6 +127,7 @@ public PluginManager(
this.blockEncodingManager = requireNonNull(blockEncodingManager, "blockEncodingManager is null");
this.handleResolver = requireNonNull(handleResolver, "handleResolver is null");
this.exchangeManagerRegistry = requireNonNull(exchangeManagerRegistry, "exchangeManagerRegistry is null");
this.pluginInstallers = requireNonNull(pluginInstallers, "pluginInstallers is null");
}

public void loadPlugins()
Expand Down Expand Up @@ -253,6 +256,10 @@ private void installPluginInternal(Plugin plugin, Function<CatalogHandle, ClassL
log.info("Registering exchange manager %s", exchangeManagerFactory.getName());
exchangeManagerRegistry.addExchangeManagerFactory(exchangeManagerFactory);
}

for (PluginInstaller pluginInstaller : pluginInstallers) {
pluginInstaller.installPlugin(plugin);
}
}

public static PluginClassLoader createClassLoader(String pluginName, List<URL> urls)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ protected void setup(Binder binder)
newOptionalBinder(binder, PluginsProvider.class).setDefault()
.to(ServerPluginsProvider.class).in(Scopes.SINGLETON);
configBinder(binder).bindConfig(ServerPluginsProviderConfig.class);
newSetBinder(binder, PluginInstaller.class);

// block encodings
binder.bind(BlockEncodingManager.class).in(Scopes.SINGLETON);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,8 @@ private LocalQueryRunner(
typeRegistry,
blockEncodingManager,
handleResolver,
exchangeManagerRegistry);
exchangeManagerRegistry,
ImmutableSet.of());

catalogManager.registerGlobalSystemConnector(globalSystemConnector);

Expand Down