use of com.facebook.presto.spi.classloader.ThreadContextClassLoader in project presto by prestodb.
the class AtopConnectorFactory method create.
@Override
public Connector create(String connectorId, Map<String, String> requiredConfig, ConnectorContext context) {
requireNonNull(requiredConfig, "requiredConfig is null");
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
Bootstrap app = new Bootstrap(new AtopModule(atopFactoryClass, context.getTypeManager(), context.getNodeManager(), context.getNodeManager().getEnvironment(), connectorId), installModuleIf(AtopConnectorConfig.class, config -> config.getSecurity().equalsIgnoreCase(SECURITY_NONE), new AllowAllAccessControlModule()), installModuleIf(AtopConnectorConfig.class, config -> config.getSecurity().equalsIgnoreCase(SECURITY_FILE), binder -> {
binder.install(new FileBasedAccessControlModule());
binder.install(new JsonModule());
}));
Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(requiredConfig).initialize();
return injector.getInstance(AtopConnector.class);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
use of com.facebook.presto.spi.classloader.ThreadContextClassLoader in project presto by prestodb.
the class HiveConnector method beginTransaction.
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) {
checkConnectorSupports(READ_UNCOMMITTED, isolationLevel);
ConnectorTransactionHandle transaction = new HiveTransactionHandle();
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
transactionManager.put(transaction, metadataFactory.create());
}
return transaction;
}
use of com.facebook.presto.spi.classloader.ThreadContextClassLoader in project presto by prestodb.
the class HiveConnector method rollback.
@Override
public void rollback(ConnectorTransactionHandle transaction) {
HiveMetadata metadata = (HiveMetadata) transactionManager.remove(transaction);
checkArgument(metadata != null, "no such transaction: %s", transaction);
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
metadata.rollback();
}
}
use of com.facebook.presto.spi.classloader.ThreadContextClassLoader in project presto by prestodb.
the class HiveConnectorFactory 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 MBeanModule(), new JsonModule(), new HiveClientModule(connectorId, context.getTypeManager(), context.getPageIndexerFactory(), context.getNodeManager()), new HiveMetastoreModule(connectorId, Optional.ofNullable(metastore)), new HiveSecurityModule(), new HiveAuthenticationModule(), binder -> {
MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
binder.bind(MBeanServer.class).toInstance(new RebindSafeMBeanServer(platformMBeanServer));
binder.bind(NodeVersion.class).toInstance(new NodeVersion(context.getNodeManager().getCurrentNode().getVersion()));
});
Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
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);
ConnectorAccessControl accessControl = injector.getInstance(ConnectorAccessControl.class);
return new HiveConnector(lifeCycleManager, metadataFactory, transactionManager, new ClassLoaderSafeConnectorSplitManager(splitManager, classLoader), new ClassLoaderSafeConnectorPageSourceProvider(connectorPageSource, classLoader), new ClassLoaderSafeConnectorPageSinkProvider(pageSinkProvider, classLoader), new ClassLoaderSafeNodePartitioningProvider(connectorDistributionProvider, classLoader), ImmutableSet.of(), hiveSessionProperties.getSessionProperties(), HiveSchemaProperties.SCHEMA_PROPERTIES, hiveTableProperties.getTableProperties(), accessControl, classLoader);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
use of com.facebook.presto.spi.classloader.ThreadContextClassLoader in project presto by prestodb.
the class JdbcConnectorFactory method create.
@Override
public Connector create(String connectorId, Map<String, String> requiredConfig, ConnectorContext context) {
requireNonNull(requiredConfig, "requiredConfig is null");
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
Bootstrap app = new Bootstrap(new JdbcModule(connectorId), module);
Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(requiredConfig).initialize();
return injector.getInstance(JdbcConnector.class);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
Aggregations