use of org.elasticsearch.common.breaker.NoopCircuitBreaker in project elasticsearch by elastic.
the class HierarchyCircuitBreakerService method registerBreaker.
/**
* Allows to register a custom circuit breaker.
* Warning: Will overwrite any existing custom breaker with the same name.
*/
@Override
public void registerBreaker(BreakerSettings breakerSettings) {
// Validate the settings
validateSettings(new BreakerSettings[] { breakerSettings });
if (breakerSettings.getType() == CircuitBreaker.Type.NOOP) {
CircuitBreaker breaker = new NoopCircuitBreaker(breakerSettings.getName());
breakers.put(breakerSettings.getName(), breaker);
} else {
CircuitBreaker oldBreaker;
CircuitBreaker breaker = new ChildMemoryCircuitBreaker(breakerSettings, Loggers.getLogger(CHILD_LOGGER_PREFIX + breakerSettings.getName()), this, breakerSettings.getName());
for (; ; ) {
oldBreaker = breakers.putIfAbsent(breakerSettings.getName(), breaker);
if (oldBreaker == null) {
return;
}
breaker = new ChildMemoryCircuitBreaker(breakerSettings, (ChildMemoryCircuitBreaker) oldBreaker, Loggers.getLogger(CHILD_LOGGER_PREFIX + breakerSettings.getName()), this, breakerSettings.getName());
if (breakers.replace(breakerSettings.getName(), oldBreaker, breaker)) {
return;
}
}
}
}
use of org.elasticsearch.common.breaker.NoopCircuitBreaker in project crate by crate.
the class LuceneBatchIteratorTest method testLuceneBatchIterator.
@Test
public void testLuceneBatchIterator() throws Exception {
BatchIteratorTester tester = new BatchIteratorTester(() -> {
return new LuceneBatchIterator(indexSearcher, new MatchAllDocsQuery(), null, false, new CollectorContext(mock(IndexFieldDataService.class), new CollectorFieldsVisitor(0)), new RamAccountingContext("dummy", new NoopCircuitBreaker("dummy")), columnRefs, columnRefs);
});
tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
use of org.elasticsearch.common.breaker.NoopCircuitBreaker in project crate by crate.
the class NodeFetchOperationTest method testSysOperationsIsClearedIfNothingToFetch.
@Test
public void testSysOperationsIsClearedIfNothingToFetch() throws Exception {
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) Executors.newFixedThreadPool(1);
try {
JobsLogs jobsLogs = new JobsLogs(() -> true);
NodeFetchOperation fetchOperation = new NodeFetchOperation(threadPoolExecutor, 2, jobsLogs, new TasksService(clusterService, jobsLogs), new NoopCircuitBreaker("dummy"));
fetchOperation.fetch(UUID.randomUUID(), 1, null, true).get(5, TimeUnit.SECONDS);
assertThat(StreamSupport.stream(jobsLogs.activeOperations().spliterator(), false).count(), is(0L));
} finally {
threadPoolExecutor.shutdown();
threadPoolExecutor.awaitTermination(2, TimeUnit.SECONDS);
}
}
use of org.elasticsearch.common.breaker.NoopCircuitBreaker in project crate by crate.
the class WindowBatchIteratorTest method testWindowBatchIteratorAccountsUsedMemory.
@Test
public void testWindowBatchIteratorAccountsUsedMemory() {
RamAccounting ramAccounting = ConcurrentRamAccounting.forCircuitBreaker("test", new NoopCircuitBreaker("dummy"));
BatchIterator<Row> iterator = WindowFunctionBatchIterator.of(TestingBatchIterators.range(0, 10), new RowAccountingWithEstimators(List.of(DataTypes.INTEGER), ramAccounting, 32), (partitionStart, partitionEnd, currentIndex, sortedRows) -> 0, (partitionStart, partitionEnd, currentIndex, sortedRows) -> currentIndex, null, null, 1, () -> 1, Runnable::run, List.of(rowNumberWindowFunction()), List.of(), new Boolean[] { null }, new Input[][] { new Input[0] });
TestingRowConsumer consumer = new TestingRowConsumer();
consumer.accept(iterator, null);
// should've accounted for 10 integers of 48 bytes each (16 for the integer, 32 for the ArrayList element)
assertThat(ramAccounting.totalBytes(), is(480L));
}
use of org.elasticsearch.common.breaker.NoopCircuitBreaker in project crate by crate.
the class SqlHttpHandlerTest method testUserIfHttpBasicAuthIsPresent.
@Test
public void testUserIfHttpBasicAuthIsPresent() {
SqlHttpHandler handler = new SqlHttpHandler(Settings.EMPTY, mock(SQLOperations.class), (s) -> new NoopCircuitBreaker("dummy"), User::of, sessionContext -> AccessControl.DISABLED, Netty4CorsConfigBuilder.forAnyOrigin().build());
User user = handler.userFromAuthHeader("Basic QWxhZGRpbjpPcGVuU2VzYW1l");
assertThat(user.name(), is("Aladdin"));
}
Aggregations