Search in sources :

Example 1 with SessionPropertyConfigurationManagerFactory

use of io.trino.spi.session.SessionPropertyConfigurationManagerFactory in project trino by trinodb.

the class PluginManager method installPluginInternal.

private void installPluginInternal(Plugin plugin, Function<CatalogName, ClassLoader> duplicatePluginClassLoaderFactory) {
    for (BlockEncoding blockEncoding : plugin.getBlockEncodings()) {
        log.info("Registering block encoding %s", blockEncoding.getName());
        blockEncodingManager.addBlockEncoding(blockEncoding);
    }
    for (Type type : plugin.getTypes()) {
        log.info("Registering type %s", type.getTypeSignature());
        typeRegistry.addType(type);
    }
    for (ParametricType parametricType : plugin.getParametricTypes()) {
        log.info("Registering parametric type %s", parametricType.getName());
        typeRegistry.addParametricType(parametricType);
    }
    for (ConnectorFactory connectorFactory : plugin.getConnectorFactories()) {
        log.info("Registering connector %s", connectorFactory.getName());
        connectorManager.addConnectorFactory(connectorFactory, duplicatePluginClassLoaderFactory);
    }
    Set<Class<?>> functions = plugin.getFunctions();
    if (!functions.isEmpty()) {
        log.info("Registering functions from %s", plugin.getClass().getSimpleName());
        InternalFunctionBundleBuilder builder = InternalFunctionBundle.builder();
        functions.forEach(builder::functions);
        globalFunctionCatalog.addFunctions(builder.build());
    }
    for (SessionPropertyConfigurationManagerFactory sessionConfigFactory : plugin.getSessionPropertyConfigurationManagerFactories()) {
        log.info("Registering session property configuration manager %s", sessionConfigFactory.getName());
        sessionPropertyDefaults.addConfigurationManagerFactory(sessionConfigFactory);
    }
    for (ResourceGroupConfigurationManagerFactory configurationManagerFactory : plugin.getResourceGroupConfigurationManagerFactories()) {
        log.info("Registering resource group configuration manager %s", configurationManagerFactory.getName());
        resourceGroupManager.addConfigurationManagerFactory(configurationManagerFactory);
    }
    for (SystemAccessControlFactory accessControlFactory : plugin.getSystemAccessControlFactories()) {
        log.info("Registering system access control %s", accessControlFactory.getName());
        accessControlManager.addSystemAccessControlFactory(accessControlFactory);
    }
    passwordAuthenticatorManager.ifPresent(authenticationManager -> {
        for (PasswordAuthenticatorFactory authenticatorFactory : plugin.getPasswordAuthenticatorFactories()) {
            log.info("Registering password authenticator %s", authenticatorFactory.getName());
            authenticationManager.addPasswordAuthenticatorFactory(authenticatorFactory);
        }
    });
    for (CertificateAuthenticatorFactory authenticatorFactory : plugin.getCertificateAuthenticatorFactories()) {
        log.info("Registering certificate authenticator %s", authenticatorFactory.getName());
        certificateAuthenticatorManager.addCertificateAuthenticatorFactory(authenticatorFactory);
    }
    headerAuthenticatorManager.ifPresent(authenticationManager -> {
        for (HeaderAuthenticatorFactory authenticatorFactory : plugin.getHeaderAuthenticatorFactories()) {
            log.info("Registering header authenticator %s", authenticatorFactory.getName());
            authenticationManager.addHeaderAuthenticatorFactory(authenticatorFactory);
        }
    });
    for (EventListenerFactory eventListenerFactory : plugin.getEventListenerFactories()) {
        log.info("Registering event listener %s", eventListenerFactory.getName());
        eventListenerManager.addEventListenerFactory(eventListenerFactory);
    }
    for (GroupProviderFactory groupProviderFactory : plugin.getGroupProviderFactories()) {
        log.info("Registering group provider %s", groupProviderFactory.getName());
        groupProviderManager.addGroupProviderFactory(groupProviderFactory);
    }
    for (ExchangeManagerFactory exchangeManagerFactory : plugin.getExchangeManagerFactories()) {
        log.info("Registering exchange manager %s", exchangeManagerFactory.getName());
        exchangeManagerRegistry.addExchangeManagerFactory(exchangeManagerFactory);
    }
}
Also used : ResourceGroupConfigurationManagerFactory(io.trino.spi.resourcegroups.ResourceGroupConfigurationManagerFactory) HeaderAuthenticatorFactory(io.trino.spi.security.HeaderAuthenticatorFactory) EventListenerFactory(io.trino.spi.eventlistener.EventListenerFactory) SystemAccessControlFactory(io.trino.spi.security.SystemAccessControlFactory) Type(io.trino.spi.type.Type) ParametricType(io.trino.spi.type.ParametricType) PasswordAuthenticatorFactory(io.trino.spi.security.PasswordAuthenticatorFactory) ConnectorFactory(io.trino.spi.connector.ConnectorFactory) InternalFunctionBundleBuilder(io.trino.metadata.InternalFunctionBundle.InternalFunctionBundleBuilder) ParametricType(io.trino.spi.type.ParametricType) SessionPropertyConfigurationManagerFactory(io.trino.spi.session.SessionPropertyConfigurationManagerFactory) BlockEncoding(io.trino.spi.block.BlockEncoding) CertificateAuthenticatorFactory(io.trino.spi.security.CertificateAuthenticatorFactory) GroupProviderFactory(io.trino.spi.security.GroupProviderFactory) ExchangeManagerFactory(io.trino.spi.exchange.ExchangeManagerFactory)

Example 2 with SessionPropertyConfigurationManagerFactory

use of io.trino.spi.session.SessionPropertyConfigurationManagerFactory in project trino by trinodb.

the class TestSessionPropertyDefaults method testApplyDefaultProperties.

@Test
public void testApplyDefaultProperties() {
    SessionPropertyDefaults sessionPropertyDefaults = new SessionPropertyDefaults(TEST_NODE_INFO, new AllowAllAccessControlManager());
    SessionPropertyManager sessionPropertyManager = new SessionPropertyManager();
    sessionPropertyManager.addConnectorSessionProperties(new CatalogName("testCatalog"), ImmutableList.of(PropertyMetadata.stringProperty("explicit_set", "Test property", null, false), PropertyMetadata.stringProperty("catalog_default", "Test property", null, false)));
    SessionPropertyConfigurationManagerFactory factory = new TestingSessionPropertyConfigurationManagerFactory(ImmutableMap.<String, String>builder().put(QUERY_MAX_MEMORY, // Will be overridden
    "2GB").put(QUERY_MAX_TOTAL_MEMORY, // Will remain default
    "2GB").buildOrThrow(), ImmutableMap.of("testCatalog", ImmutableMap.<String, String>builder().put("explicit_set", // Will be overridden
    "override").put("catalog_default", // Will remain default
    "catalog_default").buildOrThrow()));
    sessionPropertyDefaults.addConfigurationManagerFactory(factory);
    sessionPropertyDefaults.setConfigurationManager(factory.getName(), ImmutableMap.of());
    Session session = Session.builder(sessionPropertyManager).setQueryId(new QueryId("test_query_id")).setIdentity(Identity.ofUser("testUser")).setSystemProperty(QUERY_MAX_MEMORY, // Override this default system property
    "1GB").setSystemProperty(JOIN_DISTRIBUTION_TYPE, "partitioned").setSystemProperty(HASH_PARTITION_COUNT, "43").setCatalogSessionProperty("testCatalog", "explicit_set", // Override this default catalog property
    "explicit_set").build();
    assertEquals(session.getSystemProperties(), ImmutableMap.<String, String>builder().put(QUERY_MAX_MEMORY, "1GB").put(JOIN_DISTRIBUTION_TYPE, "partitioned").put(HASH_PARTITION_COUNT, "43").buildOrThrow());
    assertEquals(session.getCatalogProperties(), ImmutableMap.of("testCatalog", ImmutableMap.<String, String>builder().put("explicit_set", "explicit_set").buildOrThrow()));
    session = sessionPropertyDefaults.newSessionWithDefaultProperties(session, Optional.empty(), TEST_RESOURCE_GROUP_ID);
    assertEquals(session.getSystemProperties(), ImmutableMap.<String, String>builder().put(QUERY_MAX_MEMORY, // User provided value overrides default value
    "1GB").put(JOIN_DISTRIBUTION_TYPE, // User provided value is used
    "partitioned").put(HASH_PARTITION_COUNT, // User provided value is used
    "43").put(QUERY_MAX_TOTAL_MEMORY, // Default value is used
    "2GB").buildOrThrow());
    assertEquals(session.getCatalogProperties(), ImmutableMap.of("testCatalog", ImmutableMap.<String, String>builder().put("explicit_set", // User provided value overrides default value
    "explicit_set").put("catalog_default", // Default value is used
    "catalog_default").buildOrThrow()));
}
Also used : AllowAllAccessControlManager(io.trino.testing.AllowAllAccessControlManager) QueryId(io.trino.spi.QueryId) SessionPropertyManager(io.trino.metadata.SessionPropertyManager) TestingSessionPropertyConfigurationManagerFactory(io.trino.spi.session.TestingSessionPropertyConfigurationManagerFactory) CatalogName(io.trino.connector.CatalogName) TestingSessionPropertyConfigurationManagerFactory(io.trino.spi.session.TestingSessionPropertyConfigurationManagerFactory) SessionPropertyConfigurationManagerFactory(io.trino.spi.session.SessionPropertyConfigurationManagerFactory) Session(io.trino.Session) Test(org.testng.annotations.Test)

Example 3 with SessionPropertyConfigurationManagerFactory

use of io.trino.spi.session.SessionPropertyConfigurationManagerFactory 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);
}
Also used : SessionPropertyConfigurationManagerFactory(io.trino.spi.session.SessionPropertyConfigurationManagerFactory) ThreadContextClassLoader(io.trino.spi.classloader.ThreadContextClassLoader) SessionPropertyConfigurationManager(io.trino.spi.session.SessionPropertyConfigurationManager) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

SessionPropertyConfigurationManagerFactory (io.trino.spi.session.SessionPropertyConfigurationManagerFactory)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Session (io.trino.Session)1 CatalogName (io.trino.connector.CatalogName)1 InternalFunctionBundleBuilder (io.trino.metadata.InternalFunctionBundle.InternalFunctionBundleBuilder)1 SessionPropertyManager (io.trino.metadata.SessionPropertyManager)1 QueryId (io.trino.spi.QueryId)1 BlockEncoding (io.trino.spi.block.BlockEncoding)1 ThreadContextClassLoader (io.trino.spi.classloader.ThreadContextClassLoader)1 ConnectorFactory (io.trino.spi.connector.ConnectorFactory)1 EventListenerFactory (io.trino.spi.eventlistener.EventListenerFactory)1 ExchangeManagerFactory (io.trino.spi.exchange.ExchangeManagerFactory)1 ResourceGroupConfigurationManagerFactory (io.trino.spi.resourcegroups.ResourceGroupConfigurationManagerFactory)1 CertificateAuthenticatorFactory (io.trino.spi.security.CertificateAuthenticatorFactory)1 GroupProviderFactory (io.trino.spi.security.GroupProviderFactory)1 HeaderAuthenticatorFactory (io.trino.spi.security.HeaderAuthenticatorFactory)1 PasswordAuthenticatorFactory (io.trino.spi.security.PasswordAuthenticatorFactory)1 SystemAccessControlFactory (io.trino.spi.security.SystemAccessControlFactory)1 SessionPropertyConfigurationManager (io.trino.spi.session.SessionPropertyConfigurationManager)1 TestingSessionPropertyConfigurationManagerFactory (io.trino.spi.session.TestingSessionPropertyConfigurationManagerFactory)1