org.infinispan.commands
Class CommandsFactoryImpl

java.lang.Object
  extended by org.infinispan.commands.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 (C) 2011 Red Hat Inc.

Constructor Summary
CommandsFactoryImpl()
           
 
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 CommandsFactory.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 lifespan, 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 lifespan, 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 type, Address sender, int viewId)
          Builds a RehashControlCommand for coordinating a rehash event.
 StateTransferControlCommand buildStateTransferCommand(StateTransferControlCommand.Type type, 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 c, boolean isRemote)
          Initializes a ReplicableCommand read from a data stream with components specific to the target cache instance.
 void setupDependencies(DataContainer container, CacheNotifier notifier, Cache<Object,Object> cache, InterceptorChain interceptorChain, DistributionManager distributionManager, InvocationContextContainer icc, TransactionTable txTable, Configuration configuration, Map<Byte,ModuleCommandInitializer> moduleCommandInitializers, RecoveryManager recoveryManager, StateTransferManager stateTransferManager, LockManager lockManager, InternalEntryFactory entryFactory)
           
 void start()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandsFactoryImpl

public CommandsFactoryImpl()
Method Detail

setupDependencies

public void setupDependencies(DataContainer container,
                              CacheNotifier notifier,
                              Cache<Object,Object> cache,
                              InterceptorChain interceptorChain,
                              DistributionManager distributionManager,
                              InvocationContextContainer icc,
                              TransactionTable txTable,
                              Configuration configuration,
                              Map<Byte,ModuleCommandInitializer> moduleCommandInitializers,
                              RecoveryManager recoveryManager,
                              StateTransferManager stateTransferManager,
                              LockManager lockManager,
                              InternalEntryFactory entryFactory)

start

public void start()

buildPutKeyValueCommand

public PutKeyValueCommand buildPutKeyValueCommand(Object key,
                                                  Object value,
                                                  long lifespanMillis,
                                                  long maxIdleTimeMillis,
                                                  Set<Flag> flags)
Description copied from interface: CommandsFactory
Builds a PutKeyValueCommand

Specified by:
buildPutKeyValueCommand in interface CommandsFactory
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

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

Specified by:
buildVersionedPutKeyValueCommand in interface CommandsFactory
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

public RemoveCommand buildRemoveCommand(Object key,
                                        Object value,
                                        Set<Flag> flags)
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.
Returns:
a RemoveCommand

buildInvalidateCommand

public InvalidateCommand buildInvalidateCommand(Object... keys)
Description copied from interface: CommandsFactory
Builds an InvalidateCommand

Specified by:
buildInvalidateCommand in interface CommandsFactory
Parameters:
keys - keys to invalidate
Returns:
an InvalidateCommand

buildInvalidateFromL1Command

public InvalidateCommand buildInvalidateFromL1Command(boolean forRehash,
                                                      Object... keys)
Description copied from interface: CommandsFactory
Builds an InvalidateFromL1Command

Specified by:
buildInvalidateFromL1Command in interface CommandsFactory
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

public InvalidateCommand buildInvalidateFromL1Command(boolean forRehash,
                                                      Collection<Object> keys)
Description copied from interface: CommandsFactory
Builds an InvalidateFromL1Command

Specified by:
buildInvalidateFromL1Command in interface CommandsFactory
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

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

buildReplaceCommand

public ReplaceCommand buildReplaceCommand(Object key,
                                          Object oldValue,
                                          Object newValue,
                                          long lifespan,
                                          long maxIdleTimeMillis,
                                          Set<Flag> flags)
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
lifespan - 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

public SizeCommand buildSizeCommand()
Description copied from interface: CommandsFactory
Builds a SizeCommand

Specified by:
buildSizeCommand in interface CommandsFactory
Returns:
a SizeCommand

buildKeySetCommand

public KeySetCommand buildKeySetCommand()
Description copied from interface: CommandsFactory
Builds a KeySetCommand

Specified by:
buildKeySetCommand in interface CommandsFactory
Returns:
a KeySetCommand

buildValuesCommand

public ValuesCommand buildValuesCommand()
Description copied from interface: CommandsFactory
Builds a ValuesCommand

Specified by:
buildValuesCommand in interface CommandsFactory
Returns:
a ValuesCommand

buildEntrySetCommand

public EntrySetCommand buildEntrySetCommand()
Description copied from interface: CommandsFactory
Builds a EntrySetCommand

Specified by:
buildEntrySetCommand in interface CommandsFactory
Returns:
a EntrySetCommand

buildGetKeyValueCommand

public GetKeyValueCommand buildGetKeyValueCommand(Object key,
                                                  Set<Flag> flags)
Description copied from interface: CommandsFactory
Builds a GetKeyValueCommand

Specified by:
buildGetKeyValueCommand in interface CommandsFactory
Parameters:
key - key to get
Returns:
a GetKeyValueCommand

buildPutMapCommand

public PutMapCommand buildPutMapCommand(Map<?,?> map,
                                        long lifespan,
                                        long maxIdleTimeMillis,
                                        Set<Flag> flags)
Description copied from interface: CommandsFactory
Builds a PutMapCommand

Specified by:
buildPutMapCommand in interface CommandsFactory
Parameters:
map - map containing key/value entries to put
lifespan - 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

public ClearCommand buildClearCommand(Set<Flag> flags)
Description copied from interface: CommandsFactory
Builds a ClearCommand

Specified by:
buildClearCommand in interface CommandsFactory
Returns:
a ClearCommand

buildEvictCommand

public EvictCommand buildEvictCommand(Object key)
Description copied from interface: CommandsFactory
Builds an EvictCommand

Specified by:
buildEvictCommand in interface CommandsFactory
Parameters:
key - key to evict
Returns:
an EvictCommand

buildPrepareCommand

public PrepareCommand buildPrepareCommand(GlobalTransaction gtx,
                                          List<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 VersionedPrepareCommand buildVersionedPrepareCommand(GlobalTransaction gtx,
                                                            List<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 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 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 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

buildReplicateCommand

public MultipleRpcCommand buildReplicateCommand(List<ReplicableCommand> toReplicate)
Description copied from interface: CommandsFactory
Builds an RpcCommand "envelope" containing multiple ReplicableCommands

Specified by:
buildReplicateCommand in interface CommandsFactory
Parameters:
toReplicate - ReplicableCommands to include in the envelope
Returns:
a MultipleRpcCommand

buildSingleRpcCommand

public 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 ClusteredGetCommand buildClusteredGetCommand(Object key,
                                                    Set<Flag> flags,
                                                    boolean acquireRemoteLock,
                                                    GlobalTransaction gtx)
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
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 LockControlCommand buildLockControlCommand(Collection<Object> keys,
                                                  Set<Flag> flags,
                                                  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
Returns:
a LockControlCommand

buildLockControlCommand

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

Specified by:
buildLockControlCommand in interface CommandsFactory

buildLockControlCommand

public LockControlCommand buildLockControlCommand(Collection<Object> keys,
                                                  Set<Flag> flags)
Specified by:
buildLockControlCommand in interface CommandsFactory

buildStateTransferCommand

public StateTransferControlCommand buildStateTransferCommand(StateTransferControlCommand.Type type,
                                                             Address sender,
                                                             int viewId)
Description copied from interface: CommandsFactory
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.

Specified by:
buildStateTransferCommand in interface CommandsFactory
Parameters:
type - type of RehashControlCommand
sender - sender's Address
viewId - the last view id on the sender
Returns:
a RehashControlCommand

buildStateTransferCommand

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

Specified by:
buildStateTransferCommand in interface CommandsFactory

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 GetInDoubtTransactionsCommand buildGetInDoubtTransactionsCommand()
Description copied from interface: CommandsFactory
Builds a GetInDoubtTransactionsCommand.

Specified by:
buildGetInDoubtTransactionsCommand in interface CommandsFactory

buildTxCompletionNotificationCommand

public TxCompletionNotificationCommand buildTxCompletionNotificationCommand(Xid xid,
                                                                            GlobalTransaction globalTransaction)
Description copied from interface: CommandsFactory
Builds a TxCompletionNotificationCommand.

Specified by:
buildTxCompletionNotificationCommand in interface CommandsFactory

buildTxCompletionNotificationCommand

public 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> 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

buildMapReduceCommand

public MapReduceCommand buildMapReduceCommand(Mapper m,
                                              Reducer r,
                                              Address sender,
                                              Collection keys)
Description copied from interface: CommandsFactory
Builds a MapReduceCommand used for migration and execution of MapReduce tasks.

Specified by:
buildMapReduceCommand in interface CommandsFactory
Parameters:
m - Mapper for MapReduceTask
r - Reducer for MapReduceTask
sender - sender's Address
keys - keys used in MapReduceTask
Returns:
a MapReduceCommand

buildGetInDoubtTxInfoCommand

public GetInDoubtTxInfoCommand buildGetInDoubtTxInfoCommand()
Specified by:
buildGetInDoubtTxInfoCommand in interface CommandsFactory
See Also:
GetInDoubtTxInfoCommand

buildCompleteTransactionCommand

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

buildApplyDeltaCommand

public ApplyDeltaCommand buildApplyDeltaCommand(Object deltaAwareValueKey,
                                                Delta delta,
                                                Collection keys)
Description copied from interface: CommandsFactory
Builds a ApplyDeltaCommand used for applying Delta objects to DeltaAware containers stored in cache

Specified by:
buildApplyDeltaCommand in interface CommandsFactory
Returns:
ApplyDeltaCommand instance
See Also:
ApplyDeltaCommand

-->

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