Search in sources :

Example 16 with Bootstrap

use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.

the class DbResourceGroupConfigurationManagerFactory method create.

@Override
public ResourceGroupConfigurationManager<VariableMap> create(Map<String, String> config, ResourceGroupConfigurationManagerContext context) {
    try {
        Bootstrap app = new Bootstrap(new JsonModule(), new DbResourceGroupsModule(), new ReloadingResourceGroupConfigurationManagerModule(), binder -> binder.bind(String.class).annotatedWith(ForEnvironment.class).toInstance(context.getEnvironment()), binder -> binder.bind(ClusterMemoryPoolManager.class).toInstance(context.getMemoryPoolManager()));
        Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        return injector.getInstance(ReloadingResourceGroupConfigurationManager.class);
    } catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
Also used : ReloadingResourceGroupConfigurationManagerModule(com.facebook.presto.resourceGroups.reloading.ReloadingResourceGroupConfigurationManagerModule) Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) JsonModule(com.facebook.airlift.json.JsonModule)

Example 17 with Bootstrap

use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.

the class TestSourceQueryModule method testInvalidSourceQuerySupplier.

@Test(expectedExceptions = CreationException.class, expectedExceptionsMessageRegExp = "Unable to create injector.*")
public void testInvalidSourceQuerySupplier() throws Exception {
    Bootstrap app = new Bootstrap(ImmutableList.<Module>builder().add(new SourceQueryModule(ImmutableSet.of("test-supplier"))).build());
    app.setRequiredConfigurationProperties(ImmutableMap.<String, String>builder().putAll(DEFAULT_CONFIGURATION_PROPERTIES).put("source-query.supplier", "unknown-supplier").build()).initialize();
}
Also used : Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) Test(org.testng.annotations.Test)

Example 18 with Bootstrap

use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.

the class TestSourceQueryModule method testCustomSourceQuerySupplier.

@Test
public void testCustomSourceQuerySupplier() throws Exception {
    Bootstrap app = new Bootstrap(ImmutableList.<Module>builder().add(new SourceQueryModule(ImmutableSet.of("test-supplier"))).build());
    app.setRequiredConfigurationProperties(ImmutableMap.<String, String>builder().putAll(DEFAULT_CONFIGURATION_PROPERTIES).put("source-query.supplier", "test-supplier").build()).initialize();
}
Also used : Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) Test(org.testng.annotations.Test)

Example 19 with Bootstrap

use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.

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");
    try {
        Bootstrap app = new Bootstrap(new JsonModule(), new RedisConnectorModule(), binder -> {
            binder.bind(RedisConnectorId.class).toInstance(new RedisConnectorId(catalogName));
            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.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        return injector.getInstance(RedisConnector.class);
    } catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
Also used : JsonModule(com.facebook.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(com.facebook.airlift.bootstrap.Bootstrap) TypeManager(com.facebook.presto.common.type.TypeManager) Supplier(java.util.function.Supplier) Map(java.util.Map)

Example 20 with Bootstrap

use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.

the class TestingThriftUdfServer method start.

public static void start(Map<String, String> properties) {
    Bootstrap app = new Bootstrap(ImmutableList.<Module>builder().add(new DriftNettyServerModule()).add(new TestingThriftUdfServerModule()).build());
    app.setRequiredConfigurationProperties(properties).initialize();
}
Also used : DriftNettyServerModule(com.facebook.drift.transport.netty.server.DriftNettyServerModule) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) Module(com.google.inject.Module) DriftNettyServerModule(com.facebook.drift.transport.netty.server.DriftNettyServerModule)

Aggregations

Bootstrap (com.facebook.airlift.bootstrap.Bootstrap)61 Injector (com.google.inject.Injector)54 JsonModule (com.facebook.airlift.json.JsonModule)36 TypeManager (com.facebook.presto.common.type.TypeManager)16 Module (com.google.inject.Module)12 Test (org.testng.annotations.Test)12 LifeCycleManager (com.facebook.airlift.bootstrap.LifeCycleManager)11 NodeManager (com.facebook.presto.spi.NodeManager)10 JsonBinder.jsonBinder (com.facebook.airlift.json.JsonBinder.jsonBinder)7 FeaturesConfig (com.facebook.presto.sql.analyzer.FeaturesConfig)7 ImmutableList (com.google.common.collect.ImmutableList)7 MBeanModule (org.weakref.jmx.guice.MBeanModule)7 ConfigBinder.configBinder (com.facebook.airlift.configuration.ConfigBinder.configBinder)6 JsonCodecBinder.jsonCodecBinder (com.facebook.airlift.json.JsonCodecBinder.jsonCodecBinder)6 Type (com.facebook.presto.common.type.Type)6 FunctionAndTypeManager (com.facebook.presto.metadata.FunctionAndTypeManager)6 FunctionAndTypeManager.createTestFunctionAndTypeManager (com.facebook.presto.metadata.FunctionAndTypeManager.createTestFunctionAndTypeManager)6 HandleJsonModule (com.facebook.presto.metadata.HandleJsonModule)6 ThreadContextClassLoader (com.facebook.presto.spi.classloader.ThreadContextClassLoader)6 RowExpressionService (com.facebook.presto.spi.relation.RowExpressionService)6