Class TriangleDistributionInterceptor

  • All Implemented Interfaces:
    org.infinispan.commands.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
    • Constructor Detail

      • TriangleDistributionInterceptor

        public TriangleDistributionInterceptor()
    • Method Detail

      • start

        public void start()
      • visitPutKeyValueCommand

        public java.lang.Object visitPutKeyValueCommand​(InvocationContext ctx,
                                                        org.infinispan.commands.write.PutKeyValueCommand command)
                                                 throws java.lang.Throwable
        Specified by:
        visitPutKeyValueCommand in interface org.infinispan.commands.Visitor
        Overrides:
        visitPutKeyValueCommand in class DDAsyncInterceptor
        Throws:
        java.lang.Throwable
      • visitRemoveCommand

        public java.lang.Object visitRemoveCommand​(InvocationContext ctx,
                                                   org.infinispan.commands.write.RemoveCommand command)
                                            throws java.lang.Throwable
        Specified by:
        visitRemoveCommand in interface org.infinispan.commands.Visitor
        Overrides:
        visitRemoveCommand in class DDAsyncInterceptor
        Throws:
        java.lang.Throwable
      • visitReplaceCommand

        public java.lang.Object visitReplaceCommand​(InvocationContext ctx,
                                                    org.infinispan.commands.write.ReplaceCommand command)
                                             throws java.lang.Throwable
        Specified by:
        visitReplaceCommand in interface org.infinispan.commands.Visitor
        Overrides:
        visitReplaceCommand in class DDAsyncInterceptor
        Throws:
        java.lang.Throwable
      • visitComputeCommand

        public java.lang.Object visitComputeCommand​(InvocationContext ctx,
                                                    org.infinispan.commands.write.ComputeCommand command)
                                             throws java.lang.Throwable
        Specified by:
        visitComputeCommand in interface org.infinispan.commands.Visitor
        Overrides:
        visitComputeCommand in class DDAsyncInterceptor
        Throws:
        java.lang.Throwable
      • visitComputeIfAbsentCommand

        public java.lang.Object visitComputeIfAbsentCommand​(InvocationContext ctx,
                                                            org.infinispan.commands.write.ComputeIfAbsentCommand command)
                                                     throws java.lang.Throwable
        Specified by:
        visitComputeIfAbsentCommand in interface org.infinispan.commands.Visitor
        Overrides:
        visitComputeIfAbsentCommand in class DDAsyncInterceptor
        Throws:
        java.lang.Throwable
      • visitReadWriteKeyValueCommand

        public java.lang.Object visitReadWriteKeyValueCommand​(InvocationContext ctx,
                                                              org.infinispan.commands.functional.ReadWriteKeyValueCommand command)
                                                       throws java.lang.Throwable
        Specified by:
        visitReadWriteKeyValueCommand in interface org.infinispan.commands.Visitor
        Overrides:
        visitReadWriteKeyValueCommand in class DDAsyncInterceptor
        Throws:
        java.lang.Throwable
      • visitReadWriteKeyCommand

        public java.lang.Object visitReadWriteKeyCommand​(InvocationContext ctx,
                                                         org.infinispan.commands.functional.ReadWriteKeyCommand command)
                                                  throws java.lang.Throwable
        Specified by:
        visitReadWriteKeyCommand in interface org.infinispan.commands.Visitor
        Overrides:
        visitReadWriteKeyCommand in class DDAsyncInterceptor
        Throws:
        java.lang.Throwable
      • visitWriteOnlyKeyValueCommand

        public java.lang.Object visitWriteOnlyKeyValueCommand​(InvocationContext ctx,
                                                              org.infinispan.commands.functional.WriteOnlyKeyValueCommand command)
                                                       throws java.lang.Throwable
        Specified by:
        visitWriteOnlyKeyValueCommand in interface org.infinispan.commands.Visitor
        Overrides:
        visitWriteOnlyKeyValueCommand in class DDAsyncInterceptor
        Throws:
        java.lang.Throwable
      • visitWriteOnlyKeyCommand

        public java.lang.Object visitWriteOnlyKeyCommand​(InvocationContext ctx,
                                                         org.infinispan.commands.functional.WriteOnlyKeyCommand command)
                                                  throws java.lang.Throwable
        Specified by:
        visitWriteOnlyKeyCommand in interface org.infinispan.commands.Visitor
        Overrides:
        visitWriteOnlyKeyCommand in class DDAsyncInterceptor
        Throws:
        java.lang.Throwable
      • visitPutMapCommand

        public java.lang.Object visitPutMapCommand​(InvocationContext ctx,
                                                   org.infinispan.commands.write.PutMapCommand command)
                                            throws java.lang.Throwable
        Specified by:
        visitPutMapCommand in interface org.infinispan.commands.Visitor
        Overrides:
        visitPutMapCommand in class DDAsyncInterceptor
        Throws:
        java.lang.Throwable
      • visitWriteOnlyManyEntriesCommand

        public java.lang.Object visitWriteOnlyManyEntriesCommand​(InvocationContext ctx,
                                                                 org.infinispan.commands.functional.WriteOnlyManyEntriesCommand command)
        Specified by:
        visitWriteOnlyManyEntriesCommand in interface org.infinispan.commands.Visitor
        Overrides:
        visitWriteOnlyManyEntriesCommand in class DDAsyncInterceptor
      • visitWriteOnlyManyCommand

        public java.lang.Object visitWriteOnlyManyCommand​(InvocationContext ctx,
                                                          org.infinispan.commands.functional.WriteOnlyManyCommand command)
        Specified by:
        visitWriteOnlyManyCommand in interface org.infinispan.commands.Visitor
        Overrides:
        visitWriteOnlyManyCommand in class DDAsyncInterceptor
      • visitReadWriteManyCommand

        public java.lang.Object visitReadWriteManyCommand​(InvocationContext ctx,
                                                          org.infinispan.commands.functional.ReadWriteManyCommand command)
                                                   throws java.lang.Throwable
        Specified by:
        visitReadWriteManyCommand in interface org.infinispan.commands.Visitor
        Overrides:
        visitReadWriteManyCommand in class DDAsyncInterceptor
        Throws:
        java.lang.Throwable
      • visitReadWriteManyEntriesCommand

        public java.lang.Object visitReadWriteManyEntriesCommand​(InvocationContext ctx,
                                                                 org.infinispan.commands.functional.ReadWriteManyEntriesCommand command)
                                                          throws java.lang.Throwable
        Specified by:
        visitReadWriteManyEntriesCommand in interface org.infinispan.commands.Visitor
        Overrides:
        visitReadWriteManyEntriesCommand in class DDAsyncInterceptor
        Throws:
        java.lang.Throwable