use of io.trino.spi.classloader.ThreadContextClassLoader in project trino by trinodb.
the class EventListenerManager method createEventListener.
private EventListener createEventListener(File configFile) {
log.info("-- Loading event listener %s --", configFile);
configFile = configFile.getAbsoluteFile();
Map<String, String> properties = loadEventListenerProperties(configFile);
String name = properties.remove(EVENT_LISTENER_NAME_PROPERTY);
checkArgument(!isNullOrEmpty(name), "EventListener plugin configuration for %s does not contain %s", configFile, EVENT_LISTENER_NAME_PROPERTY);
EventListenerFactory factory = eventListenerFactories.get(name);
checkArgument(factory != null, "Event listener factory '%s' is not registered. Available factories: %s", name, eventListenerFactories.keySet());
EventListener eventListener;
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(factory.getClass().getClassLoader())) {
eventListener = factory.create(properties);
}
log.info("-- Loaded event listener %s --", configFile);
return eventListener;
}
use of io.trino.spi.classloader.ThreadContextClassLoader in project trino by trinodb.
the class GroupProviderManager method setConfiguredGroupProvider.
private void setConfiguredGroupProvider(String name, Map<String, String> properties) {
requireNonNull(name, "name is null");
requireNonNull(properties, "properties is null");
log.info("-- Loading group provider %s --", name);
GroupProviderFactory factory = groupProviderFactories.get(name);
checkState(factory != null, "Group provider %s is not registered", name);
GroupProvider groupProvider;
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(factory.getClass().getClassLoader())) {
groupProvider = factory.create(ImmutableMap.copyOf(properties));
}
checkState(configuredGroupProvider.compareAndSet(Optional.empty(), Optional.of(groupProvider)), "groupProvider is already set");
log.info("-- Loaded group provider %s --", name);
}
use of io.trino.spi.classloader.ThreadContextClassLoader in project trino by trinodb.
the class IcebergTransactionManager method rollback.
public void rollback(ConnectorTransactionHandle transaction) {
MemoizedMetadata transactionalMetadata = transactions.remove(transaction);
checkArgument(transactionalMetadata != null, "no such transaction: %s", transaction);
transactionalMetadata.optionalGet().ifPresent(metadata -> {
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
metadata.rollback();
}
});
}
use of io.trino.spi.classloader.ThreadContextClassLoader in project trino by trinodb.
the class HeaderAuthenticatorManager method loadAuthenticator.
private HeaderAuthenticator loadAuthenticator(File configFile) {
Map<String, String> properties;
try {
properties = new HashMap<>(loadPropertiesFrom(configFile.getPath()));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
String name = properties.remove(NAME_PROPERTY);
checkState(!isNullOrEmpty(name), "Header authenticator configuration %s does not contain '%s'", configFile, NAME_PROPERTY);
log.info("-- Loading header authenticator --");
HeaderAuthenticatorFactory factory = factories.get(name);
checkState(factory != null, "Header authenticator '%s' is not registered", name);
HeaderAuthenticator authenticator;
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(factory.getClass().getClassLoader())) {
authenticator = factory.create(ImmutableMap.copyOf(properties));
}
log.info("-- Loaded header authenticator %s --", name);
return authenticator;
}
use of io.trino.spi.classloader.ThreadContextClassLoader 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);
}
Aggregations