Package org.infinispan.commands.write
Class AbstractDataWriteCommand
- java.lang.Object
-
- org.infinispan.commands.read.AbstractDataCommand
-
- org.infinispan.commands.write.AbstractDataWriteCommand
-
- All Implemented Interfaces:
DataCommand
,FlagAffectedCommand
,ReplicableCommand
,SegmentSpecificCommand
,TopologyAffectedCommand
,VisitableCommand
,DataWriteCommand
,WriteCommand
,RemoteLockCommand
- Direct Known Subclasses:
AbstractWriteKeyCommand
,ApplyDeltaCommand
,ComputeCommand
,ComputeIfAbsentCommand
,PutKeyValueCommand
,RemoveCommand
,ReplaceCommand
public abstract class AbstractDataWriteCommand extends AbstractDataCommand implements DataWriteCommand, RemoteLockCommand
Stuff common to WriteCommands- Since:
- 4.0
- Author:
- Manik Surtani
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.infinispan.commands.VisitableCommand
VisitableCommand.LoadType
-
-
Field Summary
Fields Modifier and Type Field Description protected CommandInvocationId
commandInvocationId
-
Fields inherited from class org.infinispan.commands.read.AbstractDataCommand
key, segment
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractDataWriteCommand()
protected
AbstractDataWriteCommand(Object key, int segment, long flagsBitSet, CommandInvocationId commandInvocationId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canBlock()
If true, the command is processed asynchronously in a thread provided by an Infinispan thread pool.Collection<?>
getAffectedKeys()
CommandInvocationId
getCommandInvocationId()
Object
getKeyLockOwner()
It returns the lock owner of the key.Collection<?>
getKeysToLock()
It returns aCollection
with the keys to be lock.boolean
hasSkipLocking()
It checks if this command should acquire locks.boolean
hasZeroLockAcquisition()
boolean
isReturnValueExpected()
If true, a return value will be provided when performed remotely.-
Methods inherited from class org.infinispan.commands.read.AbstractDataCommand
equals, getFlagsBitSet, getKey, getSegment, getTopologyId, hashCode, printFlags, setFlagsBitSet, setKey, setTopologyId, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.infinispan.commands.DataCommand
getKey
-
Methods inherited from interface org.infinispan.commands.FlagAffectedCommand
addFlag, addFlags, addFlags, getFlags, getFlagsBitSet, hasAllFlags, hasAnyFlag, hasFlag, setFlags, setFlagsBitSet
-
Methods inherited from interface org.infinispan.commands.ReplicableCommand
getCommandId, invoke, invokeAsync, readFrom, setOrigin, writeTo
-
Methods inherited from interface org.infinispan.commands.SegmentSpecificCommand
getSegment
-
Methods inherited from interface org.infinispan.commands.TopologyAffectedCommand
getTopologyId, setTopologyId
-
Methods inherited from interface org.infinispan.commands.VisitableCommand
acceptVisitor, ignoreCommandOnStatus, loadType, perform, shouldInvoke
-
Methods inherited from interface org.infinispan.commands.write.WriteCommand
fail, getValueMatcher, isConditional, isSuccessful, isWriteOnly, setValueMatcher, updateStatusFromRemoteResponse
-
-
-
-
Field Detail
-
commandInvocationId
protected CommandInvocationId commandInvocationId
-
-
Constructor Detail
-
AbstractDataWriteCommand
protected AbstractDataWriteCommand()
-
AbstractDataWriteCommand
protected AbstractDataWriteCommand(Object key, int segment, long flagsBitSet, CommandInvocationId commandInvocationId)
-
-
Method Detail
-
getAffectedKeys
public Collection<?> getAffectedKeys()
- Specified by:
getAffectedKeys
in interfaceWriteCommand
- Returns:
- a collection of keys affected by this write command. Some commands - such as ClearCommand - may return an empty collection for this method.
-
isReturnValueExpected
public boolean isReturnValueExpected()
Description copied from interface:ReplicableCommand
If true, a return value will be provided when performed remotely. Otherwise, a remoteResponseGenerator
may choose to simply return null to save on marshalling costs.- Specified by:
isReturnValueExpected
in interfaceReplicableCommand
- Overrides:
isReturnValueExpected
in classAbstractDataCommand
- Returns:
- true or false
-
canBlock
public boolean canBlock()
Description copied from interface:ReplicableCommand
If true, the command is processed asynchronously in a thread provided by an Infinispan thread pool. Otherwise, the command is processed directly in the JGroups thread. This feature allows to avoid keep a JGroups thread busy that can originate discard of messages and retransmissions. So, the commands that can block (waiting for some state, acquiring locks, etc.) should return true.- Specified by:
canBlock
in interfaceReplicableCommand
- Overrides:
canBlock
in classAbstractDataCommand
- Returns:
true
if the command can block/wait,false
otherwise
-
getKeysToLock
public Collection<?> getKeysToLock()
Description copied from interface:RemoteLockCommand
It returns aCollection
with the keys to be lock.It may return an empty collection if no keys needs to be locked independently of the return value of
RemoteLockCommand.hasSkipLocking()
. It may contains duplicated keys andnull
is not a valid return value.- Specified by:
getKeysToLock
in interfaceRemoteLockCommand
- Returns:
- a
Collection
of keys to lock.
-
getKeyLockOwner
public final Object getKeyLockOwner()
Description copied from interface:RemoteLockCommand
It returns the lock owner of the key.Usually, in transaction caches it is the
GlobalTransaction
and in non-transactional caches theCommandInvocationId
.- Specified by:
getKeyLockOwner
in interfaceRemoteLockCommand
- Returns:
- the lock owner of the key.
-
hasZeroLockAcquisition
public final boolean hasZeroLockAcquisition()
- Specified by:
hasZeroLockAcquisition
in interfaceRemoteLockCommand
- Returns:
- it the locks should be acquire with 0 (zero) acquisition timeout.
-
hasSkipLocking
public final boolean hasSkipLocking()
Description copied from interface:RemoteLockCommand
It checks if this command should acquire locks.- Specified by:
hasSkipLocking
in interfaceRemoteLockCommand
- Returns:
true
if locks should be acquired for the keys inRemoteLockCommand.getKeysToLock()
.
-
getCommandInvocationId
public CommandInvocationId getCommandInvocationId()
- Specified by:
getCommandInvocationId
in interfaceWriteCommand
- Returns:
- the
CommandInvocationId
associated to the command.
-
-