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);
}
}
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);
}
}
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);
}
}
}
}
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);
}
}
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);
}
}
Aggregations