use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class ExampleConnectorFactory method create.
@Override
public Connector create(String catalogName, Map<String, String> requiredConfig, ConnectorContext context) {
requireNonNull(requiredConfig, "requiredConfig is null");
try {
// A plugin is not required to use Guice; it is just very convenient
Bootstrap app = new Bootstrap(new JsonModule(), new ExampleModule(catalogName, context.getTypeManager()));
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(requiredConfig).initialize();
return injector.getInstance(ExampleConnector.class);
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class AtopConnectorFactory method create.
@Override
public Connector create(String catalogName, Map<String, String> requiredConfig, ConnectorContext context) {
requireNonNull(requiredConfig, "requiredConfig is null");
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
Bootstrap app = new Bootstrap(new AtopModule(atopFactoryClass, context.getTypeManager(), context.getNodeManager(), context.getNodeManager().getEnvironment(), catalogName), installModuleIf(AtopConnectorConfig.class, config -> config.getSecurity().equalsIgnoreCase(SECURITY_NONE), new AllowAllAccessControlModule()), installModuleIf(AtopConnectorConfig.class, config -> config.getSecurity().equalsIgnoreCase(SECURITY_FILE), binder -> {
binder.install(new FileBasedAccessControlModule());
binder.install(new JsonModule());
}));
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(requiredConfig).initialize();
return injector.getInstance(AtopConnector.class);
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class MySqlFunctionNamespaceManagerFactory method create.
@Override
public FunctionNamespaceManager<?> create(String catalogName, Map<String, String> config, FunctionNamespaceManagerContext context) {
try {
Bootstrap app = new Bootstrap(new MySqlFunctionNamespaceManagerModule(catalogName), new MySqlConnectionModule(), new SimpleAddressSqlFunctionExecutorsModule());
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(MySqlFunctionNamespaceManager.class);
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class MemoryConnectorFactory method create.
@Override
public Connector create(String catalogName, Map<String, String> requiredConfig, ConnectorContext context) {
requireNonNull(requiredConfig, "requiredConfig is null");
try {
// A plugin is not required to use Guice; it is just very convenient
Bootstrap app = new Bootstrap(new JsonModule(), new MemoryModule(catalogName, context.getTypeManager(), context.getNodeManager()));
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(requiredConfig).initialize();
return injector.getInstance(MemoryConnector.class);
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class TestBenchmarkSuiteModule method testCustomBenchmarkSuiteSupplier.
@Test
public void testCustomBenchmarkSuiteSupplier() {
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-suite-supplier", "test-supplier").build()).initialize();
} finally {
if (injector != null) {
injector.getInstance(LifeCycleManager.class).stop();
}
}
}
Aggregations