Search in sources :

Example 6 with ArchiveProxy

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

the class ArchiveTest method replayExclusivePublicationWhileRecording.

@Test(timeout = 10_000)
public void replayExclusivePublicationWhileRecording() {
    final String controlChannel = archive.context().localControlChannel();
    final int controlStreamId = archive.context().localControlStreamId();
    final String recordingChannel = archive.context().recordingEventsChannel();
    final int recordingStreamId = archive.context().recordingEventsStreamId();
    final Publication controlPublication = client.addPublication(controlChannel, controlStreamId);
    final Subscription recordingEvents = client.addSubscription(recordingChannel, recordingStreamId);
    final ArchiveProxy archiveProxy = new ArchiveProxy(controlPublication);
    prePublicationActionsAndVerifications(archiveProxy, controlPublication, recordingEvents);
    final ExclusivePublication recordedPublication = client.addExclusivePublication(publishUri, PUBLISH_STREAM_ID);
    final int sessionId = recordedPublication.sessionId();
    final int termBufferLength = recordedPublication.termBufferLength();
    final int initialTermId = recordedPublication.initialTermId();
    final int maxPayloadLength = recordedPublication.maxPayloadLength();
    final long startPosition = recordedPublication.position();
    assertThat(startPosition, is(requestedStartPosition));
    assertThat(recordedPublication.initialTermId(), is(requestedInitialTermId));
    preSendChecks(archiveProxy, recordingEvents, sessionId, termBufferLength, startPosition);
    final int messageCount = MESSAGE_COUNT;
    final CountDownLatch streamConsumed = new CountDownLatch(2);
    prepMessagesAndListener(recordingEvents, messageCount, streamConsumed);
    replayConsumer = validateActiveRecordingReplay(archiveProxy, termBufferLength, initialTermId, maxPayloadLength, messageCount, streamConsumed);
    publishDataToBeRecorded(recordedPublication, messageCount);
    await(streamConsumed);
}
Also used : ArchiveProxy(io.aeron.archive.client.ArchiveProxy) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 7 with ArchiveProxy

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

the class ArchiveTest method replayExclusivePublicationWhileRecording.

@ParameterizedTest
@MethodSource("threadingModes")
@InterruptAfter(10)
public void replayExclusivePublicationWhileRecording(final ThreadingMode threadingMode, final ArchiveThreadingMode archiveThreadingMode) {
    before(threadingMode, archiveThreadingMode);
    final String controlChannel = archive.context().localControlChannel();
    final int controlStreamId = archive.context().localControlStreamId();
    final String recordingChannel = archive.context().recordingEventsChannel();
    final int recordingStreamId = archive.context().recordingEventsStreamId();
    final Publication controlPublication = client.addPublication(controlChannel, controlStreamId);
    final Subscription recordingEvents = client.addSubscription(recordingChannel, recordingStreamId);
    final ArchiveProxy archiveProxy = new ArchiveProxy(controlPublication);
    prePublicationActionsAndVerifications(archiveProxy, controlPublication, recordingEvents);
    final ExclusivePublication recordedPublication = client.addExclusivePublication(publishUri, PUBLISH_STREAM_ID);
    final int sessionId = recordedPublication.sessionId();
    final int termBufferLength = recordedPublication.termBufferLength();
    final int initialTermId = recordedPublication.initialTermId();
    final int maxPayloadLength = recordedPublication.maxPayloadLength();
    final long startPosition = recordedPublication.position();
    assertEquals(requestedStartPosition, startPosition);
    assertEquals(requestedInitialTermId, recordedPublication.initialTermId());
    preSendChecks(archiveProxy, recordingEvents, sessionId, termBufferLength, startPosition);
    final CountDownLatch latch = new CountDownLatch(2);
    prepMessagesAndListener(recordingEvents, latch);
    replayConsumer = validateActiveRecordingReplay(archiveProxy, termBufferLength, initialTermId, maxPayloadLength, latch);
    publishDataToBeRecorded(recordedPublication);
    await(latch);
}
Also used : ArchiveProxy(io.aeron.archive.client.ArchiveProxy) CountDownLatch(java.util.concurrent.CountDownLatch) InterruptAfter(io.aeron.test.InterruptAfter) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 8 with ArchiveProxy

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

the class ArchiveTest method replayExclusivePublicationWhileRecording.

@ParameterizedTest
@MethodSource("threadingModes")
@InterruptAfter(10)
public void replayExclusivePublicationWhileRecording(final ThreadingMode threadingMode, final ArchiveThreadingMode archiveThreadingMode) {
    before(threadingMode, archiveThreadingMode);
    final String controlChannel = archive.context().localControlChannel();
    final int controlStreamId = archive.context().localControlStreamId();
    final String recordingChannel = archive.context().recordingEventsChannel();
    final int recordingStreamId = archive.context().recordingEventsStreamId();
    final Publication controlPublication = client.addPublication(controlChannel, controlStreamId);
    final Subscription recordingEvents = client.addSubscription(recordingChannel, recordingStreamId);
    final ArchiveProxy archiveProxy = new ArchiveProxy(controlPublication);
    prePublicationActionsAndVerifications(archiveProxy, controlPublication, recordingEvents);
    final ExclusivePublication recordedPublication = client.addExclusivePublication(publishUri, PUBLISH_STREAM_ID);
    final int sessionId = recordedPublication.sessionId();
    final int termBufferLength = recordedPublication.termBufferLength();
    final int initialTermId = recordedPublication.initialTermId();
    final int maxPayloadLength = recordedPublication.maxPayloadLength();
    final long startPosition = recordedPublication.position();
    assertEquals(requestedStartPosition, startPosition);
    assertEquals(requestedInitialTermId, recordedPublication.initialTermId());
    preSendChecks(archiveProxy, recordingEvents, sessionId, termBufferLength, startPosition);
    final CountDownLatch latch = new CountDownLatch(2);
    prepMessagesAndListener(recordingEvents, latch);
    replayConsumer = validateActiveRecordingReplay(archiveProxy, termBufferLength, initialTermId, maxPayloadLength, latch);
    publishDataToBeRecorded(recordedPublication);
    await(latch);
}
Also used : ArchiveProxy(io.aeron.archive.client.ArchiveProxy) CountDownLatch(java.util.concurrent.CountDownLatch) InterruptAfter(io.aeron.test.InterruptAfter) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 9 with ArchiveProxy

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

the class ArchiveTest method recordAndReplayExclusivePublication.

@ParameterizedTest
@MethodSource("threadingModes")
@InterruptAfter(10)
public void recordAndReplayExclusivePublication(final ThreadingMode threadingMode, final ArchiveThreadingMode archiveThreadingMode) {
    before(threadingMode, archiveThreadingMode);
    final String controlChannel = archive.context().localControlChannel();
    final int controlStreamId = archive.context().localControlStreamId();
    final String recordingChannel = archive.context().recordingEventsChannel();
    final int recordingStreamId = archive.context().recordingEventsStreamId();
    final Publication controlPublication = client.addPublication(controlChannel, controlStreamId);
    final Subscription recordingEvents = client.addSubscription(recordingChannel, recordingStreamId);
    final ArchiveProxy archiveProxy = new ArchiveProxy(controlPublication);
    prePublicationActionsAndVerifications(archiveProxy, controlPublication, recordingEvents);
    final ExclusivePublication recordedPublication = client.addExclusivePublication(publishUri, PUBLISH_STREAM_ID);
    final int sessionId = recordedPublication.sessionId();
    final int termBufferLength = recordedPublication.termBufferLength();
    final int initialTermId = recordedPublication.initialTermId();
    final int maxPayloadLength = recordedPublication.maxPayloadLength();
    final long startPosition = recordedPublication.position();
    assertEquals(requestedStartPosition, startPosition);
    assertEquals(requestedInitialTermId, recordedPublication.initialTermId());
    preSendChecks(archiveProxy, recordingEvents, sessionId, termBufferLength, startPosition);
    prepAndSendMessages(recordingEvents, recordedPublication);
    postPublicationValidations(archiveProxy, recordingEvents, termBufferLength, initialTermId, maxPayloadLength);
}
Also used : ArchiveProxy(io.aeron.archive.client.ArchiveProxy) InterruptAfter(io.aeron.test.InterruptAfter) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

ArchiveProxy (io.aeron.archive.client.ArchiveProxy)9 InterruptAfter (io.aeron.test.InterruptAfter)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 MethodSource (org.junit.jupiter.params.provider.MethodSource)6 CountDownLatch (java.util.concurrent.CountDownLatch)3 Test (org.junit.Test)3