Class CommandAckCollector


  • public class CommandAckCollector
    extends Object
    An acknowledge collector for Triangle algorithm used in non-transactional caches for write operations.

    Acknowledges are used between the owners and the originator. They signal the completion of a write operation. The operation can complete successfully or not.

    The acknowledges are valid on the same cache topology id. So, each acknowledge is tagged with the command topology id. Acknowledges from previous topology id are discarded.

    The acknowledges from the primary owner carry the return value of the operation.

    Since:
    9.0
    Author:
    Pedro Ruivo
    • Constructor Detail

      • CommandAckCollector

        public CommandAckCollector()
    • Method Detail

      • start

        public void start()
      • create

        public <T> Collector<T> create​(long id,
                                       Collection<Address> backupOwners,
                                       int topologyId)
        Creates a collector for a single key write operation.
        Parameters:
        id - the id from CommandInvocationId.
        backupOwners - the backup owners of the key.
        topologyId - the current topology id.
      • createBiased

        public BiasedCollector createBiased​(long id,
                                            int topologyId)
      • createSegmentBasedCollector

        public <T> Collector<T> createSegmentBasedCollector​(long id,
                                                            Map<Address,​Collection<Integer>> backups,
                                                            int topologyId)
        Creates a collector for PutMapCommand.
        Parameters:
        id - the id from CommandInvocationId.getId().
        backups - a map between a backup owner and its segments affected.
        topologyId - the current topology id.
      • multiKeyBackupAck

        public void multiKeyBackupAck​(long id,
                                      Address from,
                                      int segment,
                                      int topologyId)
        Acknowledges a PutMapCommand completion in the backup owner.
        Parameters:
        id - the id from CommandInvocationId.getId().
        from - the backup owner.
        segment - the segments affected and acknowledged.
        topologyId - the topology id.
      • backupAck

        public void backupAck​(long id,
                              Address from,
                              int topologyId)
        Acknowledges a write operation completion in the backup owner.
        Parameters:
        id - the id from CommandInvocationId.getId().
        from - the backup owner.
        topologyId - the topology id.
      • completeExceptionally

        public void completeExceptionally​(long id,
                                          Throwable throwable,
                                          int topologyId)
        Acknowledges an exception during the operation execution.

        The collector is completed without waiting any further acknowledges.

        Parameters:
        id - the id from CommandInvocationId.getId().
        throwable - the Throwable.
        topologyId - the topology id.
      • getPendingCommands

        public List<Long> getPendingCommands()
        Returns:
        the pending ids from CommandInvocationId.getId() (testing purposes only)
      • hasPendingBackupAcks

        public boolean hasPendingBackupAcks​(long id)
        Parameters:
        id - the id from CommandInvocationId.getId().
        Returns:
        true if there are acknowledges pending from the backup owners, false otherwise. (testing purposes only)
      • onMembersChange

        public void onMembersChange​(Collection<Address> members)
        Notifies a change in member list.
        Parameters:
        members - the new cluster members.