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
 ClearCommand buildClearCommand(Set<Flag> flags)
          Builds a ClearCommand
 ClusteredGetCommand buildClusteredGetCommand(Object key, Set<Flag> flags)
          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(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 keys, boolean implicit, Set<Flag> flags)
          Builds a LockControlCommand to control explicit remote locking
 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
 RehashControlCommand buildRehashControlCommand(RehashControlCommand.Type type, Address sender, int viewId)
          Builds a RehashControlCommand for coordinating a rehash event.
 RehashControlCommand buildRehashControlCommand(RehashControlCommand.Type type, Address sender, int viewId, Map<Object,InternalCacheValue> state, ConsistentHash oldCH, ConsistentHash newCH)
          Builds a RehashControlCommand for coordinating a rehash event.
 RemoveCommand buildRemoveCommand(Object key, Object value, Set<Flag> flags)
          Builds a RemoveCommand
 RemoveRecoveryInfoCommand buildRemoveRecoveryInfoCommand(long internalId)
           
 RemoveRecoveryInfoCommand buildRemoveRecoveryInfoCommand(Xid xid)
          Builds a RemoveRecoveryInfoCommand.
 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 buildStateTransferControlCommand(boolean block)
          Builds a StateTransferControlCommand
 ValuesCommand buildValuesCommand()
          Builds a ValuesCommand
 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 cache, InterceptorChain interceptorChain, DistributionManager distributionManager, InvocationContextContainer icc, TransactionTable txTable, Configuration configuration, Map<Byte,ModuleCommandInitializer> moduleCommandInitializers, RecoveryManager recoveryManager)
           
 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 cache,
                              InterceptorChain interceptorChain,
                              DistributionManager distributionManager,
                              InvocationContextContainer icc,
                              TransactionTable txTable,
                              Configuration configuration,
                              Map<Byte,ModuleCommandInitializer> moduleCommandInitializers,
                              RecoveryManager recoveryManager)

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

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

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

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

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

buildStateTransferControlCommand

public StateTransferControlCommand buildStateTransferControlCommand(boolean block)
Description copied from interface: CommandsFactory
Builds a StateTransferControlCommand

Specified by:
buildStateTransferControlCommand in interface CommandsFactory
Parameters:
block - whether to start blocking or not
Returns:
a StateTransferControlCommand

buildClusteredGetCommand

public ClusteredGetCommand buildClusteredGetCommand(Object key,
                                                    Set<Flag> flags)
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 keys,
                                                  boolean implicit,
                                                  Set<Flag> flags)
Description copied from interface: CommandsFactory
Builds a LockControlCommand to control explicit remote locking

Specified by:
buildLockControlCommand in interface CommandsFactory
Parameters:
keys - keys to lock
implicit - whether the lock command was implicit (triggered internally) or explicit (triggered by an API call)
Returns:
a LockControlCommand

buildRehashControlCommand

public RehashControlCommand buildRehashControlCommand(RehashControlCommand.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:
buildRehashControlCommand in interface CommandsFactory
Parameters:
type - type of RehashControlCommand
sender - sender's Address
viewId - the last view id on the sender
Returns:
a RehashControlCommand

buildRehashControlCommand

public RehashControlCommand buildRehashControlCommand(RehashControlCommand.Type type,
                                                      Address sender,
                                                      int viewId,
                                                      Map<Object,InternalCacheValue> state,
                                                      ConsistentHash oldCH,
                                                      ConsistentHash newCH)
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:
buildRehashControlCommand 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

buildRemoveRecoveryInfoCommand

public RemoveRecoveryInfoCommand buildRemoveRecoveryInfoCommand(Xid xid)
Description copied from interface: CommandsFactory
Builds a RemoveRecoveryInfoCommand.

Specified by:
buildRemoveRecoveryInfoCommand in interface CommandsFactory

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

buildRemoveRecoveryInfoCommand

public RemoveRecoveryInfoCommand buildRemoveRecoveryInfoCommand(long internalId)
Specified by:
buildRemoveRecoveryInfoCommand in interface CommandsFactory
Parameters:
internalId - the internal id identifying the transaction to be removed.
See Also:
RemoveRecoveryInfoCommand

-->

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