Class ReplicaOfflineMsg

  • All Implemented Interfaces:
    Comparable<UpdateMsg>

    public class ReplicaOfflineMsg
    extends UpdateMsg
    Class that define messages sent by a replica (DS) to the replication server (RS) to let the RS know the date at which a replica went offline.
    • Constructor Detail

      • ReplicaOfflineMsg

        public ReplicaOfflineMsg​(CSN offlineCSN)
        Constructor of a replica offline message providing the offline timestamp in a CSN.
        Parameters:
        offlineCSN - the provided offline CSN
      • ReplicaOfflineMsg

        public ReplicaOfflineMsg​(byte[] in)
                          throws DataFormatException
        Creates a message by deserializing it from the provided byte array.
        Parameters:
        in - The provided byte array.
        Throws:
        DataFormatException - When an error occurs during decoding .
    • Method Detail

      • 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.
        Overrides:
        getBytes in class UpdateMsg
        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.
      • isEncodableFor

        public boolean isEncodableFor​(short protocolVersion)
        Whether this message has an encoding for a peer which negotiated the provided replication protocol version.

        A message which has none is dropped by Session.publish(ReplicationMsg) - its ReplicationMsg.getBytes(short) returns null - with nothing on the wire and nothing in the log, so a caller which goes on to report what the peer was told must ask this before it publishes.

        Overrides:
        isEncodableFor in class ReplicationMsg
        Parameters:
        protocolVersion - The protocol version negotiated with the peer.
        Returns:
        true if this message can be encoded for that version, false if it has no encoding for it at all.
      • isSupportedBy

        public static boolean isSupportedBy​(short protocolVersion)
        Whether a peer which negotiated the provided replication protocol version can be sent this message at all.

        The message was introduced by ProtocolVersion.REPLICATION_PROTOCOL_V8 and has no encoding below it: an older peer is not told that the replica went offline, and cannot be. This answers for the message type, for a caller which has no instance at hand - see isEncodableFor(short) for the one which has.

        Parameters:
        protocolVersion - The protocol version negotiated with the peer.
        Returns:
        true if that version carries this message, false otherwise.
      • size

        public int size()
        Return the number of bytes used by this message.
        Overrides:
        size in class UpdateMsg
        Returns:
        The number of bytes used by this message.
      • contributesToDomainState

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