Changeset 30
- Timestamp:
- 06/03/13 17:13:09 (11 years ago)
- Location:
- trunk/objectmq/src/omq
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/objectmq/src/omq/client/proxy/Proxymq.java
r20 r30 6 6 import java.lang.reflect.Proxy; 7 7 import java.util.Collection; 8 import java.util.Date; 8 9 import java.util.HashMap; 9 10 import java.util.Hashtable; … … 20 21 import omq.common.message.Request; 21 22 import omq.common.message.Response; 22 import omq.common.util.Log;23 23 import omq.common.util.ParameterQueue; 24 24 import omq.common.util.Serializer; … … 98 98 @Override 99 99 public Object invoke(Object proxy, Method method, Object[] arguments) throws Throwable { 100 //long timeStart = (new Date()).getTime(); 101 100 102 // Local methods only 101 103 String methodName = method.getName(); … … 119 121 Request request = createRequest(method, arguments); 120 122 123 //Log.saveTimeSendRequestLog("Client-time-request", request.getId(), method.getName(), timeStart); 124 125 Object response = null; 121 126 // Publish the request 122 127 if (request.isAsync()) { 123 128 System.out.println("Publish async request -> " + request.getId()); 124 129 publishAsyncRequest(request); 125 return null;126 130 } else { 127 System.out.println("Publish sync request -> " + request.getId()); 128 return publishSyncRequest(request, method.getReturnType()); 129 } 131 System.out.println("Publish sync request -> " + request.getId()); 132 response = publishSyncRequest(request, method.getReturnType()); 133 134 //long timeEnd = (new Date()).getTime(); 135 //Log.saveTimeSendRequestLog("Client-time-response", request.getId(), method.getName(), timeEnd); 136 } 137 138 return response; 130 139 } 131 140 … … 143 152 byte[] bytesRequest = Serializer.serialize(request); 144 153 channel.basicPublish(exchange, routingkey, props, bytesRequest); 145 Log.saveLog("Client-Serialize", bytesRequest);154 //Log.saveLog("Client-Serialize", bytesRequest); 146 155 } 147 156 … … 213 222 } 214 223 resp = Serializer.deserializeResponse(results.get(corrId), type); 215 Log.saveLog("Client-Deserialize", results.get(corrId)); 224 //Log.saveLog("Client-Deserialize", results.get(corrId)); 225 216 226 // Remove and indicate the key exists (a hashmap can contain a null 217 227 // object, using this we'll know whether a response has been -
trunk/objectmq/src/omq/common/broker/Broker.java
r29 r30 115 115 System.out.println("EventTrigger fanout exchange: " + UID + " Event topic: " + UID + " Event corrID: " + event.getCorrId()); 116 116 channel.exchangeDeclare(UID, "fanout"); 117 channel.basicPublish(UID, "", null, Serializer.serialize(wrapper)); 117 118 byte[] bytesResponse = Serializer.serialize(wrapper); 119 channel.basicPublish(UID, "", null, bytesResponse); 120 121 //Log.saveLog("Server-Serialize", bytesResponse); 118 122 } 119 123 -
trunk/objectmq/src/omq/common/event/EventDispatcher.java
r28 r30 96 96 97 97 System.out.println("Event received -> Topic: " + event.getTopic() + "CorrId: " + event.getCorrId()); 98 98 //Log.saveLog("Client-Deserialize", delivery.getBody()); 99 100 //long timeEnd = (new Date()).getTime(); 101 //Log.saveTimeSendRequestLog("Client-time-response", event.getCorrId(), "Event!", timeEnd); 102 99 103 // Dispatch it 100 104 dispatch(event.getTopic(), event); -
trunk/objectmq/src/omq/common/util/Log.java
r18 r30 2 2 3 3 import java.io.File; 4 import java.io.FileOutputStream;5 4 import java.io.FileWriter; 6 5 import java.io.IOException; … … 9 8 10 9 import omq.exception.EnvironmentException; 11 12 import org.apache.commons.io.IOUtils;13 10 14 11 public class Log { … … 22 19 long timeNow = (new Date()).getTime(); 23 20 24 File outputFolder = new File(debugPath + File.separator + processName);21 File outputFolder = new File(debugPath + File.separator); 25 22 outputFolder.mkdirs(); 23 24 // File outputFolder = new File(debugPath + File.separator + processName); 25 // outputFolder.mkdirs(); 26 26 27 File outputFileContent = new File(outputFolder.getAbsoluteFile() + File.separator + "content_" + timeNow);28 FileOutputStream outputStream = new FileOutputStream(outputFileContent);29 IOUtils.write(bytesResponse, outputStream);30 outputStream.close();31 27 // File outputFileContent = new File(outputFolder.getAbsoluteFile() + File.separator + "content_" + timeNow); 28 // FileOutputStream outputStream = new FileOutputStream(outputFileContent); 29 // IOUtils.write(bytesResponse, outputStream); 30 // outputStream.close(); 31 32 32 File outputFileLog = new File(debugPath + File.separator + "log"); 33 33 boolean exist = outputFileLog.exists(); … … 44 44 } 45 45 } 46 47 public static void saveTimeSendRequestLog(String processName, String coorId, String method, long timeNow) throws IOException { 48 try { 49 Properties env = Environment.getEnvironment(); 50 51 String debugPath = env.getProperty(ParameterQueue.DEBUGFILE, ""); 52 if (debugPath.length() > 0) { 53 File outputFolder = new File(debugPath + File.separator + processName); 54 outputFolder.mkdirs(); 55 56 File outputFileLog = new File(outputFolder + File.separator + "log"); 57 boolean exist = outputFileLog.exists(); 58 59 FileWriter fw = new FileWriter(outputFileLog, true); // the true will append the new data 60 if(!exist){ 61 fw.write("#CoorId\tMethod\tDate\n"); 62 } 63 fw.write(coorId + "\t" + method + "\t" + timeNow + "\n"); 64 fw.close(); 65 } 66 } catch (EnvironmentException e) { 67 throw new IOException(e.getMessage(), e); 68 } 69 } 46 70 } -
trunk/objectmq/src/omq/server/remote/request/InvocationThread.java
r23 r30 5 5 import omq.common.message.Request; 6 6 import omq.common.message.Response; 7 import omq.common.util.Log;8 7 import omq.common.util.Serializer; 9 8 … … 36 35 // Deserialize the json 37 36 Request request = Serializer.deserializeRequest(delivery.getBody(), obj); 38 Log.saveLog("Server-Deserialize", delivery.getBody());37 //Log.saveLog("Server-Deserialize", delivery.getBody()); 39 38 40 39 String methodName = request.getMethod(); … … 70 69 channel.basicPublish("", props.getReplyTo(), replyProps, bytesResponse); 71 70 72 Log.saveLog("Server-Serialize", bytesResponse);71 //Log.saveLog("Server-Serialize", bytesResponse); 73 72 } 74 73
Note: See TracChangeset
for help on using the changeset viewer.