Changeset 49
- Timestamp:
- 06/19/13 15:59:53 (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 1 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/pom.xml
r45 r49 56 56 <version>4.11</version> 57 57 </dependency> 58 <dependency> 59 <groupId>log4j</groupId> 60 <artifactId>log4j</artifactId> 61 <version>1.2.16</version> 62 </dependency> 63 <dependency> 64 <groupId>log4j</groupId> 65 <artifactId>apache-log4j-extras</artifactId> 66 <version>1.1</version> 67 </dependency> 58 68 </dependencies> 59 69 <build> -
trunk/src/main/java/omq/client/listener/ResponseListener.java
r44 r49 6 6 import java.util.Map; 7 7 import java.util.Properties; 8 9 import org.apache.log4j.Logger; 8 10 9 11 import omq.client.proxy.Proxymq; … … 26 28 */ 27 29 public class ResponseListener extends Thread { 30 private static final Logger logger = Logger.getLogger(ResponseListener.class.getName()); 28 31 private static ResponseListener rListener; 29 32 … … 78 81 } 79 82 } catch (InterruptedException i) { 80 i.printStackTrace();83 logger.error(i.toString(), i); 81 84 } catch (ShutdownSignalException e) { 82 e.printStackTrace();85 logger.error(e.toString(), e); 83 86 try { 84 87 if (channel.isOpen()) { … … 92 95 Thread.sleep(milis); 93 96 } catch (InterruptedException e2) { 94 e2.printStackTrace();97 logger.error(e2.toString(), e2); 95 98 } 96 99 } 97 100 } catch (ConsumerCancelledException e) { 98 e.printStackTrace();101 logger.error(e.toString(), e); 99 102 } catch (Exception e) { 100 e.printStackTrace();103 logger.error(e.toString(), e); 101 104 } 102 105 } … … 201 204 */ 202 205 public void kill() throws IOException { 206 logger.warn("Killing ResponseListener"); 203 207 interrupt(); 204 208 killed = true; -
trunk/src/main/java/omq/client/proxy/Proxymq.java
r47 r49 10 10 import java.util.Map; 11 11 import java.util.Properties; 12 13 import org.apache.log4j.Logger; 12 14 13 15 import omq.Remote; … … 44 46 */ 45 47 private static final long serialVersionUID = 1L; 48 private static final Logger logger = Logger.getLogger(Proxymq.class.getName()); 46 49 private static Map<String, Object> proxies = new Hashtable<String, Object>(); 47 50 … … 132 135 // Publish the request 133 136 if (request.isAsync()) { 134 System.out.println("Publish async request -> " + request.getId());137 logger.debug("Publish async request -> " + request.getId()); 135 138 publishAsyncRequest(request); 136 139 } else { 137 System.out.println("Publish sync request -> " + request.getId());140 logger.debug("Publish sync request -> " + request.getId()); 138 141 response = publishSyncRequest(request, method.getReturnType()); 139 142 … … 186 189 return getResult(corrId, timeout, type); 187 190 } catch (TimeoutException te) { 188 System.out.println("Timeout exception catched " + te); 189 te.printStackTrace(); 191 logger.error(te); 190 192 } 191 193 i++; … … 292 294 public static Object newProxyInstance(ClassLoader loader, Class<?>[] interfaces, Proxymq proxy) { 293 295 if (proxies.containsKey(proxy.getRef())) { 294 System.out.println("Proxy trobat");295 296 return proxies.get(proxy.getRef()); 296 297 } -
trunk/src/main/java/omq/common/broker/Broker.java
r47 r49 2 2 3 3 import java.io.IOException; 4 import java.net.URL; 4 5 import java.util.HashMap; 5 6 import java.util.Map; … … 20 21 import omq.server.RemoteObject; 21 22 23 import org.apache.log4j.Logger; 24 import org.apache.log4j.xml.DOMConfigurator; 25 22 26 import com.rabbitmq.client.Channel; 23 27 import com.rabbitmq.client.Connection; … … 28 32 29 33 public class Broker { 34 35 private static final Logger logger = Logger.getLogger(Broker.class.getName()); 36 30 37 private static Connection connection; 31 38 private static Channel channel; … … 45 52 public static synchronized void initBroker(Properties env) throws Exception { 46 53 if (environment == null) { 54 55 // Load log4j configuration 56 URL log4jResource = Broker.class.getResource("/log4j.xml"); 57 DOMConfigurator.configure(log4jResource); 58 47 59 remoteObjs = new HashMap<String, RemoteObject>(); 48 60 environment = env; … … 58 70 } 59 71 } else { 60 throw new InitBrokerException("Broker already started"); 72 logger.error("Broker is already started"); 73 throw new InitBrokerException("Broker is already started"); 61 74 } 62 75 } 63 76 64 77 public static void stopBroker() throws Exception { 78 logger.warn("Stopping broker"); 65 79 // Stop the client 66 80 if (clientStarted) { … … 93 107 94 108 public static void closeConnection() throws IOException { 109 logger.warn("Clossing connection"); 95 110 connectionClosed = true; 96 111 connection.close(); … … 241 256 @Override 242 257 public void shutdownCompleted(ShutdownSignalException cause) { 258 logger.warn("Shutdown message received. Cause: " + cause.getMessage()); 243 259 if (!connectionClosed) 244 260 if (cause.isHardError()) { -
trunk/src/main/java/omq/common/event/EventDispatcher.java
r44 r49 9 9 import omq.common.util.ParameterQueue; 10 10 import omq.common.util.Serializer; 11 12 import org.apache.log4j.Logger; 11 13 12 14 import com.rabbitmq.client.Channel; … … 26 28 @SuppressWarnings("rawtypes") 27 29 public class EventDispatcher extends Thread { 30 private static final Logger logger = Logger.getLogger(EventDispatcher.class.getName()); 28 31 private static EventDispatcher dispatcher; 29 32 … … 67 70 68 71 public static void stopEventDispatcher() throws Exception { 72 logger.warn("Stopping EventDispatcher"); 69 73 dispatcher.setListeners(null); 70 74 dispatcher.killed = true; … … 102 106 event = Serializer.deserializeEvent(delivery.getBody()); 103 107 104 System.out.println("Event received -> Topic: " + event.getTopic() + "CorrId: " + event.getCorrId());108 logger.info("Event received -> Topic: " + event.getTopic() + "CorrId: " + event.getCorrId()); 105 109 // Log.saveLog("Client-Deserialize", delivery.getBody()); 106 110 … … 112 116 dispatch(event.getTopic(), event); 113 117 } catch (InterruptedException i) { 114 System.out.println("InterruptedException e: " + i); 115 i.printStackTrace(); 118 logger.error(i); 116 119 } catch (ShutdownSignalException e) { 117 System.out.println("ShutdownSignalException e: " + e); 118 e.printStackTrace(); 120 logger.error(e); 119 121 try { 120 122 if (channel.isOpen()) { … … 127 129 Thread.sleep(milis); 128 130 } catch (InterruptedException e2) { 129 e2.printStackTrace();131 logger.error(e2); 130 132 } 131 e1.printStackTrace();133 logger.error(e1); 132 134 } 133 135 } catch (ConsumerCancelledException e) { 134 System.out.println("ConsumerCancelledException e: " + e); 135 e.printStackTrace(); 136 logger.error(e); 136 137 } catch (Exception e) { 137 System.out.println("Exception e: " + e); 138 e.printStackTrace(); 138 logger.error(e); 139 139 } 140 140 } … … 160 160 String reference = e.getTopic(); 161 161 162 System.out.println("EventDispatcher declaring fanout -> " + reference + " Binding with: " + queueName);162 logger.info("Declaring fanout -> " + reference + " Binding with: " + queueName); 163 163 164 164 channel.exchangeDeclare(reference, "fanout"); -
trunk/src/main/java/omq/common/util/OmqConnectionFactory.java
r44 r49 5 5 import java.security.NoSuchAlgorithmException; 6 6 import java.util.Properties; 7 8 import org.apache.log4j.Logger; 7 9 8 10 import com.rabbitmq.client.Channel; … … 16 18 */ 17 19 public class OmqConnectionFactory { 20 private static final Logger logger = Logger.getLogger(OmqConnectionFactory.class.getName()); 21 18 22 private static Connection connection; 19 23 private static int connectionTimeout = 2 * 1000; … … 34 38 working = true; 35 39 } catch (Exception e) { 36 e.printStackTrace();40 logger.error(e); 37 41 long milis = Long.parseLong(env.getProperty(ParameterQueue.RETRY_TIME_CONNECTION, "2000")); 38 42 Thread.sleep(milis); … … 64 68 factory.useSslProtocol(); 65 69 } 66 return factory.newConnection(); 70 71 Connection connection = factory.newConnection(); 72 logger.info("New connection created using: username: " + username + ", host: " + host + ", port: " + port + ", connection timeout: " 73 + connectionTimeout + " SSL enabled: " + ssl); 74 return connection; 67 75 } 68 76 69 77 public static Channel getNewChannel() throws IOException { 70 return connection.createChannel(); 78 Channel channel = connection.createChannel(); 79 logger.info("New channel created using the default connection"); 80 return channel; 71 81 } 72 82 } -
trunk/src/main/java/omq/common/util/Serializer.java
r47 r49 3 3 import java.io.IOException; 4 4 import java.util.Properties; 5 6 import org.apache.log4j.Logger; 5 7 6 8 import omq.common.broker.Broker; … … 21 23 */ 22 24 public class Serializer { 25 private static final Logger logger = Logger.getLogger(Serializer.class.getName()); 23 26 public static String kryo = "kryo"; 24 27 public static String java = "java"; … … 158 161 159 162 public static void removeSerializers() { 163 logger.warn("Removing serializers"); 160 164 serializer = null; 161 165 kryoSerializer = null; -
trunk/src/main/java/omq/common/util/Serializers/GsonImp.java
r44 r49 22 22 public byte[] serialize(Object obj) throws SerializerException { 23 23 String json = gson.toJson(obj); 24 System.out.println(json);25 24 return json.getBytes(); 26 25 } -
trunk/src/main/java/omq/server/InvocationThread.java
r47 r49 8 8 import omq.common.util.Serializer; 9 9 import omq.exception.OmqException; 10 11 import org.apache.log4j.Logger; 10 12 11 13 import com.rabbitmq.client.AMQP.BasicProperties; … … 19 21 */ 20 22 public class InvocationThread extends Thread { 23 private static final Logger logger = Logger.getLogger(InvocationThread.class.getName()); 21 24 private RemoteObject obj; 22 25 private BlockingQueue<Delivery> deliveryQueue; … … 44 47 String requestID = request.getId(); 45 48 46 System.out.println("Invoke method: " + methodName + " CorrID: " + requestID);49 logger.debug("Object: " + obj.getRef() + ", method: " + methodName + " corrID: " + requestID); 47 50 48 51 // Invoke the method … … 53 56 } catch (InvocationTargetException e) { 54 57 Throwable throwable = e.getTargetException(); 58 logger.error("Object: " + obj.getRef() + " at method: " + methodName + ", corrID" + requestID, throwable); 55 59 error = new OmqException(throwable.getClass().getCanonicalName(), throwable.getMessage()); 56 60 } catch (NoSuchMethodException e) { 61 logger.error("Object: " + obj.getRef() + " cannot find method: " + methodName); 57 62 error = new OmqException(e.getClass().getCanonicalName(), e.getMessage()); 58 63 } … … 75 80 76 81 } catch (InterruptedException i) { 77 i.printStackTrace();82 logger.error(i); 78 83 killed = true; 79 84 } catch (Exception e) { 80 System.out.println("Error a l'Invocation Thread \nException: " + e); 81 e.printStackTrace(); 85 logger.error("Object: " + obj.getRef(), e); 82 86 } 83 87 -
trunk/src/main/java/omq/server/RemoteObject.java
r44 r49 10 10 import java.util.Properties; 11 11 12 import org.apache.log4j.Logger; 13 12 14 import omq.Remote; 13 15 import omq.common.broker.Broker; … … 33 35 34 36 private static final long serialVersionUID = -1778953938739846450L; 37 private static final Logger logger = Logger.getLogger(RemoteObject.class.getName()); 35 38 36 39 private String UID; … … 85 88 try { 86 89 Delivery delivery = consumer.nextDelivery(); 87 System.out.println("RemoteObject: " + UID + " has received a message"); 90 91 logger.debug(UID + " has received a message"); 92 88 93 remoteWrapper.notifyDelivery(delivery); 89 94 } catch (InterruptedException i) { 90 i.printStackTrace();95 logger.error(i); 91 96 } catch (ShutdownSignalException e) { 92 e.printStackTrace();97 logger.error(e); 93 98 try { 94 99 if (channel.isOpen()) { … … 101 106 Thread.sleep(milis); 102 107 } catch (InterruptedException e2) { 103 e2.printStackTrace();104 } 105 e1.printStackTrace();108 logger.error(e2); 109 } 110 logger.error(e1); 106 111 } 107 112 } catch (ConsumerCancelledException e) { 108 e.printStackTrace();113 logger.error(e); 109 114 } catch (SerializerException e) { 110 e.printStackTrace();115 logger.error(e); 111 116 } catch (Exception e) { 112 e.printStackTrace();117 logger.error(e); 113 118 } 114 119 } … … 129 134 130 135 public void kill() throws IOException { 136 logger.warn("Killing objectmq: " + this.getRef()); 131 137 killed = true; 132 138 interrupt(); … … 218 224 219 225 // Declares and bindings 220 System.out.println("RemoteObject: " + UID + " declaring direct exchange: " + exchange + ", Queue: " + queue);226 logger.info("RemoteObject: " + UID + " declaring direct exchange: " + exchange + ", Queue: " + queue); 221 227 channel.exchangeDeclare(exchange, "direct"); 222 228 channel.queueDeclare(queue, durable, false, false, null); … … 224 230 225 231 // Declare the event topic fanout 226 System.out.println("RemoteObject: " + UID + " declaring fanout exchange: " + UID);232 logger.info("RemoteObject: " + UID + " declaring fanout exchange: " + UID); 227 233 channel.exchangeDeclare(UID, "fanout"); 228 234 -
trunk/src/main/java/omq/server/RemoteWrapper.java
r44 r49 4 4 import java.util.concurrent.BlockingQueue; 5 5 import java.util.concurrent.LinkedBlockingDeque; 6 7 import org.apache.log4j.Logger; 6 8 7 9 import com.rabbitmq.client.QueueingConsumer; … … 14 16 */ 15 17 public class RemoteWrapper { 18 private static final Logger logger = Logger.getLogger(RemoteWrapper.class.getName()); 19 16 20 private RemoteObject obj; 17 21 private int numThreads; … … 25 29 deliveryQueue = new LinkedBlockingDeque<QueueingConsumer.Delivery>(); 26 30 27 System.out.println("RemoteWrapper -> Object: " + obj.getRef() + ", numthreads listening = " + numThreads);31 logger.info("Object reference: " + obj.getRef() + ", numthreads listening = " + numThreads); 28 32 29 33 for (int i = 0; i < numThreads; i++) { … … 39 43 40 44 public void stopRemoteWrapper() { 45 logger.warn("Stopping Invocation threads vinculed to " + obj.getRef()); 41 46 for (InvocationThread thread : invocationList) { 42 47 thread.interrupt();
Note: See TracChangeset
for help on using the changeset viewer.