Search in sources :

Example 1 with ConnectorFactory

use of io.trino.spi.connector.ConnectorFactory 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 ConnectorFactory

use of io.trino.spi.connector.ConnectorFactory in project trino by trinodb.

the class TestHivePlugin method testThriftMetastore.

@Test
public void testThriftMetastore() {
    ConnectorFactory factory = getHiveConnectorFactory();
    factory.create("test", ImmutableMap.of("hive.metastore", "thrift", "hive.metastore.uri", "thrift://foo:1234"), new TestingConnectorContext()).shutdown();
}
Also used : ConnectorFactory(io.trino.spi.connector.ConnectorFactory) TestingConnectorContext(io.trino.testing.TestingConnectorContext) Test(org.testng.annotations.Test)

Example 3 with ConnectorFactory

use of io.trino.spi.connector.ConnectorFactory in project trino by trinodb.

the class TestHivePlugin method testRecordingMetastore.

@Test
public void testRecordingMetastore() {
    ConnectorFactory factory = getHiveConnectorFactory();
    factory.create("test", ImmutableMap.of("hive.metastore", "thrift", "hive.metastore.uri", "thrift://foo:1234", "hive.metastore-recording-path", "/tmp"), new TestingConnectorContext()).shutdown();
    factory.create("test", ImmutableMap.of("hive.metastore", "glue", "hive.metastore.glue.region", "us-east-2", "hive.metastore-recording-path", "/tmp"), new TestingConnectorContext()).shutdown();
}
Also used : ConnectorFactory(io.trino.spi.connector.ConnectorFactory) TestingConnectorContext(io.trino.testing.TestingConnectorContext) Test(org.testng.annotations.Test)

Example 4 with ConnectorFactory

use of io.trino.spi.connector.ConnectorFactory in project trino by trinodb.

the class TestHivePlugin method testInsertOverwriteIsSetToErrorWhenImmutablePartitionsIsTrue.

@Test
public void testInsertOverwriteIsSetToErrorWhenImmutablePartitionsIsTrue() {
    ConnectorFactory connectorFactory = getHiveConnectorFactory();
    Connector connector = connectorFactory.create("test", ImmutableMap.<String, String>builder().put("hive.immutable-partitions", "true").put("hive.metastore.uri", "thrift://foo:1234").buildOrThrow(), new TestingConnectorContext());
    assertThat(getDefaultValueInsertExistingPartitionsBehavior(connector)).isEqualTo(ERROR);
    connector.shutdown();
}
Also used : Connector(io.trino.spi.connector.Connector) ConnectorFactory(io.trino.spi.connector.ConnectorFactory) TestingConnectorContext(io.trino.testing.TestingConnectorContext) Test(org.testng.annotations.Test)

Example 5 with ConnectorFactory

use of io.trino.spi.connector.ConnectorFactory in project trino by trinodb.

the class TestHivePlugin method testInsertOverwriteIsSetToAppendWhenImmutablePartitionsIsFalseByDefault.

@Test
public void testInsertOverwriteIsSetToAppendWhenImmutablePartitionsIsFalseByDefault() {
    ConnectorFactory connectorFactory = getHiveConnectorFactory();
    Connector connector = connectorFactory.create("test", ImmutableMap.<String, String>builder().put("hive.metastore.uri", "thrift://foo:1234").buildOrThrow(), new TestingConnectorContext());
    assertThat(getDefaultValueInsertExistingPartitionsBehavior(connector)).isEqualTo(APPEND);
    connector.shutdown();
}
Also used : Connector(io.trino.spi.connector.Connector) ConnectorFactory(io.trino.spi.connector.ConnectorFactory) TestingConnectorContext(io.trino.testing.TestingConnectorContext) Test(org.testng.annotations.Test)

Aggregations

ConnectorFactory (io.trino.spi.connector.ConnectorFactory)66 Test (org.testng.annotations.Test)61 TestingConnectorContext (io.trino.testing.TestingConnectorContext)56 Plugin (io.trino.spi.Plugin)29 Connector (io.trino.spi.connector.Connector)13 ImmutableList (com.google.common.collect.ImmutableList)7 ImmutableMap (com.google.common.collect.ImmutableMap)7 Session (io.trino.Session)7 DistributedQueryRunner (io.trino.testing.DistributedQueryRunner)7 MockConnectorFactory (io.trino.connector.MockConnectorFactory)6 TestingSession.testSessionBuilder (io.trino.testing.TestingSession.testSessionBuilder)6 SchemaTableName (io.trino.spi.connector.SchemaTableName)5 AbstractTestQueryFramework (io.trino.testing.AbstractTestQueryFramework)5 List (java.util.List)5 Optional (java.util.Optional)5 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)5 QueryRunner (io.trino.testing.QueryRunner)4 Path (java.nio.file.Path)4 ResourceGroupManagerPlugin (io.trino.plugin.resourcegroups.ResourceGroupManagerPlugin)3 ColumnMetadata (io.trino.spi.connector.ColumnMetadata)3