Class CRDT


  • public final class CRDT
    extends Object
    Conflict-free Replicated Data Types (CRDT)s. Unless otherwise noted, the implementations of these interfaces are not thread-safe since they are expected to be used within a thread-safe process, and sent across a network to another thread-safe process where they will be merged together.
    Author:
    Randall Hauch
    • Constructor Detail

      • CRDT

        private CRDT()
    • Method Detail

      • newGCounter

        public static GCounter newGCounter()
        Create a new CRDT grow-only (G) counter. The operations on this counter are not threadsafe.
        Returns:
        the new counter; never null
      • newGCounter

        public static GCounter newGCounter​(long adds)
        Create a new CRDT grow-only (G) counter pre-populated with the given value. The operations on this counter are not threadsafe.
        Parameters:
        adds - the number of adds
        Returns:
        the new counter; never null
      • newPNCounter

        public static PNCounter newPNCounter()
        Create a new CRDT positive and negative (PN) counter. The operations on this counter are not threadsafe.
        Returns:
        the new counter; never null
      • newPNCounter

        public static PNCounter newPNCounter​(long adds,
                                             long removes)
        Create a new CRDT positive and negative (PN) counter pre-populated with the given values. The operations on this counter are not threadsafe.
        Parameters:
        adds - the number of adds
        removes - the number of removes
        Returns:
        the new counter; never null
      • newDeltaCounter

        public static DeltaCounter newDeltaCounter()
        Create a new CRDT positive and negative (PN) counter that records how much the value has changed since last reset. The operations on this counter are not threadsafe.
        Returns:
        the new counter; never null
      • newDeltaCounter

        public static DeltaCounter newDeltaCounter​(long totalAdds,
                                                   long totalRemoves,
                                                   long recentAdds,
                                                   long recentRemoves)
        Create a new CRDT positive and negative (PN) counter that records how much the value has changed since last reset. The operations on this counter are not threadsafe.
        Parameters:
        totalAdds - the total number of adds
        totalRemoves - the total number of removes
        recentAdds - the recent number of adds since last DeltaCounter.reset()
        recentRemoves - the recent number of removes since last DeltaCounter.reset()
        Returns:
        the new counter; never null
      • newDeltaCounter

        public static DeltaCounter newDeltaCounter​(DeltaCount count)
        Create a new CRDT positive and negative (PN) counter that records how much the value has changed since last reset. The operations on this counter are not threadsafe.
        Parameters:
        count - the DeltaCount instance that should be used to pre-populate the new counter; may be null
        Returns:
        the new counter; never null