public class ConcurrentCountersManager extends CountersManager
CountersManager
which allows intra-process read and write access to the same
counters buffer. Note that inter-process access is not catered for.CountersReader.CounterConsumer, CountersReader.MetaData
DEFAULT_TYPE_ID
COUNTER_LENGTH, FREE_FOR_REUSE_DEADLINE_OFFSET, FULL_LABEL_LENGTH, KEY_OFFSET, LABEL_OFFSET, labelCharset, MAX_KEY_LENGTH, MAX_LABEL_LENGTH, maxCounterId, METADATA_LENGTH, metaDataBuffer, NOT_FREE_TO_REUSE, NULL_COUNTER_ID, RECORD_ALLOCATED, RECORD_RECLAIMED, RECORD_UNUSED, TYPE_ID_OFFSET, valuesBuffer
Constructor and Description |
---|
ConcurrentCountersManager(AtomicBuffer metaDataBuffer,
AtomicBuffer valuesBuffer) |
ConcurrentCountersManager(AtomicBuffer metaDataBuffer,
AtomicBuffer valuesBuffer,
java.nio.charset.Charset labelCharset) |
ConcurrentCountersManager(AtomicBuffer metaDataBuffer,
AtomicBuffer valuesBuffer,
java.nio.charset.Charset labelCharset,
EpochClock epochClock,
long freeToReuseTimeoutMs) |
Modifier and Type | Method and Description |
---|---|
int |
allocate(int typeId,
DirectBuffer keyBuffer,
int keyOffset,
int keyLength,
DirectBuffer labelBuffer,
int labelOffset,
int labelLength)
Allocate a counter with the minimum of allocation by allowing the label an key to be provided and copied.
|
int |
allocate(java.lang.String label,
int typeId)
Allocate a new counter with a given label and type.
|
int |
allocate(java.lang.String label,
int typeId,
java.util.function.Consumer<MutableDirectBuffer> keyFunc)
Allocate a new counter with a given label.
|
void |
free(int counterId)
Free the counter identified by counterId.
|
allocate, newCounter, newCounter, newCounter, newCounter, setCounterValue
counterOffset, forEach, forEach, forEach, getCounterLabel, getCounterState, getCounterValue, getFreeForReuseDeadline, labelCharset, maxCounterId, metaDataBuffer, metaDataOffset, valuesBuffer
public ConcurrentCountersManager(AtomicBuffer metaDataBuffer, AtomicBuffer valuesBuffer)
public ConcurrentCountersManager(AtomicBuffer metaDataBuffer, AtomicBuffer valuesBuffer, java.nio.charset.Charset labelCharset)
public ConcurrentCountersManager(AtomicBuffer metaDataBuffer, AtomicBuffer valuesBuffer, java.nio.charset.Charset labelCharset, EpochClock epochClock, long freeToReuseTimeoutMs)
public int allocate(java.lang.String label, int typeId)
CountersManager
allocate
in class CountersManager
label
- to describe the counter.typeId
- for the type of counter.public int allocate(java.lang.String label, int typeId, java.util.function.Consumer<MutableDirectBuffer> keyFunc)
CountersManager
The key function will be called with a buffer with the exact length of available key space in the record for the user to store what they want for the key. No offset is required.
allocate
in class CountersManager
label
- to describe the counter.typeId
- for the type of counter.keyFunc
- for setting the key value for the counter.public int allocate(int typeId, DirectBuffer keyBuffer, int keyOffset, int keyLength, DirectBuffer labelBuffer, int labelOffset, int labelLength)
CountersManager
If the keyBuffer is null then a copy of the key is not attempted.
allocate
in class CountersManager
typeId
- for the counter.keyBuffer
- containing the optional key for the counter.keyOffset
- within the keyBuffer at which the key begins.keyLength
- of the key in the keyBuffer.labelBuffer
- containing the mandatory label for the counter.labelOffset
- within the labelBuffer at which the label begins.labelLength
- of the label in the labelBuffer.public void free(int counterId)
CountersManager
free
in class CountersManager
counterId
- the counter to freedCopyright © 2014-2018 Real Logic Ltd. All Rights Reserved.