Class ComputeIfAbsentCommand
java.lang.Object
org.infinispan.commands.read.AbstractDataCommand
org.infinispan.commands.write.AbstractDataWriteCommand
org.infinispan.commands.write.ComputeIfAbsentCommand
- All Implemented Interfaces:
DataCommand, FlagAffectedCommand, MetadataAwareCommand, CacheRpcCommand, ReplicableCommand, SegmentSpecificCommand, TopologyAffectedCommand, TracedCommand, VisitableCommand, DataWriteCommand, WriteCommand, VersionAware, RemoteLockCommand
@ProtoTypeId(1065)
public class ComputeIfAbsentCommand
extends AbstractDataWriteCommand
implements MetadataAwareCommand
-
Nested Class Summary
Nested classes/interfaces inherited from interface VisitableCommand
VisitableCommand.LoadType -
Field Summary
Fields inherited from class AbstractDataWriteCommand
commandInvocationIdFields inherited from class AbstractDataCommand
cacheName, key, origin, segment, spanAttributes, topologyIdFields inherited from interface VisitableCommand
log -
Constructor Summary
ConstructorsConstructorDescriptionComputeIfAbsentCommand(ByteString cacheName, Object key, Function<?, ?> mappingFunction, int segment, long flagsBitSet, CommandInvocationId commandInvocationId, Metadata metadata) -
Method Summary
Modifier and TypeMethodDescriptionacceptVisitor(InvocationContext ctx, Visitor visitor) Accept a visitor, and return the result of accepting this visitor.booleanvoidfail()Make subsequent invocations ofWriteCommand.isSuccessful()returnfalse.Get metadata of this command.inthashCode()voidinit(ComponentRegistry componentRegistry) booleanCertain commands only work based on a certain condition or state of the cache.final booleanIf true, a return value will be provided when performed remotely.booleanIf true, a return value will be marshalled as aSuccessfulResponse, otherwise it will be marshalled as aUnsuccessfulResponse.loadType()voidsetInternalMetadata(PrivateMetadata internalMetadata) voidsetMetadata(Metadata metadata) Sets metadata for this command.voidsetValueMatcher(ValueMatcher valueMatcher) Returns aNodeVersionrepresenting the Infinispan version in which this command was added.toString()Methods inherited from class AbstractDataWriteCommand
getAffectedKeys, getCommandInvocationId, getKeyLockOwner, getKeysToLock, hasSkipLocking, hasZeroLockAcquisitionMethods inherited from class AbstractDataCommand
getCacheName, getFlagsBitSet, getFlagsWithoutRemote, getKey, getOrigin, getSegment, getSpanAttributes, getTopologyId, getWrappedKey, printFlags, setFlagsBitSet, setKey, setOrigin, setSpanAttributes, setTopologyIdMethods inherited from interface CacheRpcCommand
getCacheName, getOrigin, setOriginMethods inherited from interface DataCommand
getKeyMethods inherited from interface DataWriteCommand
getInternalMetadata, setInternalMetadataMethods inherited from interface FlagAffectedCommand
addFlags, getFlags, getFlagsBitSet, hasAllFlags, hasAnyFlag, setFlagsBitSetMethods inherited from interface ReplicableCommand
getCommandId, logThrowable, readFrom, writeToMethods inherited from interface SegmentSpecificCommand
getSegmentMethods inherited from interface TopologyAffectedCommand
getTopologyId, setTopologyIdMethods inherited from interface TracedCommand
getOperationName, getSpanAttributes, setSpanAttributesMethods inherited from interface VisitableCommand
invokeAsyncMethods inherited from interface WriteCommand
isWriteOnly, shouldReplicate
-
Constructor Details
-
ComputeIfAbsentCommand
public ComputeIfAbsentCommand(ByteString cacheName, Object key, Function<?, ?> mappingFunction, int segment, long flagsBitSet, CommandInvocationId commandInvocationId, Metadata metadata)
-
-
Method Details
-
getInternalMetadata
- Specified by:
getInternalMetadatain interfaceDataWriteCommand
-
setInternalMetadata
- Specified by:
setInternalMetadatain interfaceDataWriteCommand
-
init
- Specified by:
initin interfaceVisitableCommand
-
getMetadata
Description copied from interface:MetadataAwareCommandGet metadata of this command.- Specified by:
getMetadatain interfaceMetadataAwareCommand- Returns:
- an instance of Metadata
-
setMetadata
Description copied from interface:MetadataAwareCommandSets metadata for this command.- Specified by:
setMetadatain interfaceMetadataAwareCommand
-
isSuccessful
public boolean isSuccessful()Description copied from interface:ReplicableCommandIf true, a return value will be marshalled as aSuccessfulResponse, otherwise it will be marshalled as aUnsuccessfulResponse.- Specified by:
isSuccessfulin interfaceReplicableCommand- Specified by:
isSuccessfulin interfaceWriteCommand- Returns:
- true if the command completed successfully, false otherwise.
-
isConditional
public boolean isConditional()Description copied from interface:WriteCommandCertain commands only work based on a certain condition or state of the cache. For example,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.- Specified by:
isConditionalin interfaceWriteCommand- Returns:
- true if the command is conditional, false otherwise
-
getValueMatcher
- Specified by:
getValueMatcherin interfaceWriteCommand- Returns:
- The current value matching policy.
-
setValueMatcher
- Specified by:
setValueMatcherin interfaceWriteCommand- Parameters:
valueMatcher- The new value matching policy.
-
fail
public void fail()Description copied from interface:WriteCommandMake subsequent invocations ofWriteCommand.isSuccessful()returnfalse.- Specified by:
failin interfaceWriteCommand
-
isReturnValueExpected
public final boolean isReturnValueExpected()Description copied from interface:ReplicableCommandIf true, a return value will be provided when performed remotely. Otherwise, a remoteResponseGeneratormay choose to simply return null to save on marshalling costs.- Specified by:
isReturnValueExpectedin interfaceReplicableCommand- Overrides:
isReturnValueExpectedin classAbstractDataWriteCommand- Returns:
- true or false
-
getMappingFunction
-
acceptVisitor
Description copied from interface:VisitableCommandAccept a visitor, and return the result of accepting this visitor.- Specified by:
acceptVisitorin interfaceVisitableCommand- Parameters:
ctx- invocation contextvisitor- visitor to accept- Returns:
- arbitrary return value
- Throws:
Throwable- in the event of problems
-
loadType
- Specified by:
loadTypein interfaceVisitableCommand- Returns:
- Nodes on which the command needs to read the previous values of the keys it acts on.
-
supportedSince
Description copied from interface:ReplicableCommandReturns aNodeVersionrepresenting the Infinispan version in which this command was added. This value is used to ensure that when the cluster contains different Infinispan versions, only commands compatible with the oldest version are transmitted.Abstract classes should not implement this method as the version should be specific to an individual implementation. Similarly, implementations which extend another
ReplicableCommandshould always override this method.- Specified by:
supportedSincein interfaceReplicableCommand- Specified by:
supportedSincein interfaceVersionAware- Returns:
- a
NodeVersioncorresponding to the Infinispan version this command was added.
-
equals
- Overrides:
equalsin classAbstractDataCommand
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractDataCommand
-
toString
- Overrides:
toStringin classAbstractDataCommand
-