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.MetaDataCOUNTER_LENGTH, DEFAULT_OWNER_ID, DEFAULT_REFERENCE_ID, DEFAULT_REGISTRATION_ID, DEFAULT_TYPE_ID, 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, OWNER_ID_OFFSET, RECORD_ALLOCATED, RECORD_RECLAIMED, RECORD_UNUSED, REFERENCE_ID_OFFSET, REGISTRATION_ID_OFFSET, TYPE_ID_OFFSET, valuesBuffer| Constructor and Description |
|---|
ConcurrentCountersManager(AtomicBuffer metaDataBuffer,
AtomicBuffer valuesBuffer)
Construct a counter manager over buffers containing the values and associated metadata.
|
ConcurrentCountersManager(AtomicBuffer metaDataBuffer,
AtomicBuffer valuesBuffer,
Charset labelCharset)
Construct a counter manager over buffers containing the values and associated metadata.
|
ConcurrentCountersManager(AtomicBuffer metaDataBuffer,
AtomicBuffer valuesBuffer,
Charset labelCharset,
EpochClock epochClock,
long freeToReuseTimeoutMs)
Create a new counter manager over buffers containing the values and associated metadata.
|
| 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 a key to be provided and copied.
|
int |
allocate(String label,
int typeId)
Allocate a new counter with a given label and type.
|
int |
allocate(String label,
int typeId,
Consumer<MutableDirectBuffer> keyFunc)
Allocate a new counter with a given label.
|
void |
appendToLabel(int counterId,
String label)
Set an
AtomicCounter label based on counter id. |
int |
available()
Number of counters available to be allocated which is a function of
CountersManager.capacity() minus the number already
allocated. |
void |
free(int counterId)
Free the counter identified by counterId.
|
void |
setCounterKey(int counterId,
Consumer<MutableDirectBuffer> keyFunc)
Set an
AtomicCounter key by on counter id, using a consumer callback to update the key metadata buffer. |
void |
setCounterKey(int counterId,
DirectBuffer keyBuffer,
int offset,
int length)
Set an
AtomicCounter key by on counter id, copying the key metadata from the supplied buffer. |
void |
setCounterLabel(int counterId,
String label)
Set an
AtomicCounter label by counter id. |
void |
setCounterOwnerId(int counterId,
long ownerId)
Set an
AtomicCounter owner id for a counter id. |
void |
setCounterReferenceId(int counterId,
long referenceId)
Set an
AtomicCounter reference id for a counter id. |
void |
setCounterRegistrationId(int counterId,
long registrationId)
Set an
AtomicCounter registration id for a counter id with ordered memory ordering. |
void |
setCounterValue(int counterId,
long value)
Set an
AtomicCounter value based for a counter id with ordered memory ordering. |
String |
toString() |
allocate, capacity, newCounter, newCounter, newCounter, newCountercounterOffset, findByRegistrationId, findByTypeIdAndRegistrationId, forEach, forEach, forEach, getCounterLabel, getCounterOwnerId, getCounterReferenceId, getCounterRegistrationId, getCounterState, getCounterTypeId, getCounterValue, getFreeForReuseDeadline, labelCharset, maxCounterId, metaDataBuffer, metaDataOffset, validateCounterId, valuesBufferpublic ConcurrentCountersManager(AtomicBuffer metaDataBuffer, AtomicBuffer valuesBuffer)
Counter labels default to StandardCharsets.UTF_8.
metaDataBuffer - containing the counter metadata.valuesBuffer - containing the counter values.public ConcurrentCountersManager(AtomicBuffer metaDataBuffer, AtomicBuffer valuesBuffer, Charset labelCharset)
metaDataBuffer - containing the counter metadata.valuesBuffer - containing the counter values.labelCharset - for the label encoding.public ConcurrentCountersManager(AtomicBuffer metaDataBuffer, AtomicBuffer valuesBuffer, Charset labelCharset, EpochClock epochClock, long freeToReuseTimeoutMs)
metaDataBuffer - containing the types, keys, and labels for the counters.valuesBuffer - containing the values of the counters themselves.labelCharset - for the label encoding.epochClock - to use for determining time for keep counter from being reused after being freed.freeToReuseTimeoutMs - timeout (in milliseconds) to keep counter from being reused after being freed.public int available()
CountersManager.capacity() minus the number already
allocated.available in class CountersManagerpublic int allocate(String label, int typeId)
allocate in class CountersManagerlabel - to describe the counter.typeId - for the type of counter.public int allocate(String label, int typeId, Consumer<MutableDirectBuffer> keyFunc)
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 CountersManagerlabel - 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)
If the keyBuffer is null then a copy of the key is not attempted.
allocate in class CountersManagertypeId - 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)
free in class CountersManagercounterId - the counter to freedpublic void setCounterValue(int counterId,
long value)
AtomicCounter value based for a counter id with ordered memory ordering.setCounterValue in class CountersManagercounterId - to be set.value - to set for the counter.public void setCounterRegistrationId(int counterId,
long registrationId)
AtomicCounter registration id for a counter id with ordered memory ordering.setCounterRegistrationId in class CountersManagercounterId - to be set.registrationId - to set for the counter.public void setCounterOwnerId(int counterId,
long ownerId)
AtomicCounter owner id for a counter id.setCounterOwnerId in class CountersManagercounterId - to be set.ownerId - to set for the counter.public void setCounterReferenceId(int counterId,
long referenceId)
AtomicCounter reference id for a counter id.setCounterReferenceId in class CountersManagercounterId - to be set.referenceId - to set for the counter.public void setCounterLabel(int counterId,
String label)
AtomicCounter label by counter id.setCounterLabel in class CountersManagercounterId - to be set.label - to set for the counter.public void setCounterKey(int counterId,
Consumer<MutableDirectBuffer> keyFunc)
AtomicCounter key by on counter id, using a consumer callback to update the key metadata buffer.setCounterKey in class CountersManagercounterId - to be set.keyFunc - callback used to set the key.public void setCounterKey(int counterId,
DirectBuffer keyBuffer,
int offset,
int length)
AtomicCounter key by on counter id, copying the key metadata from the supplied buffer.setCounterKey in class CountersManagercounterId - to be set.keyBuffer - containing the updated key.offset - offset into buffer.length - length of data to copy.public void appendToLabel(int counterId,
String label)
AtomicCounter label based on counter id.appendToLabel in class CountersManagercounterId - to be set.label - to set for the counter.public String toString()
toString in class CountersManagerCopyright © 2014-2024 Real Logic Limited. All Rights Reserved.