public class PutMapCommand extends AbstractFlagAffectedCommand implements WriteCommand, MetadataAwareCommand, RemoteLockCommand
Modifier and Type | Field and Description |
---|---|
static byte |
COMMAND_ID |
flags
Constructor and Description |
---|
PutMapCommand() |
PutMapCommand(Map<?,?> map,
CacheNotifier notifier,
Metadata metadata,
Set<Flag> flags,
CommandInvocationId commandInvocationId) |
PutMapCommand(PutMapCommand command) |
Modifier and Type | Method and Description |
---|---|
Object |
acceptVisitor(InvocationContext ctx,
Visitor visitor)
Accept a visitor, and return the result of accepting this visitor.
|
boolean |
canBlock()
If true, the command is processed asynchronously in a thread provided by an Infinispan thread pool.
|
boolean |
equals(Object o) |
Set<Object> |
getAffectedKeys() |
byte |
getCommandId()
Used by marshallers to convert this command into an id for streaming.
|
Object |
getKeyLockOwner()
It returns the lock owner of the key.
|
Collection<Object> |
getKeysToLock()
It returns a
Collection with the keys to be lock. |
Map<Object,Object> |
getMap() |
Metadata |
getMetadata()
Get metadata of this command.
|
ValueMatcher |
getValueMatcher() |
int |
hashCode() |
boolean |
hasSkipLocking()
It checks if this command should acquire locks.
|
boolean |
hasZeroLockAcquisition() |
boolean |
ignoreCommandOnStatus(ComponentStatus status)
Similar to
VisitableCommand.shouldInvoke(InvocationContext) but evaluated by InvocationContextInterceptor . |
void |
init(CacheNotifier notifier) |
boolean |
isConditional()
Certain commands only work based on a certain condition or state of the cache.
|
boolean |
isForwarded()
For non transactional caches that support concurrent writes (default), the commands are forwarded between nodes,
e.g.:
- commands is executed on node A, but some of the keys should be locked on node B
- the command is send to the main owner (B)
- B tries to acquire lock on the keys it owns, then forwards the commands to the other owners as well
- at this last stage, the command has the "isForwarded" flag set to true.
|
boolean |
isReturnValueExpected()
If true, a return value will be provided when performed remotely.
|
boolean |
isSuccessful()
Some commands may want to provide information on whether the command was successful or not.
|
Object |
perform(InvocationContext ctx)
Performs the primary function of the command.
|
void |
readFrom(ObjectInput input)
Reads this instance from the stream written by
ReplicableCommand.writeTo(ObjectOutput) . |
boolean |
readsExistingValues() |
void |
setForwarded(boolean forwarded) |
void |
setMap(Map<Object,Object> map) |
void |
setMetadata(Metadata metadata)
Sets metadata for this command.
|
void |
setValueMatcher(ValueMatcher valueMatcher) |
boolean |
shouldInvoke(InvocationContext ctx)
Used by the InboundInvocationHandler to determine whether the command should be invoked or not.
|
String |
toString() |
void |
updateStatusFromRemoteResponse(Object remoteResponse)
Used for conditional commands, to update the status of the command on the originator
based on the result of its execution on the primary owner.
|
void |
writeTo(ObjectOutput output)
Writes this instance to the
ObjectOutput . |
getTopologyId, setTopologyId
getFlags, setFlags
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isWriteOnly
alwaysReadsExistingValues
getTopologyId, setTopologyId
getParameters, setParameters
public static final byte COMMAND_ID
public PutMapCommand()
public PutMapCommand(Map<?,?> map, CacheNotifier notifier, Metadata metadata, Set<Flag> flags, CommandInvocationId commandInvocationId)
public PutMapCommand(PutMapCommand command)
public void init(CacheNotifier notifier)
public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
VisitableCommand
acceptVisitor
in interface VisitableCommand
ctx
- invocation contextvisitor
- visitor to acceptThrowable
- in the event of problemspublic Collection<Object> getKeysToLock()
RemoteLockCommand
Collection
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 and null
is not a valid return value.
getKeysToLock
in interface RemoteLockCommand
Collection
of keys to lock.public Object getKeyLockOwner()
RemoteLockCommand
Usually, in transaction caches it is the GlobalTransaction
and in
non-transactional caches the CommandInvocationId
.
getKeyLockOwner
in interface RemoteLockCommand
public boolean hasZeroLockAcquisition()
hasZeroLockAcquisition
in interface RemoteLockCommand
public boolean hasSkipLocking()
RemoteLockCommand
hasSkipLocking
in interface RemoteLockCommand
true
if locks should be acquired for the keys in RemoteLockCommand.getKeysToLock()
.public Object perform(InvocationContext ctx) throws Throwable
ReplicableCommand
perform
in interface ReplicableCommand
ctx
- invocation contextThrowable
- in the event of problems.public byte getCommandId()
ReplicableCommand
getCommandId
in interface ReplicableCommand
public void writeTo(ObjectOutput output) throws IOException
ReplicableCommand
ObjectOutput
.writeTo
in interface ReplicableCommand
output
- the stream.IOException
- if an error occurred during the I/O.public void readFrom(ObjectInput input) throws IOException, ClassNotFoundException
ReplicableCommand
ReplicableCommand.writeTo(ObjectOutput)
.readFrom
in interface ReplicableCommand
input
- the stream to read.IOException
- if an error occurred during the I/O.ClassNotFoundException
- if it tries to load an undefined class.public boolean shouldInvoke(InvocationContext ctx)
VisitableCommand
shouldInvoke
in interface VisitableCommand
public boolean isSuccessful()
WriteCommand
isSuccessful
in interface WriteCommand
public boolean isConditional()
WriteCommand
ConcurrentMap.putIfAbsent(Object, Object)
only does anything if a condition is met, i.e., the entry in
question is not already present. This method tests whether the command in question is conditional or not.isConditional
in interface WriteCommand
public ValueMatcher getValueMatcher()
getValueMatcher
in interface WriteCommand
public void setValueMatcher(ValueMatcher valueMatcher)
setValueMatcher
in interface WriteCommand
valueMatcher
- The new value matching policy.public Set<Object> getAffectedKeys()
getAffectedKeys
in interface WriteCommand
public void updateStatusFromRemoteResponse(Object remoteResponse)
WriteCommand
updateStatusFromRemoteResponse
in interface WriteCommand
public boolean isReturnValueExpected()
ReplicableCommand
ResponseGenerator
may choose to simply return null to save on marshalling costs.isReturnValueExpected
in interface ReplicableCommand
public boolean canBlock()
ReplicableCommand
canBlock
in interface ReplicableCommand
true
if the command can block/wait, false
otherwisepublic boolean ignoreCommandOnStatus(ComponentStatus status)
VisitableCommand
VisitableCommand.shouldInvoke(InvocationContext)
but evaluated by InvocationContextInterceptor
.
Commands can opt to be discarded in case the cache status is not suited (as InvalidateCommand
)ignoreCommandOnStatus
in interface VisitableCommand
public boolean readsExistingValues()
readsExistingValues
in interface VisitableCommand
true
if the command needs to read the previous values of the keys it acts on.public Metadata getMetadata()
MetadataAwareCommand
getMetadata
in interface MetadataAwareCommand
getMetadata
in class AbstractFlagAffectedCommand
public void setMetadata(Metadata metadata)
MetadataAwareCommand
setMetadata
in interface MetadataAwareCommand
setMetadata
in class AbstractFlagAffectedCommand
public boolean isForwarded()
public void setForwarded(boolean forwarded)
isForwarded()
Copyright © 2021 JBoss, a division of Red Hat. All rights reserved.