KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ha > framework > interfaces > DistributedReplicantManager


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.ha.framework.interfaces;
23
24 import org.jboss.ha.framework.interfaces.DistributedReplicantManager.ReplicantListener;
25 import java.io.Serializable JavaDoc;
26 import java.util.List JavaDoc;
27 import java.util.Collection JavaDoc;
28
29 /**
30  *
31  * @author <a HREF="mailto:bill@burkecentral.com">Bill Burke</a>.
32  * @author <a HREF="mailto:sacha.labourey@cogito-info.ch">Sacha Labourey</a>.
33  * @version $Revision: 46307 $
34  *
35  * <p><b>Revisions:</b><br>
36  * <p><b>2001/10/31: marcf</b>
37  * <ol>
38  * <li>DRM is no longer remote
39  * </ol>
40  * <p><b>2002/08/23: Sacha Labourey</b>
41  * <ol>
42  * <li>added isMasterReplica
43  * </ol>
44  */

45 public interface DistributedReplicantManager
46 {
47    /**
48     * When a particular key in the DistributedReplicantManager table gets modified, all listeners
49     * will be notified of replicant changes for that key.
50     */

51    public interface ReplicantListener
52    {
53       /**
54        * Callback called when the content/list of replicant for a given replicant key has changed
55        * @param key The name of the key of the replicant that has changed
56        * @param newReplicants The list of new replicants for the give replicant key.
57        * This list will be in a consistent order on all
58        * cluster nodes on which the current viewId is
59        * in effect
60        * @param newReplicantsViewId The new replicant view id corresponding to this change
61        */

62       public void replicantsChanged(String JavaDoc key, List JavaDoc newReplicants, int newReplicantsViewId);
63    }
64
65    /**
66     * Subscribe a new listener {@link ReplicantListener} for replicant changes
67     * @param key Name of the replicant, must be identical cluster-wide for all identical replicants
68     * @param subscriber The subscribing {@link ReplicantListener}
69     */

70    public void registerListener(String JavaDoc key, ReplicantListener subscriber);
71    /**
72     * Unsubscribe a listener {@link ReplicantListener} that had subscribed for replicant changes
73     * @param key Name of the replicant, must be identical cluster-wide for all identical replicants
74     * @param subscriber The unsubscribing {@link ReplicantListener}
75     */

76    public void unregisterListener(String JavaDoc key, ReplicantListener subscriber);
77
78    // State binding methods
79
//
80

81    /**
82     * Add a replicant, it will be attached to this cluster node
83     * @param key Replicant name. All replicas around the cluster must use the same key name.
84     * @param replicant Local data of the replicant, that is, any serializable data
85     * @throws Exception Thrown if a cluster communication problem occurs
86     */

87    public void add(String JavaDoc key, Serializable JavaDoc replicant) throws Exception JavaDoc;
88
89    /**
90     * Remove the entire key from the ReplicationService
91     * @param key Name of the replicant
92     * @throws Exception Thrown if a cluster communication problem occurs
93     */

94    public void remove(String JavaDoc key) throws Exception JavaDoc;
95
96    /**
97     * Lookup the replicant attached to this cluster node
98     * @param key The name of the replicant
99     * @return The local replicant for the given key name
100     */

101    public Serializable JavaDoc lookupLocalReplicant(String JavaDoc key);
102
103    /**
104     * Return a list of all replicants.
105     * @param key The replicant name
106     * @return A list of serialized replicants available around the cluster
107     * for the given key. This list will be in the same order in all
108     * nodes in the cluster.
109     */

110    public List JavaDoc lookupReplicants(String JavaDoc key);
111
112    /**
113     * Return a list of all replicants node names.
114     * @param key The replicant name
115     * @return A list of the node names of cluster nodes that have made available
116     * a replicant for the given key. This list will be in the same
117     * order in all nodes in the cluster.
118     */

119    public List JavaDoc lookupReplicantsNodeNames(String JavaDoc key);
120
121    /**
122     * Return a list of all services that have at least one replicant.
123     * @return A collection of service names (String)
124     */

125    public Collection JavaDoc getAllServices ();
126
127    /**
128     * Returns an id corresponding to the current view of this set of replicants.
129     * @param key The replicant name
130     * @return A view id (doesn't grow sequentially)
131     */

132    public int getReplicantsViewId(String JavaDoc key);
133    
134    /**
135     * Indicates if the current node is the master replica for this given key.
136     * @param key The replicant name
137     * @return True if this node is the master
138     */

139    public boolean isMasterReplica (String JavaDoc key);
140
141 }
142
Popular Tags