/** * Get the label for a given counter id. * * @param counterId to be read. * @return the label for the given counter id. */ public String getCounterLabel(final int counterId) { validateCounterId(counterId); return labelValue(metaDataOffset(counterId)); }
/** * Iterate over all labels in the label buffer. * * @param consumer function to be called for each label. */ public void forEach(final IntObjConsumer<String> consumer) { int counterId = 0; for (int i = 0, capacity = metaDataBuffer.capacity(); i < capacity; i += METADATA_LENGTH) { final int recordStatus = metaDataBuffer.getIntVolatile(i); if (RECORD_ALLOCATED == recordStatus) { consumer.accept(counterId, labelValue(i)); } else if (RECORD_UNUSED == recordStatus) { break; } counterId++; } }
/** * Iterate over the counters and provide the value and basic metadata. * * @param consumer for each allocated counter. */ public void forEach(final CounterConsumer consumer) { int counterId = 0; for (int i = 0, capacity = metaDataBuffer.capacity(); i < capacity; i += METADATA_LENGTH) { final int recordStatus = metaDataBuffer.getIntVolatile(i); if (RECORD_ALLOCATED == recordStatus) { consumer.accept(valuesBuffer.getLongVolatile(counterOffset(counterId)), counterId, labelValue(i)); } else if (RECORD_UNUSED == recordStatus) { break; } counterId++; } }
/** * Iterate over all the metadata in the buffer. * * @param metaData function to be called for each metadata record. */ public void forEach(final MetaData metaData) { int counterId = 0; for (int i = 0, capacity = metaDataBuffer.capacity(); i < capacity; i += METADATA_LENGTH) { final int recordStatus = metaDataBuffer.getIntVolatile(i); if (RECORD_ALLOCATED == recordStatus) { final int typeId = metaDataBuffer.getInt(i + TYPE_ID_OFFSET); final String label = labelValue(i); final DirectBuffer keyBuffer = new UnsafeBuffer(metaDataBuffer, i + KEY_OFFSET, MAX_KEY_LENGTH); metaData.accept(counterId, typeId, keyBuffer, label); } else if (RECORD_UNUSED == recordStatus) { break; } counterId++; } }
/** * Get the label for a given counter id. * * @param counterId to be read. * @return the label for the given counter id. */ public String getCounterLabel(final int counterId) { validateCounterId(counterId); return labelValue(metaDataOffset(counterId)); }
/** * Iterate over all labels in the label buffer. * * @param consumer function to be called for each label. */ public void forEach(final IntObjConsumer<String> consumer) { int counterId = 0; for (int i = 0, capacity = metaDataBuffer.capacity(); i < capacity; i += METADATA_LENGTH) { final int recordStatus = metaDataBuffer.getIntVolatile(i); if (RECORD_ALLOCATED == recordStatus) { consumer.accept(counterId, labelValue(i)); } else if (RECORD_UNUSED == recordStatus) { break; } counterId++; } }
/** * Iterate over the counters and provide the value and basic metadata. * * @param consumer for each allocated counter. */ public void forEach(final CounterConsumer consumer) { int counterId = 0; for (int i = 0, capacity = metaDataBuffer.capacity(); i < capacity; i += METADATA_LENGTH) { final int recordStatus = metaDataBuffer.getIntVolatile(i); if (RECORD_ALLOCATED == recordStatus) { consumer.accept(valuesBuffer.getLongVolatile(counterOffset(counterId)), counterId, labelValue(i)); } else if (RECORD_UNUSED == recordStatus) { break; } counterId++; } }
/** * Iterate over all the metadata in the buffer. * * @param metaData function to be called for each metadata record. */ public void forEach(final MetaData metaData) { int counterId = 0; for (int i = 0, capacity = metaDataBuffer.capacity(); i < capacity; i += METADATA_LENGTH) { final int recordStatus = metaDataBuffer.getIntVolatile(i); if (RECORD_ALLOCATED == recordStatus) { final int typeId = metaDataBuffer.getInt(i + TYPE_ID_OFFSET); final String label = labelValue(i); final DirectBuffer keyBuffer = new UnsafeBuffer(metaDataBuffer, i + KEY_OFFSET, MAX_KEY_LENGTH); metaData.accept(counterId, typeId, keyBuffer, label); } else if (RECORD_UNUSED == recordStatus) { break; } counterId++; } }