use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class JmxConnectorFactory method create.
@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
try {
Bootstrap app = new Bootstrap(binder -> {
configBinder(binder).bindConfig(JmxConnectorConfig.class);
binder.bind(MBeanServer.class).toInstance(new RebindSafeMBeanServer(mbeanServer));
binder.bind(NodeManager.class).toInstance(context.getNodeManager());
binder.bind(JmxConnector.class).in(Scopes.SINGLETON);
binder.bind(JmxHistoricalData.class).in(Scopes.SINGLETON);
binder.bind(JmxMetadata.class).in(Scopes.SINGLETON);
binder.bind(JmxSplitManager.class).in(Scopes.SINGLETON);
binder.bind(JmxPeriodicSampler.class).in(Scopes.SINGLETON);
binder.bind(JmxRecordSetProvider.class).in(Scopes.SINGLETON);
});
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(JmxConnector.class);
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class MongoConnectorFactory 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 MongoClientModule(), binder -> binder.bind(TypeManager.class).toInstance(context.getTypeManager()));
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(MongoConnector.class);
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class TestWindowNode method getJsonCodec.
private JsonCodec<WindowNode> getJsonCodec() throws Exception {
Module module = binder -> {
SqlParser sqlParser = new SqlParser();
FunctionAndTypeManager functionAndTypeManager = createTestFunctionAndTypeManager();
binder.install(new JsonModule());
binder.install(new HandleJsonModule());
binder.bind(SqlParser.class).toInstance(sqlParser);
binder.bind(TypeManager.class).toInstance(functionAndTypeManager);
configBinder(binder).bindConfig(FeaturesConfig.class);
newSetBinder(binder, Type.class);
jsonBinder(binder).addSerializerBinding(Slice.class).to(SliceSerializer.class);
jsonBinder(binder).addDeserializerBinding(Slice.class).to(SliceDeserializer.class);
jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
jsonBinder(binder).addSerializerBinding(Expression.class).to(Serialization.ExpressionSerializer.class);
jsonBinder(binder).addDeserializerBinding(Expression.class).to(Serialization.ExpressionDeserializer.class);
jsonBinder(binder).addDeserializerBinding(FunctionCall.class).to(Serialization.FunctionCallDeserializer.class);
jsonBinder(binder).addKeySerializerBinding(VariableReferenceExpression.class).to(Serialization.VariableReferenceExpressionSerializer.class);
jsonBinder(binder).addKeyDeserializerBinding(VariableReferenceExpression.class).to(Serialization.VariableReferenceExpressionDeserializer.class);
jsonCodecBinder(binder).bindJsonCodec(WindowNode.class);
};
Bootstrap app = new Bootstrap(ImmutableList.of(module));
Injector injector = app.doNotInitializeLogging().quiet().initialize();
return injector.getInstance(new Key<JsonCodec<WindowNode>>() {
});
}
use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class KuduConnectorFactory 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 KuduModule(catalogName, context.getTypeManager()));
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(KuduConnector.class);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class LdapAuthenticatorFactory method create.
@Override
public PasswordAuthenticator create(Map<String, String> config) {
try {
Bootstrap app = new Bootstrap(binder -> {
configBinder(binder).bindConfig(LdapConfig.class);
binder.bind(LdapAuthenticator.class).in(Scopes.SINGLETON);
});
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(LdapAuthenticator.class);
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
Aggregations