use of io.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class RaptorConnectorFactory method create.
@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context) {
NodeManager nodeManager = context.getNodeManager();
try {
Bootstrap app = new Bootstrap(new JsonModule(), new MBeanModule(), binder -> {
MBeanServer mbeanServer = new RebindSafeMBeanServer(getPlatformMBeanServer());
binder.bind(MBeanServer.class).toInstance(mbeanServer);
binder.bind(NodeManager.class).toInstance(nodeManager);
binder.bind(PageSorter.class).toInstance(context.getPageSorter());
binder.bind(TypeManager.class).toInstance(context.getTypeManager());
}, metadataModule, new BackupModule(backupProviders), new StorageModule(connectorId), new RaptorModule(connectorId));
Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(RaptorConnector.class);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
use of io.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class FileResourceGroupConfigurationManagerFactory method create.
@Override
public ResourceGroupConfigurationManager create(Map<String, String> config, ResourceGroupConfigurationManagerContext context) {
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
Bootstrap app = new Bootstrap(new JsonModule(), new FileResourceGroupsModule(), binder -> binder.bind(ClusterMemoryPoolManager.class).toInstance(context.getMemoryPoolManager()));
Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(FileResourceGroupConfigurationManager.class);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
use of io.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class DbResourceGroupConfigurationManagerFactory method create.
@Override
public ResourceGroupConfigurationManager create(Map<String, String> config, ResourceGroupConfigurationManagerContext context) {
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
Bootstrap app = new Bootstrap(new JsonModule(), new DbResourceGroupsModule(), binder -> binder.bind(ClusterMemoryPoolManager.class).toInstance(context.getMemoryPoolManager()));
Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(DbResourceGroupConfigurationManager.class);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
use of io.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class RedisConnectorFactory method create.
@Override
public Connector create(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 RedisConnectorModule(), binder -> {
binder.bind(RedisConnectorId.class).toInstance(new RedisConnectorId(connectorId));
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.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(RedisConnector.class);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
use of io.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class H2ResourceGroupConfigurationManagerFactory method create.
@Override
public ResourceGroupConfigurationManager create(Map<String, String> config, ResourceGroupConfigurationManagerContext context) {
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
Bootstrap app = new Bootstrap(new JsonModule(), new H2ResourceGroupsModule(), binder -> binder.bind(ClusterMemoryPoolManager.class).toInstance(context.getMemoryPoolManager()));
Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(DbResourceGroupConfigurationManager.class);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
Aggregations