use of io.aeron.status.ReadableCounter in project Aeron by real-logic.
the class CounterTest method shouldCloseReadableCounterOnUnavailableCounter.
@Test
@InterruptAfter(10)
void shouldCloseReadableCounterOnUnavailableCounter() {
clientB.addAvailableCounterHandler(this::createReadableCounter);
clientB.addUnavailableCounterHandler(this::unavailableCounterHandler);
final Counter counter = clientA.addCounter(COUNTER_TYPE_ID, keyBuffer, 0, keyBuffer.capacity(), labelBuffer, 0, COUNTER_LABEL.length());
while (null == readableCounter) {
Tests.sleep(1);
}
assertFalse(readableCounter.isClosed());
assertEquals(CountersReader.RECORD_ALLOCATED, readableCounter.state());
counter.close();
while (!readableCounter.isClosed()) {
Tests.sleep(1);
}
while (clientA.hasActiveCommands()) {
Tests.sleep(1);
}
}
use of io.aeron.status.ReadableCounter in project aeron by real-logic.
the class ConsensusModuleAgent method tryCreateAppendPosition.
private boolean tryCreateAppendPosition(final int logSessionId) {
final CountersReader counters = aeron.countersReader();
final int counterId = RecordingPos.findCounterIdBySession(counters, logSessionId);
if (CountersReader.NULL_COUNTER_ID == counterId) {
return false;
}
final long registrationId = counters.getCounterRegistrationId(counterId);
if (0 == registrationId) {
return false;
}
logRecordingId = RecordingPos.getRecordingId(counters, counterId);
appendPosition = new ReadableCounter(counters, registrationId, counterId);
logRecordedPosition = NULL_POSITION;
return true;
}
use of io.aeron.status.ReadableCounter in project aeron by real-logic.
the class CounterTest method shouldBeAbleToAddReadableCounterWithinHandler.
@Test
@InterruptAfter(10)
void shouldBeAbleToAddReadableCounterWithinHandler() {
clientB.addAvailableCounterHandler(this::createReadableCounter);
final Counter counter = clientA.addCounter(COUNTER_TYPE_ID, keyBuffer, 0, keyBuffer.capacity(), labelBuffer, 0, COUNTER_LABEL.length());
while (null == readableCounter) {
Tests.sleep(1);
}
assertEquals(CountersReader.RECORD_ALLOCATED, readableCounter.state());
assertEquals(counter.id(), readableCounter.counterId());
assertEquals(counter.registrationId(), readableCounter.registrationId());
}
use of io.aeron.status.ReadableCounter in project aeron by real-logic.
the class CounterTest method shouldCloseReadableCounterOnUnavailableCounter.
@Test
@InterruptAfter(10)
void shouldCloseReadableCounterOnUnavailableCounter() {
clientB.addAvailableCounterHandler(this::createReadableCounter);
clientB.addUnavailableCounterHandler(this::unavailableCounterHandler);
final Counter counter = clientA.addCounter(COUNTER_TYPE_ID, keyBuffer, 0, keyBuffer.capacity(), labelBuffer, 0, COUNTER_LABEL.length());
while (null == readableCounter) {
Tests.sleep(1);
}
assertFalse(readableCounter.isClosed());
assertEquals(CountersReader.RECORD_ALLOCATED, readableCounter.state());
counter.close();
while (!readableCounter.isClosed()) {
Tests.sleep(1);
}
while (clientA.hasActiveCommands()) {
Tests.sleep(1);
}
}
Aggregations