Java Code Examples for io.prestosql.spi.connector.ConnectorContext#getTypeManager()

The following examples show how to use io.prestosql.spi.connector.ConnectorContext#getTypeManager() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrometheusConnectorFactory.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public Connector create(String catalogName, Map<String, String> requiredConfig, ConnectorContext context)
{
    requireNonNull(requiredConfig, "requiredConfig is null");
    try {
        // A plugin is not required to use Guice; it is just very convenient
        Bootstrap app = new Bootstrap(
                new JsonModule(),
                new PrometheusModule(context.getTypeManager()));

        Injector injector = app
                .strictConfig()
                .doNotInitializeLogging()
                .setRequiredConfigurationProperties(requiredConfig)
                .initialize();

        return injector.getInstance(PrometheusConnector.class);
    }
    catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
 
Example 2
Source File: ExampleConnectorFactory.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public Connector create(String catalogName, Map<String, String> requiredConfig, ConnectorContext context)
{
    requireNonNull(requiredConfig, "requiredConfig is null");

    // A plugin is not required to use Guice; it is just very convenient
    Bootstrap app = new Bootstrap(
            new JsonModule(),
            new ExampleModule(context.getTypeManager()));

    Injector injector = app
            .strictConfig()
            .doNotInitializeLogging()
            .setRequiredConfigurationProperties(requiredConfig)
            .initialize();

    return injector.getInstance(ExampleConnector.class);
}
 
Example 3
Source File: AccumuloConnectorFactory.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context)
{
    requireNonNull(catalogName, "catalogName is null");
    requireNonNull(config, "requiredConfig is null");
    requireNonNull(context, "context is null");

    Bootstrap app = new Bootstrap(
            new JsonModule(),
            new AccumuloModule(context.getTypeManager()));

    Injector injector = app
            .strictConfig()
            .doNotInitializeLogging()
            .setRequiredConfigurationProperties(config)
            .initialize();

    return injector.getInstance(AccumuloConnector.class);
}
 
Example 4
Source File: MemoryConnectorFactory.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public Connector create(String catalogName, Map<String, String> requiredConfig, ConnectorContext context)
{
    requireNonNull(requiredConfig, "requiredConfig is null");

    // A plugin is not required to use Guice; it is just very convenient
    Bootstrap app = new Bootstrap(
            new JsonModule(),
            new MemoryModule(context.getTypeManager(), context.getNodeManager()));

    Injector injector = app
            .strictConfig()
            .doNotInitializeLogging()
            .setRequiredConfigurationProperties(requiredConfig)
            .initialize();

    return injector.getInstance(MemoryConnector.class);
}
 
Example 5
Source File: KuduConnectorFactory.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context)
{
    requireNonNull(config, "config is null");

    Bootstrap app = new Bootstrap(
            new JsonModule(),
            new KuduModule(context.getTypeManager()));

    Injector injector = app
            .strictConfig()
            .doNotInitializeLogging()
            .setRequiredConfigurationProperties(config)
            .initialize();

    return injector.getInstance(KuduConnector.class);
}
 
Example 6
Source File: SheetsConnectorFactory.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context)
{
    requireNonNull(config, "config is null");

    Bootstrap app = new Bootstrap(
            new JsonModule(),
            new SheetsModule(context.getTypeManager()));

    Injector injector = app
            .strictConfig()
            .doNotInitializeLogging()
            .setRequiredConfigurationProperties(config)
            .initialize();

    return injector.getInstance(SheetsConnector.class);
}
 
Example 7
Source File: PinotConnectorFactory.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context)
{
    requireNonNull(catalogName, "connectorId is null");
    requireNonNull(config, "config is null");
    Bootstrap app = new Bootstrap(
            new JsonModule(),
            new MBeanModule(),
            new PinotModule(catalogName, context.getTypeManager(), context.getNodeManager()));

    Injector injector = app.strictConfig()
            .doNotInitializeLogging()
            .setRequiredConfigurationProperties(config)
            .initialize();

    return injector.getInstance(PinotConnector.class);
}
 
Example 8
Source File: BlackHoleConnectorFactory.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public Connector create(String catalogName, Map<String, String> requiredConfig, ConnectorContext context)
{
    ListeningScheduledExecutorService executorService = listeningDecorator(newSingleThreadScheduledExecutor(daemonThreadsNamed("blackhole")));
    return new BlackHoleConnector(
            new BlackHoleMetadata(),
            new BlackHoleSplitManager(),
            new BlackHolePageSourceProvider(executorService),
            new BlackHolePageSinkProvider(executorService),
            new BlackHoleNodePartitioningProvider(context.getNodeManager()),
            context.getTypeManager(),
            executorService);
}
 
Example 9
Source File: AtopConnectorFactory.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public Connector create(String catalogName, Map<String, String> requiredConfig, ConnectorContext context)
{
    requireNonNull(requiredConfig, "requiredConfig is null");

    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
        Bootstrap app = new Bootstrap(
                new AtopModule(
                        atopFactoryClass,
                        context.getTypeManager(),
                        context.getNodeManager(),
                        context.getNodeManager().getEnvironment(),
                        catalogName),
                installModuleIf(
                        AtopConnectorConfig.class,
                        config -> config.getSecurity() == AtopSecurity.NONE,
                        new AllowAllAccessControlModule()),
                installModuleIf(
                        AtopConnectorConfig.class,
                        config -> config.getSecurity() == AtopSecurity.FILE,
                        binder -> {
                            binder.install(new FileBasedAccessControlModule(catalogName));
                            binder.install(new JsonModule());
                        }));

        Injector injector = app
                .strictConfig()
                .doNotInitializeLogging()
                .setRequiredConfigurationProperties(requiredConfig)
                .initialize();

        return injector.getInstance(AtopConnector.class);
    }
}
 
Example 10
Source File: PulsarConnectorFactory.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context) {
    requireNonNull(config, "requiredConfig is null");
    if (log.isDebugEnabled()) {
        log.debug("Creating Pulsar connector with configs: %s", config);
    }
    try {
        // A plugin is not required to use Guice; it is just very convenient
        Bootstrap app = new Bootstrap(
                new JsonModule(),
                new PulsarConnectorModule(connectorId, context.getTypeManager())
        );

        Injector injector = app
                .strictConfig()
                .doNotInitializeLogging()
                .setRequiredConfigurationProperties(config)
                .initialize();

        PulsarConnector connector = injector.getInstance(PulsarConnector.class);
        connector.initConnectorCache();
        return connector;
    } catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}