Java 类com.facebook.presto.spi.Plugin 实例源码

项目:presto    文件:TestingPrestoServerLauncher.java   
public void run()
        throws Exception
{
    try (TestingPrestoServer server = new TestingPrestoServer()) {
        for (String pluginClass : options.getPluginClassNames()) {
            Plugin plugin = (Plugin) Class.forName(pluginClass).newInstance();
            server.installPlugin(plugin);
        }

        for (Catalog catalog : options.getCatalogs()) {
            server.createCatalog(catalog.getCatalogName(), catalog.getConnectorName());
        }

        System.out.println(server.getAddress());
        waitForInterruption();
    }
}
项目:presto    文件:PluginDiscovery.java   
public static Set<String> discoverPlugins(Artifact artifact, ClassLoader classLoader)
        throws IOException
{
    if (!artifact.getExtension().equals("presto-plugin")) {
        throw new RuntimeException("Unexpected extension for main artifact: " + artifact);
    }

    File file = artifact.getFile();
    if (!file.getPath().endsWith("/target/classes")) {
        throw new RuntimeException("Unexpected file for main artifact: " + file);
    }
    if (!file.isDirectory()) {
        throw new RuntimeException("Main artifact file is not a directory: " + file);
    }

    if (new File(file, SERVICES_FILE).exists()) {
        return ImmutableSet.of();
    }

    return listClasses(file.toPath()).stream()
            .filter(name -> classInterfaces(name, classLoader).contains(Plugin.class.getName()))
            .collect(toImmutableSet());
}
项目:presto    文件:TestRaptorPlugin.java   
@SuppressWarnings("unchecked")
private static <T extends Plugin> T loadPlugin(Class<T> clazz)
{
    for (Plugin plugin : ServiceLoader.load(Plugin.class)) {
        if (clazz.isInstance(plugin)) {
            return (T) plugin;
        }
    }
    throw new AssertionError("did not find plugin: " + clazz.getName());
}
项目:presto    文件:DistributedQueryRunner.java   
@Override
public void installPlugin(Plugin plugin)
{
    long start = System.nanoTime();
    for (TestingPrestoServer server : servers) {
        server.installPlugin(plugin);
    }
    log.info("Installed plugin %s in %s", plugin.getClass().getSimpleName(), nanosSince(start).convertToMostSuccinctTimeUnit());
}
项目:presto    文件:TestPostgreSqlPlugin.java   
@Test
public void testCreateConnector()
        throws Exception
{
    Plugin plugin = new PostgreSqlPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getServices(ConnectorFactory.class));
    factory.create("test", ImmutableMap.of("connection-url", "test"));
}
项目:presto    文件:PluginManager.java   
private void loadPlugin(URLClassLoader pluginClassLoader)
        throws Exception
{
    ServiceLoader<Plugin> serviceLoader = ServiceLoader.load(Plugin.class, pluginClassLoader);
    List<Plugin> plugins = ImmutableList.copyOf(serviceLoader);

    if (plugins.isEmpty()) {
        log.warn("No service providers of type %s", Plugin.class.getName());
    }

    for (Plugin plugin : plugins) {
        log.info("Installing %s", plugin.getClass().getName());
        installPlugin(plugin);
    }
}
项目:presto    文件:TestMySqlPlugin.java   
@Test
public void testCreateConnector()
        throws Exception
{
    Plugin plugin = new MySqlPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getServices(ConnectorFactory.class));
    factory.create("test", ImmutableMap.of("connection-url", "test"));
}
项目:presto    文件:StandaloneQueryRunner.java   
public void installPlugin(Plugin plugin)
{
    server.installPlugin(plugin);
}
项目:presto    文件:TestingPrestoServer.java   
public void installPlugin(Plugin plugin)
{
    pluginManager.installPlugin(plugin);
}
项目:presto    文件:LocalQueryRunner.java   
@Override
public void installPlugin(Plugin plugin)
{
    throw new UnsupportedOperationException();
}
项目:presto    文件:QueryRunner.java   
void installPlugin(Plugin plugin);