本文整理汇总了Java中io.airlift.bootstrap.Bootstrap类的典型用法代码示例。如果您正苦于以下问题:Java Bootstrap类的具体用法?Java Bootstrap怎么用?Java Bootstrap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Bootstrap类属于io.airlift.bootstrap包,在下文中一共展示了Bootstrap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import io.airlift.bootstrap.Bootstrap; //导入依赖的package包/类
@Test
public void test()
throws Exception
{
Annotation clientAnnotation = named("test");
Bootstrap bootstrap = new Bootstrap(
new DriftNettyClientModule(),
binder -> configBinder(binder).bindConfig(DriftClientConfig.class, clientAnnotation, "prefix"));
Injector injector = bootstrap
.doNotInitializeLogging()
.strictConfig()
.initialize();
assertNotNull(injector.getInstance(Key.get(new TypeLiteral<MethodInvokerFactory<Annotation>>() {})));
assertNotNull(injector.getInstance(Key.get(DriftClientConfig.class, clientAnnotation)));
assertNotNull(injector.getInstance(Key.get(DriftNettyClientConfig.class, clientAnnotation)));
}
示例2: create
import io.airlift.bootstrap.Bootstrap; //导入依赖的package包/类
@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 HDFSModule(connectorId, context.getTypeManager())
);
Injector injector = app
.strictConfig()
.doNotInitializeLogging()
.setRequiredConfigurationProperties(config)
.initialize();
return injector.getInstance(HDFSConnector.class);
}
catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例3: create
import io.airlift.bootstrap.Bootstrap; //导入依赖的package包/类
@Override
public Connector create(final String connectorId, Map<String, String> requiredConfig, ConnectorContext context)
{
requireNonNull(requiredConfig, "config is null");
try {
Bootstrap app = new Bootstrap(
binder -> binder.bind(NodeManager.class).toInstance(context.getNodeManager()),
new KuduModule(connectorId));
Injector injector = app
.strictConfig()
.doNotInitializeLogging()
.setRequiredConfigurationProperties(requiredConfig)
.initialize();
return injector.getInstance(KuduConnector.class);
}
catch (Exception e) {
throw Throwables.propagate(e);
}
}
示例4: testGuiceMain
import io.airlift.bootstrap.Bootstrap; //导入依赖的package包/类
@Test
public void testGuiceMain()
throws Exception
{
Bootstrap app = new Bootstrap(new WavaMainModule());
Injector injector = app.strictConfig().initialize();
Element root = new Parser(Input.ofResource("new/sqlite3.wast")).parse();
YModule ymodule = new ModuleFactory(root).create();
Module module = UnitTranslation.translateModule(Name.of("sqlite3"), ymodule);
ModuleScope moduleScope = injector.getInstance(ModuleScope.class);
moduleScope.with(
ImmutableMap.of(
Key.get(Module.class), module),
() -> {
StandardDriver standardDriver = injector.getInstance(StandardDriver.class);
return null;
}).get();
}
示例5: create
import io.airlift.bootstrap.Bootstrap; //导入依赖的package包/类
@Override
public Connector create(final String connectorId, Map<String, String> requiredConfig)
{
requireNonNull(requiredConfig, "requiredConfig is null");
requireNonNull(optionalConfig, "optionalConfig is null");
try {
// A plugin is not required to use Guice; it is just very convenient
Bootstrap app = new Bootstrap(
new JsonModule(),
new ExampleModule(connectorId, typeManager));
Injector injector = app
.strictConfig()
.doNotInitializeLogging()
.setRequiredConfigurationProperties(requiredConfig)
.setOptionalConfigurationProperties(optionalConfig)
.initialize();
return injector.getInstance(ExampleConnector.class);
}
catch (Exception e) {
throw Throwables.propagate(e);
}
}
示例6: ExampleHttpServer
import io.airlift.bootstrap.Bootstrap; //导入依赖的package包/类
public ExampleHttpServer()
throws Exception
{
Bootstrap app = new Bootstrap(
new TestingNodeModule(),
new TestingHttpServerModule(),
new ExampleHttpServerModule());
Injector injector = app
.strictConfig()
.doNotInitializeLogging()
.initialize();
lifeCycleManager = injector.getInstance(LifeCycleManager.class);
baseUri = injector.getInstance(TestingHttpServer.class).getBaseUrl();
}
示例7: create
import io.airlift.bootstrap.Bootstrap; //导入依赖的package包/类
@Override
public Connector create(String connectorId, Map<String, String> requiredConfig)
{
requireNonNull(requiredConfig, "requiredConfig is null");
requireNonNull(optionalConfig, "optionalConfig is null");
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
Bootstrap app = new Bootstrap(new JdbcModule(connectorId), module);
Injector injector = app
.strictConfig()
.doNotInitializeLogging()
.setRequiredConfigurationProperties(requiredConfig)
.setOptionalConfigurationProperties(optionalConfig)
.initialize();
return injector.getInstance(JdbcConnector.class);
}
catch (Exception e) {
throw Throwables.propagate(e);
}
}
示例8: create
import io.airlift.bootstrap.Bootstrap; //导入依赖的package包/类
@Override
public Connector create(final String connectorId, Map<String, String> requiredConfig) {
checkNotNull(requiredConfig, "requiredConfig is null");
checkNotNull(optionalConfig, "optionalConfig is null");
try {
// A plugin is not required to use Guice; it is just very convenient
Bootstrap app = new Bootstrap(
new JsonModule(),
new RiakModule(connectorId, typeManager));
Injector injector = app
.strictConfig()
.doNotInitializeLogging()
.setRequiredConfigurationProperties(requiredConfig)
.setOptionalConfigurationProperties(optionalConfig)
.initialize();
return injector.getInstance(RiakConnector.class);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
示例9: testAddressSelector
import io.airlift.bootstrap.Bootstrap; //导入依赖的package包/类
private static void testAddressSelector(
AddressSelectorBinder addressSelectorBinder,
Map<String, String> configurationProperties,
List<HostAndPort> expected)
throws Exception
{
Bootstrap app = new Bootstrap(
new ThriftCodecModule(),
binder -> addressSelectorBinder.bind(binder, THRIFT_SERVICE_ANNOTATION, "testService"));
LifeCycleManager lifeCycleManager = null;
try {
Injector injector = app
.setRequiredConfigurationProperties(configurationProperties)
.strictConfig()
.doNotInitializeLogging()
.initialize();
lifeCycleManager = injector.getInstance(LifeCycleManager.class);
AddressSelector<?> addressSelector = injector.getInstance(Key.get(AddressSelector.class, THRIFT_SERVICE_ANNOTATION));
assertInstanceOf(addressSelector, SimpleAddressSelector.class);
SimpleAddressSelector simpleAddressSelector = (SimpleAddressSelector) addressSelector;
assertEquals(simpleAddressSelector.getAddresses(), expected);
}
finally {
if (lifeCycleManager != null) {
try {
lifeCycleManager.stop();
}
catch (Exception ignored) {
}
}
}
}
示例10: create
import io.airlift.bootstrap.Bootstrap; //导入依赖的package包/类
@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context) {
requireNonNull(connectorId, "connectorId is null");
requireNonNull(config, "config is null");
try {
Bootstrap app = new Bootstrap(
// new JsonModule(),
new EthereumConnectorModule(),
binder -> {
binder.bind(EthereumConnectorId.class).toInstance(new EthereumConnectorId(connectorId));
binder.bind(TypeManager.class).toInstance(context.getTypeManager());
binder.bind(NodeManager.class).toInstance(context.getNodeManager());
}
);
Injector injector = app.strictConfig()
.doNotInitializeLogging()
.setRequiredConfigurationProperties(config)
.initialize();
return injector.getInstance(EthereumConnector.class);
}
catch (Exception e) {
throw Throwables.propagate(e);
}
}
示例11: create
import io.airlift.bootstrap.Bootstrap; //导入依赖的package包/类
public Connector create(final String connectorId, Map<String, String> requiredConfig,
ConnectorContext context) {
requireNonNull(requiredConfig, "requiredConfig is null");
final String
locator_host =
requiredConfig
.getOrDefault(MonarchProperties.LOCATOR_HOST, MonarchProperties.LOCATOR_HOST_DEFAULT);
final int
locator_port =
Integer.parseInt(requiredConfig
.getOrDefault(MonarchProperties.LOCATOR_PORT, MonarchProperties.LOCATOR_PORT_DEFAULT));
// Create a client that connects to the Ampool cluster via a locator (that is already running!).
final Properties props = new Properties();
props.setProperty(Constants.MClientCacheconfig.MONARCH_CLIENT_LOG, requiredConfig
.getOrDefault(MonarchProperties.MONARCH_CLIENT_LOG, MonarchProperties.MONARCH_CLIENT_LOG_DEFAULT_LOCATION));
final AmpoolClient aClient = new AmpoolClient(locator_host, locator_port, props);
log.info("INFORMATION: AmpoolClient created successfully.");
try {
Bootstrap
app =
new Bootstrap(new AmpoolModule(connectorId, aClient, context.getTypeManager()));
Injector injector = app
.doNotInitializeLogging()
.setRequiredConfigurationProperties(requiredConfig)
.initialize();
log.info("INFORMATION: Injector initialized successfully.");
return injector.getInstance(AmpoolConnector.class);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
示例12: main
import io.airlift.bootstrap.Bootstrap; //导入依赖的package包/类
public static void main(String[] args)
throws Exception
{
if (System.getProperty("config", null) == null) {
System.setProperty("config", "etc/agent.properties");
}
Bootstrap bootstrap = new Bootstrap(
new NodeModule(),
new DiscoveryModule(),
new HttpServerModule(),
new JsonModule(),
new JaxrsModule(true), // requireExplicitBindings = true
new HttpEventModule(),
new JsonReaderModule(false),
new DynamicAnnouncementModule(),
new AgentServerModule()
);
try {
Injector injector = bootstrap.strictConfig().initialize();
injector.getInstance(Announcer.class).start();
}
catch (Exception e) {
LOG.error(e, "Error starting server");
}
}
示例13: main
import io.airlift.bootstrap.Bootstrap; //导入依赖的package包/类
public static void main(String[] args)
throws Exception
{
if (System.getProperty("config", null) == null) {
System.setProperty("config", "etc/controller.properties");
}
Bootstrap bootstrap = new Bootstrap(
new NodeModule(),
new DiscoveryModule(),
new DiscoveryServerModule(),
new HttpEventModule(),
new HttpServerModule(),
new JsonModule(),
new JaxrsModule(true), // requireExplicitBindings = true'
new JmxModule(),
new MBeanModule(),
new JsonReaderModule(false),
new ControllerServerModule()
);
try {
bootstrap.strictConfig().initialize();
}
catch (Exception e) {
LOG.error(e, "Error starting server");
}
}
示例14: create
import io.airlift.bootstrap.Bootstrap; //导入依赖的package包/类
@Override
public Connector create(String connectorId, Map<String, String> config)
{
requireNonNull(connectorId, "connectorId is null");
requireNonNull(config, "config is null");
try {
Bootstrap app = new Bootstrap(
new JsonModule(),
new KafkaConnectorModule(),
binder -> {
binder.bind(KafkaConnectorId.class).toInstance(new KafkaConnectorId(connectorId));
binder.bind(TypeManager.class).toInstance(typeManager);
binder.bind(NodeManager.class).toInstance(nodeManager);
if (tableDescriptionSupplier.isPresent()) {
binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, KafkaTopicDescription>>>() {}).toInstance(tableDescriptionSupplier.get());
}
else {
binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, KafkaTopicDescription>>>() {}).to(KafkaTableDescriptionSupplier.class).in(Scopes.SINGLETON);
}
}
);
Injector injector = app.strictConfig()
.doNotInitializeLogging()
.setRequiredConfigurationProperties(config)
.setOptionalConfigurationProperties(optionalConfig)
.initialize();
return injector.getInstance(KafkaConnector.class);
}
catch (Exception e) {
throw Throwables.propagate(e);
}
}
示例15: create
import io.airlift.bootstrap.Bootstrap; //导入依赖的package包/类
@Override
public Connector create(String connectorId, Map<String, String> config)
{
try {
Bootstrap app = new Bootstrap(
new JsonModule(),
new MBeanModule(),
binder -> {
CurrentNodeId currentNodeId = new CurrentNodeId(nodeManager.getCurrentNode().getNodeIdentifier());
MBeanServer mbeanServer = new RebindSafeMBeanServer(getPlatformMBeanServer());
binder.bind(MBeanServer.class).toInstance(mbeanServer);
binder.bind(CurrentNodeId.class).toInstance(currentNodeId);
binder.bind(NodeManager.class).toInstance(nodeManager);
binder.bind(PageSorter.class).toInstance(pageSorter);
binder.bind(BlockEncodingSerde.class).toInstance(blockEncodingSerde);
binder.bind(TypeManager.class).toInstance(typeManager);
},
metadataModule,
new BackupModule(backupProviders),
new StorageModule(connectorId),
new RaptorModule(connectorId));
Injector injector = app
.strictConfig()
.doNotInitializeLogging()
.setRequiredConfigurationProperties(config)
.setOptionalConfigurationProperties(optionalConfig)
.initialize();
return injector.getInstance(RaptorConnector.class);
}
catch (Exception e) {
throw Throwables.propagate(e);
}
}