Class TriangleDistributionInterceptor

  • All Implemented Interfaces:
    Visitor, AsyncInterceptor

    public class TriangleDistributionInterceptor
    extends BaseDistributionInterceptor
    Non-transactional interceptor used by distributed caches that supports concurrent writes.

    It is implemented based on the Triangle algorithm.

    The GetKeyValueCommand reads the value locally if it is available (the node is an owner or the value is stored in L1). If it isn't available, a remote request is made. The DataWriteCommand is performed as follow:

    • The command if forwarded to the primary owner of the key.
    • The primary owner locks the key and executes the operation; sends the BackupWriteCommand to the backup owners; releases the lock; sends the SuccessfulResponse or UnsuccessfulResponse back to the originator.
    • The backup owner applies the update and sends a BackupAckCommand back to the originator.
    • The originator collects the ack from all the owners and returns.
    The PutMapCommand is performed in a similar way:
    • The subset of the map is split by primary owner.
    • The primary owner locks the key and executes the command; splits the keys by backup owner and send them; and replies to the originator.
    • The backup owner applies the update and sends back the BackupMultiKeyAckCommand to the originator.
    • The originator collects all the acknowledges from all owners and returns.
    The acknowledges management is done by the CommandAckCollector.

    If a topology changes while a command is executed, an OutdatedTopologyException is thrown. The StateTransferInterceptor will catch it and retries the command.

    TODO: finish the wiki page and add a link to it!

    Since:
    9.0
    Author:
    Pedro Ruivo