public class CountersReader
extends java.lang.Object
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 ... | | ... | +---------------------------------------------------------------+
| Modifier and Type | Class and Description |
|---|---|
static interface |
CountersReader.MetaData
Callback function for consuming metadata records of counters.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
COUNTER_LENGTH
Length of the space allocated to a counter that includes padding to avoid false sharing.
|
static int |
FULL_LABEL_LENGTH
Length of a counter label length including length prefix.
|
static int |
KEY_OFFSET
Offset in the record at which the key is stored.
|
static int |
LABEL_OFFSET
Offset in the record at which the label is stored.
|
static int |
MAX_KEY_LENGTH
Maximum length a key can be.
|
static int |
MAX_LABEL_LENGTH
Maximum length of a label not including its length prefix.
|
static int |
METADATA_LENGTH
Length of a meta data record in bytes.
|
protected AtomicBuffer |
metaDataBuffer |
static int |
RECORD_ALLOCATED
Record currently allocated for use..
|
static int |
RECORD_RECLAIMED
Record was active and now has been reclaimed.
|
static int |
RECORD_UNUSED
Record has not been used.
|
static int |
TYPE_ID_OFFSET
Offset in the record at which the type id field is stored.
|
protected AtomicBuffer |
valuesBuffer |
| Constructor and Description |
|---|
CountersReader(AtomicBuffer metaDataBuffer,
AtomicBuffer valuesBuffer)
Construct a reader over buffers containing the values and associated metadata.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
counterOffset(int counterId)
The offset in the counter buffer for a given counterId.
|
void |
forEach(CountersReader.MetaData metaData)
Iterate over all the metadata in the buffer.
|
void |
forEach(IntObjConsumer<java.lang.String> consumer)
Iterate over all labels in the label buffer.
|
long |
getCounterValue(int counterId)
Get the value for a given counter id as a volatile read.
|
AtomicBuffer |
metaDataBuffer()
Get the buffer containing the metadata for the counters.
|
static int |
metaDataOffset(int counterId)
The offset in the metadata buffer for a given id.
|
AtomicBuffer |
valuesBuffer()
Get the buffer containing the values for the counters.
|
public static final int RECORD_UNUSED
public static final int RECORD_ALLOCATED
public static final int RECORD_RECLAIMED
public static final int METADATA_LENGTH
public static final int TYPE_ID_OFFSET
public static final int KEY_OFFSET
public static final int LABEL_OFFSET
public static final int FULL_LABEL_LENGTH
public static final int MAX_LABEL_LENGTH
public static final int MAX_KEY_LENGTH
public static final int COUNTER_LENGTH
protected final AtomicBuffer metaDataBuffer
protected final AtomicBuffer valuesBuffer
public CountersReader(AtomicBuffer metaDataBuffer, AtomicBuffer valuesBuffer)
metaDataBuffer - containing the counter metadata.valuesBuffer - containing the counter values.public AtomicBuffer metaDataBuffer()
public AtomicBuffer valuesBuffer()
public static int counterOffset(int counterId)
counterId - for which the offset should be provided.public static int metaDataOffset(int counterId)
counterId - for the record.public void forEach(IntObjConsumer<java.lang.String> consumer)
consumer - function to be called for each label.public void forEach(CountersReader.MetaData metaData)
metaData - function to be called for each metadata record.public long getCounterValue(int counterId)
counterId - to be read.Copyright © 2014 - 2016 Real Logic Ltd. All Rights Reserved.