KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > protocol > utobcast > ProcessMembership


1 /**
2  * Dream
3  * Copyright (C) 2003-2004 INRIA Rhone-Alpes
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: dream@objectweb.org
20  *
21  * Initial developer(s): Vivien Quema
22  * Contributor(s):
23  */

24
25 package org.objectweb.dream.protocol.utobcast;
26
27 import org.objectweb.dream.protocol.Process;
28
29 /**
30  * This interface defines methods for managing a group of processes.
31  */

32 public interface ProcessMembership
33 {
34   /** The commonly used name to refer to this interface. */
35   String JavaDoc ITF_NAME = "process-membership";
36
37   /**
38    * Returns the leader process.
39    *
40    * @return the leader process.
41    * @throws InterruptedException if the component is interrupted while waiting
42    * for a leader to be elected.
43    */

44   Process JavaDoc getLeader() throws InterruptedException JavaDoc;
45
46   /**
47    * Sets the leader process.
48    *
49    * @param leader the leader to set.
50    */

51   void setLeader(Process JavaDoc leader);
52
53   /**
54    * Returns the backup process.
55    *
56    * @return the backup process.
57    * @throws InterruptedException if the component is interrupted while waiting
58    * for a backup to be elected.
59    */

60   Process JavaDoc getBackup() throws InterruptedException JavaDoc;
61
62   /**
63    * Sets the backup process.
64    *
65    * @param backup the backup to set.
66    */

67   void setBackup(Process JavaDoc backup);
68
69   /**
70    * Returns the process to which this process membership component belongs.
71    *
72    * @return the process to which this process membership component belongs.
73    * @throws InterruptedException if the component is interrupted while waiting
74    * for knowing its identity.
75    */

76   Process JavaDoc getMyself() throws InterruptedException JavaDoc;
77
78   /**
79    * Sets the process to which this process membership component belongs.
80    *
81    * @param myself the process to set.
82    */

83   void setMyself(Process JavaDoc myself);
84
85   /**
86    * Returns an array containing all the processes except backup and leader
87    * processes.
88    *
89    * @return all the processes except backup and leader processes.
90    */

91   Process JavaDoc[] getOtherProcesses();
92
93   /**
94    * Sets the processes to be considered for broadcast (except backup and
95    * leader).
96    *
97    * @param processes all the processes except backup and leader processes.
98    */

99   void setOtherProcesses(Process JavaDoc[] processes);
100
101   /**
102    * Adds a process to the group of processes.
103    *
104    * @param process the process to be added.
105    */

106   void addProcess(Process JavaDoc process);
107
108   /**
109    * Removes a process from the group of processes.
110    *
111    * @param process the process to be removed.
112    */

113   void removeProcess(Process JavaDoc process);
114
115   /**
116    * Elects a new backup process. Returns <code>null</code> if no process is
117    * available for being elected.
118    *
119    * @return the elected backup, <code>null</code> if no process is available.
120    * @throws InterruptedException if the component is interrupted while waiting
121    * for a process to be added in the group.
122    */

123   Process JavaDoc electBackup() throws InterruptedException JavaDoc;
124
125   /**
126    * Elects the backup as new leader provided the curerntly registered leader is
127    * the one given in parameter. Otherwise, don't do anything.
128    *
129    * @param oldLeader the process that were supposed to be the old leader.
130    * @return the new leader.
131    */

132   Process JavaDoc electBackupAsLeader(Process JavaDoc oldLeader);
133
134 }
Popular Tags