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

Constructor Summary
CommandsFactoryImpl()
           
 
Method Summary
 ClearCommand buildClearCommand()
          Builds a ClearCommand
 ClusteredGetCommand buildClusteredGetCommand(Object key)
          Builds a ClusteredGetCommand, which is a remote lookup command
 CommitCommand buildCommitCommand(GlobalTransaction gtx)
          Builds a CommitCommand
 EntrySetCommand buildEntrySetCommand()
          Builds a EntrySetCommand
 EvictCommand buildEvictCommand(Object key)
          Builds an EvictCommand
 GetKeyValueCommand buildGetKeyValueCommand(Object key)
          Builds a GetKeyValueCommand
 InvalidateCommand buildInvalidateCommand(Object... keys)
          Builds an InvalidateCommand
 InvalidateCommand buildInvalidateFromL1Command(boolean forRehash, Object... keys)
          Builds an InvalidateFromL1Command
 KeySetCommand buildKeySetCommand()
          Builds a KeySetCommand
 LockControlCommand buildLockControlCommand(Collection keys, boolean implicit)
          Builds a LockControlCommand to control explicit remote locking
 PrepareCommand buildPrepareCommand(GlobalTransaction gtx, List<WriteCommand> modifications, boolean onePhaseCommit)
          Builds a PrepareCommand
 PutKeyValueCommand buildPutKeyValueCommand(Object key, Object value, long lifespanMillis, long maxIdleTimeMillis)
          Builds a PutKeyValueCommand
 PutMapCommand buildPutMapCommand(Map map, long lifespan, long maxIdleTimeMillis)
          Builds a PutMapCommand
 RehashControlCommand buildRehashControlCommand(Address sender, Map<Object,InternalCacheValue> state)
          Builds a RehashControlCommand for coordinating a rehash event.
 RehashControlCommand buildRehashControlCommand(RehashControlCommand.Type type, Address sender)
          Builds a RehashControlCommand for coordinating a rehash event.
 RehashControlCommand buildRehashControlCommand(RehashControlCommand.Type type, Address sender, Map<Object,InternalCacheValue> state, ConsistentHash consistentHash)
          A more generic version of this factory method that allows the setting of various fields.
 RehashControlCommand buildRehashControlCommandTxLog(Address sender, List<WriteCommand> commands)
          Builds a RehashControlCommand for coordinating a rehash event.
 RehashControlCommand buildRehashControlCommandTxLogPendingPrepares(Address sender, List<PrepareCommand> commands)
          Builds a RehashControlCommand for coordinating a rehash event.
 RemoveCommand buildRemoveCommand(Object key, Object value)
          Builds a RemoveCommand
 ReplaceCommand buildReplaceCommand(Object key, Object oldValue, Object newValue, long lifespan, long maxIdleTimeMillis)
          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
 void initializeReplicableCommand(ReplicableCommand c)
          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)
           
 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)

start

public void start()

buildPutKeyValueCommand

public PutKeyValueCommand buildPutKeyValueCommand(Object key,
                                                  Object value,
                                                  long lifespanMillis,
                                                  long maxIdleTimeMillis)
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)
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

buildReplaceCommand

public ReplaceCommand buildReplaceCommand(Object key,
                                          Object oldValue,
                                          Object newValue,
                                          long lifespan,
                                          long maxIdleTimeMillis)
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)
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)
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()
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)
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)
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:
c - command to initialize. Cannot be null.

buildLockControlCommand

public LockControlCommand buildLockControlCommand(Collection keys,
                                                  boolean implicit)
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)
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
Returns:
a RehashControlCommand

buildRehashControlCommand

public RehashControlCommand buildRehashControlCommand(Address sender,
                                                      Map<Object,InternalCacheValue> state)
Description copied from interface: CommandsFactory
Builds a RehashControlCommand for coordinating a rehash event. This version of this factory method creates a control command with a sender and a payload - a map of state to be pushed to the recipient. The RehashControlCommand.Type of this command is RehashControlCommand.Type.PUSH_STATE.

Specified by:
buildRehashControlCommand in interface CommandsFactory
Parameters:
sender - sender's Address
state - state map to be pushed to the recipient of this command
Returns:
a RehashControlCommand

buildRehashControlCommandTxLog

public RehashControlCommand buildRehashControlCommandTxLog(Address sender,
                                                           List<WriteCommand> commands)
Description copied from interface: CommandsFactory
Builds a RehashControlCommand for coordinating a rehash event. This version of this factory method creates a control command with a sender and a payload - a transaction log of writes that occured during the generation and delivery of state. The RehashControlCommand.Type of this command is RehashControlCommand.Type.DRAIN_TX.

Specified by:
buildRehashControlCommandTxLog in interface CommandsFactory
Parameters:
sender - sender's Address
commands - list of writes
Returns:
a RehashControlCommand

buildRehashControlCommandTxLogPendingPrepares

public RehashControlCommand buildRehashControlCommandTxLogPendingPrepares(Address sender,
                                                                          List<PrepareCommand> commands)
Description copied from interface: CommandsFactory
Builds a RehashControlCommand for coordinating a rehash event. This version of this factory method creates a control command with a sender and a payload - a transaction log of pending prepares that occured during the generation and delivery of state. The RehashControlCommand.Type of this command is RehashControlCommand.Type.DRAIN_TX_PREPARES.

Specified by:
buildRehashControlCommandTxLogPendingPrepares in interface CommandsFactory
Parameters:
sender - sender's Address
commands - list of pending prepares
Returns:
a RehashControlCommand

buildRehashControlCommand

public RehashControlCommand buildRehashControlCommand(RehashControlCommand.Type type,
                                                      Address sender,
                                                      Map<Object,InternalCacheValue> state,
                                                      ConsistentHash consistentHash)
Description copied from interface: CommandsFactory
A more generic version of this factory method that allows the setting of various fields.

Specified by:
buildRehashControlCommand in interface CommandsFactory
Parameters:
type - type of RehashControlCommand
sender - sender's Address
state - state to push
consistentHash - consistent hash to deliver
Returns:
a RehashControlCommand

Google Analytics

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