use of io.aeron.archive.client.RecordingEventsPoller in project aeron by real-logic.
the class ArchiveReplayLoadTest method trackRecordingProgress.
private void trackRecordingProgress(final Subscription recordingEvents, final CountDownLatch recordingStopped) {
final Thread t = new Thread(() -> {
try {
recordedLength = 0;
final IdleStrategy idleStrategy = new SleepingMillisIdleStrategy(1);
final RecordingEventsPoller poller = new RecordingEventsPoller(recordingEvents);
while (0 == expectedRecordingLength || recordedLength < expectedRecordingLength) {
idleStrategy.reset();
while (poller.poll() <= 0 && !poller.isPollComplete()) {
idleStrategy.idle();
}
switch(poller.templateId()) {
case RecordingStartedDecoder.TEMPLATE_ID:
{
final long startPosition = poller.recordingStartPosition();
recordingId = poller.recordingId();
if (0L != startPosition) {
throw new IllegalStateException("expected=0 actual=" + startPosition);
}
printf("Recording started %d %n", recordingId);
break;
}
case RecordingProgressDecoder.TEMPLATE_ID:
{
recordedLength = poller.recordingPosition() - poller.recordingStartPosition();
printf("Recording progress %d %n", recordedLength);
break;
}
}
}
} catch (final Throwable throwable) {
trackerError = throwable;
} finally {
recordingStopped.countDown();
}
});
t.setDaemon(true);
t.start();
}
Aggregations