use of io.trino.spi.session.SessionPropertyConfigurationManager in project trino by trinodb.
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, accessControl);
}
use of io.trino.spi.session.SessionPropertyConfigurationManager in project trino by trinodb.
the class SessionPropertyDefaults method setConfigurationManager.
@VisibleForTesting
public void setConfigurationManager(String name, Map<String, String> properties) {
log.info("-- Loading session property configuration manager --");
SessionPropertyConfigurationManagerFactory factory = factories.get(name);
checkState(factory != null, "Session property configuration manager '%s' is not registered", name);
SessionPropertyConfigurationManager manager;
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(factory.getClass().getClassLoader())) {
manager = factory.create(properties, configurationManagerContext);
}
checkState(delegate.compareAndSet(null, manager), "sessionPropertyConfigurationManager is already set");
log.info("-- Loaded session property configuration manager %s --", name);
}
use of io.trino.spi.session.SessionPropertyConfigurationManager in project trino by trinodb.
the class TestFileSessionPropertyManager method assertProperties.
@Override
protected void assertProperties(Map<String, String> systemProperties, Map<String, Map<String, String>> catalogProperties, SessionMatchSpec... specs) throws IOException {
try (TempFile tempFile = new TempFile()) {
Path configurationFile = tempFile.path();
Files.write(configurationFile, CODEC.toJsonBytes(Arrays.asList(specs)));
SessionPropertyConfigurationManager manager = new FileSessionPropertyManager(new FileSessionPropertyManagerConfig().setConfigFile(configurationFile.toFile()));
assertEquals(manager.getSystemSessionProperties(CONTEXT), systemProperties);
assertEquals(manager.getCatalogSessionProperties(CONTEXT), catalogProperties);
}
}
Aggregations