Search in sources :

Example 1 with RecordingEventsAdapter

use of io.aeron.archive.client.RecordingEventsAdapter in project aeron by real-logic.

the class ArchiveRecordingLoadTest method initRecordingEndIndicator.

private void initRecordingEndIndicator(final Subscription recordingEvents) {
    final RecordingEventsAdapter recordingEventsAdapter = new RecordingEventsAdapter(new FailRecordingEventsListener() {

        public void onProgress(final long recordingId0, final long startPosition, final long position) {
            if (recordingId0 != recordingId) {
                throw new IllegalStateException("expected=" + recordingId + " actual=" + recordingId0);
            }
            recordedLength = position - startPosition;
        }

        public void onStop(final long recordingId0, final long startPosition, final long stopPosition) {
            doneRecording = true;
            recordedLength = stopPosition - startPosition;
            if (recordingId0 != recordingId) {
                throw new IllegalStateException("expected=" + recordingId + " actual=" + recordingId0);
            }
        }
    }, recordingEvents, 1);
    recordingEnded = () -> recordingEventsAdapter.poll() != 0;
}
Also used : FailRecordingEventsListener(io.aeron.archive.FailRecordingEventsListener) RecordingEventsAdapter(io.aeron.archive.client.RecordingEventsAdapter)

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

Example 3 with RecordingEventsAdapter

use of io.aeron.archive.client.RecordingEventsAdapter in project aeron by real-logic.

the class EmbeddedRecordingThroughput method runRecordingEventPoller.

private void runRecordingEventPoller() {
    try (Subscription subscription = aeron.addSubscription(AeronArchive.Configuration.recordingEventsChannel(), AeronArchive.Configuration.recordingEventsStreamId())) {
        final IdleStrategy idleStrategy = new BackoffIdleStrategy(10, 100, 1, 1);
        final RecordingEventsAdapter recordingEventsAdapter = new RecordingEventsAdapter(this, subscription, FRAGMENT_COUNT_LIMIT);
        while (isRunning) {
            idleStrategy.idle(recordingEventsAdapter.poll());
        }
    }
}
Also used : BackoffIdleStrategy(org.agrona.concurrent.BackoffIdleStrategy) IdleStrategy(org.agrona.concurrent.IdleStrategy) BackoffIdleStrategy(org.agrona.concurrent.BackoffIdleStrategy) Subscription(io.aeron.Subscription) RecordingEventsAdapter(io.aeron.archive.client.RecordingEventsAdapter)

Example 4 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 5 with RecordingEventsAdapter

use of io.aeron.archive.client.RecordingEventsAdapter in project aeron by real-logic.

the class ArchiveRecordingLoadTest method initRecordingStartIndicator.

private void initRecordingStartIndicator(final Subscription recordingEvents) {
    final RecordingEventsAdapter recordingEventsAdapter = new RecordingEventsAdapter(new FailRecordingEventsListener() {

        public void onStart(final long recordingId0, final long startPosition, final int sessionId, final int streamId, final String channel, final String sourceIdentity) {
            recordingId = recordingId0;
            if (streamId != PUBLISH_STREAM_ID) {
                throw new IllegalStateException("expected=" + PUBLISH_STREAM_ID + " actual=" + streamId);
            }
        }
    }, recordingEvents, 1);
    recordingStarted = () -> recordingEventsAdapter.poll() != 0;
}
Also used : FailRecordingEventsListener(io.aeron.archive.FailRecordingEventsListener) 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