use of io.aeron.archive.codecs.RecordingSignal in project aeron by real-logic.
the class ReplicateRecordingTest method shouldReplicateMoreThanOnce.
@Test
@InterruptAfter(10)
public void shouldReplicateMoreThanOnce() {
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 recordingIdRef = new MutableLong();
final MutableReference<RecordingSignal> signalRef = new MutableReference<>();
final RecordingSignalAdapter adapter = newRecordingSignalAdapter(signalRef, recordingIdRef);
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 long dstRecordingId = recordingIdRef.get();
int dstCounterId = RecordingPos.findCounterIdByRecording(dstCounters, dstRecordingId);
awaitPosition(dstCounters, dstCounterId, publication.position());
dstAeronArchive.stopReplication(replicationId);
assertEquals(RecordingSignal.STOP, awaitSignal(signalRef, adapter));
replicationId = dstAeronArchive.replicate(srcRecordingId, dstRecordingId, SRC_CONTROL_STREAM_ID, SRC_CONTROL_REQUEST_CHANNEL, null);
assertEquals(RecordingSignal.EXTEND, awaitSignal(signalRef, adapter));
dstCounterId = RecordingPos.findCounterIdByRecording(dstCounters, dstRecordingId);
offer(publication, messageCount, messagePrefix);
awaitPosition(dstCounters, dstCounterId, publication.position());
dstAeronArchive.stopReplication(replicationId);
}
srcAeronArchive.stopRecording(subscriptionId);
}
use of io.aeron.archive.codecs.RecordingSignal in project aeron by real-logic.
the class ReplicateRecordingTest method shouldReplicateStoppedRecording.
@Test
@InterruptAfter(10)
public void shouldReplicateStoppedRecording() {
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 counters = srcAeron.countersReader();
final int counterId = awaitRecordingCounterId(counters, publication.sessionId());
srcRecordingId = RecordingPos.getRecordingId(counters, counterId);
offer(publication, messageCount, messagePrefix);
awaitPosition(counters, counterId, publication.position());
}
srcAeronArchive.stopRecording(subscriptionId);
final MutableLong dstRecordingId = new MutableLong();
final MutableReference<RecordingSignal> signalRef = new MutableReference<>();
final RecordingSignalAdapter adapter = newRecordingSignalAdapter(signalRef, dstRecordingId);
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 ObjectHashSet<RecordingSignal> transitionEventsSet = new ObjectHashSet<>();
transitionEventsSet.add(awaitSignal(signalRef, adapter));
transitionEventsSet.add(awaitSignal(signalRef, adapter));
assertTrue(transitionEventsSet.contains(RecordingSignal.STOP));
assertTrue(transitionEventsSet.contains(RecordingSignal.SYNC));
}
use of io.aeron.archive.codecs.RecordingSignal in project aeron by real-logic.
the class ReplicateRecordingTest method shouldThrowExceptionWhenSrcRecordingIdUnknown.
@Test
@InterruptAfter(10)
public void shouldThrowExceptionWhenSrcRecordingIdUnknown() {
final long unknownId = 7L;
final ControlEventListener listener = mock(ControlEventListener.class);
final MutableLong dstRecordingId = new MutableLong();
final MutableReference<RecordingSignal> signalRef = new MutableReference<>();
final RecordingSignalAdapter adapter = newRecordingSignalAdapter(listener, signalRef, dstRecordingId);
final long replicationId = dstAeronArchive.replicate(unknownId, NULL_VALUE, SRC_CONTROL_STREAM_ID, SRC_CONTROL_REQUEST_CHANNEL, null);
awaitSignalOrResponse(signalRef, adapter);
verify(listener).onResponse(eq(dstAeronArchive.controlSessionId()), eq(replicationId), eq((long) ArchiveException.UNKNOWN_RECORDING), eq(ControlResponseCode.ERROR), anyString());
}
use of io.aeron.archive.codecs.RecordingSignal in project aeron by real-logic.
the class ReplicateRecordingTest method shouldReplicateLiveRecordingAndStopAtSpecifiedPosition.
@Test
@InterruptAfter(10)
public void shouldReplicateLiveRecordingAndStopAtSpecifiedPosition() {
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);
final long firstPosition = publication.position();
awaitPosition(srcCounters, counterId, firstPosition);
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);
dstAeronArchive.replicate(srcRecordingId, NULL_VALUE, firstPosition, SRC_CONTROL_STREAM_ID, SRC_CONTROL_REQUEST_CHANNEL, null, null);
assertEquals(RecordingSignal.REPLICATE, awaitSignal(signalRef, adapter));
assertEquals(RecordingSignal.EXTEND, awaitSignal(signalRef, adapter));
assertEquals(RecordingSignal.STOP, awaitSignal(signalRef, adapter));
offer(publication, messageCount, messagePrefix);
final int srcCounterId = RecordingPos.findCounterIdByRecording(srcCounters, srcRecordingId);
awaitPosition(srcCounters, srcCounterId, publication.position());
assertTrue(firstPosition < publication.position());
long dstStopPosition;
while (NULL_POSITION == (dstStopPosition = dstAeronArchive.getStopPosition(dstRecordingId.get()))) {
Tests.yield();
}
assertEquals(firstPosition, dstStopPosition);
}
srcAeronArchive.stopRecording(subscriptionId);
}
use of io.aeron.archive.codecs.RecordingSignal in project aeron by real-logic.
the class ReplicateRecordingTest method shouldReplicateLiveRecordingAndMergeBeforeDataFlows.
@Test
@InterruptAfter(10)
public void shouldReplicateLiveRecordingAndMergeBeforeDataFlows() {
final String messagePrefix = "Message-Prefix-";
final int messageCount = 10;
final long srcRecordingId;
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)) {
final CountersReader srcCounters = srcAeron.countersReader();
final int counterId = awaitRecordingCounterId(srcCounters, publication.sessionId());
srcRecordingId = RecordingPos.getRecordingId(srcCounters, counterId);
final MutableLong dstRecordingId = new MutableLong();
adapter = newRecordingSignalAdapter(signalRef, dstRecordingId);
dstAeronArchive.replicate(srcRecordingId, NULL_VALUE, SRC_CONTROL_STREAM_ID, SRC_CONTROL_REQUEST_CHANNEL, LIVE_CHANNEL);
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);
awaitPosition(dstCounters, dstCounterId, publication.position());
}
srcAeronArchive.stopRecording(subscriptionId);
assertEquals(RecordingSignal.STOP, awaitSignal(signalRef, adapter));
}
Aggregations