Search in sources :

Example 6 with MemoryCircuitBreaker

use of org.elasticsearch.common.breaker.MemoryCircuitBreaker in project crate by crate.

the class RowAccountingWithEstimatorsTest method testRowCellsAccountingCircuitBreakingWorks.

@Test
public void testRowCellsAccountingCircuitBreakingWorks() throws Exception {
    RowCellsAccountingWithEstimators rowAccounting = new RowCellsAccountingWithEstimators(Collections.singletonList(DataTypes.INTEGER), ConcurrentRamAccounting.forCircuitBreaker("test", new MemoryCircuitBreaker(new ByteSizeValue(10, ByteSizeUnit.BYTES), 1.01, LogManager.getLogger(RowAccountingWithEstimatorsTest.class))), 0);
    expectedException.expect(CircuitBreakingException.class);
    IntStream.range(0, 3).forEach(i -> rowAccounting.accountForAndMaybeBreak(new Object[] { i }));
}
Also used : MemoryCircuitBreaker(org.elasticsearch.common.breaker.MemoryCircuitBreaker) ByteSizeValue(org.elasticsearch.common.unit.ByteSizeValue) Test(org.junit.Test)

Example 7 with MemoryCircuitBreaker

use of org.elasticsearch.common.breaker.MemoryCircuitBreaker in project crate by crate.

the class RowAccountingWithEstimatorsTest method testCircuitBreakingWorksWithExtraSizePerRow.

@Test
public void testCircuitBreakingWorksWithExtraSizePerRow() 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))), 2);
    expectedException.expect(CircuitBreakingException.class);
    RowGenerator.range(0, 2).forEach(rowAccounting::accountForAndMaybeBreak);
}
Also used : MemoryCircuitBreaker(org.elasticsearch.common.breaker.MemoryCircuitBreaker) ByteSizeValue(org.elasticsearch.common.unit.ByteSizeValue) Test(org.junit.Test)

Aggregations

MemoryCircuitBreaker (org.elasticsearch.common.breaker.MemoryCircuitBreaker)7 ByteSizeValue (org.elasticsearch.common.unit.ByteSizeValue)7 Test (org.junit.Test)7 RowCellsAccountingWithEstimators (io.crate.breaker.RowCellsAccountingWithEstimators)2 Projector (io.crate.data.Projector)2 RowAccountingWithEstimators (io.crate.breaker.RowAccountingWithEstimators)1 RowAccountingWithEstimatorsTest (io.crate.breaker.RowAccountingWithEstimatorsTest)1 Row (io.crate.data.Row)1 BytesStreamOutput (org.elasticsearch.common.io.stream.BytesStreamOutput)1 StreamInput (org.elasticsearch.common.io.stream.StreamInput)1