public class CountersManager extends CountersReader
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Counter Value | | | +---------------------------------------------------------------+ | 120 bytes of padding ... ... | +---------------------------------------------------------------+ | Repeats to end of buffer ... | | ... | +---------------------------------------------------------------+Meta Data Buffer
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Record State | +---------------------------------------------------------------+ | Type Id | +---------------------------------------------------------------+ | 120 bytes for key ... ... | +-+-------------------------------------------------------------+ |R| Label Length | +-+-------------------------------------------------------------+ | 124 bytes of Label in UTF-8 ... ... | +---------------------------------------------------------------+ | Repeats to end of buffer ... | | ... | +---------------------------------------------------------------+
CountersReader.MetaData| Modifier and Type | Field and Description |
|---|---|
static java.util.function.Consumer<MutableDirectBuffer> |
DEFAULT_KEY_FUNC
Default function to set a key when none is supplied.
|
static int |
DEFAULT_TYPE_ID
Default type id of a counter when none is supplied.
|
COUNTER_LENGTH, FULL_LABEL_LENGTH, KEY_OFFSET, LABEL_OFFSET, MAX_KEY_LENGTH, MAX_LABEL_LENGTH, METADATA_LENGTH, metaDataBuffer, RECORD_ALLOCATED, RECORD_RECLAIMED, RECORD_UNUSED, TYPE_ID_OFFSET, valuesBuffer| Constructor and Description |
|---|
CountersManager(AtomicBuffer metaDataBuffer,
AtomicBuffer valuesBuffer)
Create a new counter buffer manager over two buffers.
|
| Modifier and Type | Method and Description |
|---|---|
int |
allocate(java.lang.String label)
Allocate a new counter with a given label.
|
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.
|
AtomicCounter |
newCounter(java.lang.String label)
Allocate a counter record and wrap it with a new
AtomicCounter for use. |
AtomicCounter |
newCounter(java.lang.String label,
int typeId,
java.util.function.Consumer<MutableDirectBuffer> keyFunc)
Allocate a counter record and wrap it with a new
AtomicCounter for use. |
void |
setCounterValue(int counterId,
long value)
Set an
AtomicCounter value based on counterId. |
counterOffset, forEach, forEach, getCounterValue, metaDataBuffer, metaDataOffset, valuesBufferpublic static final int DEFAULT_TYPE_ID
public static final java.util.function.Consumer<MutableDirectBuffer> DEFAULT_KEY_FUNC
public CountersManager(AtomicBuffer metaDataBuffer, AtomicBuffer valuesBuffer)
metaDataBuffer - containing the types, keys, and labels for the counters.valuesBuffer - containing the values of the counters themselves.public int allocate(java.lang.String label)
label - to describe the counter.public int allocate(java.lang.String label,
int typeId,
java.util.function.Consumer<MutableDirectBuffer> keyFunc)
label - to describe the counter.typeId - for the type of counter.keyFunc - for setting the key value for the counter.public AtomicCounter newCounter(java.lang.String label)
AtomicCounter for use.label - to describe the counter.AtomicCounterpublic AtomicCounter newCounter(java.lang.String label, int typeId, java.util.function.Consumer<MutableDirectBuffer> keyFunc)
AtomicCounter for use.label - to describe the counter.typeId - for the type of counter.keyFunc - for setting the key value for the counter.AtomicCounterpublic void free(int counterId)
counterId - the counter to freedpublic void setCounterValue(int counterId,
long value)
AtomicCounter value based on counterId.counterId - to be set.value - to set for the counter.Copyright © 2014 - 2016 Real Logic Ltd. All Rights Reserved.