Class TriangleDistributionInterceptor
java.lang.Object
org.infinispan.interceptors.BaseAsyncInterceptor
org.infinispan.interceptors.DDAsyncInterceptor
org.infinispan.interceptors.impl.BaseRpcInterceptor
org.infinispan.interceptors.impl.ClusteringInterceptor
org.infinispan.interceptors.distribution.BaseDistributionInterceptor
org.infinispan.interceptors.distribution.TriangleDistributionInterceptor
- All Implemented Interfaces:
Visitor,AsyncInterceptor
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
BackupWriteCommandto the backup owners; releases the lock; sends theSuccessfulResponseorUnsuccessfulResponseback to the originator. - The backup owner applies the update and sends a
BackupAckCommandback to the originator. - The originator collects the ack from all the owners and returns.
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
BackupMultiKeyAckCommandto the originator. - The originator collects all the acknowledges from all owners and returns.
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
-
Nested Class Summary
Nested classes/interfaces inherited from class org.infinispan.interceptors.distribution.BaseDistributionInterceptor
BaseDistributionInterceptor.ReadManyCommandHelper<C extends VisitableCommand>, BaseDistributionInterceptor.ReadOnlyManyHelperNested classes/interfaces inherited from class org.infinispan.interceptors.impl.ClusteringInterceptor
ClusteringInterceptor.ClusteredGetAllFuture -
Field Summary
Fields inherited from class org.infinispan.interceptors.distribution.BaseDistributionInterceptor
expirationManager, isL1Enabled, isReplicated, keyPartitioner, rvrl, timeServiceFields inherited from class org.infinispan.interceptors.impl.ClusteringInterceptor
cf, dataContainer, distributionManager, entryFactory, lockManagerFields inherited from class org.infinispan.interceptors.impl.BaseRpcInterceptor
componentRegistry, defaultSynchronous, rpcManagerFields inherited from class org.infinispan.interceptors.BaseAsyncInterceptor
cacheConfiguration -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidstart()visitComputeCommand(InvocationContext ctx, ComputeCommand command) visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) visitPutMapCommand(InvocationContext ctx, PutMapCommand command) visitReadWriteKeyCommand(InvocationContext ctx, ReadWriteKeyCommand command) visitReadWriteManyCommand(InvocationContext ctx, ReadWriteManyCommand command) visitRemoveCommand(InvocationContext ctx, RemoveCommand command) visitReplaceCommand(InvocationContext ctx, ReplaceCommand command) visitWriteOnlyKeyCommand(InvocationContext ctx, WriteOnlyKeyCommand command) visitWriteOnlyManyCommand(InvocationContext ctx, WriteOnlyManyCommand command) Methods inherited from class org.infinispan.interceptors.distribution.BaseDistributionInterceptor
configure, getLog, handleFunctionalReadManyCommand, handleNonTxWriteCommand, handleRemotelyRetrievedKeys, invokeRemotely, primaryReturnHandler, readNeedsRemoteValue, remoteGetMany, remoteGetSingleKey, remoteReadOnlyCommand, retrieveDistributionInfo, unwrapFunctionalManyResultOnOrigin, unwrapFunctionalResultOnOrigin, visitClearCommand, visitGetAllCommand, visitGetCacheEntryCommand, visitGetKeyValueCommand, visitReadOnlyKeyCommand, visitReadOnlyManyCommand, wrapFunctionalManyResultOnNonOrigin, wrapFunctionalResultOnNonOriginOnReturn, wrapRemoteEntryMethods inherited from class org.infinispan.interceptors.impl.ClusteringInterceptor
getCacheTopology, getSuccessfulResponseOrFail, init, unexpected, visitSizeCommand, visitTouchCommandMethods inherited from class org.infinispan.interceptors.impl.BaseRpcInterceptor
isLocalModeForced, isSynchronous, shouldInvokeRemoteTxCommand, shouldLoad, transactionRemotelyPreparedMethods inherited from class org.infinispan.interceptors.DDAsyncInterceptor
handleDefault, visitCommand, visitCommitCommand, visitEntrySetCommand, visitEvictCommand, visitInvalidateCommand, visitInvalidateL1Command, visitKeySetCommand, visitLockControlCommand, visitPrepareCommand, visitRollbackCommand, visitUnknownCommandMethods inherited from class org.infinispan.interceptors.BaseAsyncInterceptor
asyncInvokeNext, asyncInvokeNext, asyncInvokeNext, asyncValue, delayedNull, delayedValue, delayedValue, invokeNext, invokeNextAndExceptionally, invokeNextAndFinally, invokeNextAndHandle, invokeNextThenAccept, invokeNextThenApply, isSuccessfullyDone, makeStage, setNextInterceptor, valueOrExceptionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.infinispan.commands.Visitor
visitRemoveExpiredCommand
-
Constructor Details
-
TriangleDistributionInterceptor
public TriangleDistributionInterceptor()
-
-
Method Details
-
start
public void start() -
visitPutKeyValueCommand
- Specified by:
visitPutKeyValueCommandin interfaceVisitor- Overrides:
visitPutKeyValueCommandin classDDAsyncInterceptor
-
visitIracPutKeyValueCommand
- Specified by:
visitIracPutKeyValueCommandin interfaceVisitor- Overrides:
visitIracPutKeyValueCommandin classDDAsyncInterceptor
-
visitRemoveCommand
- Specified by:
visitRemoveCommandin interfaceVisitor- Overrides:
visitRemoveCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitReplaceCommand
- Specified by:
visitReplaceCommandin interfaceVisitor- Overrides:
visitReplaceCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitComputeCommand
- Specified by:
visitComputeCommandin interfaceVisitor- Overrides:
visitComputeCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitComputeIfAbsentCommand
public Object visitComputeIfAbsentCommand(InvocationContext ctx, ComputeIfAbsentCommand command) throws Throwable - Specified by:
visitComputeIfAbsentCommandin interfaceVisitor- Overrides:
visitComputeIfAbsentCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitReadWriteKeyValueCommand
public Object visitReadWriteKeyValueCommand(InvocationContext ctx, ReadWriteKeyValueCommand command) throws Throwable - Specified by:
visitReadWriteKeyValueCommandin interfaceVisitor- Overrides:
visitReadWriteKeyValueCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitReadWriteKeyCommand
public Object visitReadWriteKeyCommand(InvocationContext ctx, ReadWriteKeyCommand command) throws Throwable - Specified by:
visitReadWriteKeyCommandin interfaceVisitor- Overrides:
visitReadWriteKeyCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitWriteOnlyKeyValueCommand
public Object visitWriteOnlyKeyValueCommand(InvocationContext ctx, WriteOnlyKeyValueCommand command) throws Throwable - Specified by:
visitWriteOnlyKeyValueCommandin interfaceVisitor- Overrides:
visitWriteOnlyKeyValueCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitWriteOnlyKeyCommand
public Object visitWriteOnlyKeyCommand(InvocationContext ctx, WriteOnlyKeyCommand command) throws Throwable - Specified by:
visitWriteOnlyKeyCommandin interfaceVisitor- Overrides:
visitWriteOnlyKeyCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitPutMapCommand
- Specified by:
visitPutMapCommandin interfaceVisitor- Overrides:
visitPutMapCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitWriteOnlyManyEntriesCommand
public Object visitWriteOnlyManyEntriesCommand(InvocationContext ctx, WriteOnlyManyEntriesCommand command) - Specified by:
visitWriteOnlyManyEntriesCommandin interfaceVisitor- Overrides:
visitWriteOnlyManyEntriesCommandin classDDAsyncInterceptor
-
visitWriteOnlyManyCommand
- Specified by:
visitWriteOnlyManyCommandin interfaceVisitor- Overrides:
visitWriteOnlyManyCommandin classDDAsyncInterceptor
-
visitReadWriteManyCommand
public Object visitReadWriteManyCommand(InvocationContext ctx, ReadWriteManyCommand command) throws Throwable - Specified by:
visitReadWriteManyCommandin interfaceVisitor- Overrides:
visitReadWriteManyCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitReadWriteManyEntriesCommand
public Object visitReadWriteManyEntriesCommand(InvocationContext ctx, ReadWriteManyEntriesCommand command) throws Throwable - Specified by:
visitReadWriteManyEntriesCommandin interfaceVisitor- Overrides:
visitReadWriteManyEntriesCommandin classDDAsyncInterceptor- Throws:
Throwable
-