Class ExpectedAcksInfo

  • Direct Known Subclasses:
    SafeDataExpectedAcksInfo, SafeReadExpectedAcksInfo

    public abstract class ExpectedAcksInfo
    extends Object
    This class is the mother class for sub-classes holding any information needed about the acks that the replication server will wait for, when he receives an update message with the assured flag on (assured replication acknowledgments expected). It also includes info/routines for constructing the final ack to be sent to the sender of the update message. It is expected to have one sub-class per assured replication sub mode.
    • Field Detail

      • csn

        protected CSN csn
        The CSN of the assured update message we want acks for.
      • expectedServersAckStatus

        protected Map<Integer,​Boolean> expectedServersAckStatus
        This gives the list of servers we are willing to wait acks from and the information about the ack from the servers. key: the id of the server. value: a boolean true if we received the ack from the server, false otherwise.
      • serversInTimeout

        protected List<Integer> serversInTimeout
        Facility for monitoring: If the timeout occurs for the original update, we call createAck(true) in the timeout code for sending back an error ack to the original server. We use this call to also save the list of server ids for server we did not have time to receive an ack from. For updating its counters, the timeout code can then call getTimeoutServers() method to now which servers did not respond in time.
    • Constructor Detail

      • ExpectedAcksInfo

        protected ExpectedAcksInfo​(CSN csn,
                                   ServerHandler requesterServerHandler,
                                   AssuredMode assuredMode,
                                   List<Integer> expectedServers)
        Creates a new ExpectedAcksInfo.
        Parameters:
        csn - The CSN of the assured update message
        requesterServerHandler - The server handler of the server that sent the assured update message
        assuredMode - The assured mode requested by the assured update message
        expectedServers - The list of servers we want an ack from
    • Method Detail

      • isExpectedServer

        public boolean isExpectedServer​(int serverId)
        Indicates whether the provided server is one of the servers an ack is expected from for the matching update message. Reads an immutable snapshot taken at construction time, so it is safe to call without holding the lock on this object.
        Parameters:
        serverId - The serverId of the server.
        Returns:
        true if an ack is expected from the provided server.
      • getRequesterServer

        public ServerHandler getRequesterServer()
        Gets the server handler of the server which requested the acknowledgments.
        Returns:
        The server handler of the server which requested the acknowledgments.
      • getTimeoutServers

        public List<Integer> getTimeoutServers()
        Gets the list of expected servers that did not respond in time.
        Returns:
        The list of expected servers that did not respond in time.
      • getAssuredMode

        public AssuredMode getAssuredMode()
        Gets the requested assured mode for the matching update message.
        Returns:
        The requested assured mode for the matching update message.
      • processReceivedAck

        public abstract boolean processReceivedAck​(ServerHandler ackingServer,
                                                   AckMsg ackMsg)
        Process the received ack from a server we are waiting an ack from.
        Parameters:
        ackingServer - The server handler of the server that sent the ack
        ackMsg - The ack message to process
        Returns:
        True if the expected number of acks has just been reached
      • createAck

        public abstract AckMsg createAck​(boolean timeout)
        Creates the ack message to be returned to the requester server, taking into account the information in the received acks from every servers.
        Parameters:
        timeout - True if we call this method when the timeout occurred, that is we did not received every expected acks in time, and thus, the timeout flag should also be enabled in the returned ack message.
        Returns:
        The ack message ready to be sent to the requester server
      • isCompleted

        public boolean isCompleted()
        Has the treatment of this object been completed or not? If true is returned, one must not modify this object (useless) nor remove it from the map where it is stored (will be or has already been done by the other code (ack timeout code, or ack processing code)).
        Returns:
        True if treatment of this object has been completed.
      • completed

        public void completed()
        Signal that treatment of this object has been completed and that it is going to be removed from the map where it is stored.