Package org.infinispan.commands
Interface SegmentSpecificCommand
-
- All Known Subinterfaces:
DataCommand
,DataWriteCommand
- All Known Implementing Classes:
AbstractDataCommand
,AbstractDataWriteCommand
,AbstractWriteKeyCommand
,ApplyDeltaCommand
,ClusteredGetCommand
,ComputeCommand
,ComputeIfAbsentCommand
,EvictCommand
,GetCacheEntryCommand
,GetKeyValueCommand
,PutKeyValueCommand
,ReadOnlyKeyCommand
,ReadWriteKeyCommand
,ReadWriteKeyValueCommand
,RemoveCommand
,RemoveExpiredCommand
,ReplaceCommand
,TxReadOnlyKeyCommand
,WriteOnlyKeyCommand
,WriteOnlyKeyValueCommand
public interface SegmentSpecificCommand
Interface to be implemented when the command can define a single segment for its operation. This is useful so that subsequent operations requiring a segment can retrieve it from the command and have it only computed once at creation time.If a command implements this interface, the command MUST ensure that it is initialized properly to always return a number 0 or greater when invoking
getSegment()
.- Since:
- 9.3
- Author:
- wburns
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static int
extractSegment(ReplicableCommand command, Object key, KeyPartitioner keyPartitioner)
Utility to extract the segment from a given command that may be aSegmentSpecificCommand
.int
getSegment()
Returns the segment that this key maps to.
-
-
-
Method Detail
-
getSegment
int getSegment()
Returns the segment that this key maps to. This must always return a number 0 or larger.- Returns:
- the segment of the key
-
extractSegment
static int extractSegment(ReplicableCommand command, Object key, KeyPartitioner keyPartitioner)
Utility to extract the segment from a given command that may be aSegmentSpecificCommand
. If the command is aSegmentSpecificCommand
, it will immediately return the value fromgetSegment()
. Otherwise it will return the result from invokingKeyPartitioner.getSegment(Object)
passing the provided key.- Parameters:
command
- the command to extract the segment fromkey
- the key the segment belongs tokeyPartitioner
- the partitioner to calculate the segment of the key- Returns:
- the segment value to use.
-
-