use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class PinotConnectorFactory method create.
@Override
public Connector create(final String connectorId, Map<String, String> config, ConnectorContext context) {
requireNonNull(connectorId, "connectorId is null");
requireNonNull(config, "config is null");
try {
Bootstrap app = new Bootstrap(new JsonModule(), new MBeanModule(), new PinotModule(connectorId), binder -> {
binder.bind(MBeanServer.class).toInstance(new RebindSafeMBeanServer(getPlatformMBeanServer()));
binder.bind(ConnectorId.class).toInstance(new ConnectorId(connectorId));
binder.bind(TypeManager.class).toInstance(context.getTypeManager());
binder.bind(FunctionMetadataManager.class).toInstance(context.getFunctionMetadataManager());
binder.bind(NodeManager.class).toInstance(context.getNodeManager());
binder.bind(RowExpressionService.class).toInstance(context.getRowExpressionService());
binder.bind(LogicalRowExpressions.class).toInstance(new LogicalRowExpressions(context.getRowExpressionService().getDeterminismEvaluator(), context.getStandardFunctionResolution(), context.getFunctionMetadataManager()));
binder.bind(StandardFunctionResolution.class).toInstance(context.getStandardFunctionResolution());
binder.bind(PinotMetrics.class).in(Scopes.SINGLETON);
newExporter(binder).export(PinotMetrics.class).as(generatedNameOf(PinotMetrics.class, connectorId));
binder.bind(ConnectorNodePartitioningProvider.class).to(PinotNodePartitioningProvider.class).in(Scopes.SINGLETON);
});
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(PinotConnector.class);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class H2FunctionNamespaceManagerFactory method create.
@Override
public FunctionNamespaceManager<?> create(String catalogName, Map<String, String> config, FunctionNamespaceManagerContext context) {
try {
Bootstrap app = new Bootstrap(new DriftNettyClientModule(), new MySqlFunctionNamespaceManagerModule(catalogName), new H2ConnectionModule(), 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 AbstractVerifyCommand method run.
@Override
public void run() {
if (configFilename != null) {
System.setProperty("config", configFilename);
}
Bootstrap app = new Bootstrap(ImmutableList.<Module>builder().add(new VerifierModule(getSqlParserOptions(), getCustomQueryFilterClasses())).add(new SourceQueryModule(getCustomSourceQuerySupplierTypes())).add(new EventClientModule(getCustomEventClientTypes())).add(new QueryActionsModule(getSqlExceptionClassifier(), getCustomQueryActionTypes())).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 TestPrestoQuerySourceQuerySupplier method setup.
@BeforeClass
public void setup() throws Exception {
queryRunner = setupPresto();
String host = queryRunner.getServer().getAddress().getHost();
int port = queryRunner.getServer().getAddress().getPort();
Bootstrap app = new Bootstrap(ImmutableList.<Module>builder().add(new SourceQueryModule(ImmutableSet.of())).add(new QueryActionsModule(PrestoExceptionClassifier.defaultBuilder().build(), ImmutableSet.of())).add(binder -> {
configBinder(binder).bindConfig(VerifierConfig.class);
binder.bind(SqlParserOptions.class).toInstance(new SqlParserOptions());
binder.bind(SqlParser.class).in(SINGLETON);
}).build());
injector = app.setRequiredConfigurationProperties(ImmutableMap.<String, String>builder().put("test-id", "10000").put("control.hosts", format("%s,%s", host, host)).put("control.jdbc-port", String.valueOf(port)).put("source-query.supplier", "presto-query").put("source-query.query", SOURCE_FETCHING_QUERY).put("source-query.catalog", CATALOG).put("source-query.schema", SCHEMA).put("source-query.username", "test_user").build()).initialize();
}
use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class TestSourceQueryModule method testMySqlSourceQuerySupplier.
@Test
public void testMySqlSourceQuerySupplier() throws Exception {
Bootstrap app = new Bootstrap(ImmutableList.<Module>builder().add(new SourceQueryModule(ImmutableSet.of())).build());
Injector injector = app.setRequiredConfigurationProperties(ImmutableMap.<String, String>builder().putAll(DEFAULT_CONFIGURATION_PROPERTIES).put("source-query.database", "jdbc://localhost:1080").put("source-query.suites", "test").put("source-query.max-queries-per-suite", "1000").build()).initialize();
assertTrue(injector.getInstance(SourceQuerySupplier.class) instanceof MySqlSourceQuerySupplier);
}
Aggregations