Search in sources :

Example 6 with NodeVersion

use of io.trino.plugin.hive.NodeVersion in project trino by trinodb.

the class InternalIcebergConnectorFactory method createConnector.

public static Connector createConnector(String catalogName, Map<String, String> config, ConnectorContext context, Module module, Optional<HiveMetastore> metastore, Optional<FileIoProvider> fileIoProvider) {
    ClassLoader classLoader = InternalIcebergConnectorFactory.class.getClassLoader();
    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
        Bootstrap app = new Bootstrap(new EventModule(), new MBeanModule(), new ConnectorObjectNameGeneratorModule(catalogName, "io.trino.plugin.iceberg", "trino.plugin.iceberg"), new JsonModule(), new IcebergModule(), new IcebergSecurityModule(), new IcebergCatalogModule(metastore), new HiveHdfsModule(), new HiveS3Module(), new HiveGcsModule(), new HiveAzureModule(), new HdfsAuthenticationModule(), new MBeanServerModule(), fileIoProvider.<Module>map(provider -> binder -> binder.bind(FileIoProvider.class).toInstance(provider)).orElse(binder -> binder.bind(FileIoProvider.class).to(HdfsFileIoProvider.class).in(SINGLETON)), binder -> {
            binder.bind(NodeVersion.class).toInstance(new NodeVersion(context.getNodeManager().getCurrentNode().getVersion()));
            binder.bind(NodeManager.class).toInstance(context.getNodeManager());
            binder.bind(TypeManager.class).toInstance(context.getTypeManager());
            binder.bind(PageIndexerFactory.class).toInstance(context.getPageIndexerFactory());
            binder.bind(CatalogName.class).toInstance(new CatalogName(catalogName));
        }, module);
        Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        LifeCycleManager lifeCycleManager = injector.getInstance(LifeCycleManager.class);
        IcebergTransactionManager transactionManager = injector.getInstance(IcebergTransactionManager.class);
        ConnectorSplitManager splitManager = injector.getInstance(ConnectorSplitManager.class);
        ConnectorPageSourceProvider connectorPageSource = injector.getInstance(ConnectorPageSourceProvider.class);
        ConnectorPageSinkProvider pageSinkProvider = injector.getInstance(ConnectorPageSinkProvider.class);
        ConnectorNodePartitioningProvider connectorDistributionProvider = injector.getInstance(ConnectorNodePartitioningProvider.class);
        Set<SessionPropertiesProvider> sessionPropertiesProviders = injector.getInstance(Key.get(new TypeLiteral<Set<SessionPropertiesProvider>>() {
        }));
        IcebergTableProperties icebergTableProperties = injector.getInstance(IcebergTableProperties.class);
        Set<Procedure> procedures = injector.getInstance(Key.get(new TypeLiteral<Set<Procedure>>() {
        }));
        Set<TableProcedureMetadata> tableProcedures = injector.getInstance(Key.get(new TypeLiteral<Set<TableProcedureMetadata>>() {
        }));
        Optional<ConnectorAccessControl> accessControl = injector.getInstance(Key.get(new TypeLiteral<Optional<ConnectorAccessControl>>() {
        }));
        return new IcebergConnector(lifeCycleManager, transactionManager, new ClassLoaderSafeConnectorSplitManager(splitManager, classLoader), new ClassLoaderSafeConnectorPageSourceProvider(connectorPageSource, classLoader), new ClassLoaderSafeConnectorPageSinkProvider(pageSinkProvider, classLoader), new ClassLoaderSafeNodePartitioningProvider(connectorDistributionProvider, classLoader), sessionPropertiesProviders, IcebergSchemaProperties.SCHEMA_PROPERTIES, icebergTableProperties.getTableProperties(), accessControl, procedures, tableProcedures);
    }
}
Also used : Module(com.google.inject.Module) HiveAzureModule(io.trino.plugin.hive.azure.HiveAzureModule) ConnectorSplitManager(io.trino.spi.connector.ConnectorSplitManager) MBeanModule(org.weakref.jmx.guice.MBeanModule) NodeManager(io.trino.spi.NodeManager) Key(com.google.inject.Key) HiveHdfsModule(io.trino.plugin.hive.HiveHdfsModule) ConnectorContext(io.trino.spi.connector.ConnectorContext) ClassLoaderSafeConnectorSplitManager(io.trino.plugin.base.classloader.ClassLoaderSafeConnectorSplitManager) ConnectorObjectNameGeneratorModule(io.trino.plugin.base.jmx.ConnectorObjectNameGeneratorModule) EventModule(io.airlift.event.client.EventModule) HiveS3Module(io.trino.plugin.hive.s3.HiveS3Module) SINGLETON(com.google.inject.Scopes.SINGLETON) SessionPropertiesProvider(io.trino.plugin.base.session.SessionPropertiesProvider) HiveMetastore(io.trino.plugin.hive.metastore.HiveMetastore) Procedure(io.trino.spi.procedure.Procedure) NodeVersion(io.trino.plugin.hive.NodeVersion) PageIndexerFactory(io.trino.spi.PageIndexerFactory) Map(java.util.Map) ClassLoaderSafeConnectorPageSinkProvider(io.trino.plugin.base.classloader.ClassLoaderSafeConnectorPageSinkProvider) ConnectorNodePartitioningProvider(io.trino.spi.connector.ConnectorNodePartitioningProvider) ConnectorAccessControl(io.trino.spi.connector.ConnectorAccessControl) ConnectorPageSourceProvider(io.trino.spi.connector.ConnectorPageSourceProvider) LifeCycleManager(io.airlift.bootstrap.LifeCycleManager) Set(java.util.Set) CatalogName(io.trino.plugin.base.CatalogName) ThreadContextClassLoader(io.trino.spi.classloader.ThreadContextClassLoader) TableProcedureMetadata(io.trino.spi.connector.TableProcedureMetadata) Injector(com.google.inject.Injector) ClassLoaderSafeNodePartitioningProvider(io.trino.plugin.base.classloader.ClassLoaderSafeNodePartitioningProvider) ClassLoaderSafeConnectorPageSourceProvider(io.trino.plugin.base.classloader.ClassLoaderSafeConnectorPageSourceProvider) HdfsAuthenticationModule(io.trino.plugin.hive.authentication.HdfsAuthenticationModule) HiveGcsModule(io.trino.plugin.hive.gcs.HiveGcsModule) Bootstrap(io.airlift.bootstrap.Bootstrap) Optional(java.util.Optional) TypeLiteral(com.google.inject.TypeLiteral) IcebergCatalogModule(io.trino.plugin.iceberg.catalog.IcebergCatalogModule) TypeManager(io.trino.spi.type.TypeManager) MBeanServerModule(io.trino.plugin.base.jmx.MBeanServerModule) ConnectorPageSinkProvider(io.trino.spi.connector.ConnectorPageSinkProvider) JsonModule(io.airlift.json.JsonModule) Connector(io.trino.spi.connector.Connector) MBeanModule(org.weakref.jmx.guice.MBeanModule) IcebergCatalogModule(io.trino.plugin.iceberg.catalog.IcebergCatalogModule) EventModule(io.airlift.event.client.EventModule) ConnectorObjectNameGeneratorModule(io.trino.plugin.base.jmx.ConnectorObjectNameGeneratorModule) SessionPropertiesProvider(io.trino.plugin.base.session.SessionPropertiesProvider) NodeVersion(io.trino.plugin.hive.NodeVersion) ClassLoaderSafeConnectorPageSourceProvider(io.trino.plugin.base.classloader.ClassLoaderSafeConnectorPageSourceProvider) TypeLiteral(com.google.inject.TypeLiteral) Injector(com.google.inject.Injector) TableProcedureMetadata(io.trino.spi.connector.TableProcedureMetadata) ThreadContextClassLoader(io.trino.spi.classloader.ThreadContextClassLoader) Bootstrap(io.airlift.bootstrap.Bootstrap) Procedure(io.trino.spi.procedure.Procedure) ThreadContextClassLoader(io.trino.spi.classloader.ThreadContextClassLoader) ClassLoaderSafeNodePartitioningProvider(io.trino.plugin.base.classloader.ClassLoaderSafeNodePartitioningProvider) ConnectorAccessControl(io.trino.spi.connector.ConnectorAccessControl) HiveAzureModule(io.trino.plugin.hive.azure.HiveAzureModule) ClassLoaderSafeConnectorPageSinkProvider(io.trino.plugin.base.classloader.ClassLoaderSafeConnectorPageSinkProvider) HdfsAuthenticationModule(io.trino.plugin.hive.authentication.HdfsAuthenticationModule) JsonModule(io.airlift.json.JsonModule) PageIndexerFactory(io.trino.spi.PageIndexerFactory) HiveS3Module(io.trino.plugin.hive.s3.HiveS3Module) NodeManager(io.trino.spi.NodeManager) LifeCycleManager(io.airlift.bootstrap.LifeCycleManager) ClassLoaderSafeConnectorPageSinkProvider(io.trino.plugin.base.classloader.ClassLoaderSafeConnectorPageSinkProvider) ConnectorPageSinkProvider(io.trino.spi.connector.ConnectorPageSinkProvider) HiveGcsModule(io.trino.plugin.hive.gcs.HiveGcsModule) ConnectorSplitManager(io.trino.spi.connector.ConnectorSplitManager) ClassLoaderSafeConnectorSplitManager(io.trino.plugin.base.classloader.ClassLoaderSafeConnectorSplitManager) ConnectorPageSourceProvider(io.trino.spi.connector.ConnectorPageSourceProvider) ClassLoaderSafeConnectorPageSourceProvider(io.trino.plugin.base.classloader.ClassLoaderSafeConnectorPageSourceProvider) HiveHdfsModule(io.trino.plugin.hive.HiveHdfsModule) MBeanServerModule(io.trino.plugin.base.jmx.MBeanServerModule) ConnectorNodePartitioningProvider(io.trino.spi.connector.ConnectorNodePartitioningProvider) ClassLoaderSafeConnectorSplitManager(io.trino.plugin.base.classloader.ClassLoaderSafeConnectorSplitManager) TypeManager(io.trino.spi.type.TypeManager) CatalogName(io.trino.plugin.base.CatalogName) Module(com.google.inject.Module) HiveAzureModule(io.trino.plugin.hive.azure.HiveAzureModule) MBeanModule(org.weakref.jmx.guice.MBeanModule) HiveHdfsModule(io.trino.plugin.hive.HiveHdfsModule) ConnectorObjectNameGeneratorModule(io.trino.plugin.base.jmx.ConnectorObjectNameGeneratorModule) EventModule(io.airlift.event.client.EventModule) HiveS3Module(io.trino.plugin.hive.s3.HiveS3Module) HdfsAuthenticationModule(io.trino.plugin.hive.authentication.HdfsAuthenticationModule) HiveGcsModule(io.trino.plugin.hive.gcs.HiveGcsModule) IcebergCatalogModule(io.trino.plugin.iceberg.catalog.IcebergCatalogModule) MBeanServerModule(io.trino.plugin.base.jmx.MBeanServerModule) JsonModule(io.airlift.json.JsonModule)

Example 7 with NodeVersion

use of io.trino.plugin.hive.NodeVersion in project trino by trinodb.

the class TestIcebergTableWithCustomLocation method createQueryRunner.

@Override
protected DistributedQueryRunner createQueryRunner() throws Exception {
    metastoreDir = Files.createTempDirectory("test_iceberg").toFile();
    HdfsConfig hdfsConfig = new HdfsConfig();
    HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hdfsConfig), ImmutableSet.of());
    hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hdfsConfig, new NoHdfsAuthentication());
    FileHiveMetastoreConfig config = new FileHiveMetastoreConfig().setCatalogDirectory(metastoreDir.toURI().toString()).setMetastoreUser("test");
    hdfsContext = new HdfsContext(ConnectorIdentity.ofUser(config.getMetastoreUser()));
    metastore = new FileHiveMetastore(new NodeVersion("testversion"), hdfsEnvironment, new MetastoreConfig(), config);
    return createIcebergQueryRunner(ImmutableMap.of(), ImmutableMap.of("iceberg.unique-table-location", "true"), ImmutableList.of(), Optional.of(metastoreDir));
}
Also used : FileHiveMetastoreConfig(io.trino.plugin.hive.metastore.file.FileHiveMetastoreConfig) NodeVersion(io.trino.plugin.hive.NodeVersion) HdfsConfigurationInitializer(io.trino.plugin.hive.HdfsConfigurationInitializer) FileHiveMetastore(io.trino.plugin.hive.metastore.file.FileHiveMetastore) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) MetastoreConfig(io.trino.plugin.hive.metastore.MetastoreConfig) FileHiveMetastoreConfig(io.trino.plugin.hive.metastore.file.FileHiveMetastoreConfig) HdfsConfig(io.trino.plugin.hive.HdfsConfig) HdfsContext(io.trino.plugin.hive.HdfsEnvironment.HdfsContext) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) HdfsConfiguration(io.trino.plugin.hive.HdfsConfiguration) NoHdfsAuthentication(io.trino.plugin.hive.authentication.NoHdfsAuthentication) HdfsEnvironment(io.trino.plugin.hive.HdfsEnvironment)

Example 8 with NodeVersion

use of io.trino.plugin.hive.NodeVersion in project trino by trinodb.

the class TestIcebergTableWithExternalLocation method createQueryRunner.

@Override
protected DistributedQueryRunner createQueryRunner() throws Exception {
    metastoreDir = Files.createTempDirectory("test_iceberg").toFile();
    HdfsConfig hdfsConfig = new HdfsConfig();
    HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hdfsConfig), ImmutableSet.of());
    hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hdfsConfig, new NoHdfsAuthentication());
    FileHiveMetastoreConfig config = new FileHiveMetastoreConfig().setCatalogDirectory(metastoreDir.toURI().toString()).setMetastoreUser("test");
    hdfsContext = new HdfsContext(ConnectorIdentity.ofUser(config.getMetastoreUser()));
    metastore = new FileHiveMetastore(new NodeVersion("testversion"), hdfsEnvironment, new MetastoreConfig(), config);
    return createIcebergQueryRunner(ImmutableMap.of(), ImmutableMap.of(), ImmutableList.of(), Optional.of(metastoreDir));
}
Also used : FileHiveMetastoreConfig(io.trino.plugin.hive.metastore.file.FileHiveMetastoreConfig) NodeVersion(io.trino.plugin.hive.NodeVersion) HdfsConfigurationInitializer(io.trino.plugin.hive.HdfsConfigurationInitializer) FileHiveMetastore(io.trino.plugin.hive.metastore.file.FileHiveMetastore) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) MetastoreConfig(io.trino.plugin.hive.metastore.MetastoreConfig) FileHiveMetastoreConfig(io.trino.plugin.hive.metastore.file.FileHiveMetastoreConfig) HdfsConfig(io.trino.plugin.hive.HdfsConfig) HdfsContext(io.trino.plugin.hive.HdfsEnvironment.HdfsContext) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) HdfsConfiguration(io.trino.plugin.hive.HdfsConfiguration) NoHdfsAuthentication(io.trino.plugin.hive.authentication.NoHdfsAuthentication) HdfsEnvironment(io.trino.plugin.hive.HdfsEnvironment)

Example 9 with NodeVersion

use of io.trino.plugin.hive.NodeVersion in project trino by trinodb.

the class TestIcebergOrcMetricsCollection method createQueryRunner.

@Override
protected QueryRunner createQueryRunner() throws Exception {
    Session session = testSessionBuilder().setCatalog("iceberg").setSchema("test_schema").setSystemProperty(TASK_CONCURRENCY, "1").setSystemProperty(TASK_WRITER_COUNT, "1").setSystemProperty(MAX_DRIVERS_PER_TASK, "1").setCatalogSessionProperty("iceberg", "orc_string_statistics_limit", Integer.MAX_VALUE + "B").build();
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(session).setNodeCount(1).build();
    File baseDir = queryRunner.getCoordinator().getBaseDataDir().resolve("iceberg_data").toFile();
    HdfsConfig hdfsConfig = new HdfsConfig();
    HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hdfsConfig), ImmutableSet.of());
    HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hdfsConfig, new NoHdfsAuthentication());
    HiveMetastore metastore = new FileHiveMetastore(new NodeVersion("test_version"), hdfsEnvironment, new MetastoreConfig(), new FileHiveMetastoreConfig().setCatalogDirectory(baseDir.toURI().toString()).setMetastoreUser("test"));
    tableOperationsProvider = new FileMetastoreTableOperationsProvider(new HdfsFileIoProvider(hdfsEnvironment));
    trinoCatalog = new TrinoHiveCatalog(new CatalogName("catalog"), memoizeMetastore(metastore, 1000), hdfsEnvironment, new TestingTypeManager(), tableOperationsProvider, "trino-version", false, false, false);
    queryRunner.installPlugin(new TestingIcebergPlugin(Optional.of(metastore), Optional.empty(), EMPTY_MODULE));
    queryRunner.createCatalog("iceberg", "iceberg");
    queryRunner.installPlugin(new TpchPlugin());
    queryRunner.createCatalog("tpch", "tpch");
    queryRunner.execute("CREATE SCHEMA test_schema");
    return queryRunner;
}
Also used : HdfsConfigurationInitializer(io.trino.plugin.hive.HdfsConfigurationInitializer) DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) MetastoreConfig(io.trino.plugin.hive.metastore.MetastoreConfig) FileHiveMetastoreConfig(io.trino.plugin.hive.metastore.file.FileHiveMetastoreConfig) HiveMetastore(io.trino.plugin.hive.metastore.HiveMetastore) FileHiveMetastore(io.trino.plugin.hive.metastore.file.FileHiveMetastore) TpchPlugin(io.trino.plugin.tpch.TpchPlugin) HdfsConfig(io.trino.plugin.hive.HdfsConfig) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) HdfsConfiguration(io.trino.plugin.hive.HdfsConfiguration) NoHdfsAuthentication(io.trino.plugin.hive.authentication.NoHdfsAuthentication) HdfsEnvironment(io.trino.plugin.hive.HdfsEnvironment) NodeVersion(io.trino.plugin.hive.NodeVersion) FileHiveMetastoreConfig(io.trino.plugin.hive.metastore.file.FileHiveMetastoreConfig) FileHiveMetastore(io.trino.plugin.hive.metastore.file.FileHiveMetastore) FileMetastoreTableOperationsProvider(io.trino.plugin.iceberg.catalog.file.FileMetastoreTableOperationsProvider) TrinoHiveCatalog(io.trino.plugin.iceberg.catalog.hms.TrinoHiveCatalog) CatalogName(io.trino.plugin.base.CatalogName) File(java.io.File) TestingTypeManager(io.trino.spi.type.TestingTypeManager) TestingConnectorSession(io.trino.testing.TestingConnectorSession) Session(io.trino.Session)

Example 10 with NodeVersion

use of io.trino.plugin.hive.NodeVersion in project trino by trinodb.

the class TestIcebergMergeAppend method createQueryRunner.

@Override
protected QueryRunner createQueryRunner() throws Exception {
    DistributedQueryRunner queryRunner = IcebergQueryRunner.createIcebergQueryRunner();
    HdfsConfig hdfsConfig = new HdfsConfig();
    HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hdfsConfig), ImmutableSet.of());
    HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hdfsConfig, new NoHdfsAuthentication());
    File baseDir = queryRunner.getCoordinator().getBaseDataDir().resolve("iceberg_data").toFile();
    HiveMetastore metastore = new FileHiveMetastore(new NodeVersion("testversion"), hdfsEnvironment, new MetastoreConfig(), new FileHiveMetastoreConfig().setCatalogDirectory(baseDir.toURI().toString()).setMetastoreUser("test"));
    tableOperationsProvider = new FileMetastoreTableOperationsProvider(new HdfsFileIoProvider(hdfsEnvironment));
    trinoCatalog = new TrinoHiveCatalog(new CatalogName("catalog"), memoizeMetastore(metastore, 1000), hdfsEnvironment, new TestingTypeManager(), tableOperationsProvider, "trino-version", false, false, false);
    return queryRunner;
}
Also used : HdfsConfigurationInitializer(io.trino.plugin.hive.HdfsConfigurationInitializer) DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) MetastoreConfig(io.trino.plugin.hive.metastore.MetastoreConfig) FileHiveMetastoreConfig(io.trino.plugin.hive.metastore.file.FileHiveMetastoreConfig) HiveMetastore(io.trino.plugin.hive.metastore.HiveMetastore) FileHiveMetastore(io.trino.plugin.hive.metastore.file.FileHiveMetastore) HdfsConfig(io.trino.plugin.hive.HdfsConfig) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) HdfsConfiguration(io.trino.plugin.hive.HdfsConfiguration) NoHdfsAuthentication(io.trino.plugin.hive.authentication.NoHdfsAuthentication) HdfsEnvironment(io.trino.plugin.hive.HdfsEnvironment) NodeVersion(io.trino.plugin.hive.NodeVersion) FileHiveMetastoreConfig(io.trino.plugin.hive.metastore.file.FileHiveMetastoreConfig) FileHiveMetastore(io.trino.plugin.hive.metastore.file.FileHiveMetastore) FileMetastoreTableOperationsProvider(io.trino.plugin.iceberg.catalog.file.FileMetastoreTableOperationsProvider) TrinoHiveCatalog(io.trino.plugin.iceberg.catalog.hms.TrinoHiveCatalog) CatalogName(io.trino.plugin.base.CatalogName) File(java.io.File) TestingTypeManager(io.trino.spi.type.TestingTypeManager)

Aggregations

NodeVersion (io.trino.plugin.hive.NodeVersion)17 HdfsEnvironment (io.trino.plugin.hive.HdfsEnvironment)13 HdfsConfig (io.trino.plugin.hive.HdfsConfig)11 HdfsConfiguration (io.trino.plugin.hive.HdfsConfiguration)11 HdfsConfigurationInitializer (io.trino.plugin.hive.HdfsConfigurationInitializer)11 HiveHdfsConfiguration (io.trino.plugin.hive.HiveHdfsConfiguration)11 NoHdfsAuthentication (io.trino.plugin.hive.authentication.NoHdfsAuthentication)11 MetastoreConfig (io.trino.plugin.hive.metastore.MetastoreConfig)11 FileHiveMetastore (io.trino.plugin.hive.metastore.file.FileHiveMetastore)10 FileHiveMetastoreConfig (io.trino.plugin.hive.metastore.file.FileHiveMetastoreConfig)10 CatalogName (io.trino.plugin.base.CatalogName)6 HiveMetastore (io.trino.plugin.hive.metastore.HiveMetastore)6 TypeManager (io.trino.spi.type.TypeManager)5 Injector (com.google.inject.Injector)4 Bootstrap (io.airlift.bootstrap.Bootstrap)4 JsonModule (io.airlift.json.JsonModule)4 NodeManager (io.trino.spi.NodeManager)4 PageIndexerFactory (io.trino.spi.PageIndexerFactory)4 ConnectorContext (io.trino.spi.connector.ConnectorContext)4 DistributedQueryRunner (io.trino.testing.DistributedQueryRunner)4