Class CommandsFactoryImpl

  • All Implemented Interfaces:
    CommandsFactory

    public class CommandsFactoryImpl
    extends Object
    implements CommandsFactory
    Since:
    4.0
    Author:
    Mircea.Markus@jboss.com, Galder ZamarreƱo, Sanne Grinovero <sanne@hibernate.org> (C) 2011 Red Hat Inc.
    • Constructor Detail

      • CommandsFactoryImpl

        public CommandsFactoryImpl()
    • Method Detail

      • start

        public void start()
      • buildPutKeyValueCommand

        public org.infinispan.commands.write.PutKeyValueCommand buildPutKeyValueCommand​(Object key,
                                                                                        Object value,
                                                                                        int segment,
                                                                                        Metadata metadata,
                                                                                        long flagsBitSet)
        Description copied from interface: CommandsFactory
        Builds a PutKeyValueCommand
        Specified by:
        buildPutKeyValueCommand in interface CommandsFactory
        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

        public org.infinispan.commands.write.RemoveCommand buildRemoveCommand​(Object key,
                                                                              Object value,
                                                                              int segment,
                                                                              long flagsBitSet)
        Description copied from interface: CommandsFactory
        Builds a RemoveCommand
        Specified by:
        buildRemoveCommand in interface CommandsFactory
        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

        public org.infinispan.commands.write.InvalidateCommand buildInvalidateCommand​(long flagsBitSet,
                                                                                      Object... keys)
        Description copied from interface: CommandsFactory
        Builds an InvalidateCommand
        Specified by:
        buildInvalidateCommand in interface CommandsFactory
        Parameters:
        flagsBitSet - Command flags provided by cache
        keys - keys to invalidate
        Returns:
        an InvalidateCommand
      • buildInvalidateFromL1Command

        public org.infinispan.commands.write.InvalidateCommand buildInvalidateFromL1Command​(long flagsBitSet,
                                                                                            Collection<Object> keys)
        Description copied from interface: CommandsFactory
        Builds an InvalidateFromL1Command
        Specified by:
        buildInvalidateFromL1Command in interface CommandsFactory
        Parameters:
        flagsBitSet - Command flags provided by cache
        keys - keys to invalidate
        Returns:
        an InvalidateFromL1Command
      • buildRemoveExpiredCommand

        public org.infinispan.commands.write.RemoveExpiredCommand buildRemoveExpiredCommand​(Object key,
                                                                                            Object value,
                                                                                            int segment,
                                                                                            Long lifespan,
                                                                                            long flagsBitSet)
        Description copied from interface: CommandsFactory
        Builds an expired remove command that is used to remove only a specific entry when it expires via lifespan
        Specified by:
        buildRemoveExpiredCommand in interface CommandsFactory
        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

        public org.infinispan.commands.write.RemoveExpiredCommand buildRemoveExpiredCommand​(Object key,
                                                                                            Object value,
                                                                                            int segment,
                                                                                            long flagsBitSet)
        Description copied from interface: CommandsFactory
        Builds an expired remove command that is used to remove only a specific entry when it expires via maxIdle
        Specified by:
        buildRemoveExpiredCommand in interface CommandsFactory
        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

        public org.infinispan.commands.write.ReplaceCommand buildReplaceCommand​(Object key,
                                                                                Object oldValue,
                                                                                Object newValue,
                                                                                int segment,
                                                                                Metadata metadata,
                                                                                long flagsBitSet)
        Description copied from interface: CommandsFactory
        Builds a ReplaceCommand
        Specified by:
        buildReplaceCommand in interface CommandsFactory
        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

        public org.infinispan.commands.write.ComputeCommand buildComputeCommand​(Object key,
                                                                                BiFunction mappingFunction,
                                                                                boolean computeIfPresent,
                                                                                int segment,
                                                                                Metadata metadata,
                                                                                long flagsBitSet)
        Description copied from interface: CommandsFactory
        Builds a ComputeCommand
        Specified by:
        buildComputeCommand in interface CommandsFactory
        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

        public org.infinispan.commands.write.ComputeIfAbsentCommand buildComputeIfAbsentCommand​(Object key,
                                                                                                Function mappingFunction,
                                                                                                int segment,
                                                                                                Metadata metadata,
                                                                                                long flagsBitSet)
        Description copied from interface: CommandsFactory
        Builds a ComputeIfAbsentCommand
        Specified by:
        buildComputeIfAbsentCommand in interface CommandsFactory
        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

        public org.infinispan.commands.read.SizeCommand buildSizeCommand​(long flagsBitSet)
        Description copied from interface: CommandsFactory
        Builds a SizeCommand
        Specified by:
        buildSizeCommand in interface CommandsFactory
        Parameters:
        flagsBitSet - Command flags provided by cache
        Returns:
        a SizeCommand
      • buildKeySetCommand

        public org.infinispan.commands.read.KeySetCommand buildKeySetCommand​(long flagsBitSet)
        Description copied from interface: CommandsFactory
        Builds a KeySetCommand
        Specified by:
        buildKeySetCommand in interface CommandsFactory
        Parameters:
        flagsBitSet - Command flags provided by cache
        Returns:
        a KeySetCommand
      • buildEntrySetCommand

        public org.infinispan.commands.read.EntrySetCommand buildEntrySetCommand​(long flagsBitSet)
        Description copied from interface: CommandsFactory
        Builds a EntrySetCommand
        Specified by:
        buildEntrySetCommand in interface CommandsFactory
        Parameters:
        flagsBitSet - Command flags provided by cache
        Returns:
        a EntrySetCommand
      • buildGetKeyValueCommand

        public org.infinispan.commands.read.GetKeyValueCommand buildGetKeyValueCommand​(Object key,
                                                                                       int segment,
                                                                                       long flagsBitSet)
        Description copied from interface: CommandsFactory
        Builds a GetKeyValueCommand
        Specified by:
        buildGetKeyValueCommand in interface CommandsFactory
        Parameters:
        key - key to get
        segment - the segment of the given key
        flagsBitSet - Command flags provided by cache
        Returns:
        a GetKeyValueCommand
      • buildGetAllCommand

        public org.infinispan.commands.read.GetAllCommand buildGetAllCommand​(Collection<?> keys,
                                                                             long flagsBitSet,
                                                                             boolean returnEntries)
        Description copied from interface: CommandsFactory
        Builds a GetAllCommand
        Specified by:
        buildGetAllCommand in interface CommandsFactory
        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
      • buildPutMapCommand

        public org.infinispan.commands.write.PutMapCommand buildPutMapCommand​(Map<?,​?> map,
                                                                              Metadata metadata,
                                                                              long flagsBitSet)
        Description copied from interface: CommandsFactory
        Builds a PutMapCommand
        Specified by:
        buildPutMapCommand in interface CommandsFactory
        Parameters:
        map - map containing key/value entries to put
        metadata - metadata of entry
        flagsBitSet - Command flags provided by cache
        Returns:
        a PutMapCommand
      • buildClearCommand

        public org.infinispan.commands.write.ClearCommand buildClearCommand​(long flagsBitSet)
        Description copied from interface: CommandsFactory
        Builds a ClearCommand
        Specified by:
        buildClearCommand in interface CommandsFactory
        Parameters:
        flagsBitSet - Command flags provided by cache
        Returns:
        a ClearCommand
      • buildEvictCommand

        public org.infinispan.commands.write.EvictCommand buildEvictCommand​(Object key,
                                                                            int segment,
                                                                            long flagsBitSet)
        Description copied from interface: CommandsFactory
        Builds an EvictCommand
        Specified by:
        buildEvictCommand in interface CommandsFactory
        Parameters:
        key - key to evict
        segment - the segment for the key
        flagsBitSet - Command flags provided by cache
        Returns:
        an EvictCommand
      • buildPrepareCommand

        public org.infinispan.commands.tx.PrepareCommand buildPrepareCommand​(GlobalTransaction gtx,
                                                                             List<org.infinispan.commands.write.WriteCommand> modifications,
                                                                             boolean onePhaseCommit)
        Description copied from interface: CommandsFactory
        Builds a PrepareCommand
        Specified by:
        buildPrepareCommand in interface CommandsFactory
        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

        public org.infinispan.commands.tx.VersionedPrepareCommand buildVersionedPrepareCommand​(GlobalTransaction gtx,
                                                                                               List<org.infinispan.commands.write.WriteCommand> modifications,
                                                                                               boolean onePhase)
        Description copied from interface: CommandsFactory
        Builds a VersionedPrepareCommand
        Specified by:
        buildVersionedPrepareCommand in interface CommandsFactory
        Parameters:
        gtx - global transaction associated with the prepare
        modifications - list of modifications
        Returns:
        a VersionedPrepareCommand
      • buildCommitCommand

        public org.infinispan.commands.tx.CommitCommand buildCommitCommand​(GlobalTransaction gtx)
        Description copied from interface: CommandsFactory
        Builds a CommitCommand
        Specified by:
        buildCommitCommand in interface CommandsFactory
        Parameters:
        gtx - global transaction associated with the commit
        Returns:
        a CommitCommand
      • buildVersionedCommitCommand

        public org.infinispan.commands.tx.VersionedCommitCommand buildVersionedCommitCommand​(GlobalTransaction gtx)
        Description copied from interface: CommandsFactory
        Builds a VersionedCommitCommand
        Specified by:
        buildVersionedCommitCommand in interface CommandsFactory
        Parameters:
        gtx - global transaction associated with the commit
        Returns:
        a VersionedCommitCommand
      • buildRollbackCommand

        public org.infinispan.commands.tx.RollbackCommand buildRollbackCommand​(GlobalTransaction gtx)
        Description copied from interface: CommandsFactory
        Builds a RollbackCommand
        Specified by:
        buildRollbackCommand in interface CommandsFactory
        Parameters:
        gtx - global transaction associated with the rollback
        Returns:
        a RollbackCommand
      • buildSingleRpcCommand

        public org.infinispan.commands.remote.SingleRpcCommand buildSingleRpcCommand​(ReplicableCommand call)
        Description copied from interface: CommandsFactory
        Builds a SingleRpcCommand "envelope" containing a single ReplicableCommand
        Specified by:
        buildSingleRpcCommand in interface CommandsFactory
        Parameters:
        call - ReplicableCommand to include in the envelope
        Returns:
        a SingleRpcCommand
      • buildClusteredGetCommand

        public org.infinispan.commands.remote.ClusteredGetCommand buildClusteredGetCommand​(Object key,
                                                                                           int segment,
                                                                                           long flagsBitSet)
        Description copied from interface: CommandsFactory
        Builds a ClusteredGetCommand, which is a remote lookup command
        Specified by:
        buildClusteredGetCommand in interface CommandsFactory
        Parameters:
        key - key to look up
        segment - the segment for the key
        flagsBitSet - Command flags provided by cache
        Returns:
        a ClusteredGetCommand
      • initializeReplicableCommand

        public void initializeReplicableCommand​(ReplicableCommand c,
                                                boolean isRemote)
        Description copied from interface: CommandsFactory
        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.

        Specified by:
        initializeReplicableCommand in interface CommandsFactory
        Parameters:
        isRemote - true if the command is deserialized and is executed remote.
        c - command to initialize. Cannot be null.
      • buildLockControlCommand

        public org.infinispan.commands.control.LockControlCommand buildLockControlCommand​(Collection<?> keys,
                                                                                          long flagsBitSet,
                                                                                          GlobalTransaction gtx)
        Description copied from interface: CommandsFactory
        Builds a LockControlCommand to control explicit remote locking
        Specified by:
        buildLockControlCommand in interface CommandsFactory
        Parameters:
        keys - keys to lock
        flagsBitSet - Command flags provided by cache
        Returns:
        a LockControlCommand
      • getCacheName

        public String getCacheName()
        Description copied from interface: CommandsFactory
        Retrieves the cache name this CommandFactory is set up to construct commands for.
        Specified by:
        getCacheName in interface CommandsFactory
        Returns:
        the name of the cache this CommandFactory is set up to construct commands for.
      • buildGetInDoubtTransactionsCommand

        public org.infinispan.commands.remote.recovery.GetInDoubtTransactionsCommand buildGetInDoubtTransactionsCommand()
        Description copied from interface: CommandsFactory
        Builds a GetInDoubtTransactionsCommand.
        Specified by:
        buildGetInDoubtTransactionsCommand in interface CommandsFactory
      • buildTxCompletionNotificationCommand

        public org.infinispan.commands.remote.recovery.TxCompletionNotificationCommand buildTxCompletionNotificationCommand​(long internalId)
        Specified by:
        buildTxCompletionNotificationCommand in interface CommandsFactory
        Parameters:
        internalId - the internal id identifying the transaction to be removed.
        See Also:
        TxCompletionNotificationCommand
      • buildDistributedExecuteCommand

        public <T> org.infinispan.commands.read.DistributedExecuteCommand<T> buildDistributedExecuteCommand​(Callable<T> callable,
                                                                                                            Address sender,
                                                                                                            Collection keys)
        Description copied from interface: CommandsFactory
        Builds a DistributedExecuteCommand used for migration and execution of distributed Callables and Runnables.
        Specified by:
        buildDistributedExecuteCommand in interface CommandsFactory
        Parameters:
        callable - the callable task
        sender - sender's Address
        keys - keys used in Callable
        Returns:
        a DistributedExecuteCommand
      • buildGetInDoubtTxInfoCommand

        public org.infinispan.commands.remote.recovery.GetInDoubtTxInfoCommand buildGetInDoubtTxInfoCommand()
        Specified by:
        buildGetInDoubtTxInfoCommand in interface CommandsFactory
        See Also:
        GetInDoubtTxInfoCommand
      • buildCompleteTransactionCommand

        public org.infinispan.commands.remote.recovery.CompleteTransactionCommand buildCompleteTransactionCommand​(Xid xid,
                                                                                                                  boolean commit)
        Description copied from interface: CommandsFactory
        Builds a CompleteTransactionCommand command.
        Specified by:
        buildCompleteTransactionCommand in interface CommandsFactory
        Parameters:
        xid - the xid identifying the transaction we want to complete.
        commit - commit(true) or rollback(false)?
      • buildCreateCacheCommand

        public CreateCacheCommand buildCreateCacheCommand​(String cacheNameToCreate,
                                                          String cacheConfigurationName,
                                                          int size)
        Description copied from interface: CommandsFactory
        Builds a CreateCacheCommand used to create/start cache around Infinispan cluster
        Specified by:
        buildCreateCacheCommand in interface CommandsFactory
        size - If size > 0, the command will wait until the cache runs on at least size nodes.
      • buildCancelCommandCommand

        public CancelCommand buildCancelCommandCommand​(UUID commandUUID)
        Description copied from interface: CommandsFactory
        Builds CancelCommandCommand used to cancel other commands executing on Infinispan cluster
        Specified by:
        buildCancelCommandCommand in interface CommandsFactory
        Parameters:
        commandUUID - UUID for command to cancel
        Returns:
        created CancelCommandCommand
      • buildXSiteStatePushCommand

        public XSiteStatePushCommand buildXSiteStatePushCommand​(XSiteState[] chunk,
                                                                long timeoutMillis)
        Description copied from interface: CommandsFactory
        Builds XSiteStatePushCommand used to transfer a single chunk of data between sites.
        Specified by:
        buildXSiteStatePushCommand in interface CommandsFactory
        Parameters:
        chunk - the data chunk
        timeoutMillis - timeout in milliseconds, for the retries in the receiver site.
        Returns:
        the XSiteStatePushCommand created
      • buildGetKeysInGroupCommand

        public org.infinispan.commands.remote.GetKeysInGroupCommand buildGetKeysInGroupCommand​(long flagsBitSet,
                                                                                               Object groupName)
        Description copied from interface: CommandsFactory
        Builds GetKeysInGroupCommand used to fetch all the keys belonging to a group.
        Specified by:
        buildGetKeysInGroupCommand in interface CommandsFactory
        Parameters:
        flagsBitSet - Command flags provided by cache
        groupName - the group name.
        Returns:
        the GetKeysInGroup created.
      • buildStreamResponseCommand

        public <R> StreamResponseCommand<R> buildStreamResponseCommand​(Object identifier,
                                                                       boolean complete,
                                                                       org.infinispan.commons.util.IntSet lostSegments,
                                                                       R response)
        Description copied from interface: CommandsFactory
        Builds StreamResponseCommand used to send back a response either intermediate or complete to the originating node with the information for the stream request.
        Specified by:
        buildStreamResponseCommand in interface CommandsFactory
        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
      • buildGetCacheEntryCommand

        public org.infinispan.commands.read.GetCacheEntryCommand buildGetCacheEntryCommand​(Object key,
                                                                                           int segment,
                                                                                           long flagsBitSet)
        Description copied from interface: CommandsFactory
        Builds a GetCacheEntryCommand
        Specified by:
        buildGetCacheEntryCommand in interface CommandsFactory
        Parameters:
        key - key to get
        segment - the segment for the key
        flagsBitSet - Command flags provided by cache
        Returns:
        a GetCacheEntryCommand
      • buildClusteredGetAllCommand

        public org.infinispan.commands.remote.ClusteredGetAllCommand buildClusteredGetAllCommand​(List<?> keys,
                                                                                                 long flagsBitSet,
                                                                                                 GlobalTransaction gtx)
        Description copied from interface: CommandsFactory
        Builds a ClusteredGetAllCommand, which is a remote lookup command
        Specified by:
        buildClusteredGetAllCommand in interface CommandsFactory
        Parameters:
        keys - key to look up
        flagsBitSet - Command flags provided by cache
        Returns:
        a ClusteredGetAllCommand
      • buildInvalidateVersionsCommand

        public org.infinispan.commands.write.InvalidateVersionsCommand buildInvalidateVersionsCommand​(int topologyId,
                                                                                                      Object[] keys,
                                                                                                      int[] topologyIds,
                                                                                                      long[] versions,
                                                                                                      boolean removed)
        Specified by:
        buildInvalidateVersionsCommand in interface CommandsFactory
      • buildBackupAckCommand

        public org.infinispan.commands.write.BackupAckCommand buildBackupAckCommand​(long id,
                                                                                    int topologyId)
        Specified by:
        buildBackupAckCommand in interface CommandsFactory
      • buildBackupMultiKeyAckCommand

        public org.infinispan.commands.write.BackupMultiKeyAckCommand buildBackupMultiKeyAckCommand​(long id,
                                                                                                    int segment,
                                                                                                    int topologyId)
        Specified by:
        buildBackupMultiKeyAckCommand in interface CommandsFactory