KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > Event


1 // $Id: Event.java,v 1.11 2005/04/20 20:25:50 belaban Exp $
2

3 package org.jgroups;
4
5
6
7 /**
8  * Used for inter-stack and intra-stack communication.
9  * @author Bela Ban
10  */

11 public class Event {
12     public static final int MSG = 1; // arg = Message
13
public static final int CONNECT = 2; // arg = group address (string)
14
public static final int CONNECT_OK = 3; // arg = group multicast address (Address)
15
public static final int DISCONNECT = 4; // arg = member address (Address)
16
public static final int DISCONNECT_OK = 5;
17     public static final int VIEW_CHANGE = 6; // arg = View (or MergeView in case of merge)
18
public static final int GET_LOCAL_ADDRESS = 7;
19     public static final int SET_LOCAL_ADDRESS = 8;
20     public static final int SUSPECT = 9; // arg = Address of suspected member
21
public static final int BLOCK = 10;
22     public static final int BLOCK_OK = 11;
23     public static final int FIND_INITIAL_MBRS = 12;
24     public static final int FIND_INITIAL_MBRS_OK = 13; // arg = Vector of PingRsps
25
public static final int MERGE = 14; // arg = Vector of Objects
26
public static final int TMP_VIEW = 15; // arg = View
27
public static final int BECOME_SERVER = 16; // sent when client has joined group
28
public static final int GET_APPLSTATE = 17; // get state from appl (arg=requestor)
29
public static final int GET_APPLSTATE_OK = 18; // arg = byte[] (state)
30
public static final int GET_STATE = 19; // arg = StateTransferInfo
31
public static final int GET_STATE_OK = 20; // arg = Object or Vector (state(s))
32
public static final int STATE_RECEIVED = 21; // arg = state
33
public static final int START_QUEUEING = 22;
34     public static final int STOP_QUEUEING = 23; // arg = Vector (event-list)
35
public static final int SWITCH_NAK = 24;
36     public static final int SWITCH_NAK_ACK = 25;
37     public static final int SWITCH_OUT_OF_BAND = 26;
38     public static final int FLUSH = 27; // arg = Vector (destinatinon for FLUSH)
39
public static final int FLUSH_OK = 28; // arg = FlushRsp
40
public static final int DROP_NEXT_MSG = 29;
41     public static final int STABLE = 30; // arg = long[] (stable seqnos for mbrs)
42
public static final int GET_MSG_DIGEST = 31; // arg = long[] (highest seqnos from mbrs)
43
public static final int GET_MSG_DIGEST_OK = 32; // arg = Digest
44
public static final int REBROADCAST_MSGS = 33; // arg = Vector (msgs with NakAckHeader)
45
public static final int REBROADCAST_MSGS_OK = 34;
46     public static final int GET_MSGS_RECEIVED = 35;
47     public static final int GET_MSGS_RECEIVED_OK = 36; // arg = long[] (highest deliverable seqnos)
48
public static final int GET_MSGS = 37; // arg = long[][] (range of seqnos for each m.)
49
public static final int GET_MSGS_OK = 38; // arg = List
50
public static final int GET_DIGEST = 39; //
51
public static final int GET_DIGEST_OK = 40; // arg = Digest (response to GET_DIGEST)
52
public static final int SET_DIGEST = 41; // arg = Digest
53
public static final int GET_DIGEST_STATE = 42; // see ./JavaStack/Protocols/pbcast/DESIGN for explanantion
54
public static final int GET_DIGEST_STATE_OK = 43; // see ./JavaStack/Protocols/pbcast/DESIGN for explanantion
55
public static final int SET_PARTITIONS = 44; // arg = Hashtable of addresses and numbers
56
public static final int MERGE_DENIED = 45; // Passed down from gms when a merge attempt fails
57
public static final int EXIT = 46; // received when member was forced out of the group
58
public static final int PERF = 47; // for performance measurements
59
public static final int SUBVIEW_MERGE = 48; // arg = vector of addresses; see JGroups/EVS/Readme.txt
60
public static final int SUBVIEWSET_MERGE = 49; // arg = vector of addresses; see JGroups/EVS/Readme.txt
61
public static final int HEARD_FROM = 50; // arg = Vector (list of Addresses)
62
public static final int UNSUSPECT = 51; // arg = Address (of unsuspected member)
63
public static final int SET_PID = 52; // arg = Integer (process id)
64
public static final int MERGE_DIGEST = 53; // arg = Digest
65
public static final int BLOCK_SEND = 54; // arg = null
66
public static final int UNBLOCK_SEND = 55; // arg = null
67
public static final int CONFIG = 56; // arg = HashMap (config properties)
68
public static final int GET_DIGEST_STABLE = 57;
69     public static final int GET_DIGEST_STABLE_OK = 58; // response to GET_DIGEST_STABLE
70
// public static final int ACK = 59; // used to flush down events
71
// public static final int ACK_OK = 60; // response to ACK
72
public static final int START = 61; // triggers start() - internal event, handled by Protocol
73
public static final int START_OK = 62; // arg = exception of null - internal event, handled by Protocol
74
public static final int STOP = 63; // triggers stop() - internal event, handled by Protocol
75
public static final int STOP_OK = 64; // arg = exception or null - internal event, handled by Protocol
76
public static final int SUSPEND_STABLE = 65; // arg = Long (max_suspend_time)
77
public static final int RESUME_STABLE = 66; // arg = null
78

79
80
81     public static final int USER_DEFINED=1000;// arg = <user def., e.g. evt type + data>
82

83
84     private int type; // type of event
85
private Object JavaDoc arg; // must be serializable if used for inter-stack communication
86

87
88     public Event(int type) {
89         this.type=type;
90     }
91
92     public Event(int type, Object JavaDoc arg) {
93         this.type=type;
94         this.arg=arg;
95     }
96
97     public int getType() {
98         return type;
99     }
100
101     public void setType(int type) {
102         this.type=type;
103     }
104
105     public Object JavaDoc getArg() {
106         return arg;
107     }
108
109     public void setArg(Object JavaDoc arg) {
110         this.arg=arg;
111     }
112
113
114
115     public static String JavaDoc type2String(int t) {
116         switch(t) {
117             case MSG: return "MSG";
118             case CONNECT: return "CONNECT";
119             case CONNECT_OK: return "CONNECT_OK";
120             case DISCONNECT: return "DISCONNECT";
121             case DISCONNECT_OK: return "DISCONNECT_OK";
122             case VIEW_CHANGE: return "VIEW_CHANGE";
123             case GET_LOCAL_ADDRESS: return "GET_LOCAL_ADDRESS";
124             case SET_LOCAL_ADDRESS: return "SET_LOCAL_ADDRESS";
125             case SUSPECT: return "SUSPECT";
126             case BLOCK: return "BLOCK";
127             case BLOCK_OK: return "BLOCK_OK";
128             case FIND_INITIAL_MBRS: return "FIND_INITIAL_MBRS";
129             case FIND_INITIAL_MBRS_OK: return "FIND_INITIAL_MBRS_OK";
130             case TMP_VIEW: return "TMP_VIEW";
131             case BECOME_SERVER: return "BECOME_SERVER";
132             case GET_APPLSTATE: return "GET_APPLSTATE";
133             case GET_APPLSTATE_OK: return "GET_APPLSTATE_OK";
134             case GET_STATE: return "GET_STATE";
135             case GET_STATE_OK: return "GET_STATE_OK";
136             case STATE_RECEIVED: return "STATE_RECEIVED";
137             case START_QUEUEING: return "START_QUEUEING";
138             case STOP_QUEUEING: return "STOP_QUEUEING";
139             case SWITCH_NAK: return "SWITCH_NAK";
140             case SWITCH_NAK_ACK: return "SWITCH_NAK_ACK";
141             case SWITCH_OUT_OF_BAND: return "SWITCH_OUT_OF_BAND";
142             case FLUSH: return "FLUSH";
143             case FLUSH_OK: return "FLUSH_OK";
144             case DROP_NEXT_MSG: return "DROP_NEXT_MSG";
145             case STABLE: return "STABLE";
146             case GET_MSG_DIGEST: return "GET_MSG_DIGEST";
147             case GET_MSG_DIGEST_OK: return "GET_MSG_DIGEST_OK";
148             case REBROADCAST_MSGS: return "REBROADCAST_MSGS";
149             case REBROADCAST_MSGS_OK: return "REBROADCAST_MSGS_OK";
150             case GET_MSGS_RECEIVED: return "GET_MSGS_RECEIVED";
151             case GET_MSGS_RECEIVED_OK: return "GET_MSGS_RECEIVED_OK";
152             case GET_MSGS: return "GET_MSGS";
153             case GET_MSGS_OK: return "GET_MSGS_OK";
154             case GET_DIGEST: return "GET_DIGEST";
155             case GET_DIGEST_OK: return "GET_DIGEST_OK";
156             case SET_DIGEST: return "SET_DIGEST";
157             case GET_DIGEST_STATE: return "GET_DIGEST_STATE";
158             case GET_DIGEST_STATE_OK: return "GET_DIGEST_STATE_OK";
159             case SET_PARTITIONS: return "SET_PARTITIONS"; // Added by gianlucac@tin.it to support PARTITIONER
160
case MERGE: return "MERGE"; // Added by gianlucac@tin.it to support partitions merging in GMS
161
case MERGE_DENIED: return "MERGE_DENIED";// as above
162
case EXIT: return "EXIT";
163             case PERF: return "PERF";
164             case SUBVIEW_MERGE: return "SUBVIEW_MERGE";
165             case SUBVIEWSET_MERGE: return "SUBVIEWSET_MERGE";
166             case HEARD_FROM: return "HEARD_FROM";
167             case UNSUSPECT: return "UNSUSPECT";
168             case SET_PID: return "SET_PID";
169             case MERGE_DIGEST: return "MERGE_DIGEST";
170             case BLOCK_SEND: return "BLOCK_SEND";
171             case UNBLOCK_SEND: return "UNBLOCK_SEND";
172             case CONFIG: return "CONFIG";
173             case GET_DIGEST_STABLE: return "GET_DIGEST_STABLE";
174             case GET_DIGEST_STABLE_OK: return "GET_DIGEST_STABLE_OK";
175             // case ACK: return "ACK";
176
// case ACK_OK: return "ACK_OK";
177
case START: return "START";
178             case START_OK: return "START_OK";
179             case STOP: return "STOP";
180             case STOP_OK: return "STOP_OK";
181             case SUSPEND_STABLE: return "SUSPEND_STABLE";
182             case RESUME_STABLE: return "RESUME_STABLE";
183
184             case USER_DEFINED: return "USER_DEFINED";
185             default: return "UNDEFINED";
186         }
187     }
188
189     public static final Event FIND_INITIAL_MBRS_EVT = new Event(Event.FIND_INITIAL_MBRS);
190     public static final Event GET_DIGEST_EVT = new Event(Event.GET_DIGEST);
191
192     public String JavaDoc toString() {
193         StringBuffer JavaDoc ret=new StringBuffer JavaDoc(64);
194         ret.append("Event[type=" + type2String(type) + ", arg=" + arg + ']');
195         return ret.toString();
196     }
197
198 }
199
200
Popular Tags