Java Code Examples for org.agrona.collections.MutableLong#set()

The following examples show how to use org.agrona.collections.MutableLong#set() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListRecordingsForUriSessionTest.java    From aeron with Apache License 2.0 6 votes vote down vote up
private Answer<Object> verifySendDescriptor(final MutableLong counter)
{
    return (invocation) ->
    {
        final UnsafeBuffer buffer = invocation.getArgument(1);
        recordingDescriptorDecoder.wrap(
            buffer,
            RecordingDescriptorHeaderDecoder.BLOCK_LENGTH,
            RecordingDescriptorDecoder.BLOCK_LENGTH,
            RecordingDescriptorDecoder.SCHEMA_VERSION);

        final int i = counter.intValue();
        assertEquals(matchingRecordingIds[i], recordingDescriptorDecoder.recordingId());
        counter.set(i + 1);

        return buffer.getInt(0);
    };
}
 
Example 2
Source File: ListRecordingsSessionTest.java    From aeron with Apache License 2.0 6 votes vote down vote up
private Answer<Object> verifySendDescriptor(final MutableLong counter)
{
    return (invocation) ->
    {
        final UnsafeBuffer buffer = invocation.getArgument(1);

        recordingDescriptorDecoder.wrap(
            buffer,
            RecordingDescriptorHeaderDecoder.BLOCK_LENGTH,
            RecordingDescriptorDecoder.BLOCK_LENGTH,
            RecordingDescriptorDecoder.SCHEMA_VERSION);

        final int i = counter.intValue();
        assertEquals(recordingIds[i], recordingDescriptorDecoder.recordingId());
        counter.set(i + 1);

        return buffer.getInt(0);
    };
}
 
Example 3
Source File: AeronUtil.java    From benchmarks with Apache License 2.0 5 votes vote down vote up
static long findLastRecordingId(
    final AeronArchive aeronArchive, final String recordingChannel, final int recordingStreamId)
{
    final MutableLong lastRecordingId = new MutableLong();

    final RecordingDescriptorConsumer consumer =
        (controlSessionId,
        correlationId,
        recordingId,
        startTimestamp,
        stopTimestamp,
        startPosition,
        stopPosition,
        initialTermId,
        segmentFileLength,
        termBufferLength,
        mtuLength,
        sessionId,
        streamId,
        strippedChannel,
        originalChannel,
        sourceIdentity) -> lastRecordingId.set(recordingId);

    int foundCount;
    do
    {
        foundCount = aeronArchive.listRecordingsForUri(0, 1, recordingChannel, recordingStreamId, consumer);
    }
    while (0 == foundCount);

    return lastRecordingId.get();
}
 
Example 4
Source File: ReplayedBasicSubscriber.java    From aeron with Apache License 2.0 5 votes vote down vote up
private static long findLatestRecording(final AeronArchive archive)
{
    final MutableLong lastRecordingId = new MutableLong();

    final RecordingDescriptorConsumer consumer =
        (controlSessionId,
        correlationId,
        recordingId,
        startTimestamp,
        stopTimestamp,
        startPosition,
        stopPosition,
        initialTermId,
        segmentFileLength,
        termBufferLength,
        mtuLength,
        sessionId,
        streamId,
        strippedChannel,
        originalChannel,
        sourceIdentity) -> lastRecordingId.set(recordingId);

    final long fromRecordingId = 0L;
    final int recordCount = 100;

    final int foundCount = archive.listRecordingsForUri(fromRecordingId, recordCount, CHANNEL, STREAM_ID, consumer);

    if (foundCount == 0)
    {
        throw new IllegalStateException("no recordings found");
    }

    return lastRecordingId.get();
}
 
Example 5
Source File: EmbeddedReplayThroughput.java    From aeron with Apache License 2.0 5 votes vote down vote up
private long findRecordingId(final String expectedChannel)
{
    final MutableLong foundRecordingId = new MutableLong();

    final RecordingDescriptorConsumer consumer =
        (controlSessionId,
        correlationId,
        recordingId,
        startTimestamp,
        stopTimestamp,
        startPosition,
        stopPosition,
        initialTermId,
        segmentFileLength,
        termBufferLength,
        mtuLength,
        sessionId,
        streamId,
        strippedChannel,
        originalChannel,
        sourceIdentity) -> foundRecordingId.set(recordingId);

    final int recordingsFound = aeronArchive.listRecordingsForUri(
        0L, 10, expectedChannel, STREAM_ID, consumer);

    if (1 != recordingsFound)
    {
        throw new IllegalStateException("should have been only one recording");
    }

    return foundRecordingId.get();
}