/** * Allocate a counter record and wrap it with a new {@link AtomicCounter} for use with a default type * of {@link #DEFAULT_TYPE_ID}. * * @param label to describe the counter. * @return a newly allocated {@link AtomicCounter} */ public AtomicCounter newCounter(final String label) { return new AtomicCounter(valuesBuffer, allocate(label), this); }
/** * Allocate a counter record and wrap it with a new {@link AtomicCounter} for use. * * @param label to describe the counter. * @param typeId for the type of counter. * @param keyFunc for setting the key value for the counter. * @return a newly allocated {@link AtomicCounter} */ public AtomicCounter newCounter(final String label, final int typeId, final Consumer<MutableDirectBuffer> keyFunc) { return new AtomicCounter(valuesBuffer, allocate(label, typeId, keyFunc), this); }
/** * Allocate a counter record and wrap it with a new {@link AtomicCounter} for use. * * @param label to describe the counter. * @param typeId for the type of counter. * @return a newly allocated {@link AtomicCounter} */ public AtomicCounter newCounter(final String label, final int typeId) { return new AtomicCounter(valuesBuffer, allocate(label, typeId), this); }
/** * Allocate a counter for tracking the last heartbeat of an entity. * * @param tempBuffer to be used for labels and key. * @param name of the counter for the label. * @param typeId of the counter for classification. * @param countersManager from which to allocated the underlying storage. * @param registrationId to be associated with the counter. * @return a new {@link AtomicCounter} for tracking the last heartbeat. */ public static AtomicCounter allocate( final MutableDirectBuffer tempBuffer, final String name, final int typeId, final CountersManager countersManager, final long registrationId) { return new AtomicCounter( countersManager.valuesBuffer(), allocateCounterId(tempBuffer, name, typeId, countersManager, registrationId), countersManager); }
/** * Allocate a per {@link io.aeron.driver.PublicationImage} indicator. * * @param tempBuffer to be used for labels and key. * @param name of the counter for the label. * @param countersManager from which to allocated the underlying storage. * @param registrationId to be associated with the counter. * @param sessionId for the stream of messages. * @param streamId for the stream of messages. * @param channel for the stream of messages. * @return a new {@link AtomicCounter} for tracking the indicator. */ public static AtomicCounter allocate( final MutableDirectBuffer tempBuffer, final String name, final CountersManager countersManager, final long registrationId, final int sessionId, final int streamId, final String channel) { final int counterId = StreamPositionCounter.allocateCounterId( tempBuffer, name, PER_IMAGE_TYPE_ID, countersManager, registrationId, sessionId, streamId, channel); return new AtomicCounter(countersManager.valuesBuffer(), counterId, countersManager); } }
private AtomicCounter awaitHeartbeatCounter(final CountersReader counters) { idleStrategy.reset(); int counterId = ServiceHeartbeat.findCounterId(counters, ctx.serviceId()); while (NULL_COUNTER_ID == counterId) { checkInterruptedStatus(); idleStrategy.idle(); counterId = ServiceHeartbeat.findCounterId(counters, ctx.serviceId()); } return new AtomicCounter(counters.valuesBuffer(), counterId); }
/** * Find the control toggle counter or return null if not found. * * @param counters to search for the control toggle. * @return the control toggle counter or return null if not found. */ public static AtomicCounter findControlToggle(final CountersReader counters) { final AtomicBuffer buffer = counters.metaDataBuffer(); for (int i = 0, size = counters.maxCounterId(); i < size; i++) { final int recordOffset = CountersReader.metaDataOffset(i); if (counters.getCounterState(i) == RECORD_ALLOCATED && buffer.getInt(recordOffset + TYPE_ID_OFFSET) == CONTROL_TOGGLE_TYPE_ID) { return new AtomicCounter(counters.valuesBuffer(), i, null); } } return null; }
final int labelLength) return new AtomicCounter( valuesBuffer, allocate(typeId, keyBuffer, keyOffset, keyLength, labelBuffer, labelOffset, labelLength),
/** * Allocate a counter record and wrap it with a new {@link AtomicCounter} for use. * * @param label to describe the counter. * @param typeId for the type of counter. * @return a newly allocated {@link AtomicCounter} */ public AtomicCounter newCounter(final String label, final int typeId) { return new AtomicCounter(valuesBuffer, allocate(label, typeId), this); }
/** * Allocate a counter record and wrap it with a new {@link AtomicCounter} for use with a default type * of {@link #DEFAULT_TYPE_ID}. * * @param label to describe the counter. * @return a newly allocated {@link AtomicCounter} */ public AtomicCounter newCounter(final String label) { return new AtomicCounter(valuesBuffer, allocate(label), this); }
/** * Allocate a counter record and wrap it with a new {@link AtomicCounter} for use. * * @param label to describe the counter. * @param typeId for the type of counter. * @param keyFunc for setting the key value for the counter. * @return a newly allocated {@link AtomicCounter} */ public AtomicCounter newCounter(final String label, final int typeId, final Consumer<MutableDirectBuffer> keyFunc) { return new AtomicCounter(valuesBuffer, allocate(label, typeId, keyFunc), this); }
/** * Allocate a counter record and wrap it with a new {@link AtomicCounter} for use. * * @param label to describe the counter. * @param typeId for the type of counter. * @param keyFunc for setting the key value for the counter. * * @return a newly allocated {@link AtomicCounter} */ public AtomicCounter newCounter(final String label, final int typeId, final Consumer<MutableDirectBuffer> keyFunc) { return new AtomicCounter(valuesBuffer, allocate(label, typeId, keyFunc), this); }
/** * Allocate a counter record and wrap it with a new {@link AtomicCounter} for use. * * @param label to describe the counter. * @return a newly allocated {@link AtomicCounter} */ public AtomicCounter newCounter(final String label) { return new AtomicCounter(valuesBuffer, allocate(label), this); }
public Metric( String name, String type, String description, Map<String, String> labels, Consumer<Metric> onClose) { this.onClose = onClose; this.value = new AtomicCounter(new UnsafeBuffer(new byte[BitUtil.SIZE_OF_LONG]), 0); this.name = name.getBytes(StandardCharsets.UTF_8); this.type = type.getBytes(StandardCharsets.UTF_8); this.description = description.getBytes(StandardCharsets.UTF_8); this.labels = new Label[labels.size()]; final List<Entry<String, String>> labelSet = new ArrayList<>(labels.entrySet()); for (int i = 0; i < labelSet.size(); i++) { final Entry<String, String> entry = labelSet.get(i); this.labels[i] = new Label(entry.getKey(), entry.getValue()); } }
public Metric( String name, String type, String description, Map<String, String> labels, Consumer<Metric> onClose) { this.onClose = onClose; this.value = new AtomicCounter(new UnsafeBuffer(new byte[BitUtil.SIZE_OF_LONG]), 0); this.name = name.getBytes(StandardCharsets.UTF_8); this.type = type.getBytes(StandardCharsets.UTF_8); this.description = description.getBytes(StandardCharsets.UTF_8); this.labels = new Label[labels.size()]; final List<Entry<String, String>> labelSet = new ArrayList<>(labels.entrySet()); for (int i = 0; i < labelSet.size(); i++) { final Entry<String, String> entry = labelSet.get(i); this.labels[i] = new Label(entry.getKey(), entry.getValue()); } }
/** * Allocate a counter for tracking the last heartbeat of an entity. * * @param tempBuffer to be used for labels and key. * @param name of the counter for the label. * @param typeId of the counter for classification. * @param countersManager from which to allocated the underlying storage. * @param registrationId to be associated with the counter. * @return a new {@link AtomicCounter} for tracking the last heartbeat. */ public static AtomicCounter allocate( final MutableDirectBuffer tempBuffer, final String name, final int typeId, final CountersManager countersManager, final long registrationId) { return new AtomicCounter( countersManager.valuesBuffer(), allocateCounterId(tempBuffer, name, typeId, countersManager, registrationId), countersManager); }
/** * Allocate a counter for tracking the last heartbeat of an entity. * * @param tempBuffer to be used for labels and key. * @param name of the counter for the label. * @param typeId of the counter for classification. * @param countersManager from which to allocated the underlying storage. * @param registrationId to be associated with the counter. * @return a new {@link AtomicCounter} for tracking the last heartbeat. */ public static AtomicCounter allocate( final MutableDirectBuffer tempBuffer, final String name, final int typeId, final CountersManager countersManager, final long registrationId) { return new AtomicCounter( countersManager.valuesBuffer(), allocateCounterId(tempBuffer, name, typeId, countersManager, registrationId), countersManager); }
/** * Allocate a per {@link io.aeron.driver.PublicationImage} indicator. * * @param tempBuffer to be used for labels and key. * @param name of the counter for the label. * @param countersManager from which to allocated the underlying storage. * @param registrationId to be associated with the counter. * @param sessionId for the stream of messages. * @param streamId for the stream of messages. * @param channel for the stream of messages. * @return a new {@link AtomicCounter} for tracking the indicator. */ public static AtomicCounter allocate( final MutableDirectBuffer tempBuffer, final String name, final CountersManager countersManager, final long registrationId, final int sessionId, final int streamId, final String channel) { final int counterId = StreamPositionCounter.allocateCounterId( tempBuffer, name, PER_IMAGE_TYPE_ID, countersManager, registrationId, sessionId, streamId, channel); return new AtomicCounter(countersManager.valuesBuffer(), counterId, countersManager); } }
/** * Find the control toggle counter or return null if not found. * * @param counters to search for the control toggle. * @return the control toggle counter or return null if not found. */ public static AtomicCounter findControlToggle(final CountersReader counters) { final AtomicBuffer buffer = counters.metaDataBuffer(); for (int i = 0, size = counters.maxCounterId(); i < size; i++) { final int recordOffset = CountersReader.metaDataOffset(i); if (counters.getCounterState(i) == RECORD_ALLOCATED && buffer.getInt(recordOffset + TYPE_ID_OFFSET) == CONTROL_TOGGLE_TYPE_ID) { return new AtomicCounter(counters.valuesBuffer(), i, null); } } return null; }
private AtomicCounter awaitHeartbeatCounter(final CountersReader counters) { idleStrategy.reset(); int counterId = ServiceHeartbeat.findCounterId(counters, ctx.serviceId()); while (NULL_COUNTER_ID == counterId) { checkInterruptedStatus(); idleStrategy.idle(); counterId = ServiceHeartbeat.findCounterId(counters, ctx.serviceId()); } return new AtomicCounter(counters.valuesBuffer(), counterId); }