Skip to content

Commit

Permalink
[Java] Wait for recording to stop before checking if it has been comp…
Browse files Browse the repository at this point in the history
…letely replicated.
  • Loading branch information
mjpt777 committed Aug 30, 2024
1 parent 2975d2a commit ef8afe8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ enum State
private ExclusivePublication responsePublication = null;
private ArchiveProxy responseArchiveProxy = null;


ReplicationSession(
final long srcRecordingId,
final long dstRecordingId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ class RecordingReplicatorTest
private static final String DST_ARCHIVE_REPLICATION_CHANNEL =
"aeron:udp?alias=dst-replication-channel|endpoint=localhost:9999";
private static final int TERM_BUFFER_LENGTH = 128 * 1024;

@RegisterExtension
final SystemTestWatcher testWatcher = new SystemTestWatcher();

private TestMediaDriver srcMediaDriver;
private TestMediaDriver dstMediaDriver;
private Archive srcArchive;
Expand Down Expand Up @@ -209,8 +211,8 @@ private long createRecording(
try (ExclusivePublication publication = aeronArchive.addRecordedExclusivePublication(channel, streamId))
{
final CountersReader counters = aeronArchive.context().aeron().countersReader();
final int counterId =
Tests.awaitRecordingCounterId(counters, publication.sessionId(), aeronArchive.archiveId());
final int counterId = Tests.awaitRecordingCounterId(
counters, publication.sessionId(), aeronArchive.archiveId());
final long recordingId = RecordingPos.getRecordingId(counters, counterId);
final BufferClaim bufferClaim = new BufferClaim();

Expand Down Expand Up @@ -263,6 +265,11 @@ private void verifyRecordingReplicated(final long srcRecordingId, final long dst
assertEquals(1, srcAeronArchive.listRecording(srcRecordingId, collector.reset()));
final RecordingDescriptor srcRecording = collector.descriptors().get(0).retain();

while (dstAeronArchive.getStopPosition(dstRecordingId) == AeronArchive.NULL_POSITION)
{
Tests.yield();
}

assertEquals(1, dstAeronArchive.listRecording(dstRecordingId, collector.reset()));
final RecordingDescriptor dstRecording = collector.descriptors().get(0).retain();

Expand Down

0 comments on commit ef8afe8

Please sign in to comment.