Java Code Examples for org.elasticsearch.indices.breaker.CircuitBreakerService#getBreaker()

The following examples show how to use org.elasticsearch.indices.breaker.CircuitBreakerService#getBreaker() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransportFetchNodeAction.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public TransportFetchNodeAction(TransportService transportService,
                                Transports transports,
                                ThreadPool threadPool,
                                StatsTables statsTables,
                                CircuitBreakerService breakerService,
                                JobContextService jobContextService,
                                NodeFetchOperation nodeFetchOperation) {
    this.transports = transports;
    this.statsTables = statsTables;
    this.nodeFetchOperation = nodeFetchOperation;
    this.circuitBreaker = breakerService.getBreaker(CrateCircuitBreakerService.QUERY);
    this.jobContextService = jobContextService;
    this.threadPool = threadPool;

    transportService.registerRequestHandler(TRANSPORT_ACTION,
            NodeFetchRequest.class,
            EXECUTOR_NAME,
            new NodeActionRequestHandler<NodeFetchRequest, NodeFetchResponse>(this) { });
}
 
Example 2
Source File: CrateCircuitBreakerServiceTest.java    From crate with Apache License 2.0 6 votes vote down vote up
@Test
public void testQueryCircuitBreakerDynamicSettings() throws Exception {
    CircuitBreakerService breakerService = new HierarchyCircuitBreakerService(
        Settings.EMPTY, clusterSettings);

    Settings newSettings = Settings.builder()
        .put(HierarchyCircuitBreakerService.QUERY_CIRCUIT_BREAKER_OVERHEAD_SETTING.getKey(), 2.0)
        .build();

    clusterSettings.applySettings(newSettings);

    CircuitBreaker breaker = breakerService.getBreaker(HierarchyCircuitBreakerService.QUERY);
    assertThat(breaker, notNullValue());
    assertThat(breaker, instanceOf(CircuitBreaker.class));
    assertThat(breaker.getOverhead(), is(2.0));
}
 
Example 3
Source File: TransportFetchNodeAction.java    From crate with Apache License 2.0 5 votes vote down vote up
@Inject
public TransportFetchNodeAction(Settings settings,
                                TransportService transportService,
                                Transports transports,
                                ThreadPool threadPool,
                                JobsLogs jobsLogs,
                                TasksService tasksService,
                                CircuitBreakerService circuitBreakerService) {
    this.transports = transports;
    this.nodeFetchOperation = new NodeFetchOperation(
        (ThreadPoolExecutor) threadPool.executor(ThreadPool.Names.SEARCH),
        EsExecutors.numberOfProcessors(settings),
        jobsLogs,
        tasksService,
        circuitBreakerService.getBreaker(HierarchyCircuitBreakerService.QUERY)
    );

    transportService.registerRequestHandler(
        TRANSPORT_ACTION,
        NodeFetchRequest::new,
        EXECUTOR_NAME,
        // force execution because this handler might receive empty close requests which
        // need to be processed to not leak the FetchTask.
        // This shouldn't cause too much of an issue because fetch requests always happen after a query phase.
        // If the threadPool is overloaded the query phase would fail first.
        true,
        false,
        new NodeActionRequestHandler<>(this)
    );
}
 
Example 4
Source File: CrateCircuitBreakerServiceTest.java    From crate with Apache License 2.0 5 votes vote down vote up
@Test
public void testQueryCircuitBreakerRegistration() throws Exception {
    CircuitBreakerService breakerService = new HierarchyCircuitBreakerService(
        Settings.EMPTY,
        clusterSettings
    );

    CircuitBreaker breaker = breakerService.getBreaker(HierarchyCircuitBreakerService.QUERY);
    assertThat(breaker, notNullValue());
    assertThat(breaker, instanceOf(CircuitBreaker.class));
    assertThat(breaker.getName(), is(HierarchyCircuitBreakerService.QUERY));
}
 
Example 5
Source File: CircuitBreakerIntegrationTest.java    From crate with Apache License 2.0 5 votes vote down vote up
@Test
public void testQueryBreakerIsDecrementedWhenQueryCompletes() {
    execute("create table t1 (text string)");
    execute("insert into t1 values ('this is some text'), ('other text')");
    refresh();

    CircuitBreakerService circuitBreakerService = internalCluster().getInstance(CircuitBreakerService.class);
    CircuitBreaker queryBreaker = circuitBreakerService.getBreaker(HierarchyCircuitBreakerService.QUERY);
    long breakerBytesUsedBeforeQuery = queryBreaker.getUsed();

    execute("select text from t1 group by text");

    assertThat(queryBreaker.getUsed(), is(breakerBytesUsedBeforeQuery));
}