use of org.agrona.collections.MutableBoolean in project aeron by real-logic.
the class BufferClaimMessageTest method shouldTransferReservedValue.
@Theory
@Test(timeout = 10_000)
public void shouldTransferReservedValue(final String channel) {
final BufferClaim bufferClaim = new BufferClaim();
try (Publication publication = aeron.addPublication(channel, STREAM_ID);
Subscription subscription = aeron.addSubscription(channel, STREAM_ID)) {
while (publication.tryClaim(MESSAGE_LENGTH, bufferClaim) < 0L) {
SystemTest.checkInterruptedStatus();
Thread.yield();
}
final long reservedValue = System.currentTimeMillis();
bufferClaim.reservedValue(reservedValue);
bufferClaim.commit();
final MutableBoolean done = new MutableBoolean();
while (!done.get()) {
final int fragments = subscription.poll((buffer, offset, length, header) -> {
assertThat(length, is(MESSAGE_LENGTH));
assertThat(header.reservedValue(), is(reservedValue));
done.value = true;
}, FRAGMENT_COUNT_LIMIT);
if (0 == fragments) {
SystemTest.checkInterruptedStatus();
Thread.yield();
}
}
}
}
use of org.agrona.collections.MutableBoolean in project aeron by real-logic.
the class ArchiveTest method preSendChecks.
private void preSendChecks(final ArchiveProxy archiveProxy, final Subscription recordingEvents, final int sessionId, final int termBufferLength, final long startPosition) {
final MutableBoolean recordingStarted = new MutableBoolean();
final RecordingEventsAdapter recordingEventsAdapter = new RecordingEventsAdapter(new FailRecordingEventsListener() {
public void onStart(final long recordingId0, final long startPosition0, final int sessionId0, final int streamId0, final String channel, final String sourceIdentity) {
recordingId = recordingId0;
assertThat(streamId0, is(PUBLISH_STREAM_ID));
assertThat(sessionId0, is(sessionId));
assertThat(startPosition0, is(startPosition));
recordingStarted.set(true);
}
}, recordingEvents, 1);
while (!recordingStarted.get()) {
if (recordingEventsAdapter.poll() == 0) {
SystemTest.checkInterruptedStatus();
Thread.yield();
}
}
verifyDescriptorListOngoingArchive(archiveProxy, termBufferLength);
}
use of org.agrona.collections.MutableBoolean in project Aeron by real-logic.
the class ArchiveToolTests method assertNoRecording.
private void assertNoRecording(final Catalog catalog, final long recordingId) {
final MutableBoolean found = new MutableBoolean();
catalog.forEach((recordingDescriptorOffset, headerEncoder, headerDecoder, descriptorEncoder, descriptorDecoder) -> {
if (recordingId == descriptorDecoder.recordingId()) {
found.set(true);
}
});
assertFalse(found.get(), () -> "recordingId=" + recordingId + " was found");
}
use of org.agrona.collections.MutableBoolean in project Aeron by real-logic.
the class ClusterTool method nextBackupQueryDeadlineMs.
/**
* Set the deadline time (MS) for the next cluster backup query.
*
* @param markFile for the cluster component.
* @param timeMs to set for the next deadline.
* @return true if successful, otherwise false.
*/
public static boolean nextBackupQueryDeadlineMs(final ClusterMarkFile markFile, final long timeMs) {
final String aeronDirectoryName = markFile.decoder().aeronDirectory();
final MutableBoolean result = new MutableBoolean(false);
try (Aeron aeron = Aeron.connect(new Aeron.Context().aeronDirectoryName(aeronDirectoryName))) {
final CountersReader countersReader = aeron.countersReader();
countersReader.forEach((counterId, typeId, keyBuffer, label) -> {
if (ClusterBackup.QUERY_DEADLINE_TYPE_ID == typeId) {
final AtomicCounter atomicCounter = new AtomicCounter(countersReader.valuesBuffer(), counterId, null);
atomicCounter.setOrdered(timeMs);
result.value = true;
}
});
}
return result.value;
}
use of org.agrona.collections.MutableBoolean in project Aeron by real-logic.
the class ArchiveTest method postPublicationValidations.
private void postPublicationValidations(final ArchiveProxy archiveProxy, final Subscription recordingEvents, final int termBufferLength, final int initialTermId, final int maxPayloadLength) {
verifyDescriptorListOngoingArchive(archiveProxy, termBufferLength);
assertNull(trackerError);
final long requestCorrelationId = client.nextCorrelationId();
if (!archiveProxy.stopRecording(publishUri, PUBLISH_STREAM_ID, requestCorrelationId, controlSessionId)) {
throw new IllegalStateException("failed to send stop recording");
}
ArchiveTests.awaitOk(controlResponse, requestCorrelationId);
final MutableBoolean isRecordingStopped = new MutableBoolean();
final RecordingEventsAdapter recordingEventsAdapter = new RecordingEventsAdapter(new FailRecordingEventsListener() {
public void onStop(final long id, final long startPosition, final long stopPosition) {
assertEquals(recordingId, id);
isRecordingStopped.set(true);
}
}, recordingEvents, 1);
while (!isRecordingStopped.get()) {
if (recordingEventsAdapter.poll() == 0) {
Tests.yield();
}
}
verifyDescriptorListOngoingArchive(archiveProxy, termBufferLength);
validateArchiveFile(recordingId);
validateReplay(archiveProxy, initialTermId, maxPayloadLength, termBufferLength);
}
Aggregations