Interface CommandsFactory

  • All Known Implementing Classes:
    CommandsFactoryImpl

    public interface CommandsFactory
    A factory to build commands, initializing and injecting dependencies accordingly. Commands built for a specific, named cache instance cannot be reused on a different cache instance since most commands contain the cache name it was built for along with references to other named-cache scoped components.
    Since:
    4.0
    Author:
    Manik Surtani, Mircea.Markus@jboss.com, Galder ZamarreƱo
    • Method Detail

      • buildPutKeyValueCommand

        PutKeyValueCommand buildPutKeyValueCommand​(Object key,
                                                   Object value,
                                                   int segment,
                                                   Metadata metadata,
                                                   long flagsBitSet)
        Builds a PutKeyValueCommand
        Parameters:
        key - key to put
        value - value to put
        segment - the segment of the given key
        metadata - metadata of entry
        flagsBitSet - Command flags provided by cache
        Returns:
        a PutKeyValueCommand
      • buildRemoveCommand

        RemoveCommand buildRemoveCommand​(Object key,
                                         Object value,
                                         int segment,
                                         long flagsBitSet)
        Builds a RemoveCommand
        Parameters:
        key - key to remove
        value - value to check for ina conditional remove, or null for an unconditional remove.
        segment - the segment of the given key
        flagsBitSet - Command flags provided by cache
        Returns:
        a RemoveCommand
      • buildInvalidateCommand

        InvalidateCommand buildInvalidateCommand​(long flagsBitSet,
                                                 Object... keys)
        Builds an InvalidateCommand
        Parameters:
        flagsBitSet - Command flags provided by cache
        keys - keys to invalidate
        Returns:
        an InvalidateCommand
      • buildInvalidateFromL1Command

        InvalidateCommand buildInvalidateFromL1Command​(long flagsBitSet,
                                                       Collection<Object> keys)
        Builds an InvalidateFromL1Command
        Parameters:
        flagsBitSet - Command flags provided by cache
        keys - keys to invalidate
        Returns:
        an InvalidateFromL1Command
      • buildRemoveExpiredCommand

        RemoveExpiredCommand buildRemoveExpiredCommand​(Object key,
                                                       Object value,
                                                       int segment,
                                                       Long lifespan,
                                                       long flagsBitSet)
        Builds an expired remove command that is used to remove only a specific entry when it expires via lifespan
        Parameters:
        key - the key of the expired entry
        value - the value of the entry when it was expired
        segment - the segment of the given key
        lifespan - the lifespan that expired from the command
        flagsBitSet - Command flags provided by cache
        Returns:
        a RemovedExpiredCommand
      • buildRemoveExpiredCommand

        RemoveExpiredCommand buildRemoveExpiredCommand​(Object key,
                                                       Object value,
                                                       int segment,
                                                       long flagsBitSet)
        Builds an expired remove command that is used to remove only a specific entry when it expires via maxIdle
        Parameters:
        key - the key of the expired entry
        value - the value of the entry when it was expired
        segment - the segment of the given key
        flagsBitSet - Command flags provided by cache
        Returns:
        a RemovedExpiredCommand
      • buildReplaceCommand

        ReplaceCommand buildReplaceCommand​(Object key,
                                           Object oldValue,
                                           Object newValue,
                                           int segment,
                                           Metadata metadata,
                                           long flagsBitSet)
        Builds a ReplaceCommand
        Parameters:
        key - key to replace
        oldValue - existing value to check for if conditional, null if unconditional.
        newValue - value to replace with
        segment - the segment of the given key
        metadata - metadata of entry
        flagsBitSet - Command flags provided by cache
        Returns:
        a ReplaceCommand
      • buildComputeCommand

        ComputeCommand buildComputeCommand​(Object key,
                                           BiFunction mappingFunction,
                                           boolean computeIfPresent,
                                           int segment,
                                           Metadata metadata,
                                           long flagsBitSet)
        Builds a ComputeCommand
        Parameters:
        key - key to compute if this key is absent
        mappingFunction - BiFunction for the key and the value
        computeIfPresent - flag to apply as computeIfPresent mode
        segment - the segment of the given key
        metadata - metadata of entry
        flagsBitSet - Command flags provided by cache
        Returns:
        a ComputeCommand
      • buildComputeIfAbsentCommand

        ComputeIfAbsentCommand buildComputeIfAbsentCommand​(Object key,
                                                           Function mappingFunction,
                                                           int segment,
                                                           Metadata metadata,
                                                           long flagsBitSet)
        Builds a ComputeIfAbsentCommand
        Parameters:
        key - key to compute if this key is absent
        mappingFunction - mappingFunction for the key
        segment - the segment of the given key
        metadata - metadata of entry
        flagsBitSet - Command flags provided by cache
        Returns:
        a ComputeCommand
      • buildSizeCommand

        SizeCommand buildSizeCommand​(long flagsBitSet)
        Builds a SizeCommand
        Parameters:
        flagsBitSet - Command flags provided by cache
        Returns:
        a SizeCommand
      • buildGetKeyValueCommand

        GetKeyValueCommand buildGetKeyValueCommand​(Object key,
                                                   int segment,
                                                   long flagsBitSet)
        Builds a GetKeyValueCommand
        Parameters:
        key - key to get
        segment - the segment of the given key
        flagsBitSet - Command flags provided by cache
        Returns:
        a GetKeyValueCommand
      • buildGetCacheEntryCommand

        GetCacheEntryCommand buildGetCacheEntryCommand​(Object key,
                                                       int segment,
                                                       long flagsBitSet)
        Builds a GetCacheEntryCommand
        Parameters:
        key - key to get
        segment - the segment for the key
        flagsBitSet - Command flags provided by cache
        Returns:
        a GetCacheEntryCommand
      • buildGetAllCommand

        GetAllCommand buildGetAllCommand​(Collection<?> keys,
                                         long flagsBitSet,
                                         boolean returnEntries)
        Builds a GetAllCommand
        Parameters:
        keys - keys to get
        flagsBitSet - Command flags provided by cache
        returnEntries - boolean indicating whether entire cache entries are returned, otherwise return just the value parts
        Returns:
        a GetKeyValueCommand
      • buildKeySetCommand

        KeySetCommand buildKeySetCommand​(long flagsBitSet)
        Builds a KeySetCommand
        Parameters:
        flagsBitSet - Command flags provided by cache
        Returns:
        a KeySetCommand
      • buildEntrySetCommand

        EntrySetCommand buildEntrySetCommand​(long flagsBitSet)
        Builds a EntrySetCommand
        Parameters:
        flagsBitSet - Command flags provided by cache
        Returns:
        a EntrySetCommand
      • buildPutMapCommand

        PutMapCommand buildPutMapCommand​(Map<?,​?> map,
                                         Metadata metadata,
                                         long flagsBitSet)
        Builds a PutMapCommand
        Parameters:
        map - map containing key/value entries to put
        metadata - metadata of entry
        flagsBitSet - Command flags provided by cache
        Returns:
        a PutMapCommand
      • buildClearCommand

        ClearCommand buildClearCommand​(long flagsBitSet)
        Builds a ClearCommand
        Parameters:
        flagsBitSet - Command flags provided by cache
        Returns:
        a ClearCommand
      • buildEvictCommand

        EvictCommand buildEvictCommand​(Object key,
                                       int segment,
                                       long flagsBitSet)
        Builds an EvictCommand
        Parameters:
        key - key to evict
        segment - the segment for the key
        flagsBitSet - Command flags provided by cache
        Returns:
        an EvictCommand
      • buildPrepareCommand

        PrepareCommand buildPrepareCommand​(GlobalTransaction gtx,
                                           List<WriteCommand> modifications,
                                           boolean onePhaseCommit)
        Builds a PrepareCommand
        Parameters:
        gtx - global transaction associated with the prepare
        modifications - list of modifications
        onePhaseCommit - is this a one-phase or two-phase transaction?
        Returns:
        a PrepareCommand
      • buildVersionedPrepareCommand

        VersionedPrepareCommand buildVersionedPrepareCommand​(GlobalTransaction gtx,
                                                             List<WriteCommand> modifications,
                                                             boolean onePhase)
        Builds a VersionedPrepareCommand
        Parameters:
        gtx - global transaction associated with the prepare
        modifications - list of modifications
        onePhase -
        Returns:
        a VersionedPrepareCommand
      • buildCommitCommand

        CommitCommand buildCommitCommand​(GlobalTransaction gtx)
        Builds a CommitCommand
        Parameters:
        gtx - global transaction associated with the commit
        Returns:
        a CommitCommand
      • buildVersionedCommitCommand

        VersionedCommitCommand buildVersionedCommitCommand​(GlobalTransaction gtx)
        Builds a VersionedCommitCommand
        Parameters:
        gtx - global transaction associated with the commit
        Returns:
        a VersionedCommitCommand
      • buildRollbackCommand

        RollbackCommand buildRollbackCommand​(GlobalTransaction gtx)
        Builds a RollbackCommand
        Parameters:
        gtx - global transaction associated with the rollback
        Returns:
        a RollbackCommand
      • initializeReplicableCommand

        void initializeReplicableCommand​(ReplicableCommand command,
                                         boolean isRemote)
        Initializes a ReplicableCommand read from a data stream with components specific to the target cache instance.

        Implementations should also be deep, in that if the command contains other commands, these should be recursed into.

        Parameters:
        command - command to initialize. Cannot be null.
        isRemote -
      • buildSingleRpcCommand

        SingleRpcCommand buildSingleRpcCommand​(ReplicableCommand call)
        Builds a SingleRpcCommand "envelope" containing a single ReplicableCommand
        Parameters:
        call - ReplicableCommand to include in the envelope
        Returns:
        a SingleRpcCommand
      • buildClusteredGetCommand

        ClusteredGetCommand buildClusteredGetCommand​(Object key,
                                                     int segment,
                                                     long flagsBitSet)
        Builds a ClusteredGetCommand, which is a remote lookup command
        Parameters:
        key - key to look up
        segment - the segment for the key
        flagsBitSet - Command flags provided by cache
        Returns:
        a ClusteredGetCommand
      • buildClusteredGetAllCommand

        ClusteredGetAllCommand buildClusteredGetAllCommand​(List<?> keys,
                                                           long flagsBitSet,
                                                           GlobalTransaction gtx)
        Builds a ClusteredGetAllCommand, which is a remote lookup command
        Parameters:
        keys - key to look up
        flagsBitSet - Command flags provided by cache
        Returns:
        a ClusteredGetAllCommand
      • buildLockControlCommand

        LockControlCommand buildLockControlCommand​(Collection<?> keys,
                                                   long flagsBitSet,
                                                   GlobalTransaction gtx)
        Builds a LockControlCommand to control explicit remote locking
        Parameters:
        keys - keys to lock
        flagsBitSet - Command flags provided by cache
        gtx -
        Returns:
        a LockControlCommand
      • buildStateRequestCommand

        StateRequestCommand buildStateRequestCommand​(StateRequestCommand.Type subtype,
                                                     Address sender,
                                                     int topologyId,
                                                     IntSet segments)
        Builds a StateRequestCommand used for requesting transactions and locks and for starting or canceling transfer of cache entries.
      • buildStateResponseCommand

        StateResponseCommand buildStateResponseCommand​(Address sender,
                                                       int viewId,
                                                       Collection<StateChunk> stateChunks,
                                                       boolean applyState,
                                                       boolean pushTransfer)
        Builds a StateResponseCommand used for pushing cache entries to another node in response to a StateRequestCommand.
      • getCacheName

        String getCacheName()
        Retrieves the cache name this CommandFactory is set up to construct commands for.
        Returns:
        the name of the cache this CommandFactory is set up to construct commands for.
      • buildDistributedExecuteCommand

        <T> DistributedExecuteCommand<T> buildDistributedExecuteCommand​(Callable<T> callable,
                                                                        Address sender,
                                                                        Collection keys)
        Builds a DistributedExecuteCommand used for migration and execution of distributed Callables and Runnables.
        Parameters:
        callable - the callable task
        sender - sender's Address
        keys - keys used in Callable
        Returns:
        a DistributedExecuteCommand
      • buildCompleteTransactionCommand

        CompleteTransactionCommand buildCompleteTransactionCommand​(Xid xid,
                                                                   boolean commit)
        Builds a CompleteTransactionCommand command.
        Parameters:
        xid - the xid identifying the transaction we want to complete.
        commit - commit(true) or rollback(false)?
      • buildApplyDeltaCommand

        @Deprecated
        default ApplyDeltaCommand buildApplyDeltaCommand​(Object deltaAwareValueKey,
                                                         Delta delta,
                                                         Collection keys)
        Deprecated.
        since 9.1
        Builds a ApplyDeltaCommand used for applying Delta objects to DeltaAware containers stored in cache
        Returns:
        ApplyDeltaCommand instance
        See Also:
        ApplyDeltaCommand
      • buildCreateCacheCommand

        CreateCacheCommand buildCreateCacheCommand​(String cacheName,
                                                   String cacheConfigurationName)
        Same as buildCreateCacheCommand(cacheName, cacheConfigurationName, false, 0).
      • buildCreateCacheCommand

        CreateCacheCommand buildCreateCacheCommand​(String tmpCacheName,
                                                   String defaultTmpCacheConfigurationName,
                                                   int size)
        Builds a CreateCacheCommand used to create/start cache around Infinispan cluster
        Parameters:
        size - If size > 0, the command will wait until the cache runs on at least size nodes.
      • buildCancelCommandCommand

        CancelCommand buildCancelCommandCommand​(UUID commandUUID)
        Builds CancelCommandCommand used to cancel other commands executing on Infinispan cluster
        Parameters:
        commandUUID - UUID for command to cancel
        Returns:
        created CancelCommandCommand
      • buildXSiteStatePushCommand

        XSiteStatePushCommand buildXSiteStatePushCommand​(XSiteState[] chunk,
                                                         long timeoutMillis)
        Builds XSiteStatePushCommand used to transfer a single chunk of data between sites.
        Parameters:
        chunk - the data chunk
        timeoutMillis - timeout in milliseconds, for the retries in the receiver site.
        Returns:
        the XSiteStatePushCommand created
      • buildSingleXSiteRpcCommand

        SingleXSiteRpcCommand buildSingleXSiteRpcCommand​(VisitableCommand command)
        Builds SingleRpcCommand used to perform VisitableCommand on the backup site,
        Parameters:
        command - the visitable command.
        Returns:
        the SingleXSiteRpcCommand created
      • buildGetKeysInGroupCommand

        GetKeysInGroupCommand buildGetKeysInGroupCommand​(long flagsBitSet,
                                                         Object groupName)
        Builds GetKeysInGroupCommand used to fetch all the keys belonging to a group.
        Parameters:
        flagsBitSet - Command flags provided by cache
        groupName - the group name.
        Returns:
        the GetKeysInGroup created.
      • buildStreamRequestCommand

        <K> org.infinispan.stream.impl.StreamRequestCommand<K> buildStreamRequestCommand​(Object id,
                                                                                         boolean parallelStream,
                                                                                         org.infinispan.stream.impl.StreamRequestCommand.Type type,
                                                                                         IntSet segments,
                                                                                         Set<K> keys,
                                                                                         Set<K> excludedKeys,
                                                                                         boolean includeLoader,
                                                                                         boolean entryStream,
                                                                                         Object terminalOperation)
      • buildStreamResponseCommand

        <R> org.infinispan.stream.impl.StreamResponseCommand<R> buildStreamResponseCommand​(Object identifier,
                                                                                           boolean complete,
                                                                                           IntSet lostSegments,
                                                                                           R response)
        Builds StreamResponseCommand used to send back a response either intermediate or complete to the originating node with the information for the stream request.
        Type Parameters:
        R - type of response
        Parameters:
        identifier - the unique identifier for the stream request
        complete - whether or not this is an intermediate or final response from this node for the given id
        lostSegments - what segments that were lost during processing
        response - the actual response
        Returns:
        the command to send back the response
      • buildStreamIteratorRequestCommand

        <K> org.infinispan.stream.impl.StreamIteratorRequestCommand<K> buildStreamIteratorRequestCommand​(Object id,
                                                                                                         boolean parallelStream,
                                                                                                         IntSet segments,
                                                                                                         Set<K> keys,
                                                                                                         Set<K> excludedKeys,
                                                                                                         boolean includeLoader,
                                                                                                         boolean entryStream,
                                                                                                         Iterable<org.infinispan.stream.impl.intops.IntermediateOperation> intOps,
                                                                                                         long batchSize)
      • buildStreamIteratorNextCommand

        org.infinispan.stream.impl.StreamIteratorNextCommand buildStreamIteratorNextCommand​(Object id,
                                                                                            long batchSize)
      • buildStreamIteratorCloseCommand

        org.infinispan.stream.impl.StreamIteratorCloseCommand buildStreamIteratorCloseCommand​(Object id)
      • buildBackupAckCommand

        BackupAckCommand buildBackupAckCommand​(long id,
                                               int topologyId)
      • buildBackupMultiKeyAckCommand

        BackupMultiKeyAckCommand buildBackupMultiKeyAckCommand​(long id,
                                                               int segment,
                                                               int topologyId)
      • buildInvalidateVersionsCommand

        InvalidateVersionsCommand buildInvalidateVersionsCommand​(int topologyId,
                                                                 Object[] keys,
                                                                 int[] topologyIds,
                                                                 long[] versions,
                                                                 boolean removed)
      • buildTouchCommand

        org.infinispan.expiration.impl.TouchCommand buildTouchCommand​(Object key,
                                                                      int segment)