org.infinispan.commands
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 Summary
 ApplyDeltaCommand buildApplyDeltaCommand(Object deltaAwareValueKey, Delta delta, Collection keys)
          Builds a ApplyDeltaCommand used for applying Delta objects to DeltaAware containers stored in cache
 ClearCommand buildClearCommand(Set<Flag> flags)
          Builds a ClearCommand
 ClusteredGetCommand buildClusteredGetCommand(Object key, Set<Flag> flags, boolean acquireRemoteLock, GlobalTransaction gtx)
          Builds a ClusteredGetCommand, which is a remote lookup command
 CommitCommand buildCommitCommand(GlobalTransaction gtx)
          Builds a CommitCommand
 CompleteTransactionCommand buildCompleteTransactionCommand(Xid xid, boolean commit)
          Builds a CompleteTransactionCommand command.
<T> DistributedExecuteCommand<T>
buildDistributedExecuteCommand(Callable<T> callable, Address sender, Collection keys)
          Builds a DistributedExecuteCommand used for migration and execution of distributed Callables and Runnables.
 EntrySetCommand buildEntrySetCommand()
          Builds a EntrySetCommand
 EvictCommand buildEvictCommand(Object key)
          Builds an EvictCommand
 GetInDoubtTransactionsCommand buildGetInDoubtTransactionsCommand()
          Builds a GetInDoubtTransactionsCommand.
 GetInDoubtTxInfoCommand buildGetInDoubtTxInfoCommand()
           
 GetKeyValueCommand buildGetKeyValueCommand(Object key, Set<Flag> flags)
          Builds a GetKeyValueCommand
 InvalidateCommand buildInvalidateCommand(Object... keys)
          Builds an InvalidateCommand
 InvalidateCommand buildInvalidateFromL1Command(Address origin, boolean forRehash, Collection<Object> keys)
           
 InvalidateCommand buildInvalidateFromL1Command(boolean forRehash, Collection<Object> keys)
          Builds an InvalidateFromL1Command
 InvalidateCommand buildInvalidateFromL1Command(boolean forRehash, Object... keys)
          Builds an InvalidateFromL1Command
 KeySetCommand buildKeySetCommand()
          Builds a KeySetCommand
 LockControlCommand buildLockControlCommand(Collection<Object> keys, Set<Flag> flags)
           
 LockControlCommand buildLockControlCommand(Collection<Object> keys, Set<Flag> flags, GlobalTransaction gtx)
          Builds a LockControlCommand to control explicit remote locking
 LockControlCommand buildLockControlCommand(Object key, Set<Flag> flags, GlobalTransaction gtx)
          Same as buildLockControlCommand(Object, java.util.Set, org.infinispan.transaction.xa.GlobalTransaction) but for locking a single key vs a collection of keys.
 MapReduceCommand buildMapReduceCommand(Mapper m, Reducer r, Address sender, Collection keys)
          Builds a MapReduceCommand used for migration and execution of MapReduce tasks.
 PrepareCommand buildPrepareCommand(GlobalTransaction gtx, List<WriteCommand> modifications, boolean onePhaseCommit)
          Builds a PrepareCommand
 PutKeyValueCommand buildPutKeyValueCommand(Object key, Object value, long lifespanMillis, long maxIdleTimeMillis, Set<Flag> flags)
          Builds a PutKeyValueCommand
 PutMapCommand buildPutMapCommand(Map<?,?> map, long lifespanMillis, long maxIdleTimeMillis, Set<Flag> flags)
          Builds a PutMapCommand
 RemoveCommand buildRemoveCommand(Object key, Object value, Set<Flag> flags)
          Builds a RemoveCommand
 ReplaceCommand buildReplaceCommand(Object key, Object oldValue, Object newValue, long lifespanMillis, long maxIdleTimeMillis, Set<Flag> flags)
          Builds a ReplaceCommand
 MultipleRpcCommand buildReplicateCommand(List<ReplicableCommand> toReplicate)
          Builds an RpcCommand "envelope" containing multiple ReplicableCommands
 RollbackCommand buildRollbackCommand(GlobalTransaction gtx)
          Builds a RollbackCommand
 SingleRpcCommand buildSingleRpcCommand(ReplicableCommand call)
          Builds a SingleRpcCommand "envelope" containing a single ReplicableCommand
 SizeCommand buildSizeCommand()
          Builds a SizeCommand
 StateTransferControlCommand buildStateTransferCommand(StateTransferControlCommand.Type subtype, Address sender, int viewId)
          Builds a RehashControlCommand for coordinating a rehash event.
 StateTransferControlCommand buildStateTransferCommand(StateTransferControlCommand.Type subtype, Address sender, int viewId, Collection<InternalCacheEntry> state, Collection<LockInfo> lockInfo)
          Builds a RehashControlCommand for coordinating a rehash event.
 TxCompletionNotificationCommand buildTxCompletionNotificationCommand(long internalId)
           
 TxCompletionNotificationCommand buildTxCompletionNotificationCommand(Xid xid, GlobalTransaction globalTransaction)
          Builds a TxCompletionNotificationCommand.
 ValuesCommand buildValuesCommand()
          Builds a ValuesCommand
 VersionedCommitCommand buildVersionedCommitCommand(GlobalTransaction gtx)
          Builds a VersionedCommitCommand
 VersionedPrepareCommand buildVersionedPrepareCommand(GlobalTransaction gtx, List<WriteCommand> modifications, boolean onePhase)
          Builds a VersionedPrepareCommand
 VersionedPutKeyValueCommand buildVersionedPutKeyValueCommand(Object key, Object value, long lifespanMillis, long maxIdleTimeMillis, EntryVersion version, Set<Flag> flags)
          Builds a special form of PutKeyValueCommand that also holds a reference to a version to be applied.
 String getCacheName()
          Retrieves the cache name this CommandFactory is set up to construct commands for.
 void initializeReplicableCommand(ReplicableCommand command, boolean isRemote)
          Initializes a ReplicableCommand read from a data stream with components specific to the target cache instance.
 

Method Detail

buildPutKeyValueCommand

PutKeyValueCommand buildPutKeyValueCommand(Object key,
                                           Object value,
                                           long lifespanMillis,
                                           long maxIdleTimeMillis,
                                           Set<Flag> flags)
Builds a PutKeyValueCommand

Parameters:
key - key to put
value - value to put
lifespanMillis - lifespan in milliseconds. -1 if lifespan is not used.
maxIdleTimeMillis - max idle time in milliseconds. -1 if maxIdle is not used.
Returns:
a PutKeyValueCommand

buildVersionedPutKeyValueCommand

VersionedPutKeyValueCommand buildVersionedPutKeyValueCommand(Object key,
                                                             Object value,
                                                             long lifespanMillis,
                                                             long maxIdleTimeMillis,
                                                             EntryVersion version,
                                                             Set<Flag> flags)
Builds a special form of PutKeyValueCommand that also holds a reference to a version to be applied.

Parameters:
key - key to put
value - value to put
lifespanMillis - lifespan in milliseconds. -1 if lifespan is not used.
maxIdleTimeMillis - max idle time in milliseconds. -1 if maxIdle is not used.
version - version to apply with this put
Returns:
a PutKeyValueCommand

buildRemoveCommand

RemoveCommand buildRemoveCommand(Object key,
                                 Object value,
                                 Set<Flag> flags)
Builds a RemoveCommand

Parameters:
key - key to remove
value - value to check for ina conditional remove, or null for an unconditional remove.
Returns:
a RemoveCommand

buildInvalidateCommand

InvalidateCommand buildInvalidateCommand(Object... keys)
Builds an InvalidateCommand

Parameters:
keys - keys to invalidate
Returns:
an InvalidateCommand

buildInvalidateFromL1Command

InvalidateCommand buildInvalidateFromL1Command(boolean forRehash,
                                               Object... keys)
Builds an InvalidateFromL1Command

Parameters:
forRehash - set to true if the invalidation is happening due to a new node taking ownership. False if it is due to a write, changing the state of the entry.
keys - keys to invalidate
Returns:
an InvalidateFromL1Command

buildInvalidateFromL1Command

InvalidateCommand buildInvalidateFromL1Command(boolean forRehash,
                                               Collection<Object> keys)
Builds an InvalidateFromL1Command

Parameters:
forRehash - set to true if the invalidation is happening due to a new node taking ownership. False if it is due to a write, changing the state of the entry.
keys - keys to invalidate
Returns:
an InvalidateFromL1Command

buildInvalidateFromL1Command

InvalidateCommand buildInvalidateFromL1Command(Address origin,
                                               boolean forRehash,
                                               Collection<Object> keys)
See Also:
buildInvalidateFromL1Command(org.infinispan.remoting.transport.Address, boolean, java.util.Collection)

buildReplaceCommand

ReplaceCommand buildReplaceCommand(Object key,
                                   Object oldValue,
                                   Object newValue,
                                   long lifespanMillis,
                                   long maxIdleTimeMillis,
                                   Set<Flag> flags)
Builds a ReplaceCommand

Parameters:
key - key to replace
oldValue - existing value to check for if conditional, null if unconditional.
newValue - value to replace with
lifespanMillis - lifespan in milliseconds. -1 if lifespan is not used.
maxIdleTimeMillis - max idle time in milliseconds. -1 if maxIdle is not used.
Returns:
a ReplaceCommand

buildSizeCommand

SizeCommand buildSizeCommand()
Builds a SizeCommand

Returns:
a SizeCommand

buildGetKeyValueCommand

GetKeyValueCommand buildGetKeyValueCommand(Object key,
                                           Set<Flag> flags)
Builds a GetKeyValueCommand

Parameters:
key - key to get
Returns:
a GetKeyValueCommand

buildKeySetCommand

KeySetCommand buildKeySetCommand()
Builds a KeySetCommand

Returns:
a KeySetCommand

buildValuesCommand

ValuesCommand buildValuesCommand()
Builds a ValuesCommand

Returns:
a ValuesCommand

buildEntrySetCommand

EntrySetCommand buildEntrySetCommand()
Builds a EntrySetCommand

Returns:
a EntrySetCommand

buildPutMapCommand

PutMapCommand buildPutMapCommand(Map<?,?> map,
                                 long lifespanMillis,
                                 long maxIdleTimeMillis,
                                 Set<Flag> flags)
Builds a PutMapCommand

Parameters:
map - map containing key/value entries to put
lifespanMillis - lifespan in milliseconds. -1 if lifespan is not used.
maxIdleTimeMillis - max idle time in milliseconds. -1 if maxIdle is not used.
Returns:
a PutMapCommand

buildClearCommand

ClearCommand buildClearCommand(Set<Flag> flags)
Builds a ClearCommand

Returns:
a ClearCommand

buildEvictCommand

EvictCommand buildEvictCommand(Object key)
Builds an EvictCommand

Parameters:
key - key to evict
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 -

buildReplicateCommand

MultipleRpcCommand buildReplicateCommand(List<ReplicableCommand> toReplicate)
Builds an RpcCommand "envelope" containing multiple ReplicableCommands

Parameters:
toReplicate - ReplicableCommands to include in the envelope
Returns:
a MultipleRpcCommand

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,
                                             Set<Flag> flags,
                                             boolean acquireRemoteLock,
                                             GlobalTransaction gtx)
Builds a ClusteredGetCommand, which is a remote lookup command

Parameters:
key - key to look up
Returns:
a ClusteredGetCommand

buildLockControlCommand

LockControlCommand buildLockControlCommand(Collection<Object> keys,
                                           Set<Flag> flags,
                                           GlobalTransaction gtx)
Builds a LockControlCommand to control explicit remote locking

Parameters:
keys - keys to lock
gtx -
Returns:
a LockControlCommand

buildLockControlCommand

LockControlCommand buildLockControlCommand(Object key,
                                           Set<Flag> flags,
                                           GlobalTransaction gtx)
Same as buildLockControlCommand(Object, java.util.Set, org.infinispan.transaction.xa.GlobalTransaction) but for locking a single key vs a collection of keys.


buildLockControlCommand

LockControlCommand buildLockControlCommand(Collection<Object> keys,
                                           Set<Flag> flags)

buildStateTransferCommand

StateTransferControlCommand buildStateTransferCommand(StateTransferControlCommand.Type subtype,
                                                      Address sender,
                                                      int viewId)
Builds a RehashControlCommand for coordinating a rehash event. This version of this factory method creates a simple control command with just a command type and sender.

Parameters:
subtype - type of RehashControlCommand
sender - sender's Address
viewId - the last view id on the sender
Returns:
a RehashControlCommand

buildStateTransferCommand

StateTransferControlCommand buildStateTransferCommand(StateTransferControlCommand.Type subtype,
                                                      Address sender,
                                                      int viewId,
                                                      Collection<InternalCacheEntry> state,
                                                      Collection<LockInfo> lockInfo)
Builds a RehashControlCommand for coordinating a rehash event. This particular variation of RehashControlCommand coordinates rehashing of nodes when a node join or leaves


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.

buildGetInDoubtTransactionsCommand

GetInDoubtTransactionsCommand buildGetInDoubtTransactionsCommand()
Builds a GetInDoubtTransactionsCommand.


buildTxCompletionNotificationCommand

TxCompletionNotificationCommand buildTxCompletionNotificationCommand(Xid xid,
                                                                     GlobalTransaction globalTransaction)
Builds a TxCompletionNotificationCommand.


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

buildMapReduceCommand

MapReduceCommand buildMapReduceCommand(Mapper m,
                                       Reducer r,
                                       Address sender,
                                       Collection keys)
Builds a MapReduceCommand used for migration and execution of MapReduce tasks.

Parameters:
m - Mapper for MapReduceTask
r - Reducer for MapReduceTask
sender - sender's Address
keys - keys used in MapReduceTask
Returns:
a MapReduceCommand

buildGetInDoubtTxInfoCommand

GetInDoubtTxInfoCommand buildGetInDoubtTxInfoCommand()
See Also:
GetInDoubtTxInfoCommand

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)?

buildTxCompletionNotificationCommand

TxCompletionNotificationCommand buildTxCompletionNotificationCommand(long internalId)
Parameters:
internalId - the internal id identifying the transaction to be removed.
See Also:
TxCompletionNotificationCommand

buildApplyDeltaCommand

ApplyDeltaCommand buildApplyDeltaCommand(Object deltaAwareValueKey,
                                         Delta delta,
                                         Collection keys)
Builds a ApplyDeltaCommand used for applying Delta objects to DeltaAware containers stored in cache

Returns:
ApplyDeltaCommand instance
See Also:
ApplyDeltaCommand

-->

Copyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.