Search in sources :

Example 1 with ClassLoaderSafeConnectorMetadata

use of com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorMetadata 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);
        ConnectorMetadata 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, new ClassLoaderSafeConnectorMetadata(metadata, classLoader), new ClassLoaderSafeConnectorSplitManager(splitManager, classLoader), connectorRecordSet, classLoader, new ClassLoaderSafeConnectorPageSourceProvider(connectorPageSource, classLoader));
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
Also used : ClassLoaderSafeConnectorMetadata(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorMetadata) 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) ClassLoaderSafeConnectorMetadata(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorMetadata) ThreadContextClassLoader(com.facebook.presto.spi.classloader.ThreadContextClassLoader)

Example 2 with ClassLoaderSafeConnectorMetadata

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

the class HiveConnector method getMetadata.

@Override
public ConnectorMetadata getMetadata(ConnectorTransactionHandle transaction) {
    ConnectorMetadata metadata = transactionManager.get(transaction);
    checkArgument(metadata != null, "no such transaction: %s", transaction);
    return new ClassLoaderSafeConnectorMetadata(metadata, classLoader);
}
Also used : ClassLoaderSafeConnectorMetadata(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorMetadata) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ClassLoaderSafeConnectorMetadata(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorMetadata)

Aggregations

ClassLoaderSafeConnectorMetadata (com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorMetadata)2 ThreadContextClassLoader (com.facebook.presto.spi.classloader.ThreadContextClassLoader)1 ConnectorMetadata (com.facebook.presto.spi.connector.ConnectorMetadata)1 ClassLoaderSafeConnectorPageSourceProvider (com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorPageSourceProvider)1 ClassLoaderSafeConnectorSplitManager (com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorSplitManager)1 Injector (com.google.inject.Injector)1 Bootstrap (io.airlift.bootstrap.Bootstrap)1 LifeCycleManager (io.airlift.bootstrap.LifeCycleManager)1 JsonModule (io.airlift.json.JsonModule)1