Search in sources :

Example 6 with RecordingEventsAdapter

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);
}
Also used : MutableBoolean(org.agrona.collections.MutableBoolean) RecordingEventsAdapter(io.aeron.archive.client.RecordingEventsAdapter)

Example 7 with RecordingEventsAdapter

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;
}
Also used : RecordingEventsAdapter(io.aeron.archive.client.RecordingEventsAdapter)

Example 8 with RecordingEventsAdapter

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);
}
Also used : MutableBoolean(org.agrona.collections.MutableBoolean) RecordingEventsAdapter(io.aeron.archive.client.RecordingEventsAdapter)

Example 9 with RecordingEventsAdapter

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;
}
Also used : RecordingEventsAdapter(io.aeron.archive.client.RecordingEventsAdapter)

Aggregations

RecordingEventsAdapter (io.aeron.archive.client.RecordingEventsAdapter)9 MutableBoolean (org.agrona.collections.MutableBoolean)4 FailRecordingEventsListener (io.aeron.archive.FailRecordingEventsListener)2 Subscription (io.aeron.Subscription)1 BackoffIdleStrategy (org.agrona.concurrent.BackoffIdleStrategy)1 IdleStrategy (org.agrona.concurrent.IdleStrategy)1