KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > buddyreplication > BuddyLocator


1 /*
2  * JBoss, Home of Professional Open Source
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.cache.buddyreplication;
8
9 import org.jboss.cache.config.BuddyReplicationConfig;
10 import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
11 import org.jgroups.Address;
12
13 import java.util.List JavaDoc;
14 import java.util.Map JavaDoc;
15
16 /**
17  * Buddy Locators help the {@see BuddyManager} select buddies for its buddy group.
18  * <p/>
19  * Implementations of this class must declare a public no-arguments constructor.
20  * </p>
21  *
22  * @author <a HREF="mailto:manik@jboss.org">Manik Surtani (manik@jboss.org)</a>
23  */

24 public interface BuddyLocator
25 {
26    /**
27     * Gets the configuration for this BuddyLocator.
28     *
29     * @return object encapsulating this object's configuration.
30     * Should not return <code>null</code>. If {@link #init(BuddyLocatorConfig)}
31     * has not been called or <code>null</code> was passed to it, the
32     * returned value should be the default config for the
33     * given BuddyLocator implementation.
34     */

35    public BuddyLocatorConfig getConfig();
36
37    /**
38     * Initialize this <code>BuddyLocator</code>.
39     *
40     * @param config configuration for this <code>BuddyLocator</code>. May be
41     * <code>null</code>, in which case the implementation should
42     * use its default configuration.
43     */

44    public void init(BuddyReplicationConfig.BuddyLocatorConfig config);
45
46    /**
47     * Choose a set of buddies for the given node. Invoked when a change in
48     * cluster membership is detected.
49     *
50     * @param buddyPoolMap Map<Address, String> mapping nodes in the cluster to
51     * the "buddy pool" they have identified themselves as
52     * belonging too. A BuddyLocator implementation can use
53     * this information to preferentially assign buddies from
54     * the same buddy pool as <code>dataOwner</code>. May be
55     * <code>null</code> if buddy pools aren't configured.
56     * @param currentMembership List<Address> of the current cluster members
57     * @param dataOwner Address of the node for which buddies should be selected
58     * @return List<Address> of the nodes that should serve as buddies for
59     * <code>dataOwner</code>. Will not be <code>null</code>, may
60     * be empty.
61     */

62    public List JavaDoc<Address> locateBuddies(Map JavaDoc<Address, String JavaDoc> buddyPoolMap, List JavaDoc<Address> currentMembership, Address dataOwner);
63 }
64
Popular Tags