use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class HiveFunctionNamespaceManagerFactory method create.
@Override
public FunctionNamespaceManager<?> create(String catalogName, Map<String, String> config, FunctionNamespaceManagerContext context) {
requireNonNull(config, "config is null");
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
Bootstrap app = new Bootstrap(new HiveFunctionModule(catalogName, classLoader, context.getTypeManager()));
Injector injector = app.noStrictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).quiet().initialize();
return injector.getInstance(FunctionNamespaceManager.class);
}
}
use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class TestHiveSplit method getJsonCodec.
private JsonCodec<HiveSplit> getJsonCodec() throws Exception {
Module module = binder -> {
binder.install(new JsonModule());
binder.install(new HandleJsonModule());
configBinder(binder).bindConfig(FeaturesConfig.class);
FunctionAndTypeManager functionAndTypeManager = createTestFunctionAndTypeManager();
binder.bind(TypeManager.class).toInstance(functionAndTypeManager);
jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
newSetBinder(binder, Type.class);
binder.bind(BlockEncodingSerde.class).to(BlockEncodingManager.class).in(Scopes.SINGLETON);
newSetBinder(binder, BlockEncoding.class);
jsonBinder(binder).addSerializerBinding(Block.class).to(BlockJsonSerde.Serializer.class);
jsonBinder(binder).addDeserializerBinding(Block.class).to(BlockJsonSerde.Deserializer.class);
jsonCodecBinder(binder).bindJsonCodec(HiveSplit.class);
};
Bootstrap app = new Bootstrap(ImmutableList.of(module));
Injector injector = app.doNotInitializeLogging().quiet().initialize();
HandleResolver handleResolver = injector.getInstance(HandleResolver.class);
handleResolver.addConnectorName("hive", new HiveHandleResolver());
return injector.getInstance(new Key<JsonCodec<HiveSplit>>() {
});
}
use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class TestBenchmarkSuiteModule method testDbBenchmarkSuiteSupplier.
@Test
public void testDbBenchmarkSuiteSupplier() {
Bootstrap app = new Bootstrap(ImmutableList.<Module>builder().add(new BenchmarkSuiteModule(ImmutableSet.of())).build());
Injector injector = null;
try {
injector = app.setRequiredConfigurationProperties(ImmutableMap.<String, String>builder().putAll(DEFAULT_CONFIGURATION_PROPERTIES).put("benchmark-suite.database-url", "jdbc://localhost:1080").put("benchmark-suite.suite", "test").build()).initialize();
assertTrue(injector.getInstance(BenchmarkSuiteSupplier.class) instanceof MySqlBenchmarkSuiteSupplier);
} finally {
if (injector != null) {
injector.getInstance(LifeCycleManager.class).stop();
}
}
}
use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class TestBenchmarkSuiteModule method testInvalidBenchmarkSuiteSupplier.
@Test(expectedExceptions = CreationException.class, expectedExceptionsMessageRegExp = "Unable to create injector.*")
public void testInvalidBenchmarkSuiteSupplier() {
Bootstrap app = new Bootstrap(ImmutableList.<Module>builder().add(new BenchmarkSuiteModule(ImmutableSet.of("test-supplier"))).build());
Injector injector = null;
try {
injector = app.setRequiredConfigurationProperties(ImmutableMap.<String, String>builder().putAll(DEFAULT_CONFIGURATION_PROPERTIES).put("benchmark-query-supplier", "unknown-supplier").build()).initialize();
} finally {
if (injector != null) {
injector.getInstance(LifeCycleManager.class).stop();
}
}
}
use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class TestingElasticsearchConnectorFactory 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 ElasticsearchConnectorModule(), binder -> {
binder.bind(TypeManager.class).toInstance(context.getTypeManager());
binder.bind(NodeManager.class).toInstance(context.getNodeManager());
});
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(ElasticsearchConnector.class);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations