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