Search in sources :

Example 1 with ArchiveProxy

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

the class ArchiveTest method recordAndReplayRegularPublication.

@Test(timeout = 10_000)
public void recordAndReplayRegularPublication() {
    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 Publication recordedPublication = client.addPublication(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();
    preSendChecks(archiveProxy, recordingEvents, sessionId, termBufferLength, startPosition);
    final int messageCount = prepAndSendMessages(recordingEvents, recordedPublication);
    postPublicationValidations(archiveProxy, recordingEvents, termBufferLength, initialTermId, maxPayloadLength, messageCount);
}
Also used : ArchiveProxy(io.aeron.archive.client.ArchiveProxy) Test(org.junit.Test)

Example 2 with ArchiveProxy

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

the class ArchiveTest method recordAndReplayConcurrentPublication.

@ParameterizedTest
@MethodSource("threadingModes")
@InterruptAfter(10)
public void recordAndReplayConcurrentPublication(final ThreadingMode threadingMode, final ArchiveThreadingMode archiveThreadingMode) {
    before(threadingMode, archiveThreadingMode);
    final Publication controlPublication = client.addPublication(archive.context().localControlChannel(), archive.context().localControlStreamId());
    final ArchiveProxy archiveProxy = new ArchiveProxy(controlPublication);
    final Subscription recordingEvents = client.addSubscription(archive.context().recordingEventsChannel(), archive.context().recordingEventsStreamId());
    prePublicationActionsAndVerifications(archiveProxy, controlPublication, recordingEvents);
    final Publication recordedPublication = client.addExclusivePublication(publishUri, PUBLISH_STREAM_ID);
    final int termBufferLength = recordedPublication.termBufferLength();
    final long startPosition = recordedPublication.position();
    preSendChecks(archiveProxy, recordingEvents, recordedPublication.sessionId(), termBufferLength, startPosition);
    prepAndSendMessages(recordingEvents, recordedPublication);
    postPublicationValidations(archiveProxy, recordingEvents, termBufferLength, recordedPublication.initialTermId(), recordedPublication.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)

Example 3 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)

Example 4 with ArchiveProxy

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

the class ArchiveTest method recordAndReplayConcurrentPublication.

@ParameterizedTest
@MethodSource("threadingModes")
@InterruptAfter(10)
public void recordAndReplayConcurrentPublication(final ThreadingMode threadingMode, final ArchiveThreadingMode archiveThreadingMode) {
    before(threadingMode, archiveThreadingMode);
    final Publication controlPublication = client.addPublication(archive.context().localControlChannel(), archive.context().localControlStreamId());
    final ArchiveProxy archiveProxy = new ArchiveProxy(controlPublication);
    final Subscription recordingEvents = client.addSubscription(archive.context().recordingEventsChannel(), archive.context().recordingEventsStreamId());
    prePublicationActionsAndVerifications(archiveProxy, controlPublication, recordingEvents);
    final Publication recordedPublication = client.addExclusivePublication(publishUri, PUBLISH_STREAM_ID);
    final int termBufferLength = recordedPublication.termBufferLength();
    final long startPosition = recordedPublication.position();
    preSendChecks(archiveProxy, recordingEvents, recordedPublication.sessionId(), termBufferLength, startPosition);
    prepAndSendMessages(recordingEvents, recordedPublication);
    postPublicationValidations(archiveProxy, recordingEvents, termBufferLength, recordedPublication.initialTermId(), recordedPublication.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)

Example 5 with ArchiveProxy

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

the class ArchiveTest method recordAndReplayExclusivePublication.

@Test(timeout = 10_000)
public void recordAndReplayExclusivePublication() {
    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 = prepAndSendMessages(recordingEvents, recordedPublication);
    postPublicationValidations(archiveProxy, recordingEvents, termBufferLength, initialTermId, maxPayloadLength, messageCount);
}
Also used : ArchiveProxy(io.aeron.archive.client.ArchiveProxy) Test(org.junit.Test)

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