use of io.airlift.json.JsonModule 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.json.JsonModule 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.json.JsonModule 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.json.JsonModule 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);
}
}
use of io.airlift.json.JsonModule in project presto by prestodb.
the class KafkaConnectorFactory 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 KafkaConnectorModule(), binder -> {
binder.bind(KafkaConnectorId.class).toInstance(new KafkaConnectorId(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, KafkaTopicDescription>>>() {
}).toInstance(tableDescriptionSupplier.get());
} else {
binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, KafkaTopicDescription>>>() {
}).to(KafkaTableDescriptionSupplier.class).in(Scopes.SINGLETON);
}
});
Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(KafkaConnector.class);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
Aggregations