Search in sources :

Example 1 with RecordingEventsPoller

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();
}
Also used : SleepingMillisIdleStrategy(org.agrona.concurrent.SleepingMillisIdleStrategy) RecordingEventsPoller(io.aeron.archive.client.RecordingEventsPoller) IdleStrategy(org.agrona.concurrent.IdleStrategy) SleepingMillisIdleStrategy(org.agrona.concurrent.SleepingMillisIdleStrategy)

Aggregations

RecordingEventsPoller (io.aeron.archive.client.RecordingEventsPoller)1 IdleStrategy (org.agrona.concurrent.IdleStrategy)1 SleepingMillisIdleStrategy (org.agrona.concurrent.SleepingMillisIdleStrategy)1