// Path: benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/remote/AeronUtil.java
// static void checkPublicationResult(final long result)
// {
//     if (result == CLOSED ||
//         result == NOT_CONNECTED ||
//         result == MAX_POSITION_EXCEEDED)
//     {
//         throw new AeronException("Publication error: " + result);
//     }
// }


import io.aeron.ExclusivePublication;
import io.aeron.Image;
import io.aeron.cluster.client.AeronCluster;
import io.aeron.cluster.codecs.CloseReason;
import io.aeron.cluster.service.ClientSession;
import io.aeron.cluster.service.Cluster;
import io.aeron.cluster.service.ClusteredService;
import io.aeron.logbuffer.BufferClaim;
import io.aeron.logbuffer.Header;
import org.agrona.DirectBuffer;
import org.agrona.MutableDirectBuffer;
import org.agrona.concurrent.IdleStrategy;
import static uk.co.real_logic.benchmarks.aeron.remote.AeronUtil.checkPublicationResult;
    }

    public void onSessionOpen(final ClientSession session, final long timestamp)
    {
    }

    public void onSessionClose(final ClientSession session, final long timestamp, final CloseReason closeReason)
    {
    }

    public void onSessionMessage(
        final ClientSession session,
        final long timestamp,
        final DirectBuffer buffer,
        final int offset,
        final int length,
        final Header header)
    {
        if (null == session)
        {
            return; // skip non-client calls
        }

        final IdleStrategy idleStrategy = this.idleStrategy;
        final BufferClaim bufferClaim = this.bufferClaim;

        idleStrategy.reset();
        long result;
        while ((result = session.tryClaim(length, bufferClaim)) <= 0)
        {
// Path: benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/remote/AeronUtil.java
// static void checkPublicationResult(final long result)
// {
//     if (result == CLOSED ||
//         result == NOT_CONNECTED ||
//         result == MAX_POSITION_EXCEEDED)
//     {
//         throw new AeronException("Publication error: " + result);
//     }
// }


// Path: benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/remote/EchoClusteredService.java
import io.aeron.ExclusivePublication;
import io.aeron.Image;
import io.aeron.cluster.client.AeronCluster;
import io.aeron.cluster.codecs.CloseReason;
import io.aeron.cluster.service.ClientSession;
import io.aeron.cluster.service.Cluster;
import io.aeron.cluster.service.ClusteredService;
import io.aeron.logbuffer.BufferClaim;
import io.aeron.logbuffer.Header;
import org.agrona.DirectBuffer;
import org.agrona.MutableDirectBuffer;
import org.agrona.concurrent.IdleStrategy;
import static uk.co.real_logic.benchmarks.aeron.remote.AeronUtil.checkPublicationResult;

    }

    public void onSessionOpen(final ClientSession session, final long timestamp)
    {
    }

    public void onSessionClose(final ClientSession session, final long timestamp, final CloseReason closeReason)
    {
    }

    public void onSessionMessage(
        final ClientSession session,
        final long timestamp,
        final DirectBuffer buffer,
        final int offset,
        final int length,
        final Header header)
    {
        if (null == session)
        {
            return; // skip non-client calls
        }

        final IdleStrategy idleStrategy = this.idleStrategy;
        final BufferClaim bufferClaim = this.bufferClaim;

        idleStrategy.reset();
        long result;
        while ((result = session.tryClaim(length, bufferClaim)) <= 0)
        {
            checkPublicationResult(result);