当前位置: 首页>>代码示例>>Java>>正文


Java Publication.MAX_POSITION_EXCEEDED属性代码示例

本文整理汇总了Java中io.aeron.Publication.MAX_POSITION_EXCEEDED属性的典型用法代码示例。如果您正苦于以下问题:Java Publication.MAX_POSITION_EXCEEDED属性的具体用法?Java Publication.MAX_POSITION_EXCEEDED怎么用?Java Publication.MAX_POSITION_EXCEEDED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在io.aeron.Publication的用法示例。


在下文中一共展示了Publication.MAX_POSITION_EXCEEDED属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: send

private void send(final int length)
{
    final int fullLength = MessageHeaderEncoder.ENCODED_LENGTH + length;
    while (true)
    {
        // TODO: Under back pressure it should drop sends and then do an update on timeout to avoid tail loss.
        final long result = recordingEventsPublication.offer(outboundBuffer, 0, fullLength);
        if (result > 0 || result == Publication.NOT_CONNECTED)
        {
            idleStrategy.reset();
            break;
        }

        if (result == Publication.CLOSED || result == Publication.MAX_POSITION_EXCEEDED)
        {
            throw new IllegalStateException();
        }

        idleStrategy.idle();
    }
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:21,代码来源:RecordingEventsProxy.java

示例2: offer

private boolean offer(final int length)
{
    retryIdleStrategy.reset();

    int attempts = retryAttempts;
    while (true)
    {
        final long result;
        if ((result = publication.offer(buffer, 0, MessageHeaderEncoder.ENCODED_LENGTH + length)) > 0)
        {
            return true;
        }

        if (result == Publication.CLOSED)
        {
            throw new IllegalStateException("Connection to the archive has been closed");
        }

        if (result == Publication.NOT_CONNECTED)
        {
            throw new IllegalStateException("Connection to the archive is no longer available");
        }

        if (result == Publication.MAX_POSITION_EXCEEDED)
        {
            throw new IllegalStateException("Publication failed due to max position being reached");
        }

        if (--attempts <= 0)
        {
            return false;
        }

        retryIdleStrategy.idle();
    }
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:36,代码来源:ArchiveProxy.java

示例3: offerWithTimeout

private boolean offerWithTimeout(final int length, final AgentInvoker aeronClientInvoker)
{
    retryIdleStrategy.reset();

    final long deadlineNs = nanoClock.nanoTime() + connectTimeoutNs;
    while (true)
    {
        final long result;
        if ((result = publication.offer(buffer, 0, MessageHeaderEncoder.ENCODED_LENGTH + length)) > 0)
        {
            return true;
        }

        if (null != aeronClientInvoker)
        {
            aeronClientInvoker.invoke();
        }

        if (result == Publication.CLOSED)
        {
            throw new IllegalStateException("Connection to the archive has been closed");
        }

        if (result == Publication.MAX_POSITION_EXCEEDED)
        {
            throw new IllegalStateException("Publication failed due to max position being reached");
        }

        if (nanoClock.nanoTime() > deadlineNs)
        {
            return false;
        }

        retryIdleStrategy.idle();
    }
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:36,代码来源:ArchiveProxy.java

示例4: checkResult

private static void checkResult(final Publication controlPublication, final long result)
{
    if (result == Publication.NOT_CONNECTED ||
        result == Publication.CLOSED ||
        result == Publication.MAX_POSITION_EXCEEDED)
    {
        throw new IllegalStateException("Response channel is down: " + controlPublication.channel());
    }
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:9,代码来源:ControlResponseProxy.java

示例5: checkResult

private static void checkResult(final long result)
{
    if (result == Publication.CLOSED || result == Publication.MAX_POSITION_EXCEEDED)
    {
        throw new IllegalStateException("Unexpected publication state: " + result);
    }
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:7,代码来源:MemberStatusPublisher.java

示例6: checkResult

protected static void checkResult(final long result)
{
    if (result == Publication.NOT_CONNECTED ||
        result == Publication.CLOSED ||
        result == Publication.MAX_POSITION_EXCEEDED)
    {
        throw new IllegalStateException("Unexpected publication state: " + result);
    }
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:9,代码来源:SnapshotTaker.java

示例7: checkResult

private static void checkResult(final long result)
{
    if (result == Publication.NOT_CONNECTED ||
        result == Publication.CLOSED ||
        result == Publication.MAX_POSITION_EXCEEDED)
    {
        throw new IllegalStateException("Unexpected publication state: " + result);
    }
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:9,代码来源:ConsensusModuleProxy.java

示例8: main

public static void main(final String[] args) throws Exception
{
    // Allocate enough buffer size to hold maximum message length
    // The UnsafeBuffer class is part of the Agrona library and is used for efficient buffer management
    final UnsafeBuffer buffer = new UnsafeBuffer(BufferUtil.allocateDirectAligned(512, BitUtil.CACHE_LINE_LENGTH));

    // The channel (an endpoint identifier) to send the message to
    final String channel = "aeron:udp?endpoint=localhost:40123";

    // A unique identifier for a stream within a channel. Stream ID 0 is reserved
    // for internal use and should not be used by applications.
    final int streamId = 10;

    System.out.println("Publishing to " + channel + " on stream Id " + streamId);

    // Create a context, needed for client connection to media driver
    // A separate media driver process needs to be running prior to starting this application
    final Aeron.Context ctx = new Aeron.Context();

    // Create an Aeron instance with client-provided context configuration and connect to the
    // media driver, and create a Publication.  The Aeron and Publication classes implement
    // AutoCloseable, and will automatically clean up resources when this try block is finished.
    try (Aeron aeron = Aeron.connect(ctx);
        Publication publication = aeron.addPublication(channel, streamId))
    {
        final String message = "Hello World! ";
        final byte[] messageBytes = message.getBytes();
        buffer.putBytes(0, messageBytes);

        // Wait for 5 seconds to connect to a subscriber
        final long deadlineNs = System.nanoTime() + TimeUnit.SECONDS.toNanos(5);
        while (!publication.isConnected())
        {
            if (System.nanoTime() >= deadlineNs)
            {
                System.out.println("Failed to connect to subscriber");
                return;
            }

            Thread.sleep(1);
        }

        // Try to publish the buffer. 'offer' is a non-blocking call.
        // If it returns less than 0, the message was not sent, and the offer should be retried.
        final long result = publication.offer(buffer, 0, messageBytes.length);

        if (result < 0L)
        {
            if (result == Publication.BACK_PRESSURED)
            {
                System.out.println(" Offer failed due to back pressure");
            }
            else if (result == Publication.NOT_CONNECTED)
            {
                System.out.println(" Offer failed because publisher is not connected to subscriber");
            }
            else if (result == Publication.ADMIN_ACTION)
            {
                System.out.println("Offer failed because of an administration action in the system");
            }
            else if (result == Publication.CLOSED)
            {
                System.out.println("Offer failed publication is closed");
            }
            else if (result == Publication.MAX_POSITION_EXCEEDED)
            {
                System.out.println("Offer failed due to publication reaching max position");
            }
            else
            {
                System.out.println(" Offer failed due to unknown reason");
            }
        }
        else
        {
            System.out.println(" yay !!");
        }

        System.out.println("Done sending.");
    }
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:81,代码来源:SimplePublisher.java


注:本文中的io.aeron.Publication.MAX_POSITION_EXCEEDED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。