use of io.aeron.archive.codecs.RecordingSignal in project aeron by real-logic.
the class ReplicateRecordingTest method shouldReplicateLiveWithoutMergingRecording.
@Test
@InterruptAfter(10)
public void shouldReplicateLiveWithoutMergingRecording() {
final String messagePrefix = "Message-Prefix-";
final int messageCount = 10;
final long srcRecordingId;
final long subscriptionId = srcAeronArchive.startRecording(LIVE_CHANNEL, LIVE_STREAM_ID, LOCAL);
try (Publication publication = srcAeron.addPublication(LIVE_CHANNEL, LIVE_STREAM_ID)) {
final CountersReader srcCounters = srcAeron.countersReader();
final int counterId = awaitRecordingCounterId(srcCounters, publication.sessionId());
srcRecordingId = RecordingPos.getRecordingId(srcCounters, counterId);
offer(publication, messageCount, messagePrefix);
awaitPosition(srcCounters, counterId, publication.position());
final MutableLong dstRecordingId = new MutableLong();
final MutableReference<RecordingSignal> signalRef = new MutableReference<>();
final RecordingSignalAdapter adapter = newRecordingSignalAdapter(signalRef, dstRecordingId);
final long replicationId = dstAeronArchive.replicate(srcRecordingId, NULL_VALUE, SRC_CONTROL_STREAM_ID, SRC_CONTROL_REQUEST_CHANNEL, null);
assertEquals(RecordingSignal.REPLICATE, awaitSignal(signalRef, adapter));
assertEquals(RecordingSignal.EXTEND, awaitSignal(signalRef, adapter));
final CountersReader dstCounters = dstAeron.countersReader();
final int dstCounterId = RecordingPos.findCounterIdByRecording(dstCounters, dstRecordingId.get());
awaitPosition(dstCounters, dstCounterId, publication.position());
offer(publication, messageCount, messagePrefix);
awaitPosition(dstCounters, dstCounterId, publication.position());
dstAeronArchive.stopReplication(replicationId);
assertEquals(RecordingSignal.STOP, awaitSignal(signalRef, adapter));
}
srcAeronArchive.stopRecording(subscriptionId);
}
use of io.aeron.archive.codecs.RecordingSignal in project aeron by real-logic.
the class ReplicateRecordingTest method shouldReplicateLiveRecordingAndMergeWhileFollowingWithTaggedSubscription.
@Test
@InterruptAfter(10)
public void shouldReplicateLiveRecordingAndMergeWhileFollowingWithTaggedSubscription() {
final String messagePrefix = "Message-Prefix-";
final int messageCount = 10;
final long srcRecordingId;
final long channelTagId = dstAeron.nextCorrelationId();
final long subscriptionTagId = dstAeron.nextCorrelationId();
final String taggedChannel = "aeron:udp?control-mode=manual|rejoin=false|tags=" + channelTagId + "," + subscriptionTagId;
final long subscriptionId = srcAeronArchive.startRecording(LIVE_CHANNEL, LIVE_STREAM_ID, LOCAL);
final MutableReference<RecordingSignal> signalRef = new MutableReference<>();
final RecordingSignalAdapter adapter;
try (Publication publication = srcAeron.addPublication(LIVE_CHANNEL, LIVE_STREAM_ID);
Subscription taggedSubscription = dstAeron.addSubscription(taggedChannel, LIVE_STREAM_ID)) {
final CountersReader srcCounters = srcAeron.countersReader();
final int counterId = awaitRecordingCounterId(srcCounters, publication.sessionId());
srcRecordingId = RecordingPos.getRecordingId(srcCounters, counterId);
offer(publication, messageCount, messagePrefix);
awaitPosition(srcCounters, counterId, publication.position());
final MutableLong dstRecordingId = new MutableLong();
adapter = newRecordingSignalAdapter(signalRef, dstRecordingId);
dstAeronArchive.taggedReplicate(srcRecordingId, NULL_VALUE, channelTagId, subscriptionTagId, SRC_CONTROL_STREAM_ID, SRC_CONTROL_REQUEST_CHANNEL, LIVE_CHANNEL);
consume(taggedSubscription, messageCount, messagePrefix);
offer(publication, messageCount, messagePrefix);
consume(taggedSubscription, messageCount, messagePrefix);
assertEquals(RecordingSignal.REPLICATE, awaitSignal(signalRef, adapter));
assertEquals(RecordingSignal.EXTEND, awaitSignal(signalRef, adapter));
assertEquals(RecordingSignal.MERGE, awaitSignal(signalRef, adapter));
final CountersReader dstCounters = dstAeron.countersReader();
final int dstCounterId = RecordingPos.findCounterIdByRecording(dstCounters, dstRecordingId.get());
offer(publication, messageCount, messagePrefix);
consume(taggedSubscription, messageCount, messagePrefix);
awaitPosition(dstCounters, dstCounterId, publication.position());
final Image image = taggedSubscription.imageBySessionId(publication.sessionId());
assertEquals(publication.position(), image.position());
}
srcAeronArchive.stopRecording(subscriptionId);
assertEquals(RecordingSignal.STOP, awaitSignal(signalRef, adapter));
}
Aggregations