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


Java CountersManager.allocate方法代码示例

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


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

示例1: allocateCounterId

import org.agrona.concurrent.status.CountersManager; //导入方法依赖的package包/类
public static int allocateCounterId(
    final MutableDirectBuffer tempBuffer,
    final String name,
    final int typeId,
    final CountersManager countersManager,
    final long registrationId,
    final int sessionId,
    final int streamId,
    final String channel)
{
    tempBuffer.putLong(REGISTRATION_ID_OFFSET, registrationId);
    tempBuffer.putInt(SESSION_ID_OFFSET, sessionId);
    tempBuffer.putInt(STREAM_ID_OFFSET, streamId);

    final int channelLength = tempBuffer.putStringWithoutLengthAscii(
        CHANNEL_OFFSET + SIZE_OF_INT, channel, 0, MAX_CHANNEL_LENGTH);
    tempBuffer.putInt(CHANNEL_OFFSET, channelLength);
    final int keyLength = CHANNEL_OFFSET + SIZE_OF_INT + channelLength;

    int labelLength = 0;
    labelLength += tempBuffer.putStringWithoutLengthAscii(keyLength + labelLength, name);
    labelLength += tempBuffer.putStringWithoutLengthAscii(keyLength + labelLength, ": ");
    labelLength += tempBuffer.putLongAscii(keyLength + labelLength, registrationId);
    labelLength += tempBuffer.putStringWithoutLengthAscii(keyLength + labelLength, " ");
    labelLength += tempBuffer.putIntAscii(keyLength + labelLength, sessionId);
    labelLength += tempBuffer.putStringWithoutLengthAscii(keyLength + labelLength, " ");
    labelLength += tempBuffer.putIntAscii(keyLength + labelLength, streamId);
    labelLength += tempBuffer.putStringWithoutLengthAscii(keyLength + labelLength, " ");
    labelLength += tempBuffer.putStringWithoutLengthAscii(
        keyLength + labelLength, channel, 0, MAX_LABEL_LENGTH - labelLength);

    return countersManager.allocate(
        typeId,
        tempBuffer,
        0,
        keyLength,
        tempBuffer,
        keyLength,
        labelLength
    );
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:42,代码来源:StreamPositionCounter.java

示例2: allocate

import org.agrona.concurrent.status.CountersManager; //导入方法依赖的package包/类
/**
 * Allocate a counter for tracking a position on a stream of messages.
 *
 * @param tempBuffer      to be used for labels and key.
 * @param name            of the counter for the label.
 * @param typeId          of the counter for classification.
 * @param countersManager from which to allocated the underlying storage.
 * @param registrationId  to be associated with the counter.
 * @param sessionId       for the stream of messages.
 * @param streamId        for the stream of messages.
 * @param channel         for the stream of messages.
 * @param joinPosition    for the label.
 * @return a new {@link UnsafeBufferPosition} for tracking the stream.
 */
public static UnsafeBufferPosition allocate(
    final MutableDirectBuffer tempBuffer,
    final String name,
    final int typeId,
    final CountersManager countersManager,
    final long registrationId,
    final int sessionId,
    final int streamId,
    final String channel,
    final long joinPosition)
{
    tempBuffer.putLong(REGISTRATION_ID_OFFSET, registrationId);
    tempBuffer.putInt(SESSION_ID_OFFSET, sessionId);
    tempBuffer.putInt(STREAM_ID_OFFSET, streamId);

    final int channelLength = tempBuffer.putStringWithoutLengthAscii(
        CHANNEL_OFFSET + SIZE_OF_INT, channel, 0, MAX_CHANNEL_LENGTH);
    tempBuffer.putInt(CHANNEL_OFFSET, channelLength);
    final int keyLength = CHANNEL_OFFSET + SIZE_OF_INT + channelLength;

    int labelLength = 0;
    labelLength += tempBuffer.putStringWithoutLengthAscii(keyLength + labelLength, name);
    labelLength += tempBuffer.putStringWithoutLengthAscii(keyLength + labelLength, ": ");
    labelLength += tempBuffer.putLongAscii(keyLength + labelLength, registrationId);
    labelLength += tempBuffer.putStringWithoutLengthAscii(keyLength + labelLength, " ");
    labelLength += tempBuffer.putIntAscii(keyLength + labelLength, sessionId);
    labelLength += tempBuffer.putStringWithoutLengthAscii(keyLength + labelLength, " ");
    labelLength += tempBuffer.putIntAscii(keyLength + labelLength, streamId);
    labelLength += tempBuffer.putStringWithoutLengthAscii(keyLength + labelLength, " ");
    labelLength += tempBuffer.putStringWithoutLengthAscii(
        keyLength + labelLength, channel, 0, MAX_LABEL_LENGTH - labelLength);

    if (labelLength < (MAX_LABEL_LENGTH - 20))
    {
        labelLength += tempBuffer.putStringWithoutLengthAscii(keyLength + labelLength, " @");
        labelLength += tempBuffer.putLongAscii(keyLength + labelLength, joinPosition);
    }

    final int counterId = countersManager.allocate(
        typeId,
        tempBuffer,
        0,
        keyLength,
        tempBuffer,
        keyLength,
        labelLength
    );

    return new UnsafeBufferPosition((UnsafeBuffer)countersManager.valuesBuffer(), counterId, countersManager);
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:65,代码来源:StreamPositionCounter.java


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