Search in sources :

Example 1 with SessionPropertyConfigurationManager

use of io.prestosql.spi.session.SessionPropertyConfigurationManager in project hetu-core by openlookeng.

the class SessionPropertyDefaults method setConfigurationManager.

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

Example 2 with SessionPropertyConfigurationManager

use of io.prestosql.spi.session.SessionPropertyConfigurationManager in project hetu-core by openlookeng.

the class TestFileSessionPropertyManager method assertProperties.

private static void assertProperties(Map<String, String> properties, 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()));
        assertEquals(manager.getSystemSessionProperties(CONTEXT), properties);
    }
}
Also used : Path(java.nio.file.Path) TempFile(io.airlift.testing.TempFile) SessionPropertyConfigurationManager(io.prestosql.spi.session.SessionPropertyConfigurationManager)

Example 3 with SessionPropertyConfigurationManager

use of io.prestosql.spi.session.SessionPropertyConfigurationManager in project hetu-core by openlookeng.

the class SessionPropertyDefaults method newSessionWithDefaultProperties.

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

Aggregations

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