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:
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
GetKeyValueCommandreads 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. TheDataWriteCommandis 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.
PutMapCommandis 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
OutdatedTopologyExceptionis thrown. TheStateTransferInterceptorwill 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>, BaseDistributionInterceptor.ReadOnlyManyHelper
-
-
Field Summary
-
Fields inherited from class org.infinispan.interceptors.distribution.BaseDistributionInterceptor
expirationManager, isL1Enabled, isReplicated, keyPartitioner, rvrl, timeService
-
Fields inherited from class org.infinispan.interceptors.impl.ClusteringInterceptor
cf, dataContainer, distributionManager, entryFactory, lockManager
-
Fields inherited from class org.infinispan.interceptors.impl.BaseRpcInterceptor
componentRegistry, defaultSynchronous, rpcManager
-
Fields inherited from class org.infinispan.interceptors.BaseAsyncInterceptor
cacheConfiguration
-
-
Constructor Summary
Constructors Constructor Description TriangleDistributionInterceptor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidstart()ObjectvisitComputeCommand(InvocationContext ctx, org.infinispan.commands.write.ComputeCommand command)ObjectvisitComputeIfAbsentCommand(InvocationContext ctx, org.infinispan.commands.write.ComputeIfAbsentCommand command)ObjectvisitPutKeyValueCommand(InvocationContext ctx, org.infinispan.commands.write.PutKeyValueCommand command)ObjectvisitPutMapCommand(InvocationContext ctx, org.infinispan.commands.write.PutMapCommand command)ObjectvisitReadWriteKeyCommand(InvocationContext ctx, org.infinispan.commands.functional.ReadWriteKeyCommand command)ObjectvisitReadWriteKeyValueCommand(InvocationContext ctx, org.infinispan.commands.functional.ReadWriteKeyValueCommand command)ObjectvisitReadWriteManyCommand(InvocationContext ctx, org.infinispan.commands.functional.ReadWriteManyCommand command)ObjectvisitReadWriteManyEntriesCommand(InvocationContext ctx, org.infinispan.commands.functional.ReadWriteManyEntriesCommand command)ObjectvisitRemoveCommand(InvocationContext ctx, org.infinispan.commands.write.RemoveCommand command)ObjectvisitReplaceCommand(InvocationContext ctx, org.infinispan.commands.write.ReplaceCommand command)ObjectvisitWriteOnlyKeyCommand(InvocationContext ctx, org.infinispan.commands.functional.WriteOnlyKeyCommand command)ObjectvisitWriteOnlyKeyValueCommand(InvocationContext ctx, org.infinispan.commands.functional.WriteOnlyKeyValueCommand command)ObjectvisitWriteOnlyManyCommand(InvocationContext ctx, org.infinispan.commands.functional.WriteOnlyManyCommand command)ObjectvisitWriteOnlyManyEntriesCommand(InvocationContext ctx, org.infinispan.commands.functional.WriteOnlyManyEntriesCommand command)-
Methods inherited from class org.infinispan.interceptors.distribution.BaseDistributionInterceptor
checkTopologyId, configure, getLog, handleFunctionalReadManyCommand, handleNonTxWriteCommand, handleRemotelyRetrievedKeys, invokeRemotely, readNeedsRemoteValue, remoteGetMany, remoteGetSingleKey, remoteReadOnlyCommand, retrieveDistributionInfo, unwrapFunctionalManyResultOnOrigin, unwrapFunctionalResultOnOrigin, visitClearCommand, visitGetAllCommand, visitGetCacheEntryCommand, visitGetKeysInGroupCommand, visitGetKeyValueCommand, visitReadOnlyKeyCommand, visitReadOnlyManyCommand, visitSizeCommand, wrapFunctionalManyResultOnNonOrigin, wrapFunctionalResultOnNonOriginOnReturn, wrapRemoteEntry
-
Methods inherited from class org.infinispan.interceptors.impl.ClusteringInterceptor
getSuccessfulResponseOrFail, unexpected
-
Methods inherited from class org.infinispan.interceptors.impl.BaseRpcInterceptor
init, isLocalModeForced, isSynchronous, shouldInvokeRemoteTxCommand, shouldTotalOrderRollbackBeInvokedRemotely, totalOrderPrepare, totalOrderTxCommit, totalOrderTxRollback, transactionRemotelyPrepared
-
Methods inherited from class org.infinispan.interceptors.DDAsyncInterceptor
handleDefault, visitCommand, visitCommitCommand, visitDistributedExecuteCommand, visitEntrySetCommand, visitEvictCommand, visitInvalidateCommand, visitInvalidateL1Command, visitKeySetCommand, visitLockControlCommand, visitPrepareCommand, visitRollbackCommand, visitUnknownCommand
-
Methods inherited from class org.infinispan.interceptors.BaseAsyncInterceptor
asyncInvokeNext, asyncInvokeNext, asyncInvokeNext, asyncValue, delayedValue, delayedValue, invokeNext, invokeNextAndExceptionally, invokeNextAndFinally, invokeNextAndHandle, invokeNextThenAccept, invokeNextThenApply, isSuccessfullyDone, makeStage, setNextInterceptor, valueOrException
-
-
-
-
Method Detail
-
start
public void start()
-
visitPutKeyValueCommand
public Object visitPutKeyValueCommand(InvocationContext ctx, org.infinispan.commands.write.PutKeyValueCommand command) throws Throwable
- Specified by:
visitPutKeyValueCommandin interfaceorg.infinispan.commands.Visitor- Overrides:
visitPutKeyValueCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitRemoveCommand
public Object visitRemoveCommand(InvocationContext ctx, org.infinispan.commands.write.RemoveCommand command) throws Throwable
- Specified by:
visitRemoveCommandin interfaceorg.infinispan.commands.Visitor- Overrides:
visitRemoveCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitReplaceCommand
public Object visitReplaceCommand(InvocationContext ctx, org.infinispan.commands.write.ReplaceCommand command) throws Throwable
- Specified by:
visitReplaceCommandin interfaceorg.infinispan.commands.Visitor- Overrides:
visitReplaceCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitComputeCommand
public Object visitComputeCommand(InvocationContext ctx, org.infinispan.commands.write.ComputeCommand command) throws Throwable
- Specified by:
visitComputeCommandin interfaceorg.infinispan.commands.Visitor- Overrides:
visitComputeCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitComputeIfAbsentCommand
public Object visitComputeIfAbsentCommand(InvocationContext ctx, org.infinispan.commands.write.ComputeIfAbsentCommand command) throws Throwable
- Specified by:
visitComputeIfAbsentCommandin interfaceorg.infinispan.commands.Visitor- Overrides:
visitComputeIfAbsentCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitReadWriteKeyValueCommand
public Object visitReadWriteKeyValueCommand(InvocationContext ctx, org.infinispan.commands.functional.ReadWriteKeyValueCommand command) throws Throwable
- Specified by:
visitReadWriteKeyValueCommandin interfaceorg.infinispan.commands.Visitor- Overrides:
visitReadWriteKeyValueCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitReadWriteKeyCommand
public Object visitReadWriteKeyCommand(InvocationContext ctx, org.infinispan.commands.functional.ReadWriteKeyCommand command) throws Throwable
- Specified by:
visitReadWriteKeyCommandin interfaceorg.infinispan.commands.Visitor- Overrides:
visitReadWriteKeyCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitWriteOnlyKeyValueCommand
public Object visitWriteOnlyKeyValueCommand(InvocationContext ctx, org.infinispan.commands.functional.WriteOnlyKeyValueCommand command) throws Throwable
- Specified by:
visitWriteOnlyKeyValueCommandin interfaceorg.infinispan.commands.Visitor- Overrides:
visitWriteOnlyKeyValueCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitWriteOnlyKeyCommand
public Object visitWriteOnlyKeyCommand(InvocationContext ctx, org.infinispan.commands.functional.WriteOnlyKeyCommand command) throws Throwable
- Specified by:
visitWriteOnlyKeyCommandin interfaceorg.infinispan.commands.Visitor- Overrides:
visitWriteOnlyKeyCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitPutMapCommand
public Object visitPutMapCommand(InvocationContext ctx, org.infinispan.commands.write.PutMapCommand command) throws Throwable
- Specified by:
visitPutMapCommandin interfaceorg.infinispan.commands.Visitor- Overrides:
visitPutMapCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitWriteOnlyManyEntriesCommand
public Object visitWriteOnlyManyEntriesCommand(InvocationContext ctx, org.infinispan.commands.functional.WriteOnlyManyEntriesCommand command)
- Specified by:
visitWriteOnlyManyEntriesCommandin interfaceorg.infinispan.commands.Visitor- Overrides:
visitWriteOnlyManyEntriesCommandin classDDAsyncInterceptor
-
visitWriteOnlyManyCommand
public Object visitWriteOnlyManyCommand(InvocationContext ctx, org.infinispan.commands.functional.WriteOnlyManyCommand command)
- Specified by:
visitWriteOnlyManyCommandin interfaceorg.infinispan.commands.Visitor- Overrides:
visitWriteOnlyManyCommandin classDDAsyncInterceptor
-
visitReadWriteManyCommand
public Object visitReadWriteManyCommand(InvocationContext ctx, org.infinispan.commands.functional.ReadWriteManyCommand command) throws Throwable
- Specified by:
visitReadWriteManyCommandin interfaceorg.infinispan.commands.Visitor- Overrides:
visitReadWriteManyCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitReadWriteManyEntriesCommand
public Object visitReadWriteManyEntriesCommand(InvocationContext ctx, org.infinispan.commands.functional.ReadWriteManyEntriesCommand command) throws Throwable
- Specified by:
visitReadWriteManyEntriesCommandin interfaceorg.infinispan.commands.Visitor- Overrides:
visitReadWriteManyEntriesCommandin classDDAsyncInterceptor- Throws:
Throwable
-
-