本文整理汇总了Java中org.elasticsearch.indices.breaker.CircuitBreakerModule类的典型用法代码示例。如果您正苦于以下问题:Java CircuitBreakerModule类的具体用法?Java CircuitBreakerModule怎么用?Java CircuitBreakerModule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CircuitBreakerModule类属于org.elasticsearch.indices.breaker包,在下文中一共展示了CircuitBreakerModule类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testClientBootstrapUpdated
import org.elasticsearch.indices.breaker.CircuitBreakerModule; //导入依赖的package包/类
@Test
public void testClientBootstrapUpdated() throws Exception {
Settings settings = ImmutableSettings.settingsBuilder()
.put("name", "found-client-test")
.put("transport.type", "org.elasticsearch.transport.netty.FoundNettyTransport")
.build();
ModulesBuilder modules = new ModulesBuilder();
modules.add(new Version.Module(Version.CURRENT));
modules.add(new SettingsModule(settings));
modules.add(new ClusterNameModule(settings));
modules.add(new TransportModule(settings));
modules.add(new ThreadPoolModule(settings));
modules.add(new CircuitBreakerModule(settings));
Injector injector = modules.createInjector();
FoundNettyTransport transport = injector.getInstance(FoundNettyTransport.class);
transport.start();
Field clientBootstrapField = transport.getClass().getSuperclass().getDeclaredField("clientBootstrap");
clientBootstrapField.setAccessible(true);
ClientBootstrap clientBootstrap = (ClientBootstrap)clientBootstrapField.get(transport);
ChannelPipeline pipeline = clientBootstrap.getPipelineFactory().getPipeline();
FoundAuthenticatingChannelHandler channelHandler = pipeline.get(FoundAuthenticatingChannelHandler.class);
assertNotNull(channelHandler);
}
示例2: build
import org.elasticsearch.indices.breaker.CircuitBreakerModule; //导入依赖的package包/类
/**
* Builds a new instance of the transport client.
*/
public TransportClient build() {
Settings settings = InternalSettingsPreparer.prepareSettings(this.settings);
settings = settingsBuilder()
.put(NettyTransport.PING_SCHEDULE, "5s") // enable by default the transport schedule ping interval
.put(settings)
.put("network.server", false)
.put("node.client", true)
.put(CLIENT_TYPE_SETTING, CLIENT_TYPE)
.build();
PluginsService pluginsService = new PluginsService(settings, null, null, pluginClasses);
this.settings = pluginsService.updatedSettings();
Version version = Version.CURRENT;
final ThreadPool threadPool = new ThreadPool(settings);
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry();
boolean success = false;
try {
ModulesBuilder modules = new ModulesBuilder();
modules.add(new Version.Module(version));
// plugin modules must be added here, before others or we can get crazy injection errors...
for (Module pluginModule : pluginsService.nodeModules()) {
modules.add(pluginModule);
}
modules.add(new PluginsModule(pluginsService));
modules.add(new SettingsModule(this.settings));
modules.add(new NetworkModule(namedWriteableRegistry));
modules.add(new ClusterNameModule(this.settings));
modules.add(new ThreadPoolModule(threadPool));
modules.add(new TransportModule(this.settings, namedWriteableRegistry));
modules.add(new SearchModule() {
@Override
protected void configure() {
// noop
}
});
modules.add(new ActionModule(true));
modules.add(new ClientTransportModule());
modules.add(new CircuitBreakerModule(this.settings));
pluginsService.processModules(modules);
Injector injector = modules.createInjector();
final TransportService transportService = injector.getInstance(TransportService.class);
transportService.start();
transportService.acceptIncomingRequests();
TransportClient transportClient = new TransportClient(injector);
success = true;
return transportClient;
} finally {
if (!success) {
ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS);
}
}
}
示例3: build
import org.elasticsearch.indices.breaker.CircuitBreakerModule; //导入依赖的package包/类
public TransportClient build() {
Settings settings = InternalSettingsPreparer.prepareSettings(this.settings);
settings = settingsBuilder()
.put("transport.ping.schedule", this.settings.get("ping.interval", "30s"))
.put(settings)
.put("network.server", false)
.put("node.client", true)
.put(CLIENT_TYPE_SETTING, CLIENT_TYPE)
.build();
PluginsService pluginsService = new PluginsService(settings, null, null, pluginClasses);
this.settings = pluginsService.updatedSettings();
Version version = Version.CURRENT;
final ThreadPool threadPool = new ThreadPool(settings);
final NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry();
boolean success = false;
try {
ModulesBuilder modules = new ModulesBuilder();
modules.add(new Version.Module(version));
// plugin modules must be added here, before others or we can get crazy injection errors...
for (Module pluginModule : pluginsService.nodeModules()) {
modules.add(pluginModule);
}
modules.add(new PluginsModule(pluginsService));
modules.add(new SettingsModule(this.settings));
modules.add(new NetworkModule(namedWriteableRegistry));
modules.add(new ClusterNameModule(this.settings));
modules.add(new ThreadPoolModule(threadPool));
modules.add(new TransportModule(this.settings, namedWriteableRegistry));
modules.add(new SearchModule() {
@Override
protected void configure() {
// noop
}
});
modules.add(new ActionModule(true));
modules.add(new ClientTransportModule(hostFailedListener));
modules.add(new CircuitBreakerModule(this.settings));
pluginsService.processModules(modules);
Injector injector = modules.createInjector();
injector.getInstance(TransportService.class).start();
TransportClient transportClient = new TransportClient(injector);
success = true;
return transportClient;
} finally {
if (!success) {
ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS);
}
}
}