Search in sources :

Example 1 with HiveConnector

use of com.facebook.presto.hive.HiveConnector in project carbondata by apache.

the class CarbondataConnectorFactory method create.

@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
    requireNonNull(config, "config is null");
    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
        Bootstrap app = new Bootstrap(new EventModule(), new MBeanModule(), new JsonModule(), new CarbondataModule(catalogName), new HiveS3Module(catalogName), new HiveMetastoreModule(catalogName, Optional.ofNullable(null)), new HiveSecurityModule(), new HiveAuthenticationModule(), new HiveProcedureModule(), binder -> {
            javax.management.MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
            binder.bind(javax.management.MBeanServer.class).toInstance(new RebindSafeMBeanServer(platformMBeanServer));
            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(PageSorter.class).toInstance(context.getPageSorter());
            configBinder(binder).bindConfig(CarbonTableConfig.class);
        });
        Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        setCarbonEnum();
        LifeCycleManager lifeCycleManager = injector.getInstance(LifeCycleManager.class);
        HiveMetadataFactory metadataFactory = injector.getInstance(HiveMetadataFactory.class);
        HiveTransactionManager transactionManager = injector.getInstance(HiveTransactionManager.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);
        HiveSessionProperties hiveSessionProperties = injector.getInstance(HiveSessionProperties.class);
        HiveTableProperties hiveTableProperties = injector.getInstance(HiveTableProperties.class);
        HiveAnalyzeProperties hiveAnalyzeProperties = injector.getInstance(HiveAnalyzeProperties.class);
        ConnectorAccessControl accessControl = new PartitionsAwareAccessControl(injector.getInstance(ConnectorAccessControl.class));
        Set<Procedure> procedures = injector.getInstance(Key.get(new TypeLiteral<Set<Procedure>>() {
        }));
        return new HiveConnector(lifeCycleManager, metadataFactory, transactionManager, new ClassLoaderSafeConnectorSplitManager(splitManager, classLoader), new ClassLoaderSafeConnectorPageSourceProvider(connectorPageSource, classLoader), new ClassLoaderSafeConnectorPageSinkProvider(pageSinkProvider, classLoader), new ClassLoaderSafeNodePartitioningProvider(connectorDistributionProvider, classLoader), ImmutableSet.of(), procedures, hiveSessionProperties.getSessionProperties(), HiveSchemaProperties.SCHEMA_PROPERTIES, hiveTableProperties.getTableProperties(), hiveAnalyzeProperties.getAnalyzeProperties(), accessControl, classLoader);
    } catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
Also used : HiveProcedureModule(com.facebook.presto.hive.HiveProcedureModule) MBeanModule(org.weakref.jmx.guice.MBeanModule) HiveMetadataFactory(com.facebook.presto.hive.HiveMetadataFactory) EventModule(io.airlift.event.client.EventModule) HiveSessionProperties(com.facebook.presto.hive.HiveSessionProperties) NodeVersion(com.facebook.presto.hive.NodeVersion) ClassLoaderSafeConnectorPageSourceProvider(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorPageSourceProvider) TypeLiteral(com.google.inject.TypeLiteral) RebindSafeMBeanServer(com.facebook.presto.hive.RebindSafeMBeanServer) Injector(com.google.inject.Injector) HiveSecurityModule(com.facebook.presto.hive.security.HiveSecurityModule) Bootstrap(io.airlift.bootstrap.Bootstrap) PageSorter(com.facebook.presto.spi.PageSorter) Procedure(com.facebook.presto.spi.procedure.Procedure) HiveMetastoreModule(com.facebook.presto.hive.metastore.HiveMetastoreModule) HiveConnector(com.facebook.presto.hive.HiveConnector) ThreadContextClassLoader(com.facebook.presto.spi.classloader.ThreadContextClassLoader) HiveAnalyzeProperties(com.facebook.presto.hive.HiveAnalyzeProperties) ClassLoaderSafeNodePartitioningProvider(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeNodePartitioningProvider) RebindSafeMBeanServer(com.facebook.presto.hive.RebindSafeMBeanServer) ConnectorAccessControl(com.facebook.presto.spi.connector.ConnectorAccessControl) HiveTableProperties(com.facebook.presto.hive.HiveTableProperties) PartitionsAwareAccessControl(com.facebook.presto.hive.security.PartitionsAwareAccessControl) HiveAuthenticationModule(com.facebook.presto.hive.authentication.HiveAuthenticationModule) ClassLoaderSafeConnectorPageSinkProvider(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorPageSinkProvider) JsonModule(io.airlift.json.JsonModule) PageIndexerFactory(com.facebook.presto.spi.PageIndexerFactory) HiveS3Module(com.facebook.presto.hive.s3.HiveS3Module) NodeManager(com.facebook.presto.spi.NodeManager) LifeCycleManager(io.airlift.bootstrap.LifeCycleManager) ClassLoaderSafeConnectorPageSinkProvider(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorPageSinkProvider) ConnectorPageSinkProvider(com.facebook.presto.spi.connector.ConnectorPageSinkProvider) ConnectorSplitManager(com.facebook.presto.spi.connector.ConnectorSplitManager) ClassLoaderSafeConnectorSplitManager(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorSplitManager) ConnectorPageSourceProvider(com.facebook.presto.spi.connector.ConnectorPageSourceProvider) ClassLoaderSafeConnectorPageSourceProvider(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorPageSourceProvider) ConnectorNodePartitioningProvider(com.facebook.presto.spi.connector.ConnectorNodePartitioningProvider) ClassLoaderSafeConnectorSplitManager(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorSplitManager) TypeManager(com.facebook.presto.spi.type.TypeManager) HiveTransactionManager(com.facebook.presto.hive.HiveTransactionManager)

Aggregations

HiveAnalyzeProperties (com.facebook.presto.hive.HiveAnalyzeProperties)1 HiveConnector (com.facebook.presto.hive.HiveConnector)1 HiveMetadataFactory (com.facebook.presto.hive.HiveMetadataFactory)1 HiveProcedureModule (com.facebook.presto.hive.HiveProcedureModule)1 HiveSessionProperties (com.facebook.presto.hive.HiveSessionProperties)1 HiveTableProperties (com.facebook.presto.hive.HiveTableProperties)1 HiveTransactionManager (com.facebook.presto.hive.HiveTransactionManager)1 NodeVersion (com.facebook.presto.hive.NodeVersion)1 RebindSafeMBeanServer (com.facebook.presto.hive.RebindSafeMBeanServer)1 HiveAuthenticationModule (com.facebook.presto.hive.authentication.HiveAuthenticationModule)1 HiveMetastoreModule (com.facebook.presto.hive.metastore.HiveMetastoreModule)1 HiveS3Module (com.facebook.presto.hive.s3.HiveS3Module)1 HiveSecurityModule (com.facebook.presto.hive.security.HiveSecurityModule)1 PartitionsAwareAccessControl (com.facebook.presto.hive.security.PartitionsAwareAccessControl)1 NodeManager (com.facebook.presto.spi.NodeManager)1 PageIndexerFactory (com.facebook.presto.spi.PageIndexerFactory)1 PageSorter (com.facebook.presto.spi.PageSorter)1 ThreadContextClassLoader (com.facebook.presto.spi.classloader.ThreadContextClassLoader)1 ConnectorAccessControl (com.facebook.presto.spi.connector.ConnectorAccessControl)1 ConnectorNodePartitioningProvider (com.facebook.presto.spi.connector.ConnectorNodePartitioningProvider)1