public void logReplicationSessionDone(
        final long controlSessionId,
        final long replicationId,
        final long srcRecordingId,
        final long replayPosition,
        final long srcStopPosition,
        final long dstRecordingId,
        final long dstStopPosition,
        final long position,
        final boolean isClosed,
        final boolean isEndOfStream,
        final boolean isSynced)
    {
        final int length = replicationSessionDoneLength();
        final int captureLength = captureLength(length);
        final int encodedLength = encodedLength(captureLength);
        final ManyToOneRingBuffer ringBuffer = this.ringBuffer;
        final int index = ringBuffer.tryClaim(REPLICATION_SESSION_DONE.toEventCodeId(), encodedLength);

        if (index > 0)
        {
            try
            {
                encodeReplicationSessionDone(
                    (UnsafeBuffer)ringBuffer.buffer(),
                    index,
                    captureLength,
                    length,
                    controlSessionId,
                    replicationId,
                    srcRecordingId,
                    replayPosition,
                    srcStopPosition,
                    dstRecordingId,
                    dstStopPosition,
                    position,
                    isClosed,
                    isEndOfStream,
                    isSynced);
            }
            finally
            {
                ringBuffer.commit(index);
            }
        }
    }
@Test
    void logReplicationSessionDone()
    {
        final long controlSessionId = 232345;
        final long replicationId = 456456;
        final long srcRecordingId = 345123;
        final long replayPosition = 2345;
        final long srcStopPosition = 3245;
        final long dstRecordingId = 435675346;
        final long dstStopPosition = 5685623;
        final long position = 3425234;
        final boolean isClosed = true;
        final boolean isEndOfStream = true;
        final boolean isSynced = false;

        final int offset = ALIGNMENT * 3;
        logBuffer.putLong(CAPACITY + TAIL_POSITION_OFFSET, offset);

        logger.logReplicationSessionDone(
            controlSessionId,
            replicationId,
            srcRecordingId,
            replayPosition,
            srcStopPosition,
            dstRecordingId,
            dstStopPosition,
            position,
            isClosed,
            isEndOfStream,
            isSynced);

        verifyLogHeader(
            logBuffer,
            offset,
            REPLICATION_SESSION_DONE.toEventCodeId(),
            replicationSessionDoneLength(),
            replicationSessionDoneLength());

        final StringBuilder sb = new StringBuilder();
        ArchiveEventDissector.dissectReplicationSessionDone(
            logBuffer, encodedMsgOffset(offset), sb);

        final String expectedMessagePattern =
            "\\[[0-9]+\\.[0-9]+] ARCHIVE: REPLICATION_SESSION_DONE \\[67/67]: controlSessionId=" + controlSessionId +
            " replicationId=" + replicationId + " srcRecordingId=" + srcRecordingId +
            " replayPosition=" + replayPosition + " srcStopPosition=" + srcStopPosition +
            " dstRecordingId=" + dstRecordingId + " dstStopPosition=" + dstStopPosition + " position=" + position +
            " isClosed=" + isClosed + " isEndOfStream=" + isEndOfStream + " isSynced=" + isSynced;

        assertThat(sb.toString(), Matchers.matchesPattern(expectedMessagePattern));
    }