Search in sources :

Example 6 with ThreadContextClassLoader

use of com.facebook.presto.spi.classloader.ThreadContextClassLoader in project presto by prestodb.

the class FileResourceGroupConfigurationManagerFactory method create.

@Override
public ResourceGroupConfigurationManager create(Map<String, String> config, ResourceGroupConfigurationManagerContext context) {
    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
        Bootstrap app = new Bootstrap(new JsonModule(), new FileResourceGroupsModule(), binder -> binder.bind(ClusterMemoryPoolManager.class).toInstance(context.getMemoryPoolManager()));
        Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        return injector.getInstance(FileResourceGroupConfigurationManager.class);
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
Also used : Injector(com.google.inject.Injector) Bootstrap(io.airlift.bootstrap.Bootstrap) ThreadContextClassLoader(com.facebook.presto.spi.classloader.ThreadContextClassLoader) JsonModule(io.airlift.json.JsonModule)

Example 7 with ThreadContextClassLoader

use of com.facebook.presto.spi.classloader.ThreadContextClassLoader in project presto by prestodb.

the class DbResourceGroupConfigurationManagerFactory method create.

@Override
public ResourceGroupConfigurationManager create(Map<String, String> config, ResourceGroupConfigurationManagerContext context) {
    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
        Bootstrap app = new Bootstrap(new JsonModule(), new DbResourceGroupsModule(), binder -> binder.bind(ClusterMemoryPoolManager.class).toInstance(context.getMemoryPoolManager()));
        Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        return injector.getInstance(DbResourceGroupConfigurationManager.class);
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
Also used : Injector(com.google.inject.Injector) Bootstrap(io.airlift.bootstrap.Bootstrap) ThreadContextClassLoader(com.facebook.presto.spi.classloader.ThreadContextClassLoader) JsonModule(io.airlift.json.JsonModule)

Example 8 with ThreadContextClassLoader

use of com.facebook.presto.spi.classloader.ThreadContextClassLoader in project presto by prestodb.

the class H2ResourceGroupConfigurationManagerFactory method create.

@Override
public ResourceGroupConfigurationManager create(Map<String, String> config, ResourceGroupConfigurationManagerContext context) {
    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
        Bootstrap app = new Bootstrap(new JsonModule(), new H2ResourceGroupsModule(), binder -> binder.bind(ClusterMemoryPoolManager.class).toInstance(context.getMemoryPoolManager()));
        Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        return injector.getInstance(DbResourceGroupConfigurationManager.class);
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
Also used : Injector(com.google.inject.Injector) Bootstrap(io.airlift.bootstrap.Bootstrap) ThreadContextClassLoader(com.facebook.presto.spi.classloader.ThreadContextClassLoader) JsonModule(io.airlift.json.JsonModule)

Example 9 with ThreadContextClassLoader

use of com.facebook.presto.spi.classloader.ThreadContextClassLoader in project carbondata by apache.

the class CarbondataConnectorFactory method create.

@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context) {
    requireNonNull(config, "config is null");
    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
        Bootstrap app = new Bootstrap(new JsonModule(), new CarbondataModule(connectorId, context.getTypeManager()));
        Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        LifeCycleManager lifeCycleManager = injector.getInstance(LifeCycleManager.class);
        CarbondataMetadata metadata = injector.getInstance(CarbondataMetadata.class);
        ConnectorSplitManager splitManager = injector.getInstance(ConnectorSplitManager.class);
        ConnectorRecordSetProvider connectorRecordSet = injector.getInstance(ConnectorRecordSetProvider.class);
        ConnectorPageSourceProvider connectorPageSource = injector.getInstance(ConnectorPageSourceProvider.class);
        return new CarbondataConnector(lifeCycleManager, metadata, new ClassLoaderSafeConnectorSplitManager(splitManager, classLoader), connectorRecordSet, classLoader, new ClassLoaderSafeConnectorPageSourceProvider(connectorPageSource, classLoader));
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
Also used : JsonModule(io.airlift.json.JsonModule) ClassLoaderSafeConnectorPageSourceProvider(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorPageSourceProvider) LifeCycleManager(io.airlift.bootstrap.LifeCycleManager) ClassLoaderSafeConnectorSplitManager(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorSplitManager) ClassLoaderSafeConnectorPageSourceProvider(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorPageSourceProvider) Injector(com.google.inject.Injector) ClassLoaderSafeConnectorSplitManager(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorSplitManager) Bootstrap(io.airlift.bootstrap.Bootstrap) ThreadContextClassLoader(com.facebook.presto.spi.classloader.ThreadContextClassLoader)

Example 10 with ThreadContextClassLoader

use of com.facebook.presto.spi.classloader.ThreadContextClassLoader in project carbondata by apache.

the class CarbonTableReader method getCarbonCache.

// for worker node to initialize carbon metastore
public CarbonTableCacheModel getCarbonCache(SchemaTableName table) {
    if (!cc.containsKey(table)) {
        try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(FileFactory.class.getClassLoader())) {
            if (carbonFileList == null) {
                fileType = FileFactory.getFileType(config.getStorePath());
                try {
                    carbonFileList = FileFactory.getCarbonFile(config.getStorePath(), fileType);
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }
            }
        }
        updateSchemaTables();
        parseCarbonMetadata(table);
    }
    if (cc.containsKey(table))
        return cc.get(table);
    else
        return null;
}
Also used : ThreadContextClassLoader(com.facebook.presto.spi.classloader.ThreadContextClassLoader) KeyGenException(org.apache.carbondata.core.keygenerator.KeyGenException) IndexBuilderException(org.apache.carbondata.core.datastore.exception.IndexBuilderException) IOException(java.io.IOException) FileFactory(org.apache.carbondata.core.datastore.impl.FileFactory)

Aggregations

ThreadContextClassLoader (com.facebook.presto.spi.classloader.ThreadContextClassLoader)15 Injector (com.google.inject.Injector)7 Bootstrap (io.airlift.bootstrap.Bootstrap)7 JsonModule (io.airlift.json.JsonModule)6 Connector (com.facebook.presto.spi.connector.Connector)2 ClassLoaderSafeConnectorPageSourceProvider (com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorPageSourceProvider)2 ClassLoaderSafeConnectorSplitManager (com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorSplitManager)2 LifeCycleManager (io.airlift.bootstrap.LifeCycleManager)2 IOException (java.io.IOException)2 RowPagesBuilder (com.facebook.presto.RowPagesBuilder)1 SECURITY_FILE (com.facebook.presto.atop.AtopConnectorConfig.SECURITY_FILE)1 SECURITY_NONE (com.facebook.presto.atop.AtopConnectorConfig.SECURITY_NONE)1 InformationSchemaConnector (com.facebook.presto.connector.informationSchema.InformationSchemaConnector)1 SystemConnector (com.facebook.presto.connector.system.SystemConnector)1 HiveAuthenticationModule (com.facebook.presto.hive.authentication.HiveAuthenticationModule)1 HiveMetastoreModule (com.facebook.presto.hive.metastore.HiveMetastoreModule)1 HiveSecurityModule (com.facebook.presto.hive.security.HiveSecurityModule)1 OrcDataSource (com.facebook.presto.orc.OrcDataSource)1 OrcRecordReader (com.facebook.presto.orc.OrcRecordReader)1 AllowAllAccessControlModule (com.facebook.presto.plugin.base.security.AllowAllAccessControlModule)1