Java Code Examples for io.aeron.ExclusivePublication#offer()

The following examples show how to use io.aeron.ExclusivePublication#offer() . 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: AeronUtil.java    From benchmarks with Apache License 2.0 6 votes vote down vote up
static int sendMessages(
    final ExclusivePublication publication,
    final UnsafeBuffer offerBuffer,
    final int numberOfMessages,
    final int messageLength,
    final long timestamp,
    final long checksum)
{
    int count = 0;
    for (int i = 0; i < numberOfMessages; i++)
    {
        offerBuffer.putLong(0, timestamp, LITTLE_ENDIAN);
        offerBuffer.putLong(messageLength - SIZE_OF_LONG, checksum, LITTLE_ENDIAN);

        final long result = publication.offer(offerBuffer, 0, messageLength, null);
        if (result < 0)
        {
            checkPublicationResult(result);
            break;
        }
        count++;
    }

    return count;
}
 
Example 2
Source File: TestNode.java    From aeron with Apache License 2.0 6 votes vote down vote up
public void onTakeSnapshot(final ExclusivePublication snapshotPublication)
{
    final ExpandableArrayBuffer buffer = new ExpandableArrayBuffer(SNAPSHOT_MSG_LENGTH);
    buffer.putInt(0, messageCount);

    for (int i = 0; i < SNAPSHOT_FRAGMENT_COUNT; i++)
    {
        idleStrategy.reset();
        while (snapshotPublication.offer(buffer, 0, SNAPSHOT_MSG_LENGTH) <= 0)
        {
            idleStrategy.idle();
        }
    }

    wasSnapshotTaken = true;
}
 
Example 3
Source File: ReplayIndexTest.java    From artio with Apache License 2.0 5 votes vote down vote up
private long publishBuffer(final ExclusivePublication publication)
{
    long position;
    while ((position = publication.offer(buffer, START, logEntryLength + PREFIX_LENGTH)) <= 0)
    {
        Thread.yield();
    }
    return position;
}
 
Example 4
Source File: BasicAuctionClusteredService.java    From aeron with Apache License 2.0 5 votes vote down vote up
public void onTakeSnapshot(final ExclusivePublication snapshotPublication)
{
    snapshotBuffer.putLong(CUSTOMER_ID_OFFSET, auction.getCurrentWinningCustomerId());           // <1>
    snapshotBuffer.putLong(PRICE_OFFSET, auction.getBestPrice());

    while (snapshotPublication.offer(snapshotBuffer, 0, SNAPSHOT_MESSAGE_LENGTH) < 0)     // <2>
    {
        idleStrategy.idle();
    }
}
 
Example 5
Source File: SingleNodeCluster.java    From aeron with Apache License 2.0 5 votes vote down vote up
public void onTakeSnapshot(final ExclusivePublication snapshotPublication)
{
    System.out.println("onTakeSnapshot messageCount=" + messageCount);

    buffer.putInt(0, messageCount);
    idleStrategy.reset();
    while (snapshotPublication.offer(buffer, 0, 4) < 0)
    {
        idleStrategy.idle();
    }
}