void onSignal(final long correlationId, final long recordingId, final long position, final RecordingSignal signal)
    {
        if (correlationId == replicationId)
        {
            if (RecordingSignal.EXTEND == signal)
            {
                final CountersReader counters = archive.context().aeron().countersReader();
                recordingPositionCounterId =
                    RecordingPos.findCounterIdByRecording(counters, recordingId, archive.archiveId());
            }
            else if (RecordingSignal.SYNC == signal)
            {
                hasSynced = true;
            }
            else if (RecordingSignal.REPLICATE_END == signal)
            {
                hasReplicationEnded = true;
            }
            else if (RecordingSignal.STOP == signal)
            {
                if (NULL_POSITION != position)
                {
                    this.position = position;
                }
                hasStopped = true;
            }
            else if (RecordingSignal.DELETE == signal)
            {
                throw new ClusterException("recording was deleted during replication: " + this);
            }

            this.lastRecordingSignal = signal;

            if (NULL_VALUE != recordingId)
            {
                this.recordingId = recordingId;
            }

            if (NULL_POSITION != position)
            {
                this.position = position;
            }
        }
    }
@Test
    void shouldFailIfRecordingLogIsDeletedDuringReplication()
    {
        final RecordingSignal recordingSignal = RecordingSignal.DELETE;
        final long stopPosition = 982734;
        final long nowNs = 0;

        final ReplicationParams replicationParams = new ReplicationParams()
            .dstRecordingId(DST_RECORDING_ID)
            .stopPosition(stopPosition)
            .replicationChannel(REPLICATION_CHANNEL)
            .replicationSessionId(Aeron.NULL_VALUE);

        final RecordingReplication logReplication = new RecordingReplication(
            aeronArchive,
            SRC_RECORDING_ID,
            ENDPOINT,
            SRC_STREAM_ID,
            replicationParams,
            PROGRESS_CHECK_TIMEOUT_NS,
            PROGRESS_CHECK_INTERVAL_NS,
            nowNs);

        assertThrows(
            ClusterException.class,
            () -> logReplication.onSignal(REPLICATION_ID, DST_RECORDING_ID, stopPosition - 1, recordingSignal));
    }