view rep/REP.java @ 372:e16b6326fdac

*** empty log message ***
author kono
date Wed, 22 Oct 2008 00:42:47 +0900
parents f0bd158dace6
children 29f01a7ce71f
line wrap: on
line source

package rep;

public enum REP {
	 REPCMD_INSERT	( 6),
	 REPCMD_INSERT_ACK	( 7),
	 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];
     }

}