use of io.airlift.bootstrap.Bootstrap in project presto by prestodb.
the class PrestoVerifier method run.
public int run(String[] args) throws Exception {
if (args.length > 0) {
System.setProperty("config", args[0]);
}
ImmutableList.Builder<Module> builder = ImmutableList.<Module>builder().add(new PrestoVerifierModule()).addAll(getAdditionalModules());
Bootstrap app = new Bootstrap(builder.build());
Injector injector = app.strictConfig().initialize();
try {
VerifierConfig config = injector.getInstance(VerifierConfig.class);
injector.injectMembers(this);
Set<String> supportedEventClients = injector.getInstance(Key.get(new TypeLiteral<Set<String>>() {
}, Names.named(SUPPORTED_EVENT_CLIENTS)));
for (String clientType : config.getEventClients()) {
checkArgument(supportedEventClients.contains(clientType), "Unsupported event client: %s", clientType);
}
Set<EventClient> eventClients = injector.getInstance(Key.get(new TypeLiteral<Set<EventClient>>() {
}));
VerifierDao dao = new DBI(config.getQueryDatabase()).onDemand(VerifierDao.class);
ImmutableList.Builder<QueryPair> queriesBuilder = ImmutableList.builder();
for (String suite : config.getSuites()) {
queriesBuilder.addAll(dao.getQueriesBySuite(suite, config.getMaxQueries()));
}
List<QueryPair> queries = queriesBuilder.build();
queries = applyOverrides(config, queries);
queries = filterQueryTypes(new SqlParser(getParserOptions()), config, queries);
queries = filterQueries(queries);
if (config.getShadowWrites()) {
Sets.SetView<QueryType> allowedTypes = Sets.union(config.getTestQueryTypes(), config.getControlQueryTypes());
checkArgument(!Sets.intersection(allowedTypes, ImmutableSet.of(CREATE, MODIFY)).isEmpty(), "CREATE or MODIFY queries must be allowed in test or control to use write shadowing");
queries = rewriteQueries(new SqlParser(getParserOptions()), config, queries);
}
// Load jdbc drivers if needed
if (config.getAdditionalJdbcDriverPath() != null) {
List<URL> urlList = getUrls(config.getAdditionalJdbcDriverPath());
URL[] urls = new URL[urlList.size()];
urlList.toArray(urls);
if (config.getTestJdbcDriverName() != null) {
loadJdbcDriver(urls, config.getTestJdbcDriverName());
}
if (config.getControlJdbcDriverName() != null) {
loadJdbcDriver(urls, config.getControlJdbcDriverName());
}
}
// TODO: construct this with Guice
Verifier verifier = new Verifier(System.out, config, eventClients);
return verifier.run(queries);
} finally {
injector.getInstance(LifeCycleManager.class).stop();
}
}
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);
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);
}
}
use of io.airlift.bootstrap.Bootstrap in project airlift by airlift.
the class TestMBeanServerResource method setup.
@BeforeMethod
public void setup() throws Exception {
Bootstrap app = new Bootstrap(new TestingNodeModule(), new TestingHttpServerModule(), new JsonModule(), new JmxHttpRpcModule(TheServlet.class), binder -> {
binder.bind(MBeanServer.class).toInstance(platformMBeanServer);
binder.bind(TestMBean.class).in(Scopes.SINGLETON);
});
Injector injector = app.doNotInitializeLogging().initialize();
lifeCycleManager = injector.getInstance(LifeCycleManager.class);
TestingHttpServer server = injector.getInstance(TestingHttpServer.class);
testMBean = injector.getInstance(TestMBean.class);
testMBeanName = new ObjectName(generatedNameOf(TestMBean.class));
MBeanExporter exporter = new MBeanExporter(platformMBeanServer);
exporter.export(testMBeanName.toString(), testMBean);
JMXConnector connect = JMXConnectorFactory.connect(new JMXServiceURL("service:jmx:" + server.getBaseUrl()), ImmutableMap.of(JMXConnector.CREDENTIALS, new String[] { "foo", "bar" }));
mbeanServerConnection = connect.getMBeanServerConnection();
}
use of io.airlift.bootstrap.Bootstrap in project airlift by airlift.
the class TestServer method setup.
@BeforeMethod
public void setup() throws Exception {
Bootstrap app = new Bootstrap(new TestingNodeModule(), new TestingHttpServerModule(), new JsonModule(), new JaxrsModule(), new JmxHttpModule(), new JmxModule(), new MainModule());
Injector injector = app.doNotInitializeLogging().initialize();
lifeCycleManager = injector.getInstance(LifeCycleManager.class);
server = injector.getInstance(TestingHttpServer.class);
client = new JettyHttpClient();
}
use of io.airlift.bootstrap.Bootstrap in project airlift by airlift.
the class TestHttpClientBinder method testWithoutFilters.
@Test
public void testWithoutFilters() {
Injector injector = new Bootstrap(binder -> httpClientBinder(binder).bindHttpClient("foo", FooClient.class)).quiet().initialize();
assertNotNull(injector.getInstance(Key.get(HttpClient.class, FooClient.class)));
}
Aggregations