use of com.facebook.airlift.json.JsonModule in project presto by prestodb.
the class FileSessionPropertyManagerFactory method create.
@Override
public SessionPropertyConfigurationManager create(Map<String, String> config, SessionPropertyConfigurationManagerContext context) {
try {
Bootstrap app = new Bootstrap(new JsonModule(), new FileSessionPropertyManagerModule());
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(FileSessionPropertyManager.class);
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
use of com.facebook.airlift.json.JsonModule in project presto by prestodb.
the class FileResourceGroupConfigurationManagerFactory method create.
@Override
public ResourceGroupConfigurationManager<VariableMap> create(Map<String, String> config, ResourceGroupConfigurationManagerContext context) {
try {
Bootstrap app = new Bootstrap(new JsonModule(), new FileResourceGroupsModule(), binder -> binder.bind(ClusterMemoryPoolManager.class).toInstance(context.getMemoryPoolManager()));
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(FileResourceGroupConfigurationManager.class);
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
use of com.facebook.airlift.json.JsonModule in project presto by prestodb.
the class DbResourceGroupConfigurationManagerFactory method create.
@Override
public ResourceGroupConfigurationManager<VariableMap> create(Map<String, String> config, ResourceGroupConfigurationManagerContext context) {
try {
Bootstrap app = new Bootstrap(new JsonModule(), new DbResourceGroupsModule(), new ReloadingResourceGroupConfigurationManagerModule(), binder -> binder.bind(String.class).annotatedWith(ForEnvironment.class).toInstance(context.getEnvironment()), binder -> binder.bind(ClusterMemoryPoolManager.class).toInstance(context.getMemoryPoolManager()));
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(ReloadingResourceGroupConfigurationManager.class);
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
use of com.facebook.airlift.json.JsonModule in project presto by prestodb.
the class RedisConnectorFactory method create.
@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
requireNonNull(catalogName, "catalogName is null");
requireNonNull(config, "config is null");
try {
Bootstrap app = new Bootstrap(new JsonModule(), new RedisConnectorModule(), binder -> {
binder.bind(RedisConnectorId.class).toInstance(new RedisConnectorId(catalogName));
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.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(RedisConnector.class);
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
use of com.facebook.airlift.json.JsonModule in project presto by prestodb.
the class TestHeartbeatFailureDetector method testExcludesCurrentNode.
@Test
public void testExcludesCurrentNode() throws Exception {
Bootstrap app = new Bootstrap(new TestingNodeModule(), new TestingJmxModule(), new TestingDiscoveryModule(), new TestingHttpServerModule(), new TraceTokenModule(), new JsonModule(), new JaxrsModule(true), new FailureDetectorModule(), new Module() {
@Override
public void configure(Binder binder) {
configBinder(binder).bindConfig(InternalCommunicationConfig.class);
configBinder(binder).bindConfig(QueryManagerConfig.class);
discoveryBinder(binder).bindSelector("presto");
discoveryBinder(binder).bindHttpAnnouncement("presto");
// Jersey with jetty 9 requires at least one resource
// todo add a dummy resource to airlift jaxrs in this case
jaxrsBinder(binder).bind(FooResource.class);
}
});
Injector injector = app.doNotInitializeLogging().quiet().initialize();
ServiceSelector selector = injector.getInstance(Key.get(ServiceSelector.class, serviceType("presto")));
assertEquals(selector.selectAllServices().size(), 1);
HeartbeatFailureDetector detector = injector.getInstance(HeartbeatFailureDetector.class);
detector.updateMonitoredServices();
assertEquals(detector.getTotalCount(), 0);
assertEquals(detector.getActiveCount(), 0);
assertEquals(detector.getFailedCount(), 0);
assertTrue(detector.getFailed().isEmpty());
}
Aggregations