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);
}
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);
}
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);
}
}
Aggregations