Search in sources :

Example 1 with ResourceGroupConfigurationManager

use of com.facebook.presto.spi.resourceGroups.ResourceGroupConfigurationManager in project presto by prestodb.

the class InternalResourceGroupManager method setConfigurationManager.

@VisibleForTesting
public void setConfigurationManager(String name, Map<String, String> properties) {
    requireNonNull(name, "name is null");
    requireNonNull(properties, "properties is null");
    log.info("-- Loading resource group configuration manager --");
    ResourceGroupConfigurationManagerFactory configurationManagerFactory = configurationManagerFactories.get(name);
    checkState(configurationManagerFactory != null, "Resource group configuration manager %s is not registered", name);
    ResourceGroupConfigurationManager configurationManager = configurationManagerFactory.create(ImmutableMap.copyOf(properties), () -> memoryPoolManager);
    checkState(this.configurationManager.compareAndSet(null, configurationManager), "configurationManager already set");
    log.info("-- Loaded resource group configuration manager %s --", name);
}
Also used : ResourceGroupConfigurationManagerFactory(com.facebook.presto.spi.resourceGroups.ResourceGroupConfigurationManagerFactory) ResourceGroupConfigurationManager(com.facebook.presto.spi.resourceGroups.ResourceGroupConfigurationManager) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with ResourceGroupConfigurationManager

use of com.facebook.presto.spi.resourceGroups.ResourceGroupConfigurationManager in project presto by prestodb.

the class TestFileResourceGroupConfigurationManager method testConfiguration.

@Test
public void testConfiguration() {
    ResourceGroupConfigurationManager manager = parse("resource_groups_config.json");
    ResourceGroup global = new TestingResourceGroup(new ResourceGroupId("global"));
    manager.configure(global, new SelectionContext(true, "user", Optional.empty(), 1));
    assertEquals(global.getSoftMemoryLimit(), new DataSize(1, MEGABYTE));
    assertEquals(global.getSoftCpuLimit(), new Duration(1, HOURS));
    assertEquals(global.getHardCpuLimit(), new Duration(1, DAYS));
    assertEquals(global.getCpuQuotaGenerationMillisPerSecond(), 1000 * 24);
    assertEquals(global.getMaxQueuedQueries(), 1000);
    assertEquals(global.getMaxRunningQueries(), 100);
    assertEquals(global.getSchedulingPolicy(), WEIGHTED);
    assertEquals(global.getSchedulingWeight(), 0);
    assertEquals(global.getJmxExport(), true);
    ResourceGroup sub = new TestingResourceGroup(new ResourceGroupId(new ResourceGroupId("global"), "sub"));
    manager.configure(sub, new SelectionContext(true, "user", Optional.empty(), 1));
    assertEquals(sub.getSoftMemoryLimit(), new DataSize(2, MEGABYTE));
    assertEquals(sub.getMaxRunningQueries(), 3);
    assertEquals(sub.getMaxQueuedQueries(), 4);
    assertEquals(sub.getSchedulingPolicy(), null);
    assertEquals(sub.getSchedulingWeight(), 5);
    assertEquals(sub.getJmxExport(), false);
}
Also used : ResourceGroupId(com.facebook.presto.spi.resourceGroups.ResourceGroupId) ResourceGroupConfigurationManager(com.facebook.presto.spi.resourceGroups.ResourceGroupConfigurationManager) DataSize(io.airlift.units.DataSize) Duration(io.airlift.units.Duration) SelectionContext(com.facebook.presto.spi.resourceGroups.SelectionContext) ResourceGroup(com.facebook.presto.spi.resourceGroups.ResourceGroup) Test(org.testng.annotations.Test)

Example 3 with ResourceGroupConfigurationManager

use of com.facebook.presto.spi.resourceGroups.ResourceGroupConfigurationManager in project presto by prestodb.

the class TestFileResourceGroupConfigurationManager method testMissing.

@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "No matching configuration found for: missing")
public void testMissing() {
    ResourceGroupConfigurationManager manager = parse("resource_groups_config.json");
    ResourceGroup missing = new TestingResourceGroup(new ResourceGroupId("missing"));
    manager.configure(missing, new SelectionContext(true, "user", Optional.empty(), 1));
}
Also used : ResourceGroupId(com.facebook.presto.spi.resourceGroups.ResourceGroupId) ResourceGroupConfigurationManager(com.facebook.presto.spi.resourceGroups.ResourceGroupConfigurationManager) SelectionContext(com.facebook.presto.spi.resourceGroups.SelectionContext) ResourceGroup(com.facebook.presto.spi.resourceGroups.ResourceGroup) Test(org.testng.annotations.Test)

Aggregations

ResourceGroupConfigurationManager (com.facebook.presto.spi.resourceGroups.ResourceGroupConfigurationManager)3 ResourceGroup (com.facebook.presto.spi.resourceGroups.ResourceGroup)2 ResourceGroupId (com.facebook.presto.spi.resourceGroups.ResourceGroupId)2 SelectionContext (com.facebook.presto.spi.resourceGroups.SelectionContext)2 Test (org.testng.annotations.Test)2 ResourceGroupConfigurationManagerFactory (com.facebook.presto.spi.resourceGroups.ResourceGroupConfigurationManagerFactory)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 DataSize (io.airlift.units.DataSize)1 Duration (io.airlift.units.Duration)1