use of io.aeron.archive.codecs.ControlResponseCode 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);
}
use of io.aeron.archive.codecs.ControlResponseCode in project aeron by real-logic.
the class AeronArchive method pollForResponse.
private long pollForResponse(final long correlationId) {
final long deadlineNs = nanoClock.nanoTime() + messageTimeoutNs;
final ControlResponsePoller poller = controlResponsePoller;
while (true) {
pollNextResponse(correlationId, deadlineNs, poller);
if (poller.controlSessionId() != controlSessionId || poller.templateId() != ControlResponseDecoder.TEMPLATE_ID) {
invokeAeronClient();
continue;
}
if (poller.code() == ControlResponseCode.ERROR) {
throw new IllegalStateException("response for correlationId=" + correlationId + ", error: " + poller.errorMessage());
}
final ControlResponseCode code = poller.code();
if (ControlResponseCode.OK != code) {
throw new IllegalStateException("Unexpected response code: " + code);
}
if (poller.correlationId() == correlationId) {
return poller.relevantId();
}
}
}
use of io.aeron.archive.codecs.ControlResponseCode 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);
}
use of io.aeron.archive.codecs.ControlResponseCode 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);
}
use of io.aeron.archive.codecs.ControlResponseCode in project aeron by real-logic.
the class AeronArchive method awaitSessionOpened.
private long awaitSessionOpened(final long correlationId) {
final long deadlineNs = nanoClock.nanoTime() + messageTimeoutNs;
final ControlResponsePoller poller = controlResponsePoller;
awaitConnection(deadlineNs, poller);
while (true) {
pollNextResponse(correlationId, deadlineNs, poller);
if (poller.correlationId() != correlationId || poller.templateId() != ControlResponseDecoder.TEMPLATE_ID) {
invokeAeronClient();
continue;
}
final ControlResponseCode code = poller.code();
if (code != ControlResponseCode.OK) {
if (code == ControlResponseCode.ERROR) {
throw new IllegalStateException("Error: " + poller.errorMessage());
}
throw new IllegalStateException("Unexpected response: code=" + code);
}
return poller.controlSessionId();
}
}
Aggregations