Search in sources :

Example 1 with ControlResponseAdapter

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

the class TestUtil method awaitOk.

public static void awaitOk(final Subscription controlResponse, final long expectedCorrelationId) {
    final ControlResponseAdapter controlResponseAdapter = new ControlResponseAdapter(new FailControlResponseListener() {

        public void onResponse(final long controlSessionId, final long correlationId, final long relevantId, final ControlResponseCode code, final String errorMessage) {
            if (ControlResponseCode.OK != code) {
                System.out.println(errorMessage);
                throw new IllegalStateException("expected=" + ControlResponseCode.OK + " actual=" + code);
            }
            if (correlationId != expectedCorrelationId) {
                throw new IllegalStateException("expected=" + expectedCorrelationId + " actual=" + correlationId);
            }
        }
    }, controlResponse, 1);
    await(() -> controlResponseAdapter.poll() != 0);
}
Also used : ControlResponseAdapter(io.aeron.archive.client.ControlResponseAdapter) ControlResponseCode(io.aeron.archive.codecs.ControlResponseCode)

Example 2 with ControlResponseAdapter

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

the class ArchiveTest method verifyDescriptorListOngoingArchive.

private void verifyDescriptorListOngoingArchive(final ArchiveProxy archiveProxy, final int publicationTermBufferLength) {
    final long requestCorrelationId = client.nextCorrelationId();
    archiveProxy.listRecording(recordingId, requestCorrelationId, controlSessionId);
    final MutableBoolean isDone = new MutableBoolean();
    final ControlResponseAdapter controlResponseAdapter = new ControlResponseAdapter(new FailControlResponseListener() {

        public void onRecordingDescriptor(final long controlSessionId, final long correlationId, final long recordingId, final long startTimestamp, final long stopTimestamp, final long startPosition, final long stopPosition, final int initialTermId, final int segmentFileLength, final int termBufferLength, final int mtuLength, final int sessionId, final int streamId, final String strippedChannel, final String originalChannel, final String sourceIdentity) {
            assertEquals(requestCorrelationId, correlationId);
            assertEquals(ArchiveTest.this.recordingId, recordingId);
            assertEquals(publicationTermBufferLength, termBufferLength);
            assertEquals(PUBLISH_STREAM_ID, streamId);
            assertEquals(publishUri, originalChannel);
            isDone.set(true);
        }
    }, controlResponse, 1);
    while (!isDone.get()) {
        if (controlResponseAdapter.poll() == 0) {
            if (!controlResponse.isConnected()) {
                throw new IllegalStateException("control response not connected");
            }
            Tests.yield();
        }
    }
}
Also used : ControlResponseAdapter(io.aeron.archive.client.ControlResponseAdapter) MutableBoolean(org.agrona.collections.MutableBoolean)

Example 3 with ControlResponseAdapter

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

the class ArchiveTest method verifyDescriptorListOngoingArchive.

private void verifyDescriptorListOngoingArchive(final ArchiveProxy archiveProxy, final int publicationTermBufferLength) {
    final long requestCorrelationId = client.nextCorrelationId();
    archiveProxy.listRecording(recordingId, requestCorrelationId, controlSessionId);
    final MutableBoolean isDone = new MutableBoolean();
    final ControlResponseAdapter controlResponseAdapter = new ControlResponseAdapter(new FailControlResponseListener() {

        public void onRecordingDescriptor(final long controlSessionId, final long correlationId, final long recordingId, final long startTimestamp, final long stopTimestamp, final long startPosition, final long stopPosition, final int initialTermId, final int segmentFileLength, final int termBufferLength, final int mtuLength, final int sessionId, final int streamId, final String strippedChannel, final String originalChannel, final String sourceIdentity) {
            assertEquals(requestCorrelationId, correlationId);
            assertEquals(ArchiveTest.this.recordingId, recordingId);
            assertEquals(publicationTermBufferLength, termBufferLength);
            assertEquals(PUBLISH_STREAM_ID, streamId);
            assertEquals(publishUri, originalChannel);
            isDone.set(true);
        }
    }, controlResponse, 1);
    while (!isDone.get()) {
        if (controlResponseAdapter.poll() == 0) {
            if (!controlResponse.isConnected()) {
                throw new IllegalStateException("control response not connected");
            }
            Tests.yield();
        }
    }
}
Also used : ControlResponseAdapter(io.aeron.archive.client.ControlResponseAdapter) MutableBoolean(org.agrona.collections.MutableBoolean)

Example 4 with ControlResponseAdapter

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

the class ArchiveTests method awaitConnectedReply.

public static void awaitConnectedReply(final Subscription controlResponse, final long expectedCorrelationId, final LongConsumer receiveSessionId) {
    final ControlResponseAdapter controlResponseAdapter = new ControlResponseAdapter(new FailControlResponseListener() {

        public void onResponse(final long controlSessionId, final long correlationId, final long relevantId, final ControlResponseCode code, final String errorMessage) {
            if (ControlResponseCode.OK != code) {
                throw new IllegalStateException("expected=" + ControlResponseCode.OK + " actual=" + code);
            }
            if (correlationId != expectedCorrelationId) {
                throw new IllegalStateException("expected=" + expectedCorrelationId + " actual=" + correlationId);
            }
            receiveSessionId.accept(controlSessionId);
        }
    }, controlResponse, 1);
    Tests.await(() -> controlResponseAdapter.poll() != 0, TIMEOUT_NS);
}
Also used : ControlResponseAdapter(io.aeron.archive.client.ControlResponseAdapter) ControlResponseCode(io.aeron.archive.codecs.ControlResponseCode)

Example 5 with ControlResponseAdapter

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

the class ArchiveTests method awaitOk.

public static void awaitOk(final Subscription controlResponse, final long expectedCorrelationId) {
    final ControlResponseAdapter controlResponseAdapter = new ControlResponseAdapter(new FailControlResponseListener() {

        public void onResponse(final long controlSessionId, final long correlationId, final long relevantId, final ControlResponseCode code, final String errorMessage) {
            if (ControlResponseCode.OK != code) {
                System.out.println(errorMessage);
                throw new IllegalStateException("expected=" + ControlResponseCode.OK + " actual=" + code);
            }
            if (correlationId != expectedCorrelationId) {
                throw new IllegalStateException("expected=" + expectedCorrelationId + " actual=" + correlationId);
            }
        }
    }, controlResponse, 1);
    Tests.await(() -> controlResponseAdapter.poll() != 0, TIMEOUT_NS);
}
Also used : ControlResponseAdapter(io.aeron.archive.client.ControlResponseAdapter) ControlResponseCode(io.aeron.archive.codecs.ControlResponseCode)

Aggregations

ControlResponseAdapter (io.aeron.archive.client.ControlResponseAdapter)11 ControlResponseCode (io.aeron.archive.codecs.ControlResponseCode)9 MutableBoolean (org.agrona.collections.MutableBoolean)2