1 46 50 package org.mr.kernel.control; 51 52 import java.io.IOException ; 53 54 import org.mr.core.util.byteable.Byteable; 55 import org.mr.core.util.byteable.ByteableInputStream; 56 import org.mr.core.util.byteable.ByteableMap; 57 import org.mr.core.util.byteable.ByteableOutputStream; 58 import org.mr.core.util.byteable.ByteableRegistry; 59 60 61 68 public class ControlSignal implements Byteable { 69 70 public static final byte OPERATION_TYPE_RECALL =1; 71 public static final byte OPERATION_TYPE_ADVERTISE =2; 72 public static final byte OPERATION_TYPE_UPDATE_SERVICE_ACTOR_STATE =3; 73 public static final byte OPERATION_TYPE_QUEUE_REGISTER =4; 74 public static final byte OPERATION_TYPE_QUEUE_UNREGISTER =5; 75 public static final byte OPERATION_TYPE_GET_QUEUE_COPY =6; 76 public static final byte OPERATION_TYPE_ENQUEUE =7; 77 public static final byte OPERATION_TYPE_GET_MANAGEMENT_PROPERTIES =8; 78 public static final byte OPERATION_TYPE_UNSUBSCRIBE_DURABLE =9; 79 80 81 public static final String SERVICE_ACTORS_UPDATE_KEY = "serviceAcotrsUpdateKey"; 82 public static final String NUMBER_OF_RECEIVE_ON_QUEUE_KEY ="receiveNum"; 83 public static final String SERVICE_UPDATE_NEEDED = "updatedNeeded"; 84 public static final String ENQUEUED_MESSAGE = "enqueueMsg"; 85 public static final String JMX_RMI_PORT="JMXrmiPort"; 86 public static final String JMX_HTTP_PORT="JMXhttpPort"; 87 public static final String MANAGEABLE_LAYER="manageable"; 88 public static final String MANTA_VERSION = "mantaVersion"; 89 public static final String LAYER_TYPE = "layerType"; 90 91 92 public static volatile long controlIdRunningCount = ControlSignalMessageConsumer.START_CONTROL_SIGNAL_ID-1; 93 94 private byte operation ; 95 96 private long controlId; 97 98 private ByteableMap params = new ByteableMap(); 99 100 101 102 103 public ControlSignal(byte operation){ 104 this.operation = operation; 105 this.controlId = createControlId(); 106 107 } 108 109 private synchronized long createControlId(){ 110 controlIdRunningCount ++; 111 return controlIdRunningCount; 112 } 113 114 117 public byte getOperation() { 118 return operation; 119 } 120 121 124 public void setOperation(byte operation) { 125 this.operation = operation; 126 } 127 128 131 public ByteableMap getParams() { 132 return params; 133 } 134 135 138 public void setParams(ByteableMap params) { 139 this.params = params; 140 } 141 142 public String toString(){ 143 StringBuffer buff = new StringBuffer (); 144 buff.append("ControlSignal{ operation="); 145 buff.append(operation); 146 buff.append(" controlId="); 147 buff.append(controlId); 148 buff.append(" params="); 149 buff.append(params); 150 return buff.toString(); 151 } 152 153 156 public long getControlId() { 157 return controlId; 158 } 159 160 163 public String getByteableName() { 164 return "ContSig"; 165 } 166 167 170 public void toBytes(ByteableOutputStream out) throws IOException { 171 out.writeByte(operation); 172 out.writeLong(controlId); 173 out.writeByteable(params); 174 175 176 177 } 178 179 182 public Byteable createInstance(ByteableInputStream in) throws IOException { 183 byte operation = in.readByte(); 184 ControlSignal result = new ControlSignal(operation ); 185 result.controlId = in.readLong(); 186 result.params =(ByteableMap) in.readByteable(); 187 return result; 188 } 189 190 193 public void registerToByteableRegistry() { 194 ByteableRegistry.registerByteableFactory(getByteableName() , this); 195 } 196 197 public static void register(){ 198 ControlSignal instance = new ControlSignal((byte)0); 199 instance.registerToByteableRegistry(); 200 } 201 202 203 204 } 205 | Popular Tags |