Permalink
Browse files

additional logging

  • Loading branch information...
1 parent 96299a5 commit c683d4cdd3773da4be7fb3c04c546e868126d91e @vblagoje vblagoje committed Mar 11, 2010
Showing with 28 additions and 4 deletions.
  1. +28 −4 src/org/jgroups/stack/GossipRouter.java
View
32 src/org/jgroups/stack/GossipRouter.java
@@ -49,7 +49,7 @@
* @author Bela Ban
* @author Vladimir Blagojevic
* @author Ovidiu Feodorov <ovidiuf@users.sourceforge.net>
- * @version $Id: GossipRouter.java,v 1.68.4.2 2010/03/09 17:04:16 vlada Exp $
+ * @version $Id: GossipRouter.java,v 1.68.4.3 2010/03/11 03:46:44 vlada Exp $
* @since 2.1.1
*/
public class GossipRouter {
@@ -383,6 +383,9 @@ private void mainLoop() {
if(sock_read_timeout > 0)
sock.setSoTimeout((int)sock_read_timeout);
+ if(log.isDebugEnabled())
+ log.debug("Accepted connection, socket is " + sock);
+
ConnectionHandler ch=new ConnectionHandler(sock);
getDefaultThreadPoolThreadFactory().newThread(ch).start();
}
@@ -437,14 +440,25 @@ private void removeEntry(String group, Address addr) {
ConcurrentMap<Address, ConnectionHandler> map;
if(group != null) {
map=routingTable.get(group);
- if(map != null && map.remove(addr) != null && map.isEmpty())
- routingTable.remove(group);
+ if(map != null && map.remove(addr) != null) {
+ if(log.isTraceEnabled())
+ log.trace("Removed " +addr + " from group " + group);
+
+ if(map.isEmpty()) {
+ routingTable.remove(group);
+ if(log.isTraceEnabled())
+ log.trace("Removed group " + group);
+ }
+ }
}
else {
for(Map.Entry<String,ConcurrentMap<Address,ConnectionHandler>> entry: routingTable.entrySet()) {
map=entry.getValue();
- if(map != null && map.remove(addr) != null && map.isEmpty())
+ if(map != null && map.remove(addr) != null && map.isEmpty()) {
routingTable.remove(entry.getKey());
+ if(log.isTraceEnabled())
+ log.trace("Removed " + entry.getKey() + " from group " + group);
+ }
}
}
@@ -577,6 +591,9 @@ public ConnectionHandler(Socket sock) throws IOException {
void close() {
if(active.compareAndSet(true, false)) {
+ if(log.isDebugEnabled())
+ log.debug("Closing connection handler " + this.toString());
+
Util.close(input);
Util.close(output);
Util.close(sock);
@@ -615,6 +632,9 @@ private void readLoop() {
known_groups.add(group);
ConcurrentMap<Address,ConnectionHandler> map;
+ if(log.isTraceEnabled())
+ log.trace("Received " + request + " on socket " + sock);
+
switch(command) {
case GossipRouter.CONNECT:
@@ -717,6 +737,10 @@ private void handleConnect(GossipData request, Address addr, String group) throw
}
output.writeByte(CONNECT_OK);
output.flush();
+
+ if(log.isTraceEnabled())
+ log.trace("Connection established, added " +addr + " to group "+ group);
+
} catch (Exception e) {
removeEntry(group, addr);
try {

0 comments on commit c683d4c

Please sign in to comment.