Class ClusterCounters

java.lang.Object
io.aeron.cluster.service.ClusterCounters

public final class ClusterCounters extends Object
For allocating and finding cluster associated counters identified by ClusteredServiceContainer.Context.clusterId().
  • Field Details

    • CLUSTER_ID_LABEL_SUFFIX

      public static final String CLUSTER_ID_LABEL_SUFFIX
      Suffix for `clusterId` in the counter label.
      See Also:
  • Method Details

    • allocate

      public static Counter allocate(Aeron aeron, MutableDirectBuffer tempBuffer, String name, int typeId, int clusterId)
      Allocate a counter to represent component state within a cluster.
      Parameters:
      aeron - to allocate the counter.
      tempBuffer - temporary storage to create label and metadata.
      name - of the counter for the label.
      typeId - for the counter.
      clusterId - to which the allocated counter belongs.
      Returns:
      the new Counter.
    • allocateVersioned

      public static Counter allocateVersioned(Aeron aeron, MutableDirectBuffer tempBuffer, String name, int typeId, int clusterId, String version, String commitHashCode)
      Allocate a counter to represent component state within a cluster and append a version info to its label.
      Parameters:
      aeron - to allocate the counter.
      tempBuffer - temporary storage to create label and metadata.
      name - of the counter for the label.
      typeId - for the counter.
      clusterId - to which the allocated counter belongs.
      version - of the component.
      commitHashCode - Git commit SHA of the component.
      Returns:
      the new Counter.
    • find

      public static int find(CountersReader counters, int typeId, int clusterId)
      Find the counter id for a type of counter in a cluster.
      Parameters:
      counters - to search within.
      typeId - of the counter.
      clusterId - to which the allocated counter belongs.
      Returns:
      the matching counter id or Aeron.NULL_VALUE if not found.
    • allocateServiceCounter

      public static Counter allocateServiceCounter(Aeron aeron, MutableDirectBuffer tempBuffer, String name, int typeId, int clusterId, int serviceId)
      Allocate a counter to represent component state within a cluster.
      Parameters:
      aeron - to allocate the counter.
      tempBuffer - temporary storage to create label and metadata.
      name - of the counter for the label.
      typeId - for the counter.
      clusterId - to which the allocated counter belongs.
      serviceId - to which the allocated counter belongs.
      Returns:
      the Counter for the commit position.