org.jboss.cache.buddyreplication
Class BuddyFqnTransformer

java.lang.Object
  extended by org.jboss.cache.commands.AbstractVisitor
      extended by org.jboss.cache.buddyreplication.BuddyFqnTransformer
All Implemented Interfaces:
Visitor

public class BuddyFqnTransformer
extends AbstractVisitor

For each command the fqns are chnaged such that they are under the current buddy group's backup subtree (e.g., /_buddy_backup_/my_host:7890/) rather than the root (/).

Since:
2.2
Author:
Mircea.Markus@jboss.com

Field Summary
static String BUDDY_BACKUP_SUBTREE
           
static Fqn<String> BUDDY_BACKUP_SUBTREE_FQN
           
 
Constructor Summary
BuddyFqnTransformer(String buddyGroupName)
           
BuddyFqnTransformer(String buddyGroupName, CommandsFactory cf)
           
 
Method Summary
static Fqn getActualFqn(Fqn fqn)
           
static Fqn getBackupFqn(org.jgroups.Address dataOwnerAddress, Fqn origFqn)
          Utility method that retrieves a buddy backup Fqn given the actual Fqn of some data and the data owner's Address.
 Fqn getBackupFqn(Fqn originalFqn)
          Assumes the backup Fqn if the current instance is the data owner.
static Fqn getBackupFqn(Fqn buddyGroupRoot, Fqn origFqn)
          Utility method that retrieves a buddy backup Fqn given the actual Fqn of some data and the backup subtree for the buddy group in question
static Fqn getBackupFqn(String buddyGroupName, Fqn origFqn)
          Utility method that retrieves a buddy backup Fqn given the actual Fqn of some data and the buddy group name.
static Fqn<String> getBackupRoot(org.jgroups.Address dataOwner)
           
static Fqn getBackupRootFromFqn(Fqn fqn)
          Returns the buddy backp root portion of a given Fqn, provided it is a backup Fqn.
static Fqn<String> getDeadBackupRoot(org.jgroups.Address dataOwner)
          Returns the backup root of a dead data owner
static String getGroupNameFromAddress(org.jgroups.Address address)
           
static boolean isBackupFqn(Fqn name)
           
static boolean isDeadBackupFqn(Fqn name)
          Tests whether a given Fqn belongs to a dead backup region.
static boolean isDeadBackupRoot(Fqn f)
           
 List<ReversibleCommand> transformBatch(List<ReversibleCommand> toTransform)
           
 Object visitCommitCommand(InvocationContext ctx, CommitCommand commitCommand)
          Visits a CommitCommand.
 Object visitCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command)
          Visits a CreateNodeCommand.
 Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command)
          Visits a EvictCommand.
 Object visitExistsNodeCommand(InvocationContext ctx, ExistsCommand command)
          Visits a RemoteExistsCommand.
 Object visitGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command)
          Visits a GetChildrenNamesCommand.
 Object visitGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command)
          Visits a GetDataMapCommand.
 Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand command)
          Visits a GetKeysCommand.
 Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command)
          Visits a GetKeyValueCommand.
 Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command)
          Visits a GetNodeCommand.
 Object visitGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command)
          Visits a GravitateDataCommand.
 Object visitInvalidateCommand(InvocationContext ctx, InvalidateCommand command)
          Visits a InvalidateCommand.
 Object visitMoveCommand(InvocationContext ctx, MoveCommand command)
          Visits a MoveCommand.
 Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command)
          Visits a OptimisticPrepareCommand.
 Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command)
          Visits a PrepareCommand.
 Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command)
          Visits a PutDataMapCommand.
 Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command)
          Visits a PutKeyValueCommand.
 Object visitRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command)
          Visits a RemoveDataCommand.
 Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command)
          Visits a RemoveKeyCommand.
 Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command)
          Visits a RemoveNodeCommand.
 Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command)
          Visits a RollbackCommand.
 
Methods inherited from class org.jboss.cache.commands.AbstractVisitor
handleDefault, visitCollection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUDDY_BACKUP_SUBTREE

public static final String BUDDY_BACKUP_SUBTREE
See Also:
Constant Field Values

BUDDY_BACKUP_SUBTREE_FQN

public static final Fqn<String> BUDDY_BACKUP_SUBTREE_FQN
Constructor Detail

BuddyFqnTransformer

public BuddyFqnTransformer(String buddyGroupName)

BuddyFqnTransformer

public BuddyFqnTransformer(String buddyGroupName,
                           CommandsFactory cf)
Method Detail

visitCommitCommand

public Object visitCommitCommand(InvocationContext ctx,
                                 CommitCommand commitCommand)
                          throws Throwable
Description copied from interface: Visitor
Visits a CommitCommand.

Specified by:
visitCommitCommand in interface Visitor
Overrides:
visitCommitCommand in class AbstractVisitor
Parameters:
ctx - invocation context
commitCommand - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitPutDataMapCommand

public Object visitPutDataMapCommand(InvocationContext ctx,
                                     PutDataMapCommand command)
                              throws Throwable
Description copied from interface: Visitor
Visits a PutDataMapCommand.

Specified by:
visitPutDataMapCommand in interface Visitor
Overrides:
visitPutDataMapCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitPutKeyValueCommand

public Object visitPutKeyValueCommand(InvocationContext ctx,
                                      PutKeyValueCommand command)
                               throws Throwable
Description copied from interface: Visitor
Visits a PutKeyValueCommand.

Specified by:
visitPutKeyValueCommand in interface Visitor
Overrides:
visitPutKeyValueCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitRemoveNodeCommand

public Object visitRemoveNodeCommand(InvocationContext ctx,
                                     RemoveNodeCommand command)
                              throws Throwable
Description copied from interface: Visitor
Visits a RemoveNodeCommand.

Specified by:
visitRemoveNodeCommand in interface Visitor
Overrides:
visitRemoveNodeCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitRemoveDataCommand

public Object visitRemoveDataCommand(InvocationContext ctx,
                                     RemoveDataCommand command)
                              throws Throwable
Description copied from interface: Visitor
Visits a RemoveDataCommand.

Specified by:
visitRemoveDataCommand in interface Visitor
Overrides:
visitRemoveDataCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitEvictFqnCommand

public Object visitEvictFqnCommand(InvocationContext ctx,
                                   EvictCommand command)
                            throws Throwable
Description copied from interface: Visitor
Visits a EvictCommand.

Specified by:
visitEvictFqnCommand in interface Visitor
Overrides:
visitEvictFqnCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitInvalidateCommand

public Object visitInvalidateCommand(InvocationContext ctx,
                                     InvalidateCommand command)
                              throws Throwable
Description copied from interface: Visitor
Visits a InvalidateCommand.

Specified by:
visitInvalidateCommand in interface Visitor
Overrides:
visitInvalidateCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitRemoveKeyCommand

public Object visitRemoveKeyCommand(InvocationContext ctx,
                                    RemoveKeyCommand command)
                             throws Throwable
Description copied from interface: Visitor
Visits a RemoveKeyCommand.

Specified by:
visitRemoveKeyCommand in interface Visitor
Overrides:
visitRemoveKeyCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitGetDataMapCommand

public Object visitGetDataMapCommand(InvocationContext ctx,
                                     GetDataMapCommand command)
                              throws Throwable
Description copied from interface: Visitor
Visits a GetDataMapCommand.

Specified by:
visitGetDataMapCommand in interface Visitor
Overrides:
visitGetDataMapCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitExistsNodeCommand

public Object visitExistsNodeCommand(InvocationContext ctx,
                                     ExistsCommand command)
                              throws Throwable
Description copied from interface: Visitor
Visits a RemoteExistsCommand.

Specified by:
visitExistsNodeCommand in interface Visitor
Overrides:
visitExistsNodeCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitGetKeyValueCommand

public Object visitGetKeyValueCommand(InvocationContext ctx,
                                      GetKeyValueCommand command)
                               throws Throwable
Description copied from interface: Visitor
Visits a GetKeyValueCommand.

Specified by:
visitGetKeyValueCommand in interface Visitor
Overrides:
visitGetKeyValueCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitGetNodeCommand

public Object visitGetNodeCommand(InvocationContext ctx,
                                  GetNodeCommand command)
                           throws Throwable
Description copied from interface: Visitor
Visits a GetNodeCommand.

Specified by:
visitGetNodeCommand in interface Visitor
Overrides:
visitGetNodeCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitGetKeysCommand

public Object visitGetKeysCommand(InvocationContext ctx,
                                  GetKeysCommand command)
                           throws Throwable
Description copied from interface: Visitor
Visits a GetKeysCommand.

Specified by:
visitGetKeysCommand in interface Visitor
Overrides:
visitGetKeysCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitGetChildrenNamesCommand

public Object visitGetChildrenNamesCommand(InvocationContext ctx,
                                           GetChildrenNamesCommand command)
                                    throws Throwable
Description copied from interface: Visitor
Visits a GetChildrenNamesCommand.

Specified by:
visitGetChildrenNamesCommand in interface Visitor
Overrides:
visitGetChildrenNamesCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitMoveCommand

public Object visitMoveCommand(InvocationContext ctx,
                               MoveCommand command)
                        throws Throwable
Description copied from interface: Visitor
Visits a MoveCommand.

Specified by:
visitMoveCommand in interface Visitor
Overrides:
visitMoveCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitGravitateDataCommand

public Object visitGravitateDataCommand(InvocationContext ctx,
                                        GravitateDataCommand command)
                                 throws Throwable
Description copied from interface: Visitor
Visits a GravitateDataCommand.

Specified by:
visitGravitateDataCommand in interface Visitor
Overrides:
visitGravitateDataCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitPrepareCommand

public Object visitPrepareCommand(InvocationContext ctx,
                                  PrepareCommand command)
                           throws Throwable
Description copied from interface: Visitor
Visits a PrepareCommand.

Specified by:
visitPrepareCommand in interface Visitor
Overrides:
visitPrepareCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitRollbackCommand

public Object visitRollbackCommand(InvocationContext ctx,
                                   RollbackCommand command)
                            throws Throwable
Description copied from interface: Visitor
Visits a RollbackCommand.

Specified by:
visitRollbackCommand in interface Visitor
Overrides:
visitRollbackCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitOptimisticPrepareCommand

public Object visitOptimisticPrepareCommand(InvocationContext ctx,
                                            OptimisticPrepareCommand command)
                                     throws Throwable
Description copied from interface: Visitor
Visits a OptimisticPrepareCommand.

Specified by:
visitOptimisticPrepareCommand in interface Visitor
Overrides:
visitOptimisticPrepareCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitCreateNodeCommand

public Object visitCreateNodeCommand(InvocationContext ctx,
                                     CreateNodeCommand command)
                              throws Throwable
Description copied from interface: Visitor
Visits a CreateNodeCommand.

Specified by:
visitCreateNodeCommand in interface Visitor
Overrides:
visitCreateNodeCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

getBackupFqn

public Fqn getBackupFqn(Fqn originalFqn)
Assumes the backup Fqn if the current instance is the data owner.


transformBatch

public List<ReversibleCommand> transformBatch(List<ReversibleCommand> toTransform)
                                       throws Throwable
Throws:
Throwable

getBackupFqn

public static Fqn getBackupFqn(org.jgroups.Address dataOwnerAddress,
                               Fqn origFqn)
Utility method that retrieves a buddy backup Fqn given the actual Fqn of some data and the data owner's Address.

Parameters:
dataOwnerAddress - the JGroups Address of the data owner
origFqn - the original Fqn
Returns:
a backup Fqn

getBackupFqn

public static Fqn getBackupFqn(String buddyGroupName,
                               Fqn origFqn)
Utility method that retrieves a buddy backup Fqn given the actual Fqn of some data and the buddy group name.

Parameters:
buddyGroupName - the buddy group name
origFqn - the original Fqn
Returns:
a backup Fqn

getBackupFqn

public static Fqn getBackupFqn(Fqn buddyGroupRoot,
                               Fqn origFqn)
Utility method that retrieves a buddy backup Fqn given the actual Fqn of some data and the backup subtree for the buddy group in question

Parameters:
buddyGroupRoot - the subtree under which data for a particular buddy is backed up
origFqn - the original Fqn
Returns:
a backup Fqn

isBackupFqn

public static boolean isBackupFqn(Fqn name)

getActualFqn

public static Fqn getActualFqn(Fqn fqn)

isDeadBackupFqn

public static boolean isDeadBackupFqn(Fqn name)
Tests whether a given Fqn belongs to a dead backup region.

Parameters:
name - fqn to test
Returns:
true if the fqn is a part of a dead backup region; false otherwise.

getBackupRoot

public static Fqn<String> getBackupRoot(org.jgroups.Address dataOwner)
Parameters:
dataOwner - owner of a data set
Returns:
a backup root for a given data owner

getDeadBackupRoot

public static Fqn<String> getDeadBackupRoot(org.jgroups.Address dataOwner)
Returns the backup root of a dead data owner

Parameters:
dataOwner - owner of data
Returns:
Fqn of dead data owner's root

isDeadBackupRoot

public static boolean isDeadBackupRoot(Fqn f)

getGroupNameFromAddress

public static String getGroupNameFromAddress(org.jgroups.Address address)

getBackupRootFromFqn

public static Fqn getBackupRootFromFqn(Fqn fqn)
Returns the buddy backp root portion of a given Fqn, provided it is a backup Fqn. If it is not a backup Fqn, Fqn.ROOT is returned.

Parameters:
fqn - fqn


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