Class CrdtManager
java.lang.Object
com.loomcache.server.datastructures.crdt.CrdtManager
Manager for CRDT instances across the distributed cache.
The CrdtManager maintains a registry of all CRDT instances and handles merge operations during replication. It tracks statistics about CRDT usage and manages convergence of state across replicas.
Key responsibilities:
- Registry for all CRDT instances
- Tracking CRDT types and instance counts
- Handling merge operations during replication
- Collecting and reporting statistics
- Since:
- 1.3
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<E> @Nullable GSet<E> Get a registered G-Set.intGet the number of registered CRDT instances.<V> @Nullable LWWRegister<V> getLWWRegister(String name) Get a registered LWW-Register.<E> @Nullable ORSet<E> Get a registered OR-Set.@Nullable PNCountergetPNCounter(String name) Get a registered PN-Counter.getStats()Get current statistics about CRDT usage.longGet the total number of merge operations performed.voidIncrement the merge counter (called by replication logic).<E> voidregisterGSet(String name, GSet<E> set) Register a G-Set instance.<V> voidregisterLWWRegister(String name, LWWRegister<V> register) Register an LWW-Register instance.<E> voidregisterORSet(String name, ORSet<E> set) Register an OR-Set instance.voidregisterPNCounter(String name, PNCounter counter) Register a PN-Counter instance.voidreset()Clear all registered CRDT instances.
-
Constructor Details
-
CrdtManager
-
-
Method Details
-
registerPNCounter
Register a PN-Counter instance.- Parameters:
name- the unique name of the CRDT instancecounter- the PN-Counter instance- Throws:
IllegalArgumentException- if name already exists
-
getPNCounter
-
registerGSet
Register a G-Set instance.- Parameters:
name- the unique name of the CRDT instanceset- the G-Set instance- Throws:
IllegalArgumentException- if name already exists
-
getGSet
-
registerORSet
Register an OR-Set instance.- Parameters:
name- the unique name of the CRDT instanceset- the OR-Set instance- Throws:
IllegalArgumentException- if name already exists
-
getORSet
-
registerLWWRegister
Register an LWW-Register instance.- Parameters:
name- the unique name of the CRDT instanceregister- the LWW-Register instance- Throws:
IllegalArgumentException- if name already exists
-
getLWWRegister
Get a registered LWW-Register.- Parameters:
name- the name of the CRDT instance- Returns:
- the LWW-Register, or null if not found
-
getInstanceCount
public int getInstanceCount()Get the number of registered CRDT instances.- Returns:
- the total number of instances
-
getTotalMerges
public long getTotalMerges()Get the total number of merge operations performed.- Returns:
- the merge count
-
recordMerge
public void recordMerge()Increment the merge counter (called by replication logic). -
getStats
Get current statistics about CRDT usage.- Returns:
- a CrdtStats record with usage information
-
reset
public void reset()Clear all registered CRDT instances.
-