pt.unl.fct.di.novasys.babel.crdts.delta.implementations

Class DeltaLWWRegister

  • All Implemented Interfaces:
    DeltaCRDT, GenericCRDT


    public class DeltaLWWRegister
    extends DeltaBasedCRDT
    A delta-based register with a last-writer-wins policy (LWW). It allows the assignment of the register and obtaining its value.
    • Field Detail

      • serializer

        public static pt.unl.fct.di.novasys.network.ISerializer<DeltaLWWRegister> serializer
        A serializer that serializes the CRDT into (and from) a ByteBuf.
    • Constructor Detail

      • DeltaLWWRegister

        public DeltaLWWRegister(ReplicaID replicaID)
        Creates a delta-based register by passing the replica identifier. The register is initialized as an empty string.
        Parameters:
        replicaID - replica identifier
      • DeltaLWWRegister

        public DeltaLWWRegister(ReplicaID replicaID,
                                String value)
        Creates a delta-based register with a default value, by passing the replica identifier. The register is initialized as an empty string.
        Parameters:
        replicaID - replica identifier
        value - the initial value of the register
      • DeltaLWWRegister

        public DeltaLWWRegister(VVState state)
        Creates a delta-based register by passing the replica current state. The register is initialized as an empty string.
        Parameters:
        state - replica current state
      • DeltaLWWRegister

        public DeltaLWWRegister(VVState state,
                                String value)
        Creates a delta-based register by passing the replica current state. The register is initialized with an initial value.
        Parameters:
        state - replica current state
        value - the initial value of the register
    • Method Detail

      • copy

        public GenericCRDT copy()
        Description copied from interface: GenericCRDT
        Creates a copy of the CRDT. Modifications on the copy don't modify the original.
        Returns:
        a copy of the CRDT
      • get

        public String get()
        Obtains the value of the register
        Returns:
        the value of the register
      • assign

        public DeltaLWWRegister assign(String value)
        Assigns a new value to the register
        Parameters:
        value - value to assign
        Returns:
        a delta with the operation
      • serialize

        public void serialize(io.netty.buffer.ByteBuf in)
                       throws IOException
        Description copied from interface: GenericCRDT
        Serializes the CRDT into a ByteBuf
        Parameters:
        in - ByteBuf to serialize the CRDT to
        Throws:
        IOException - if an error occurs while serializing

Copyright © 2024. All rights reserved.