Search in sources :

Example 1 with ReloadingResourceGroupConfigurationManagerModule

use of com.facebook.presto.resourceGroups.reloading.ReloadingResourceGroupConfigurationManagerModule in project presto by prestodb.

the class H2ResourceGroupConfigurationManagerFactory method create.

@Override
public ResourceGroupConfigurationManager<VariableMap> create(Map<String, String> config, ResourceGroupConfigurationManagerContext context) {
    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
        Bootstrap app = new Bootstrap(new JsonModule(), new H2ResourceGroupsModule(), new NodeModule(), new ReloadingResourceGroupConfigurationManagerModule(), binder -> binder.bind(ResourceGroupConfigurationManagerContext.class).toInstance(context), binder -> binder.bind(ClusterMemoryPoolManager.class).toInstance(context.getMemoryPoolManager()));
        Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).quiet().initialize();
        return injector.getInstance(ReloadingResourceGroupConfigurationManager.class);
    } catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
Also used : ReloadingResourceGroupConfigurationManagerModule(com.facebook.presto.resourceGroups.reloading.ReloadingResourceGroupConfigurationManagerModule) NodeModule(com.facebook.airlift.node.NodeModule) Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) ThreadContextClassLoader(com.facebook.presto.spi.classloader.ThreadContextClassLoader) JsonModule(com.facebook.airlift.json.JsonModule)

Example 2 with ReloadingResourceGroupConfigurationManagerModule

use of com.facebook.presto.resourceGroups.reloading.ReloadingResourceGroupConfigurationManagerModule 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);
    }
}
Also used : ReloadingResourceGroupConfigurationManagerModule(com.facebook.presto.resourceGroups.reloading.ReloadingResourceGroupConfigurationManagerModule) Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) JsonModule(com.facebook.airlift.json.JsonModule)

Aggregations

Bootstrap (com.facebook.airlift.bootstrap.Bootstrap)2 JsonModule (com.facebook.airlift.json.JsonModule)2 ReloadingResourceGroupConfigurationManagerModule (com.facebook.presto.resourceGroups.reloading.ReloadingResourceGroupConfigurationManagerModule)2 Injector (com.google.inject.Injector)2 NodeModule (com.facebook.airlift.node.NodeModule)1 ThreadContextClassLoader (com.facebook.presto.spi.classloader.ThreadContextClassLoader)1