diff options
author | jestin | 2012-04-27 08:55:56 +0000 |
---|---|---|
committer | jestin | 2012-04-27 08:55:56 +0000 |
commit | 6fbefad24ec7e8783365db61b03357d50ee0dd56 (patch) | |
tree | cf6433a80330d03095b4664af121db5461c99306 /src | |
parent | 0617ac556d840cb313f93bbb36ec61677a7cc191 (diff) | |
download | ivy-java-6fbefad24ec7e8783365db61b03357d50ee0dd56.zip ivy-java-6fbefad24ec7e8783365db61b03357d50ee0dd56.tar.gz ivy-java-6fbefad24ec7e8783365db61b03357d50ee0dd56.tar.bz2 ivy-java-6fbefad24ec7e8783365db61b03357d50ee0dd56.tar.xz |
added names to the threads, in order to allow jvisualvm debug
removed a "My DEBUG" message on the console
Diffstat (limited to 'src')
-rwxr-xr-x | src/Ivy.java | 3 | ||||
-rwxr-xr-x | src/IvyClient.java | 7 | ||||
-rw-r--r-- | src/IvyDaemon.java | 1 | ||||
-rwxr-xr-x | src/IvyWatcher.java | 8 | ||||
-rw-r--r-- | src/Probe.java | 1 | ||||
-rw-r--r-- | src/SelfIvyClient.java | 1 | ||||
-rw-r--r-- | src/Waiter.java | 1 | ||||
-rw-r--r-- | src/WaiterClient.java | 1 |
8 files changed, 20 insertions, 3 deletions
diff --git a/src/Ivy.java b/src/Ivy.java index b727c2a..2a0a6d5 100755 --- a/src/Ivy.java +++ b/src/Ivy.java @@ -188,6 +188,8 @@ public class Ivy implements Runnable { private boolean starting = false; protected Object readyToSend = new Object(); private boolean doSendToSelf = false; + + // FIXME should not be static ? (findbugs) private static int serial = 0; private int myserial = serial++; private static long current = System.currentTimeMillis(); @@ -350,6 +352,7 @@ public class Ivy implements Runnable { // readies the rendezvous : an IvyWatcher (thread) per domain bus for (Domain dom: d) watchers.addElement(new IvyWatcher(this , dom.domainaddr , dom.port)); serverThread = new Thread(this); + serverThread.setName("Ivy TCP server Thread"); serverThread.start(); // sends the broadcasts and listen to incoming connexions for (IvyWatcher iw: watchers) iw.doStart(); diff --git a/src/IvyClient.java b/src/IvyClient.java index 80b30b8..441013f 100755 --- a/src/IvyClient.java +++ b/src/IvyClient.java @@ -122,6 +122,7 @@ public class IvyClient extends Thread { // private variables private final static int MAXPONGCALLBACKS = 10; + // FIXME should not be static ? (findbugs) private static int pingSerial = 0; private static final Object lock = new Object(); private static int clientSerial=0; /* an unique ID for each IvyClient */ @@ -167,6 +168,7 @@ public class IvyClient extends Thread { } remoteHostname = socket.getInetAddress().getHostName(); clientThread = new Thread(this); // clientThread handles the incoming traffic + clientThread.setName("Ivy client thread to "+remoteHostname+":"+remotePort); } /* removed from the constructor, to avoid Mulithread correctnaess issuses @@ -265,9 +267,12 @@ public class IvyClient extends Thread { */ public void ping(PingCallback pc) throws IvyException { PCHadd(pingSerial,pc); - sendString(Ping,pingSerial++,""); + sendString(Ping,pingSerial,""); + incSerial(); } + private synchronized static void incSerial() {pingSerial++;} + /////////////////////////////////////////////////// // // PROTECTED METHODS diff --git a/src/IvyDaemon.java b/src/IvyDaemon.java index 3ec54e6..2c0e42a 100644 --- a/src/IvyDaemon.java +++ b/src/IvyDaemon.java @@ -95,6 +95,7 @@ public class IvyDaemon implements Runnable { this.bus=bus; serviceSocket = new ServerSocket(servicePort) ; clientThread=new Thread(this); + clientThread.setName("Ivy client thread set by Daemon ?! "); } protected void doStart() { diff --git a/src/IvyWatcher.java b/src/IvyWatcher.java index 54eca11..cbd3910 100755 --- a/src/IvyWatcher.java +++ b/src/IvyWatcher.java @@ -98,6 +98,7 @@ class IvyWatcher extends Thread { private int port; private volatile Thread listenThread = null; private InetAddress group; + // FIXME should not be static ? (findbugs) private static int serial=0; private int myserial=serial++; private String busWatcherId = null; @@ -114,6 +115,7 @@ class IvyWatcher extends Thread { this.port=port; busWatcherId=bus.getWatcherId(); listenThread = new Thread(this); + listenThread.setName("Ivy Watcher thread for "+domainaddr+":"+port); // create the MulticastSocket try { group = InetAddress.getByName(domainaddr); @@ -199,7 +201,7 @@ class IvyWatcher extends Thread { try { Socket s = new Socket(remotehost,remotePort); s.setReceiveBufferSize(bus.getBufferSize()); - System.out.println("MY DEBUG - buffer size="+s.getReceiveBufferSize()); + //System.out.println("MY DEBUG - buffer size="+s.getReceiveBufferSize()); s.setTcpNoDelay(true); bus.createIvyClient(s,remotePort,false); } catch ( java.net.ConnectException jnc ) { @@ -261,7 +263,9 @@ class IvyWatcher extends Thread { this.data=data; bus = b; packet=new DatagramPacket(data.getBytes(),data.length(),group,port); - new Thread((PacketSender.this)).start(); + Thread t = new Thread((PacketSender.this)); + t.setName("Ivy Packet sender"); + t.start(); } public void run() { traceDebug("PacketSender thread started"); // THREADDEBUG diff --git a/src/Probe.java b/src/Probe.java index c8021c5..6a4c75c 100644 --- a/src/Probe.java +++ b/src/Probe.java @@ -177,6 +177,7 @@ public class Probe implements IvyApplicationListener, IvyMessageListener, IvyBin this.bus=bus; bus.addApplicationListener(this); looperThread=new Thread(this); + looperThread.setName("Ivy Probe looper thread on readline"); looperThread.start(); } diff --git a/src/SelfIvyClient.java b/src/SelfIvyClient.java index 2cfc016..1957124 100644 --- a/src/SelfIvyClient.java +++ b/src/SelfIvyClient.java @@ -191,6 +191,7 @@ public class SelfIvyClient extends IvyClient { args=a; t=new Thread(Runner.this); bus.registerThread(t); + t.setName("Ivy Runner Thread to execute an async callback"); t.start(); bus.unRegisterThread(t); } diff --git a/src/Waiter.java b/src/Waiter.java index ae5d7bc..51b68fb 100644 --- a/src/Waiter.java +++ b/src/Waiter.java @@ -20,6 +20,7 @@ class Waiter implements Runnable, IvyMessageListener { this.timeout=timeout; if (timeout<=0) forever=true; t=new Thread(this); + t.setName("Ivy Waiter thread, for message"); } public IvyClient waitFor() { diff --git a/src/WaiterClient.java b/src/WaiterClient.java index 70c3f81..007a179 100644 --- a/src/WaiterClient.java +++ b/src/WaiterClient.java @@ -25,6 +25,7 @@ class WaiterClient extends IvyApplicationAdapter implements Runnable { name=n; if (timeout<=0) forever=true; t=new Thread(this); + t.setName("Ivy Waiter thread, for client"); } IvyClient waitForClient() { |