Search in sources :

Example 1 with SessionPropertyConfigurationManager

use of com.facebook.presto.spi.session.SessionPropertyConfigurationManager in project presto by prestodb.

the class SessionPropertyDefaults method setConfigurationManager.

@VisibleForTesting
public void setConfigurationManager(String configManagerName, Map<String, String> properties) {
    log.info("-- Loading session property configuration manager --");
    SessionPropertyConfigurationManagerFactory factory = factories.get(configManagerName);
    checkState(factory != null, "Session property configuration manager '%s' is not registered", configManagerName);
    SessionPropertyConfigurationManager manager = factory.create(properties, configurationManagerContext);
    checkState(delegate.compareAndSet(null, manager), "sessionPropertyConfigurationManager is already set");
    log.info("-- Loaded session property configuration manager %s --", configManagerName);
}
Also used : SessionPropertyConfigurationManagerFactory(com.facebook.presto.spi.session.SessionPropertyConfigurationManagerFactory) SessionPropertyConfigurationManager(com.facebook.presto.spi.session.SessionPropertyConfigurationManager) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with SessionPropertyConfigurationManager

use of com.facebook.presto.spi.session.SessionPropertyConfigurationManager in project presto by prestodb.

the class SessionPropertyDefaults method newSessionWithDefaultProperties.

public Session newSessionWithDefaultProperties(Session session, Optional<String> queryType, Optional<ResourceGroupId> resourceGroupId) {
    SessionPropertyConfigurationManager configurationManager = delegate.get();
    if (configurationManager == null) {
        return session;
    }
    SessionConfigurationContext context = new SessionConfigurationContext(session.getIdentity().getUser(), session.getSource(), session.getClientTags(), queryType, resourceGroupId, session.getClientInfo());
    SystemSessionPropertyConfiguration systemPropertyConfiguration = configurationManager.getSystemSessionProperties(context);
    Map<String, Map<String, String>> catalogPropertyOverrides = configurationManager.getCatalogSessionProperties(context);
    return session.withDefaultProperties(systemPropertyConfiguration, catalogPropertyOverrides);
}
Also used : SystemSessionPropertyConfiguration(com.facebook.presto.spi.session.SessionPropertyConfigurationManager.SystemSessionPropertyConfiguration) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Map(java.util.Map) SessionPropertyConfigurationManager(com.facebook.presto.spi.session.SessionPropertyConfigurationManager) SessionConfigurationContext(com.facebook.presto.spi.session.SessionConfigurationContext)

Example 3 with SessionPropertyConfigurationManager

use of com.facebook.presto.spi.session.SessionPropertyConfigurationManager in project presto by prestodb.

the class TestFileSessionPropertyManager method assertProperties.

private static void assertProperties(Map<String, String> defaultProperties, Map<String, String> overrideProperties, SessionMatchSpec... spec) throws IOException {
    try (TempFile tempFile = new TempFile()) {
        Path configurationFile = tempFile.path();
        Files.write(configurationFile, CODEC.toJsonBytes(Arrays.asList(spec)));
        SessionPropertyConfigurationManager manager = new FileSessionPropertyManager(new FileSessionPropertyManagerConfig().setConfigFile(configurationFile.toFile()));
        SystemSessionPropertyConfiguration propertyConfiguration = manager.getSystemSessionProperties(CONTEXT);
        assertEquals(propertyConfiguration.systemPropertyDefaults, defaultProperties);
        assertEquals(propertyConfiguration.systemPropertyOverrides, overrideProperties);
    }
}
Also used : Path(java.nio.file.Path) TempFile(com.facebook.airlift.testing.TempFile) SystemSessionPropertyConfiguration(com.facebook.presto.spi.session.SessionPropertyConfigurationManager.SystemSessionPropertyConfiguration) SessionPropertyConfigurationManager(com.facebook.presto.spi.session.SessionPropertyConfigurationManager)

Aggregations

SessionPropertyConfigurationManager (com.facebook.presto.spi.session.SessionPropertyConfigurationManager)3 SystemSessionPropertyConfiguration (com.facebook.presto.spi.session.SessionPropertyConfigurationManager.SystemSessionPropertyConfiguration)2 TempFile (com.facebook.airlift.testing.TempFile)1 SessionConfigurationContext (com.facebook.presto.spi.session.SessionConfigurationContext)1 SessionPropertyConfigurationManagerFactory (com.facebook.presto.spi.session.SessionPropertyConfigurationManagerFactory)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1