Class CounterService

java.lang.Object
org.jgroups.blocks.atomic.CounterService

public class CounterService extends Object
Provides a distributed counter (similar to AtomicLong) which can be atomically updated across a cluster.
Since:
3.0.0
  • Field Details

    • counter_prot

      protected COUNTER counter_prot
  • Constructor Details

    • CounterService

      public CounterService(JChannel ch)
  • Method Details

    • setChannel

      public void setChannel(JChannel ch)
    • getOrCreateCounter

      @Deprecated public Counter getOrCreateCounter(String name, long initial_value)
      Deprecated.
      since 5.2. Use getOrCreateSyncCounter(String, long) instead.
      Returns an existing counter, or creates a new one if none exists
      Parameters:
      name - Name of the counter, different counters have to have different names
      initial_value - The initial value of a new counter if there is no existing counter. Ignored if the counter already exists
      Returns:
      The counter implementation
    • getOrCreateSyncCounter

      public SyncCounter getOrCreateSyncCounter(String name, long initial_value)
    • getOrCreateAsyncCounter

      public CompletionStage<AsyncCounter> getOrCreateAsyncCounter(String name, long initial_value)
      Returns an existing counter, or creates a new one if none exists
      Parameters:
      name - Name of the counter, different counters have to have different names
      initial_value - The initial value of a new counter if there is no existing counter. Ignored if the counter already exists
      Returns:
      A CompletionStage which is completed with the counter implementation.
    • deleteCounter

      public void deleteCounter(String name)
      Deletes a counter instance (on the coordinator)
      Parameters:
      name - The name of the counter. No-op if the counter doesn't exist
    • printCounters

      public String printCounters()
    • dumpPendingRequests

      public String dumpPendingRequests()