From 6a0be62488b406149903a7368cea8df0f1f27d33 Mon Sep 17 00:00:00 2001 From: jestin Date: Tue, 4 Jun 2002 17:02:02 +0000 Subject: Many major corrections, see changelogs for details. - Domain bug fix - die semantics OK - non CPU-eating socket listeners cVS: ---------------------------------------------------------------------- --- src/Ivy.java | 10 +++- src/IvyClient.java | 19 ++++-- src/IvyWatcher.java | 160 +++++++++++++++++++++++++++++++------------------- src/Makefile | 26 ++++---- src/Probe.java | 8 ++- src/TestIvy.java | 13 +++- src/TestIvySwing.java | 1 + 7 files changed, 150 insertions(+), 87 deletions(-) diff --git a/src/Ivy.java b/src/Ivy.java index fe11428..f5e32e2 100755 --- a/src/Ivy.java +++ b/src/Ivy.java @@ -43,7 +43,7 @@ public class Ivy implements Runnable, IvyApplicationListener { /** * the library version */ - public static String libVersion ="1.0.9"; + public static String libVersion ="1.0.10"; private boolean debug; private static int serial=0; /* an unique ID for each regexp */ @@ -110,10 +110,13 @@ public class Ivy implements Runnable, IvyApplicationListener { * disconnects from the Ivy bus. */ public void stop() { - if (!ivyRunning) { return; } + if (!ivyRunning) { + traceDebug("was already stropped ..."); + return; + } try { - app.close(); ivyRunning = false; + app.close(); watch.stop(); for (int i=0;ihttp://www.tls.cena.fr/products/ivy/ * - * right now, the rendez vous is on a UDP socket. The watcher will answer to + * right now, the rendez vous is either an UDP socket or a TCP multicast. + * The watcher will answer to * each peer advertising its arrival on the bus. The intrinsics of Unix are so * that the broadcast is done using the same socket, which is not a good * thing. + * + * CHANGELOG: + * 1.0.10: + * - isInDomain() is wrong in multicast. I've removed it + * - there was a remanence effect in the datagrampacket buffer. I clean it up after each message + * - cleaned up the getDomain() and getPort() code + * - close message sends an interruption on all threads for a clean exit + * - removed the timeout bug eating all the CPU resources + * - now handles a Vector of broadcast listeners */ class IvyWatcher implements Runnable { private static boolean debug = (System.getProperty("IVY_DEBUG")!=null); - private Vector domainaddrList; + //private Vector domainaddrList; private boolean watcherrunning = false; private boolean isMulticastAddress = false; - private Thread broadcastListener ; + private Vector broadcastListener ; private Ivy bus; /* master bus controler */ private DatagramSocket broadcast; /* supervision socket */ // it can also be a MulticastSocket, which inherits from the previous @@ -35,7 +46,7 @@ class IvyWatcher implements Runnable { */ IvyWatcher(Ivy bus) throws IvyException { this.bus = bus; - domainaddrList = new Vector(); + //domainaddrList = new Vector(); } /** @@ -54,11 +65,14 @@ class IvyWatcher implements Runnable { while( watcherrunning && bus.ivyRunning ) try { broadcast.receive(packet); String msg = new String(packet.getData()) ; + // clean up the buffer after each message + for (int i=0;iivywatcher<-- "+s); diff --git a/src/Makefile b/src/Makefile index fbd2ffb..c5e5060 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,30 +1,30 @@ -# JAVAJAR = /usr/lib/j2re1.3/lib/rt.jar -#CLASSPATH = -classpath $(JAVAJAR) -JAVACOPTS = -d . -deprecation $(CLASSPATH) +# Be sure to set this before compiling ... +# JIKESPATH = /usr/lib/j2re1.3/lib/rt.jar:/usr/share/java/repository +JAVACOPTS = -d . -deprecation +.SUFFIXES: .java .class SRCS = *.java + OBJS = $(SRCS:.java=.class) JAR = ../lib/Ivy.jar - VER = 1.0.9 + VER = 1.0.10 DIST = ../lib/ivy-java-$(VER).jar JAVAC = jikes -# JAVAC = javac + #JAVAC = javac DOCS = ../doc/html/api +.java.class: + $(JAVAC) $< + ivy-java: $(JAVAC) $(JAVACOPTS) $(SRCS) -all: - $(JAVAC) $(JAVACOPTS) $(SRCS) +all: $(OBJS) clean: - /bin/rm -f -- *class *~ *.bak $(JAR) - ctags $(SRCS) + /bin/rm -f -- $(OBJS) *~ *.bak $(JAR) -jar: - fastjar cvfm $(JAR) ../manifest fr - dist: cd .. - fastjar cvfm $(DIST) ../manifest fr src debian redhat doc Makefile manifest TODO + fastjar cvfm $(DIST) ../manifest fr gnu docs: rm -fR $(DOCS)/*html diff --git a/src/Probe.java b/src/Probe.java index 7719e73..be2275e 100644 --- a/src/Probe.java +++ b/src/Probe.java @@ -8,7 +8,12 @@ import gnu.getopt.Getopt; * @see fr.dgac.ivy.TestIvySwing * @author Yannick Jestin * @author http://www.tls.cena.fr/products/ivy/ - * TODO BUG ! Should exit on end of user input + * + * + * Changelog: + * 1.0.10 + * Should exit on end of user input + * Should handle multiple domains - it was a IvyWatcher problem - */ class Probe implements IvyApplicationListener, IvyMessageListener { @@ -82,6 +87,7 @@ class Probe implements IvyApplicationListener, IvyMessageListener { public void die(IvyClient client, int id) { looping=false; System.out.println("received die msg from " + client.getApplicationName() ); + System.exit(0); } public void directMessage(IvyClient client, int id, String arg) { diff --git a/src/TestIvy.java b/src/TestIvy.java index 27a6d08..802f982 100755 --- a/src/TestIvy.java +++ b/src/TestIvy.java @@ -12,6 +12,10 @@ import java.awt.event.* ; * @author François-Régis Colin * @author Yannick Jestin * @author http://www.tls.cena.fr/products/ivy/ + * + * CHANGELOG + * 1.0.10: + * - System.exit on bus die */ class TestIvy extends Panel implements IvyApplicationListener { @@ -41,14 +45,16 @@ class TestIvy extends Panel implements IvyApplicationListener { tfSend.addActionListener(new SENDCB()); p.add(tfSend,BorderLayout.CENTER); add(p,BorderLayout.SOUTH); - bus = new Ivy("JAVA TESTBUS","Testbus is ready",this); + bus = new Ivy("JAVATESTBUS","Testbus is ready",this); bus.start(null); append( "Ivy Domain: "+ bus.getDomain(null) ); } + public static Frame f; + public static void main(String[] args) throws IvyException { TestIvy tb = new TestIvy(); - Frame f = new Frame("TestIvy"); + f = new Frame("TestIvy"); f.addWindowListener( tb.new WCCB(f,tb)) ; f.add(tb, BorderLayout.CENTER); f.pack(); @@ -63,7 +69,8 @@ class TestIvy extends Panel implements IvyApplicationListener { append(client.getApplicationName() + " disconnected " ); } public void die(IvyClient client, int id) { - append(client.getApplicationName() + " die "+ id ); + f.dispose(); + System.exit(0); } public void directMessage(IvyClient client, int id, String arg) { append(client.getApplicationName() + " direct Message "+ id + arg ); diff --git a/src/TestIvySwing.java b/src/TestIvySwing.java index f3f2ae6..ed61741 100644 --- a/src/TestIvySwing.java +++ b/src/TestIvySwing.java @@ -43,6 +43,7 @@ class TestIvySwing extends JPanel implements IvyApplicationListener { "127.255.255.255:2010", "10.192.36:3110", "10.0.0:54321", + "228.1.2.4:4567", }; private static java.util.Vector domainList; -- cgit v1.1