Search in sources :

Example 1 with IcebergCatalogModule

use of io.trino.plugin.iceberg.catalog.IcebergCatalogModule 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)

Aggregations

Injector (com.google.inject.Injector)1 Key (com.google.inject.Key)1 Module (com.google.inject.Module)1 SINGLETON (com.google.inject.Scopes.SINGLETON)1 TypeLiteral (com.google.inject.TypeLiteral)1 Bootstrap (io.airlift.bootstrap.Bootstrap)1 LifeCycleManager (io.airlift.bootstrap.LifeCycleManager)1 EventModule (io.airlift.event.client.EventModule)1 JsonModule (io.airlift.json.JsonModule)1 CatalogName (io.trino.plugin.base.CatalogName)1 ClassLoaderSafeConnectorPageSinkProvider (io.trino.plugin.base.classloader.ClassLoaderSafeConnectorPageSinkProvider)1 ClassLoaderSafeConnectorPageSourceProvider (io.trino.plugin.base.classloader.ClassLoaderSafeConnectorPageSourceProvider)1 ClassLoaderSafeConnectorSplitManager (io.trino.plugin.base.classloader.ClassLoaderSafeConnectorSplitManager)1 ClassLoaderSafeNodePartitioningProvider (io.trino.plugin.base.classloader.ClassLoaderSafeNodePartitioningProvider)1 ConnectorObjectNameGeneratorModule (io.trino.plugin.base.jmx.ConnectorObjectNameGeneratorModule)1 MBeanServerModule (io.trino.plugin.base.jmx.MBeanServerModule)1 SessionPropertiesProvider (io.trino.plugin.base.session.SessionPropertiesProvider)1 HiveHdfsModule (io.trino.plugin.hive.HiveHdfsModule)1 NodeVersion (io.trino.plugin.hive.NodeVersion)1 HdfsAuthenticationModule (io.trino.plugin.hive.authentication.HdfsAuthenticationModule)1