org.jboss.cache.buddyreplication
Class NextMemberBuddyLocator

java.lang.Object
  extended by org.jboss.cache.buddyreplication.NextMemberBuddyLocator
All Implemented Interfaces:
BuddyLocator

@ThreadSafe
public class NextMemberBuddyLocator
extends Object
implements BuddyLocator

This buddy locator uses a next-in-line algorithm to select buddies for a buddy group. This algorithm allows for the following properties, all of which are optional.

Author:
Manik Surtani (manik@jboss.org)

Constructor Summary
NextMemberBuddyLocator()
           
 
Method Summary
 BuddyReplicationConfig.BuddyLocatorConfig getConfig()
          Gets the configuration for this BuddyLocator.
 void init(BuddyReplicationConfig.BuddyLocatorConfig buddyLocatorConfig)
          Initialize this BuddyLocator.
 List<org.jgroups.Address> locateBuddies(Map<org.jgroups.Address,String> buddyPoolMap, List<org.jgroups.Address> currentMembership, org.jgroups.Address dataOwner)
          Choose a set of buddies for the given node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NextMemberBuddyLocator

public NextMemberBuddyLocator()
Method Detail

getConfig

public BuddyReplicationConfig.BuddyLocatorConfig getConfig()
Description copied from interface: BuddyLocator
Gets the configuration for this BuddyLocator.

Specified by:
getConfig in interface BuddyLocator
Returns:
object encapsulating this object's configuration. Should not return null. If BuddyLocator.init(org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig) has not been called or null was passed to it, the returned value should be the default config for the given BuddyLocator implementation.

init

public void init(BuddyReplicationConfig.BuddyLocatorConfig buddyLocatorConfig)
Description copied from interface: BuddyLocator
Initialize this BuddyLocator.

Specified by:
init in interface BuddyLocator
Parameters:
buddyLocatorConfig - configuration for this BuddyLocator. May be null, in which case the implementation should use its default configuration.

locateBuddies

public List<org.jgroups.Address> locateBuddies(Map<org.jgroups.Address,String> buddyPoolMap,
                                               List<org.jgroups.Address> currentMembership,
                                               org.jgroups.Address dataOwner)
Description copied from interface: BuddyLocator
Choose a set of buddies for the given node. Invoked when a change in cluster membership is detected.

Specified by:
locateBuddies in interface BuddyLocator
Parameters:
buddyPoolMap - Map mapping nodes in the cluster to the "buddy pool" they have identified themselves as belonging too. A BuddyLocator implementation can use this information to preferentially assign buddies from the same buddy pool as dataOwner. May be null if buddy pools aren't configured.
currentMembership - List
of the current cluster members
dataOwner - Address of the node for which buddies should be selected
Returns:
List
of the nodes that should serve as buddies for dataOwner. Will not be null, may be empty.


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