Search in sources :

Example 1 with ControlledEgressListener

use of io.aeron.cluster.client.ControlledEgressListener in project Aeron by real-logic.

the class ClusterTest method injectAdminRequestControlledEgressListener.

private MutableBoolean injectAdminRequestControlledEgressListener(final long expectedCorrelationId, final AdminRequestType expectedRequestType, final AdminResponseCode expectedResponseCode, final String expectedMessage) {
    final MutableBoolean responseReceived = new MutableBoolean();
    cluster.controlledEgressListener(new ControlledEgressListener() {

        public ControlledFragmentHandler.Action onMessage(final long clusterSessionId, final long timestamp, final DirectBuffer buffer, final int offset, final int length, final Header header) {
            return ControlledFragmentHandler.Action.ABORT;
        }

        public void onAdminResponse(final long clusterSessionId, final long correlationId, final AdminRequestType requestType, final AdminResponseCode responseCode, final String message, final DirectBuffer payload, final int payloadOffset, final int payloadLength) {
            responseReceived.set(true);
            assertEquals(expectedCorrelationId, correlationId);
            assertEquals(expectedRequestType, requestType);
            assertEquals(expectedResponseCode, responseCode);
            assertEquals(expectedMessage, message);
            assertNotNull(payload);
            final int minPayloadOffset = MessageHeaderEncoder.ENCODED_LENGTH + AdminResponseEncoder.BLOCK_LENGTH + AdminResponseEncoder.messageHeaderLength() + message.length() + AdminResponseEncoder.payloadHeaderLength();
            assertTrue(payloadOffset > minPayloadOffset);
            assertEquals(0, payloadLength);
        }
    });
    return responseReceived;
}
Also used : DirectBuffer(org.agrona.DirectBuffer) Header(io.aeron.logbuffer.Header) MutableBoolean(org.agrona.collections.MutableBoolean) ControlledEgressListener(io.aeron.cluster.client.ControlledEgressListener)

Aggregations

ControlledEgressListener (io.aeron.cluster.client.ControlledEgressListener)1 Header (io.aeron.logbuffer.Header)1 DirectBuffer (org.agrona.DirectBuffer)1 MutableBoolean (org.agrona.collections.MutableBoolean)1