Class UpdateMsg

    • Field Detail

      • protocolVersion

        protected short protocolVersion
        Protocol version.
      • csn

        protected CSN csn
        The CSN of this update.
      • assuredFlag

        protected boolean assuredFlag
        True when the update must use assured replication.
      • assuredMode

        protected AssuredMode assuredMode
        When assuredFlag is true, defines the requested assured mode.
      • safeDataLevel

        protected byte safeDataLevel
        When assured mode is safe data, gives the requested level.
    • Constructor Detail

      • UpdateMsg

        protected UpdateMsg()
        Creates a new empty UpdateMsg.
      • UpdateMsg

        public UpdateMsg​(CSN csn,
                         byte[] payload)
        Creates a new UpdateMsg with the given informations.

        This constructor is only used for testing.

        Parameters:
        csn - The CSN associated with the change encoded in this message.
        payload - The payload that must be encoded in this message.
    • Method Detail

      • getCSN

        public CSN getCSN()
        Get the CSN from the message.
        Returns:
        the CSN
      • isAssured

        public boolean isAssured()
        Get a boolean indicating if the Update must be processed as an Asynchronous or as an assured replication.
        Returns:
        Returns the assuredFlag.
      • setAssured

        public void setAssured​(boolean assured)
        Set the Update message as an assured message.
        Parameters:
        assured - If the message is assured or not. Using true implies setAssuredMode method must be called.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getAssuredMode

        public AssuredMode getAssuredMode()
        Get the assured mode in this message.
        Returns:
        The assured mode in this message
      • getSafeDataLevel

        public byte getSafeDataLevel()
        Get the safe data level in this message.
        Returns:
        The safe data level in this message
      • setAssuredMode

        public void setAssuredMode​(AssuredMode assuredMode)
        Set the assured mode. Assured boolean must be set to true for this field to mean something.
        Parameters:
        assuredMode - The chosen assured mode.
      • setSafeDataLevel

        public void setSafeDataLevel​(byte safeDataLevel)
        Set the safe data level. Assured mode should be set to safe data for this field to mean something.
        Parameters:
        safeDataLevel - The chosen safe data level.
      • getVersion

        public short getVersion()
        Get the version included in the update message. Means the replication protocol version with which this update message was instantiated.
        Returns:
        The version with which this update message was instantiated.
      • size

        public int size()
        Return the number of bytes used by this message.
        Returns:
        The number of bytes used by this message.
      • encodeHeader

        protected ByteArrayBuilder encodeHeader​(byte msgType,
                                                short protocolVersion)
        Encode the common header for all the UpdateMsg. This uses the current protocol version.
        Parameters:
        msgType - The type of UpdateMsg to encode.
        protocolVersion - The ProtocolVersion to use when encoding.
        Returns:
        a byte array builder containing the common header
      • decodeHeader

        protected void decodeHeader​(byte allowedType,
                                    ByteArrayScanner scanner)
                             throws DataFormatException
        Decode the Header part of this Update message, and check its type.
        Parameters:
        allowedType - The allowed type of this Update Message.
        scanner - The encoded form of the UpdateMsg.
        Throws:
        DataFormatException - if the scanner does not contain a valid common header.
      • getBytes

        public byte[] getBytes()
        Returns the encoded representation of this update message using the current protocol version.
        Returns:
        The encoded representation of this update message.
      • getBytes

        public byte[] getBytes​(short protocolVersion)
        This implementation is only called during unit testing, so we are free to force the protocol version. Underlying implementations override this method in order to provide version specific encodings. Serializes the PDU using the provided replication protocol version. WARNING: should be overwritten by a PDU (sub class) we want to support older protocol version serialization for.
        Specified by:
        getBytes in class ReplicationMsg
        Parameters:
        protocolVersion - The protocol version to use for serialization. The version should normally be older than the current one.
        Returns:
        The encoded PDU, or null if the message isn't supported in that protocol version.
      • getPayload

        public byte[] getPayload()
        Get the payload of the UpdateMsg.
        Returns:
        The payload of the UpdateMsg.
      • contributesToDomainState

        public boolean contributesToDomainState()
        Whether the current message can update the "ds-sync-state" attribute.
        Returns:
        true if current message can update the "ds-sync-state" attribute, false otherwise.