use of io.aeron.archive.client.RecordingEventsAdapter 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 isRecordingStarted = new MutableBoolean();
final RecordingEventsAdapter recordingEventsAdapter = new RecordingEventsAdapter(new FailRecordingEventsListener() {
public void onStart(final long recordingId, final long startPosition0, final int sessionId0, final int streamId, final String channel, final String sourceIdentity) {
ArchiveTest.this.recordingId = recordingId;
assertEquals(PUBLISH_STREAM_ID, streamId);
assertEquals(sessionId, sessionId0);
assertEquals(startPosition, startPosition0);
isRecordingStarted.set(true);
}
}, recordingEvents, 1);
while (!isRecordingStarted.get()) {
if (recordingEventsAdapter.poll() == 0) {
if (!recordingEvents.isConnected()) {
throw new IllegalStateException("recording events not connected");
}
Tests.yield();
}
}
verifyDescriptorListOngoingArchive(archiveProxy, termBufferLength);
}
use of io.aeron.archive.client.RecordingEventsAdapter in project Aeron by real-logic.
the class ArchiveTest method trackRecordingProgress.
private Thread trackRecordingProgress(final Subscription recordingEvents, final CountDownLatch latch) {
recorded = 0;
final RecordingEventsAdapter recordingEventsAdapter = new RecordingEventsAdapter(new FailRecordingEventsListener() {
public void onProgress(final long recordingId0, final long startPosition, final long position) {
assertEquals(recordingId, recordingId0);
recorded = position - startPosition;
}
}, recordingEvents, 1);
final Thread thread = new Thread(() -> {
try {
while (NULL_POSITION == stopPosition || recorded < totalRecordingLength) {
if (recordingEventsAdapter.poll() == 0) {
if (!recordingEvents.isConnected()) {
break;
}
Tests.sleep(1);
}
}
} catch (final Exception ex) {
ex.printStackTrace();
trackerError = ex;
}
latch.countDown();
});
thread.setDaemon(true);
thread.setName("recording-progress-tracker");
thread.start();
return thread;
}
use of io.aeron.archive.client.RecordingEventsAdapter 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);
}
use of io.aeron.archive.client.RecordingEventsAdapter in project aeron by real-logic.
the class ArchiveTest method trackRecordingProgress.
private Thread trackRecordingProgress(final Subscription recordingEvents, final CountDownLatch latch) {
recorded = 0;
final RecordingEventsAdapter recordingEventsAdapter = new RecordingEventsAdapter(new FailRecordingEventsListener() {
public void onProgress(final long recordingId0, final long startPosition, final long position) {
assertEquals(recordingId, recordingId0);
recorded = position - startPosition;
}
}, recordingEvents, 1);
final Thread thread = new Thread(() -> {
try {
while (NULL_POSITION == stopPosition || recorded < totalRecordingLength) {
if (recordingEventsAdapter.poll() == 0) {
if (!recordingEvents.isConnected()) {
break;
}
Tests.sleep(1);
}
}
} catch (final Exception ex) {
ex.printStackTrace();
trackerError = ex;
}
latch.countDown();
});
thread.setDaemon(true);
thread.setName("recording-progress-tracker");
thread.start();
return thread;
}
Aggregations