Search in sources :

Example 46 with Bootstrap

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

the class AccumuloConnectorFactory method create.

@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");
    try {
        // A plugin is not required to use Guice; it is just very convenient
        // Unless you don't really know how to Guice, then it is less convenient
        Bootstrap app = new Bootstrap(new JsonModule(), new AccumuloModule(catalogName, context.getTypeManager()));
        Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        return injector.getInstance(AccumuloConnector.class);
    } catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
Also used : Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) JsonModule(com.facebook.airlift.json.JsonModule)

Example 47 with Bootstrap

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

the class DruidConnectorFactory method create.

@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
    requireNonNull(config, "config is null");
    try {
        Bootstrap app = new Bootstrap(new JsonModule(), new DruidModule(), new DruidAuthenticationModule(), binder -> {
            binder.bind(TypeManager.class).toInstance(context.getTypeManager());
            binder.bind(FunctionMetadataManager.class).toInstance(context.getFunctionMetadataManager());
            binder.bind(RowExpressionService.class).toInstance(context.getRowExpressionService());
            binder.bind(StandardFunctionResolution.class).toInstance(context.getStandardFunctionResolution());
            binder.bind(DeterminismEvaluator.class).toInstance(context.getRowExpressionService().getDeterminismEvaluator());
        });
        Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        return injector.getInstance(DruidConnector.class);
    } catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
Also used : DruidAuthenticationModule(com.facebook.presto.druid.authentication.DruidAuthenticationModule) RowExpressionService(com.facebook.presto.spi.relation.RowExpressionService) DeterminismEvaluator(com.facebook.presto.spi.relation.DeterminismEvaluator) Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) TypeManager(com.facebook.presto.common.type.TypeManager) StandardFunctionResolution(com.facebook.presto.spi.function.StandardFunctionResolution) JsonModule(com.facebook.airlift.json.JsonModule) FunctionMetadataManager(com.facebook.presto.spi.function.FunctionMetadataManager)

Example 48 with Bootstrap

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

the class AbstractBenchmarkCommand method run.

@Override
public void run() {
    Bootstrap app = new Bootstrap(ImmutableList.<Module>builder().add(new BenchmarkSuiteModule(getCustomBenchmarkSuiteSupplierTypes())).add(new BenchmarkModule(getSqlParserOptions(), getParsingOptions(), getExceptionClassifier())).add(new EventClientModule(ImmutableSet.of())).addAll(getAdditionalModules()).build());
    Injector injector = null;
    try {
        injector = app.initialize();
    } catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    } finally {
        if (injector != null) {
            try {
                injector.getInstance(LifeCycleManager.class).stop();
            } catch (Exception e) {
                log.error(e);
            }
        }
    }
}
Also used : LifeCycleManager(com.facebook.airlift.bootstrap.LifeCycleManager) Injector(com.google.inject.Injector) BenchmarkModule(com.facebook.presto.benchmark.framework.BenchmarkModule) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) BenchmarkModule(com.facebook.presto.benchmark.framework.BenchmarkModule) BenchmarkSuiteModule(com.facebook.presto.benchmark.source.BenchmarkSuiteModule) Module(com.google.inject.Module) EventClientModule(com.facebook.presto.benchmark.event.EventClientModule) BenchmarkSuiteModule(com.facebook.presto.benchmark.source.BenchmarkSuiteModule) EventClientModule(com.facebook.presto.benchmark.event.EventClientModule)

Example 49 with Bootstrap

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

the class PercentileClusterTtlProviderFactory method create.

@Override
public ClusterTtlProvider create(Map<String, String> config) {
    try {
        Bootstrap app = new Bootstrap(new PercentileBasedClusterTtlProviderModule());
        Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        return injector.getInstance(ClusterTtlProvider.class);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap)

Example 50 with Bootstrap

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

the class TestMySqlFunctionNamespaceManager method setup.

@BeforeClass
public void setup() throws Exception {
    this.mySqlServer = new TestingMySqlServer("testuser", "testpass", DB);
    Bootstrap app = new Bootstrap(new MySqlFunctionNamespaceManagerModule(TEST_CATALOG), new SimpleAddressSqlFunctionExecutorsModule(), new DriftNettyClientModule(), new MySqlConnectionModule());
    Map<String, String> config = ImmutableMap.<String, String>builder().put("function-cache-expiration", "0s").put("function-instance-cache-expiration", "0s").put("database-url", mySqlServer.getJdbcUrl(DB)).build();
    try {
        this.injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        this.functionNamespaceManager = injector.getInstance(MySqlFunctionNamespaceManager.class);
        this.jdbi = injector.getInstance(Jdbi.class);
    } catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
Also used : SimpleAddressSqlFunctionExecutorsModule(com.facebook.presto.functionNamespace.execution.SimpleAddressSqlFunctionExecutorsModule) Jdbi(org.jdbi.v3.core.Jdbi) TestingMySqlServer(com.facebook.presto.testing.mysql.TestingMySqlServer) DriftNettyClientModule(com.facebook.drift.transport.netty.client.DriftNettyClientModule) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) PrestoException(com.facebook.presto.spi.PrestoException) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) BeforeClass(org.testng.annotations.BeforeClass)

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