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();
}
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));
}
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));
}
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);
}
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());
}
}
Aggregations