Package org.jgroups.blocks.atomic
Class CounterService
- java.lang.Object
-
- org.jgroups.blocks.atomic.CounterService
-
public class CounterService extends java.lang.Object
Provides a distributed counter (similar to AtomicLong) which can be atomically updated across a cluster.- Since:
- 3.0.0
- Author:
- Bela Ban
-
-
Field Summary
Fields Modifier and Type Field Description protected COUNTER
counter_prot
-
Constructor Summary
Constructors Constructor Description CounterService(JChannel ch)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
deleteCounter(java.lang.String name)
Deletes a counter instance (on the coordinator)java.lang.String
dumpPendingRequests()
java.util.concurrent.CompletionStage<AsyncCounter>
getOrCreateAsyncCounter(java.lang.String name, long initial_value)
Returns an existing counter, or creates a new one if none existsCounter
getOrCreateCounter(java.lang.String name, long initial_value)
Deprecated.since 5.2.SyncCounter
getOrCreateSyncCounter(java.lang.String name, long initial_value)
java.lang.String
printCounters()
void
setChannel(JChannel ch)
-
-
-
Field Detail
-
counter_prot
protected COUNTER counter_prot
-
-
Constructor Detail
-
CounterService
public CounterService(JChannel ch)
-
-
Method Detail
-
setChannel
public void setChannel(JChannel ch)
-
getOrCreateCounter
@Deprecated public Counter getOrCreateCounter(java.lang.String name, long initial_value)
Deprecated.since 5.2. UsegetOrCreateSyncCounter(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 namesinitial_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(java.lang.String name, long initial_value)
-
getOrCreateAsyncCounter
public java.util.concurrent.CompletionStage<AsyncCounter> getOrCreateAsyncCounter(java.lang.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 namesinitial_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(java.lang.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 java.lang.String printCounters()
-
dumpPendingRequests
public java.lang.String dumpPendingRequests()
-
-