001: // $Id: Event.java,v 1.24.2.1 2006/12/04 22:47:16 vlada Exp $
002:
003: package org.jgroups;
004:
005: /**
006: * Used for inter-stack and intra-stack communication.
007: * @author Bela Ban
008: */
009: public class Event {
010: public static final int MSG = 1; // arg = Message
011: public static final int CONNECT = 2; // arg = group address (string)
012: public static final int CONNECT_OK = 3; // arg = null (or exception if JOIN failed)
013: public static final int DISCONNECT = 4; // arg = member address (Address)
014: public static final int DISCONNECT_OK = 5;
015: public static final int VIEW_CHANGE = 6; // arg = View (or MergeView in case of merge)
016: public static final int GET_LOCAL_ADDRESS = 7;
017: public static final int SET_LOCAL_ADDRESS = 8;
018: public static final int SUSPECT = 9; // arg = Address of suspected member
019: public static final int BLOCK = 10;
020: public static final int BLOCK_OK = 11;
021: public static final int FIND_INITIAL_MBRS = 12;
022: public static final int FIND_INITIAL_MBRS_OK = 13; // arg = Vector of PingRsps
023: public static final int MERGE = 14; // arg = Vector of Objects
024: public static final int TMP_VIEW = 15; // arg = View
025: public static final int BECOME_SERVER = 16; // sent when client has joined group
026: public static final int GET_APPLSTATE = 17; // get state from appl (arg=StateTransferInfo)
027: public static final int GET_APPLSTATE_OK = 18; // arg = StateTranferInfo (includes state)
028: public static final int GET_STATE = 19; // arg = StateTransferInfo
029: public static final int GET_STATE_OK = 20; // arg = StateTransferInfo
030: public static final int STATE_RECEIVED = 21; // arg = StateTransferInfo (with state and state_id)
031: public static final int START_QUEUEING = 22;
032: public static final int STOP_QUEUEING = 23; // arg = Vector (event-list)
033: public static final int SWITCH_NAK = 24;
034: public static final int SWITCH_NAK_ACK = 25;
035: public static final int SWITCH_OUT_OF_BAND = 26;
036: public static final int FLUSH = 27; // arg = Vector (destinatinon for FLUSH)
037: public static final int FLUSH_OK = 28; // arg = FlushRsp
038: public static final int DROP_NEXT_MSG = 29;
039: public static final int STABLE = 30; // arg = long[] (stable seqnos for mbrs)
040: public static final int GET_MSG_DIGEST = 31; // arg = long[] (highest seqnos from mbrs)
041: public static final int GET_MSG_DIGEST_OK = 32; // arg = Digest
042: public static final int REBROADCAST_MSGS = 33; // arg = Vector (msgs with NakAckHeader)
043: public static final int REBROADCAST_MSGS_OK = 34;
044: public static final int GET_MSGS_RECEIVED = 35;
045: public static final int GET_MSGS_RECEIVED_OK = 36; // arg = long[] (highest deliverable seqnos)
046: public static final int GET_MSGS = 37; // arg = long[][] (range of seqnos for each m.)
047: public static final int GET_MSGS_OK = 38; // arg = List
048: public static final int GET_DIGEST = 39; //
049: public static final int GET_DIGEST_OK = 40; // arg = Digest (response to GET_DIGEST)
050: public static final int SET_DIGEST = 41; // arg = Digest
051: public static final int GET_DIGEST_STATE = 42; // see ./JavaStack/Protocols/pbcast/DESIGN for explanantion
052: public static final int GET_DIGEST_STATE_OK = 43; // see ./JavaStack/Protocols/pbcast/DESIGN for explanantion
053: public static final int SET_PARTITIONS = 44; // arg = Hashtable of addresses and numbers
054: public static final int MERGE_DENIED = 45; // Passed down from gms when a merge attempt fails
055: public static final int EXIT = 46; // received when member was forced out of the group
056: public static final int PERF = 47; // for performance measurements
057: public static final int SUBVIEW_MERGE = 48; // arg = vector of addresses; see JGroups/EVS/Readme.txt
058: public static final int SUBVIEWSET_MERGE = 49; // arg = vector of addresses; see JGroups/EVS/Readme.txt
059: public static final int HEARD_FROM = 50; // arg = Vector (list of Addresses)
060: public static final int UNSUSPECT = 51; // arg = Address (of unsuspected member)
061: public static final int SET_PID = 52; // arg = Integer (process id)
062: public static final int MERGE_DIGEST = 53; // arg = Digest
063: public static final int CONFIG = 56; // arg = HashMap (config properties)
064: public static final int GET_DIGEST_STABLE = 57;
065: public static final int GET_DIGEST_STABLE_OK = 58; // response to GET_DIGEST_STABLE
066: // public static final int ACK = 59; // used to flush down events
067: // public static final int ACK_OK = 60; // response to ACK
068: public static final int START = 61; // triggers start() - internal event, handled by Protocol
069: public static final int START_OK = 62; // arg = exception of null - internal event, handled by Protocol
070: public static final int STOP = 63; // triggers stop() - internal event, handled by Protocol
071: public static final int STOP_OK = 64; // arg = exception or null - internal event, handled by Protocol
072: public static final int SUSPEND_STABLE = 65; // arg = Long (max_suspend_time)
073: public static final int RESUME_STABLE = 66; // arg = null
074: public static final int ENABLE_UNICASTS_TO = 67; // arg = Address (member)
075: public static final int SUSPEND = 68; // arg = View|null
076: public static final int SUSPEND_OK = 69; // arg = null
077: public static final int RESUME = 70; // arg = null
078: public static final int STATE_TRANSFER_INPUTSTREAM = 71; // arg=java.io.InputStream subclass
079: public static final int STATE_TRANSFER_OUTPUTSTREAM = 72; // arg=java.io.OutputStream subclass
080: public static final int STATE_TRANSFER_INPUTSTREAM_CLOSED = 73;//arg=null
081: public static final int STATE_TRANSFER_OUTPUTSTREAM_CLOSED = 74;//arg=null
082: public static final int UNBLOCK = 75; //arg=null (indicate end of flush round)
083: public static final int SUSPEND_FAILED = 76; // arg = null
084:
085: public static final int USER_DEFINED = 1000;// arg = <user def., e.g. evt type + data>
086:
087: private int type; // type of event
088: private Object arg; // must be serializable if used for inter-stack communication
089:
090: public Event(int type) {
091: this .type = type;
092: }
093:
094: public Event(int type, Object arg) {
095: this .type = type;
096: this .arg = arg;
097: }
098:
099: public int getType() {
100: return type;
101: }
102:
103: public void setType(int type) {
104: this .type = type;
105: }
106:
107: public Object getArg() {
108: return arg;
109: }
110:
111: public void setArg(Object arg) {
112: this .arg = arg;
113: }
114:
115: public static String type2String(int t) {
116: switch (t) {
117: case MSG:
118: return "MSG";
119: case CONNECT:
120: return "CONNECT";
121: case CONNECT_OK:
122: return "CONNECT_OK";
123: case DISCONNECT:
124: return "DISCONNECT";
125: case DISCONNECT_OK:
126: return "DISCONNECT_OK";
127: case VIEW_CHANGE:
128: return "VIEW_CHANGE";
129: case GET_LOCAL_ADDRESS:
130: return "GET_LOCAL_ADDRESS";
131: case SET_LOCAL_ADDRESS:
132: return "SET_LOCAL_ADDRESS";
133: case SUSPECT:
134: return "SUSPECT";
135: case BLOCK:
136: return "BLOCK";
137: case BLOCK_OK:
138: return "BLOCK_OK";
139: case FIND_INITIAL_MBRS:
140: return "FIND_INITIAL_MBRS";
141: case FIND_INITIAL_MBRS_OK:
142: return "FIND_INITIAL_MBRS_OK";
143: case TMP_VIEW:
144: return "TMP_VIEW";
145: case BECOME_SERVER:
146: return "BECOME_SERVER";
147: case GET_APPLSTATE:
148: return "GET_APPLSTATE";
149: case GET_APPLSTATE_OK:
150: return "GET_APPLSTATE_OK";
151: case GET_STATE:
152: return "GET_STATE";
153: case GET_STATE_OK:
154: return "GET_STATE_OK";
155: case STATE_RECEIVED:
156: return "STATE_RECEIVED";
157: case START_QUEUEING:
158: return "START_QUEUEING";
159: case STOP_QUEUEING:
160: return "STOP_QUEUEING";
161: case SWITCH_NAK:
162: return "SWITCH_NAK";
163: case SWITCH_NAK_ACK:
164: return "SWITCH_NAK_ACK";
165: case SWITCH_OUT_OF_BAND:
166: return "SWITCH_OUT_OF_BAND";
167: case FLUSH:
168: return "FLUSH";
169: case FLUSH_OK:
170: return "FLUSH_OK";
171: case DROP_NEXT_MSG:
172: return "DROP_NEXT_MSG";
173: case STABLE:
174: return "STABLE";
175: case GET_MSG_DIGEST:
176: return "GET_MSG_DIGEST";
177: case GET_MSG_DIGEST_OK:
178: return "GET_MSG_DIGEST_OK";
179: case REBROADCAST_MSGS:
180: return "REBROADCAST_MSGS";
181: case REBROADCAST_MSGS_OK:
182: return "REBROADCAST_MSGS_OK";
183: case GET_MSGS_RECEIVED:
184: return "GET_MSGS_RECEIVED";
185: case GET_MSGS_RECEIVED_OK:
186: return "GET_MSGS_RECEIVED_OK";
187: case GET_MSGS:
188: return "GET_MSGS";
189: case GET_MSGS_OK:
190: return "GET_MSGS_OK";
191: case GET_DIGEST:
192: return "GET_DIGEST";
193: case GET_DIGEST_OK:
194: return "GET_DIGEST_OK";
195: case SET_DIGEST:
196: return "SET_DIGEST";
197: case GET_DIGEST_STATE:
198: return "GET_DIGEST_STATE";
199: case GET_DIGEST_STATE_OK:
200: return "GET_DIGEST_STATE_OK";
201: case SET_PARTITIONS:
202: return "SET_PARTITIONS"; // Added by gianlucac@tin.it to support PARTITIONER
203: case MERGE:
204: return "MERGE"; // Added by gianlucac@tin.it to support partitions merging in GMS
205: case MERGE_DENIED:
206: return "MERGE_DENIED";// as above
207: case EXIT:
208: return "EXIT";
209: case PERF:
210: return "PERF";
211: case SUBVIEW_MERGE:
212: return "SUBVIEW_MERGE";
213: case SUBVIEWSET_MERGE:
214: return "SUBVIEWSET_MERGE";
215: case HEARD_FROM:
216: return "HEARD_FROM";
217: case UNSUSPECT:
218: return "UNSUSPECT";
219: case SET_PID:
220: return "SET_PID";
221: case MERGE_DIGEST:
222: return "MERGE_DIGEST";
223: case CONFIG:
224: return "CONFIG";
225: case GET_DIGEST_STABLE:
226: return "GET_DIGEST_STABLE";
227: case GET_DIGEST_STABLE_OK:
228: return "GET_DIGEST_STABLE_OK";
229: // case ACK: return "ACK";
230: // case ACK_OK: return "ACK_OK";
231: case START:
232: return "START";
233: case START_OK:
234: return "START_OK";
235: case STOP:
236: return "STOP";
237: case STOP_OK:
238: return "STOP_OK";
239: case SUSPEND_STABLE:
240: return "SUSPEND_STABLE";
241: case RESUME_STABLE:
242: return "RESUME_STABLE";
243: case ENABLE_UNICASTS_TO:
244: return "ENABLE_UNICASTS_TO";
245: case SUSPEND:
246: return "SUSPEND";
247: case SUSPEND_OK:
248: return "SUSPEND_OK";
249: case RESUME:
250: return "RESUME";
251: case STATE_TRANSFER_INPUTSTREAM:
252: return "STATE_TRANSFER_INPUTSTREAM";
253: case STATE_TRANSFER_OUTPUTSTREAM:
254: return "STATE_TRANSFER_OUTPUTSTREAM";
255: case STATE_TRANSFER_INPUTSTREAM_CLOSED:
256: return "STATE_TRANSFER_INPUTSTREAM_CLOSED";
257: case STATE_TRANSFER_OUTPUTSTREAM_CLOSED:
258: return "STATE_TRANSFER_OUTPUTSTREAM_CLOSED";
259: case UNBLOCK:
260: return "UNBLOCK";
261: case SUSPEND_FAILED:
262: return "SUSPEND_FAILED";
263:
264: case USER_DEFINED:
265: return "USER_DEFINED";
266: default:
267: return "UNDEFINED(" + t + ")";
268: }
269: }
270:
271: public static final Event FIND_INITIAL_MBRS_EVT = new Event(
272: Event.FIND_INITIAL_MBRS);
273: public static final Event GET_DIGEST_EVT = new Event(
274: Event.GET_DIGEST);
275:
276: public String toString() {
277: StringBuffer ret = new StringBuffer(64);
278: ret.append("Event[type=" + type2String(type) + ", arg=" + arg
279: + ']');
280: return ret.toString();
281: }
282:
283: }
|