當前位置: 首頁>>代碼示例>>Java>>正文


Java CircuitBreakerModule類代碼示例

本文整理匯總了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);
}
 
開發者ID:foundit,項目名稱:elasticsearch-transport-module,代碼行數:31,代碼來源:TestFoundNettyTransport.java

示例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);
        }
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:62,代碼來源:TransportClient.java

示例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);
        }
    }
}
 
開發者ID:jprante,項目名稱:elasticsearch-helper,代碼行數:51,代碼來源:TransportClient.java


注:本文中的org.elasticsearch.indices.breaker.CircuitBreakerModule類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。