use of io.airlift.bootstrap.Bootstrap 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);
}
}
use of io.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class MongoConnectorFactory method create.
@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context) {
requireNonNull(config, "config is null");
try {
Bootstrap app = new Bootstrap(new JsonModule(), new MongoClientModule(), binder -> binder.bind(TypeManager.class).toInstance(context.getTypeManager()));
Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(MongoConnector.class);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
use of io.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class JmxConnectorFactory method create.
@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context) {
try {
Bootstrap app = new Bootstrap(binder -> {
configBinder(binder).bindConfig(JmxConnectorConfig.class);
binder.bind(MBeanServer.class).toInstance(new RebindSafeMBeanServer(mbeanServer));
binder.bind(NodeManager.class).toInstance(context.getNodeManager());
binder.bind(JmxConnector.class).in(Scopes.SINGLETON);
binder.bind(JmxHistoricalData.class).in(Scopes.SINGLETON);
binder.bind(JmxMetadata.class).in(Scopes.SINGLETON);
binder.bind(JmxSplitManager.class).in(Scopes.SINGLETON);
binder.bind(JmxPeriodicSampler.class).in(Scopes.SINGLETON);
binder.bind(JmxRecordSetProvider.class).in(Scopes.SINGLETON);
});
Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(JmxConnector.class);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
use of io.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class LocalFileConnectorFactory method create.
@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context) {
requireNonNull(config, "config is null");
try {
Bootstrap app = new Bootstrap(binder -> binder.bind(NodeManager.class).toInstance(context.getNodeManager()), new LocalFileModule(connectorId));
Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(LocalFileConnector.class);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
use of io.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class AccumuloConnectorFactory method create.
@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context) {
requireNonNull(connectorId, "connectorId is null");
requireNonNull(config, "requiredConfig is null");
requireNonNull(context, "context is null");
try {
// A plugin is not required to use Guice; it is just very convenient
// Unless you don't really know how to Guice, then it is less convenient
Bootstrap app = new Bootstrap(new JsonModule(), new AccumuloModule(connectorId, context.getTypeManager()));
Injector injector = app.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
return injector.getInstance(AccumuloConnector.class);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
Aggregations