Search in sources :

Example 6 with HierarchyCircuitBreakerService

use of org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService in project elasticsearch by elastic.

the class RestControllerTests method setup.

@Before
public void setup() {
    Settings settings = Settings.EMPTY;
    circuitBreakerService = new HierarchyCircuitBreakerService(Settings.builder().put(HierarchyCircuitBreakerService.IN_FLIGHT_REQUESTS_CIRCUIT_BREAKER_LIMIT_SETTING.getKey(), BREAKER_LIMIT).build(), new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
    // we can do this here only because we know that we don't adjust breaker settings dynamically in the test
    inFlightRequestsBreaker = circuitBreakerService.getBreaker(CircuitBreaker.IN_FLIGHT_REQUESTS);
    HttpServerTransport httpServerTransport = new TestHttpServerTransport();
    restController = new RestController(settings, Collections.emptySet(), null, null, circuitBreakerService);
    restController.registerHandler(RestRequest.Method.GET, "/", (request, channel, client) -> channel.sendResponse(new BytesRestResponse(RestStatus.OK, BytesRestResponse.TEXT_CONTENT_TYPE, BytesArray.EMPTY)));
    restController.registerHandler(RestRequest.Method.GET, "/error", (request, channel, client) -> {
        throw new IllegalArgumentException("test error");
    });
    httpServerTransport.start();
}
Also used : ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) HierarchyCircuitBreakerService(org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService) HttpServerTransport(org.elasticsearch.http.HttpServerTransport) Settings(org.elasticsearch.common.settings.Settings) HttpTransportSettings(org.elasticsearch.http.HttpTransportSettings) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) Before(org.junit.Before)

Example 7 with HierarchyCircuitBreakerService

use of org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService in project crate by crate.

the class CrateCircuitBreakerServiceTest method testQueryCircuitBreakerRegistration.

@Test
public void testQueryCircuitBreakerRegistration() throws Exception {
    NodeSettingsService settingsService = new NodeSettingsService(Settings.EMPTY);
    CircuitBreakerService esBreakerService = new HierarchyCircuitBreakerService(Settings.EMPTY, settingsService);
    CrateCircuitBreakerService breakerService = new CrateCircuitBreakerService(Settings.EMPTY, settingsService, esBreakerService);
    CircuitBreaker breaker = breakerService.getBreaker(CrateCircuitBreakerService.QUERY);
    assertThat(breaker, notNullValue());
    assertThat(breaker, instanceOf(CircuitBreaker.class));
    assertThat(breaker.getName(), is(CrateCircuitBreakerService.QUERY));
}
Also used : CircuitBreaker(org.elasticsearch.common.breaker.CircuitBreaker) HierarchyCircuitBreakerService(org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService) NodeSettingsService(org.elasticsearch.node.settings.NodeSettingsService) CircuitBreakerService(org.elasticsearch.indices.breaker.CircuitBreakerService) HierarchyCircuitBreakerService(org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 8 with HierarchyCircuitBreakerService

use of org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService in project crate by crate.

the class CrateCircuitBreakerServiceTest method testStats.

@Test
public void testStats() throws Exception {
    NodeSettingsService settingsService = new NodeSettingsService(Settings.EMPTY);
    CircuitBreakerService esBreakerService = new HierarchyCircuitBreakerService(Settings.EMPTY, settingsService);
    CrateCircuitBreakerService breakerService = new CrateCircuitBreakerService(Settings.EMPTY, settingsService, esBreakerService);
    CircuitBreakerStats[] stats = breakerService.stats().getAllStats();
    assertThat(stats.length, is(7));
    CircuitBreakerStats queryBreakerStats = breakerService.stats(CrateCircuitBreakerService.QUERY);
    assertThat(queryBreakerStats.getEstimated(), is(0L));
}
Also used : CircuitBreakerStats(org.elasticsearch.indices.breaker.CircuitBreakerStats) HierarchyCircuitBreakerService(org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService) NodeSettingsService(org.elasticsearch.node.settings.NodeSettingsService) CircuitBreakerService(org.elasticsearch.indices.breaker.CircuitBreakerService) HierarchyCircuitBreakerService(org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 9 with HierarchyCircuitBreakerService

use of org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService in project crate by crate.

the class JobsLogsTest method beforeClass.

@BeforeClass
public static void beforeClass() {
    CircuitBreakerService esBreakerService = new HierarchyCircuitBreakerService(Settings.EMPTY, nodeSettingsService);
    breakerService = new CrateCircuitBreakerService(Settings.EMPTY, nodeSettingsService, esBreakerService);
}
Also used : HierarchyCircuitBreakerService(org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService) CrateCircuitBreakerService(io.crate.breaker.CrateCircuitBreakerService) CircuitBreakerService(org.elasticsearch.indices.breaker.CircuitBreakerService) HierarchyCircuitBreakerService(org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService) CrateCircuitBreakerService(io.crate.breaker.CrateCircuitBreakerService) BeforeClass(org.junit.BeforeClass)

Example 10 with HierarchyCircuitBreakerService

use of org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService in project elasticsearch by elastic.

the class BigArraysTests method testMaxSizeExceededOnNew.

public void testMaxSizeExceededOnNew() throws Exception {
    final int size = scaledRandomIntBetween(5, 1 << 22);
    for (String type : Arrays.asList("Byte", "Int", "Long", "Float", "Double", "Object")) {
        HierarchyCircuitBreakerService hcbs = new HierarchyCircuitBreakerService(Settings.builder().put(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING.getKey(), size - 1, ByteSizeUnit.BYTES).build(), new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
        BigArrays bigArrays = new BigArrays(null, hcbs, false).withCircuitBreaking();
        Method create = BigArrays.class.getMethod("new" + type + "Array", long.class);
        try {
            create.invoke(bigArrays, size);
            fail("expected an exception on " + create);
        } catch (InvocationTargetException e) {
            assertTrue(e.getCause() instanceof CircuitBreakingException);
        }
        assertEquals(0, hcbs.getBreaker(CircuitBreaker.REQUEST).getUsed());
    }
}
Also used : ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) CircuitBreakingException(org.elasticsearch.common.breaker.CircuitBreakingException) HierarchyCircuitBreakerService(org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

HierarchyCircuitBreakerService (org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService)12 CircuitBreakerService (org.elasticsearch.indices.breaker.CircuitBreakerService)8 ClusterSettings (org.elasticsearch.common.settings.ClusterSettings)7 CrateUnitTest (io.crate.test.integration.CrateUnitTest)4 CircuitBreaker (org.elasticsearch.common.breaker.CircuitBreaker)4 Settings (org.elasticsearch.common.settings.Settings)4 NodeSettingsService (org.elasticsearch.node.settings.NodeSettingsService)4 Test (org.junit.Test)4 BreakerSettings (org.elasticsearch.indices.breaker.BreakerSettings)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 CircuitBreakingException (org.elasticsearch.common.breaker.CircuitBreakingException)2 Before (org.junit.Before)2 CrateCircuitBreakerService (io.crate.breaker.CrateCircuitBreakerService)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)1 ByteSizeValue (org.elasticsearch.common.unit.ByteSizeValue)1