Search in sources :

Example 6 with TypeDeserializerModule

use of io.trino.plugin.base.TypeDeserializerModule in project trino by trinodb.

the class AccumuloConnectorFactory method create.

@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
    requireNonNull(catalogName, "catalogName is null");
    requireNonNull(config, "config is null");
    requireNonNull(context, "context is null");
    Bootstrap app = new Bootstrap(new JsonModule(), new TypeDeserializerModule(context.getTypeManager()), new AccumuloModule());
    Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
    return injector.getInstance(AccumuloConnector.class);
}
Also used : Injector(com.google.inject.Injector) Bootstrap(io.airlift.bootstrap.Bootstrap) JsonModule(io.airlift.json.JsonModule) TypeDeserializerModule(io.trino.plugin.base.TypeDeserializerModule)

Example 7 with TypeDeserializerModule

use of io.trino.plugin.base.TypeDeserializerModule in project trino by trinodb.

the class TestingKinesisConnectorFactory method create.

@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
    requireNonNull(catalogName, "catalogName is null");
    requireNonNull(config, "config is null");
    try {
        Bootstrap app = new Bootstrap(new JsonModule(), new TypeDeserializerModule(context.getTypeManager()), new KinesisModule(), binder -> {
            binder.bind(NodeManager.class).toInstance(context.getNodeManager());
            binder.bind(KinesisClientProvider.class).toInstance(kinesisClientProvider);
            binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, KinesisStreamDescription>>>() {
            }).to(KinesisTableDescriptionSupplier.class).in(Scopes.SINGLETON);
        });
        Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        KinesisConnector connector = injector.getInstance(KinesisConnector.class);
        return connector;
    } catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
Also used : JsonModule(io.airlift.json.JsonModule) SchemaTableName(io.trino.spi.connector.SchemaTableName) NodeManager(io.trino.spi.NodeManager) Injector(com.google.inject.Injector) Bootstrap(io.airlift.bootstrap.Bootstrap) Supplier(java.util.function.Supplier) TypeDeserializerModule(io.trino.plugin.base.TypeDeserializerModule)

Example 8 with TypeDeserializerModule

use of io.trino.plugin.base.TypeDeserializerModule in project trino by trinodb.

the class RedisConnectorFactory method create.

@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
    requireNonNull(catalogName, "catalogName is null");
    requireNonNull(config, "config is null");
    Bootstrap app = new Bootstrap(new JsonModule(), new TypeDeserializerModule(context.getTypeManager()), new RedisConnectorModule(), binder -> {
        binder.bind(NodeManager.class).toInstance(context.getNodeManager());
        if (tableDescriptionSupplier.isPresent()) {
            binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, RedisTableDescription>>>() {
            }).toInstance(tableDescriptionSupplier.get());
        } else {
            binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, RedisTableDescription>>>() {
            }).to(RedisTableDescriptionSupplier.class).in(Scopes.SINGLETON);
        }
    });
    Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
    return injector.getInstance(RedisConnector.class);
}
Also used : JsonModule(io.airlift.json.JsonModule) SchemaTableName(io.trino.spi.connector.SchemaTableName) NodeManager(io.trino.spi.NodeManager) TypeLiteral(com.google.inject.TypeLiteral) Injector(com.google.inject.Injector) Bootstrap(io.airlift.bootstrap.Bootstrap) Supplier(java.util.function.Supplier) Map(java.util.Map) TypeDeserializerModule(io.trino.plugin.base.TypeDeserializerModule)

Example 9 with TypeDeserializerModule

use of io.trino.plugin.base.TypeDeserializerModule in project trino by trinodb.

the class PinotConnectorFactory method create.

@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
    requireNonNull(catalogName, "catalogName is null");
    requireNonNull(config, "config is null");
    ImmutableList.Builder<Module> modulesBuilder = ImmutableList.<Module>builder().add(new JsonModule()).add(new MBeanModule()).add(new TypeDeserializerModule(context.getTypeManager())).add(new PinotModule(catalogName, context.getNodeManager())).add(new PinotAuthenticationModule());
    extension.ifPresent(modulesBuilder::add);
    Bootstrap app = new Bootstrap(modulesBuilder.build());
    Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
    return injector.getInstance(PinotConnector.class);
}
Also used : PinotAuthenticationModule(io.trino.plugin.pinot.auth.PinotAuthenticationModule) MBeanModule(org.weakref.jmx.guice.MBeanModule) ImmutableList(com.google.common.collect.ImmutableList) Injector(com.google.inject.Injector) Bootstrap(io.airlift.bootstrap.Bootstrap) Module(com.google.inject.Module) MBeanModule(org.weakref.jmx.guice.MBeanModule) TypeDeserializerModule(io.trino.plugin.base.TypeDeserializerModule) PinotAuthenticationModule(io.trino.plugin.pinot.auth.PinotAuthenticationModule) JsonModule(io.airlift.json.JsonModule) JsonModule(io.airlift.json.JsonModule) TypeDeserializerModule(io.trino.plugin.base.TypeDeserializerModule)

Example 10 with TypeDeserializerModule

use of io.trino.plugin.base.TypeDeserializerModule in project trino by trinodb.

the class KinesisConnectorFactory method create.

@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
    requireNonNull(catalogName, "catalogName is null");
    requireNonNull(config, "config is null");
    try {
        Bootstrap app = new Bootstrap(new JsonModule(), new TypeDeserializerModule(context.getTypeManager()), new KinesisModule(), binder -> {
            binder.bind(NodeManager.class).toInstance(context.getNodeManager());
            binder.bind(KinesisClientProvider.class).to(KinesisClientManager.class).in(Scopes.SINGLETON);
            binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, KinesisStreamDescription>>>() {
            }).to(KinesisTableDescriptionSupplier.class).in(Scopes.SINGLETON);
        });
        Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        return injector.getInstance(KinesisConnector.class);
    } catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
Also used : JsonModule(io.airlift.json.JsonModule) SchemaTableName(io.trino.spi.connector.SchemaTableName) NodeManager(io.trino.spi.NodeManager) Injector(com.google.inject.Injector) Bootstrap(io.airlift.bootstrap.Bootstrap) Supplier(java.util.function.Supplier) TypeDeserializerModule(io.trino.plugin.base.TypeDeserializerModule)

Aggregations

Injector (com.google.inject.Injector)11 Bootstrap (io.airlift.bootstrap.Bootstrap)11 JsonModule (io.airlift.json.JsonModule)11 TypeDeserializerModule (io.trino.plugin.base.TypeDeserializerModule)11 NodeManager (io.trino.spi.NodeManager)6 SchemaTableName (io.trino.spi.connector.SchemaTableName)3 Supplier (java.util.function.Supplier)3 Module (com.google.inject.Module)2 TypeLiteral (com.google.inject.TypeLiteral)2 CatalogNameModule (io.trino.plugin.base.CatalogNameModule)2 ConnectorObjectNameGeneratorModule (io.trino.plugin.base.jmx.ConnectorObjectNameGeneratorModule)2 MBeanServerModule (io.trino.plugin.base.jmx.MBeanServerModule)2 MBeanModule (org.weakref.jmx.guice.MBeanModule)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)1 Binder (com.google.inject.Binder)1 Key (com.google.inject.Key)1 Scopes (com.google.inject.Scopes)1 Multibinder.newSetBinder (com.google.inject.multibindings.Multibinder.newSetBinder)1 LifeCycleManager (io.airlift.bootstrap.LifeCycleManager)1