diff src/rep/REP.java @ 193:3133040ee4f4

(no commit message)
author one
date Wed, 31 Dec 2008 15:06:22 +0900
parents
children fce2776071d4
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/rep/REP.java	Wed Dec 31 15:06:22 2008 +0900
@@ -0,0 +1,66 @@
+package rep;
+
+public enum REP {
+	 REPCMD_INSERT_USER	( 5),
+	 REPCMD_INSERT	( 6),
+	 REPCMD_INSERT_ACK	( 7),
+	 REPCMD_DELETE_USER	( 8),
+	 REPCMD_DELETE	( 9),
+	 REPCMD_DELETE_ACK	( 10),
+	 REPCMD_CLOSE	( 11),
+	 REPCMD_CLOSE_2	( 12),
+	 REPCMD_NOP		( 15),
+	 SMCMD_JOIN		( 41),
+	 SMCMD_JOIN_ACK	( 42),
+	 SMCMD_PUT		( 45),
+	 SMCMD_PUT_ACK	( 46),
+	 SMCMD_SELECT	( 47),
+	 SMCMD_SELECT_ACK	( 48), 
+	 SMCMD_SELECT0(49),
+	 SMCMD_QUIT		( 53),
+	 SMCMD_QUIT_ACK	( 54),
+	 SMCMD_SM_JOIN   ( 62),
+	 SMCMD_SM_JOIN_ACK ( 63),
+	 SMCMD_UPDATE ( 65),
+	 SMCMD_UPDATE_ACK ( 66),
+	 SMCMD_START_MERGE ( 75),
+	 SMCMD_START_MERGE_ACK ( 76),
+	 SMCMD_END_MERGE ( 77),
+	 SMCMD_QUIT_2 ( 67),
+	 SMCMD_QUIT_2_ACK ( 68),
+
+
+	 SM_EID ( -1),
+	 MERGE_EID ( -2),
+
+	 SMCMD_SYNC ( 83),
+	 SMCMD_SYNC_ACK ( 84);
+	 
+	 public final int id;
+	 
+	 REP(int id) {
+		 this.id = id;
+	 }
+
+	 static int max = 0;
+	 static int min = 100;
+
+     static REP rep[] ;
+     static {
+    	 // Certainly this is ridiculous...
+         for (REP r : REP.values()) {
+        	 if (max<r.id) max = r.id;
+        	 if (min>r.id) min = r.id;
+         }
+         rep = new REP[max-min+1];
+         for (REP r : REP.values()) {
+        	 rep[r.id-min] = r;
+         }
+     }
+     
+     public static REP newREP(int id) {
+    	 //  return new REP(id); this does not work...
+    	 return rep[id-min];
+     }
+
+}