Search in sources :

Example 6 with JsonModule

use of io.airlift.json.JsonModule in project presto by prestodb.

the class FileResourceGroupConfigurationManagerFactory method create.

@Override
public ResourceGroupConfigurationManager create(Map<String, String> config, ResourceGroupConfigurationManagerContext context) {
    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
        Bootstrap app = new Bootstrap(new JsonModule(), new FileResourceGroupsModule(), binder -> binder.bind(ClusterMemoryPoolManager.class).toInstance(context.getMemoryPoolManager()));
        Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        return injector.getInstance(FileResourceGroupConfigurationManager.class);
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
Also used : Injector(com.google.inject.Injector) Bootstrap(io.airlift.bootstrap.Bootstrap) ThreadContextClassLoader(com.facebook.presto.spi.classloader.ThreadContextClassLoader) JsonModule(io.airlift.json.JsonModule)

Example 7 with JsonModule

use of io.airlift.json.JsonModule in project presto by prestodb.

the class DbResourceGroupConfigurationManagerFactory method create.

@Override
public ResourceGroupConfigurationManager create(Map<String, String> config, ResourceGroupConfigurationManagerContext context) {
    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
        Bootstrap app = new Bootstrap(new JsonModule(), new DbResourceGroupsModule(), binder -> binder.bind(ClusterMemoryPoolManager.class).toInstance(context.getMemoryPoolManager()));
        Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        return injector.getInstance(DbResourceGroupConfigurationManager.class);
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
Also used : Injector(com.google.inject.Injector) Bootstrap(io.airlift.bootstrap.Bootstrap) ThreadContextClassLoader(com.facebook.presto.spi.classloader.ThreadContextClassLoader) JsonModule(io.airlift.json.JsonModule)

Example 8 with JsonModule

use of io.airlift.json.JsonModule in project presto by prestodb.

the class RedisConnectorFactory method create.

@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context) {
    requireNonNull(connectorId, "connectorId is null");
    requireNonNull(config, "config is null");
    try {
        Bootstrap app = new Bootstrap(new JsonModule(), new RedisConnectorModule(), binder -> {
            binder.bind(RedisConnectorId.class).toInstance(new RedisConnectorId(connectorId));
            binder.bind(TypeManager.class).toInstance(context.getTypeManager());
            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.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        return injector.getInstance(RedisConnector.class);
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
Also used : JsonModule(io.airlift.json.JsonModule) SchemaTableName(com.facebook.presto.spi.SchemaTableName) NodeManager(com.facebook.presto.spi.NodeManager) TypeLiteral(com.google.inject.TypeLiteral) Injector(com.google.inject.Injector) Bootstrap(io.airlift.bootstrap.Bootstrap) TypeManager(com.facebook.presto.spi.type.TypeManager) Supplier(java.util.function.Supplier) Map(java.util.Map)

Example 9 with JsonModule

use of io.airlift.json.JsonModule in project presto by prestodb.

the class H2ResourceGroupConfigurationManagerFactory method create.

@Override
public ResourceGroupConfigurationManager create(Map<String, String> config, ResourceGroupConfigurationManagerContext context) {
    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
        Bootstrap app = new Bootstrap(new JsonModule(), new H2ResourceGroupsModule(), binder -> binder.bind(ClusterMemoryPoolManager.class).toInstance(context.getMemoryPoolManager()));
        Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        return injector.getInstance(DbResourceGroupConfigurationManager.class);
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
Also used : Injector(com.google.inject.Injector) Bootstrap(io.airlift.bootstrap.Bootstrap) ThreadContextClassLoader(com.facebook.presto.spi.classloader.ThreadContextClassLoader) JsonModule(io.airlift.json.JsonModule)

Example 10 with JsonModule

use of io.airlift.json.JsonModule in project presto by prestodb.

the class KafkaConnectorFactory method create.

@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context) {
    requireNonNull(connectorId, "connectorId is null");
    requireNonNull(config, "config is null");
    try {
        Bootstrap app = new Bootstrap(new JsonModule(), new KafkaConnectorModule(), binder -> {
            binder.bind(KafkaConnectorId.class).toInstance(new KafkaConnectorId(connectorId));
            binder.bind(TypeManager.class).toInstance(context.getTypeManager());
            binder.bind(NodeManager.class).toInstance(context.getNodeManager());
            if (tableDescriptionSupplier.isPresent()) {
                binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, KafkaTopicDescription>>>() {
                }).toInstance(tableDescriptionSupplier.get());
            } else {
                binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, KafkaTopicDescription>>>() {
                }).to(KafkaTableDescriptionSupplier.class).in(Scopes.SINGLETON);
            }
        });
        Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        return injector.getInstance(KafkaConnector.class);
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
Also used : JsonModule(io.airlift.json.JsonModule) SchemaTableName(com.facebook.presto.spi.SchemaTableName) NodeManager(com.facebook.presto.spi.NodeManager) TypeLiteral(com.google.inject.TypeLiteral) Injector(com.google.inject.Injector) Bootstrap(io.airlift.bootstrap.Bootstrap) TypeManager(com.facebook.presto.spi.type.TypeManager) Supplier(java.util.function.Supplier) Map(java.util.Map)

Aggregations

Injector (com.google.inject.Injector)19 JsonModule (io.airlift.json.JsonModule)19 Bootstrap (io.airlift.bootstrap.Bootstrap)17 ThreadContextClassLoader (com.facebook.presto.spi.classloader.ThreadContextClassLoader)6 MBeanModule (org.weakref.jmx.guice.MBeanModule)4 NodeManager (com.facebook.presto.spi.NodeManager)3 TypeManager (com.facebook.presto.spi.type.TypeManager)3 Module (com.google.inject.Module)3 LifeCycleManager (io.airlift.bootstrap.LifeCycleManager)3 JaxrsModule (io.airlift.jaxrs.JaxrsModule)3 Map (java.util.Map)3 MBeanServer (javax.management.MBeanServer)3 BeforeMethod (org.testng.annotations.BeforeMethod)3 SchemaTableName (com.facebook.presto.spi.SchemaTableName)2 ClassLoaderSafeConnectorPageSourceProvider (com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorPageSourceProvider)2 ClassLoaderSafeConnectorSplitManager (com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorSplitManager)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Binder (com.google.inject.Binder)2 TypeLiteral (com.google.inject.TypeLiteral)2 TraceTokenModule (io.airlift.tracetoken.TraceTokenModule)2