本文整理匯總了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
);
}
示例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);
}