use of org.elasticsearch.common.breaker.MemoryCircuitBreaker in project crate by crate.
the class RowAccountingWithEstimatorsTest method testCircuitBreakingWorks.
@Test
public void testCircuitBreakingWorks() throws Exception {
RowAccountingWithEstimators rowAccounting = new RowAccountingWithEstimators(Collections.singletonList(DataTypes.INTEGER), ConcurrentRamAccounting.forCircuitBreaker("test", new MemoryCircuitBreaker(new ByteSizeValue(10, ByteSizeUnit.BYTES), 1.01, LogManager.getLogger(RowAccountingWithEstimatorsTest.class))));
expectedException.expect(CircuitBreakingException.class);
RowGenerator.range(0, 3).forEach(rowAccounting::accountForAndMaybeBreak);
}
use of org.elasticsearch.common.breaker.MemoryCircuitBreaker in project crate by crate.
the class SortingProjectorTest method testUsedMemoryIsAccountedFor.
@Test
public void testUsedMemoryIsAccountedFor() throws Exception {
MemoryCircuitBreaker circuitBreaker = new MemoryCircuitBreaker(new ByteSizeValue(30, ByteSizeUnit.BYTES), 1, LogManager.getLogger(SortingProjectorTest.class));
RowCellsAccountingWithEstimators rowAccounting = new RowCellsAccountingWithEstimators(List.of(DataTypes.LONG, DataTypes.BOOLEAN), ConcurrentRamAccounting.forCircuitBreaker("testContext", circuitBreaker), 0);
Projector projector = createProjector(rowAccounting, 1, 0);
consumer.accept(projector.apply(TestingBatchIterators.range(1, 11)), null);
expectedException.expect(CircuitBreakingException.class);
consumer.getResult();
}
use of org.elasticsearch.common.breaker.MemoryCircuitBreaker in project crate by crate.
the class SortingTopNProjectorTest method testUsedMemoryIsAccountedFor.
@Test
public void testUsedMemoryIsAccountedFor() throws Exception {
MemoryCircuitBreaker circuitBreaker = new MemoryCircuitBreaker(new ByteSizeValue(30, ByteSizeUnit.BYTES), 1, LogManager.getLogger(SortingTopNProjectorTest.class));
RowCellsAccountingWithEstimators rowAccounting = new RowCellsAccountingWithEstimators(List.of(DataTypes.LONG, DataTypes.BOOLEAN), ConcurrentRamAccounting.forCircuitBreaker("testContext", circuitBreaker), 0);
Projector projector = getProjector(rowAccounting, 1, 100_000, TopN.NO_OFFSET, FIRST_CELL_ORDERING);
consumer.accept(projector.apply(TestingBatchIterators.range(1, 11)), null);
expectedException.expect(CircuitBreakingException.class);
consumer.getResult();
}
use of org.elasticsearch.common.breaker.MemoryCircuitBreaker in project crate by crate.
the class RamAccountingPageIteratorTest method testCircuitBreaking.
@Test
public void testCircuitBreaking() throws Exception {
PagingIterator<Integer, Row> pagingIterator = PagingIterator.create(2, true, null, () -> new RowAccountingWithEstimators(List.of(DataTypes.STRING, DataTypes.STRING, DataTypes.STRING), ConcurrentRamAccounting.forCircuitBreaker("test", new MemoryCircuitBreaker(new ByteSizeValue(197, ByteSizeUnit.BYTES), 1, LogManager.getLogger(RowAccountingWithEstimatorsTest.class)))));
expectedException.expect(CircuitBreakingException.class);
expectedException.expectMessage("Data too large, data for field [test] would be [288/288b], which is larger than the limit of [197/197b]");
pagingIterator.merge(Arrays.asList(new KeyIterable<>(0, Collections.singletonList(TEST_ROWS[0])), new KeyIterable<>(1, Collections.singletonList(TEST_ROWS[1]))));
}
use of org.elasticsearch.common.breaker.MemoryCircuitBreaker in project crate by crate.
the class NodeFetchResponseTest method testResponseCircuitBreaker.
@Test
public void testResponseCircuitBreaker() throws Exception {
NodeFetchResponse orig = new NodeFetchResponse(fetched);
BytesStreamOutput out = new BytesStreamOutput();
orig.writeTo(out);
StreamInput in = out.bytes().streamInput();
expectedException.expect(CircuitBreakingException.class);
new NodeFetchResponse(in, streamers, ConcurrentRamAccounting.forCircuitBreaker("test", new MemoryCircuitBreaker(new ByteSizeValue(2, ByteSizeUnit.BYTES), 1.0, LogManager.getLogger(NodeFetchResponseTest.class))));
}
Aggregations