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

[pull] master from trinodb:master #640

Merged
merged 1 commit into from
Nov 14, 2024
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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ 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 plugins are enabled for the development server, adjust the value of
`plugin.bundles` in `config.properties`. Each entry in this list must represent a plugin
specified by one of the following options:
* A path to a `pom.xml` or `*.pom` file describing a Maven project that produces a plugin.
* Maven coordinates, in the form `<groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>`. The plugin will be loaded via Maven and therefore must be available in your local repository or a remote repository.
* A path to a plugin directory containing JAR files. See [Deploying a custom plugin](https://trino.io/docs/current/develop/spi-overview.html#deploying-a-custom-plugin) for more details.

If you want to use a plugin in a catalog, you must 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
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@
import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.function.Function;
import java.util.stream.Stream;

import static com.google.common.collect.ImmutableList.toImmutableList;
import static io.trino.server.PluginDiscovery.discoverPlugins;
Expand Down Expand Up @@ -83,7 +87,12 @@ private PluginClassLoader doBuildClassLoader(String plugin, Function<List<URL>,
if (file.isFile() && (file.getName().equals("pom.xml") || file.getName().endsWith(".pom"))) {
return buildClassLoaderFromPom(file, classLoaderFactory);
}
return buildClassLoaderFromCoordinates(plugin, classLoaderFactory);
else if (file.isDirectory()) {
return buildClassLoaderFromDirectory(file, classLoaderFactory);
}
else {
return buildClassLoaderFromCoordinates(plugin, classLoaderFactory);
}
}

private PluginClassLoader buildClassLoaderFromPom(File pomFile, Function<List<URL>, PluginClassLoader> classLoaderFactory)
Expand All @@ -103,6 +112,24 @@ private PluginClassLoader buildClassLoaderFromPom(File pomFile, Function<List<UR
return classLoader;
}

private static PluginClassLoader buildClassLoaderFromDirectory(File pluginDirectory, Function<List<URL>, PluginClassLoader> classLoaderFactory)
throws IOException
{
Function<Path, URL> pathToUrl = path -> {
try {
return path.toUri().toURL();
}
catch (MalformedURLException e) {
throw new UncheckedIOException(e);
}
};
List<URL> jars;
try (Stream<Path> paths = Files.list(pluginDirectory.toPath())) {
jars = paths.map(pathToUrl).collect(toImmutableList());
}
return classLoaderFactory.apply(jars);
}

private PluginClassLoader buildClassLoaderFromCoordinates(String coordinates, Function<List<URL>, PluginClassLoader> classLoaderFactory)
throws IOException
{
Expand Down
Loading