aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/Ivy.java24
-rwxr-xr-xsrc/IvyClient.java26
-rw-r--r--src/IvyDaemon.java8
-rwxr-xr-xsrc/IvyWatcher.java3
-rw-r--r--src/Probe.java7
5 files changed, 39 insertions, 29 deletions
diff --git a/src/Ivy.java b/src/Ivy.java
index fc0a613..08f3c6c 100755
--- a/src/Ivy.java
+++ b/src/Ivy.java
@@ -21,6 +21,11 @@ import java.util.Hashtable;
*bus.bindMsg("(.*)",myMessageListener);
*bus.start(null);
*</pre>
+ *
+ * CHANGELOG:
+ * 1.0.12:
+ * - removed the close() disconnect(IvyClient c). Fixes a big badaboum bug
+ * - getDomain becomes public
*/
public class Ivy implements Runnable, IvyApplicationListener {
@@ -41,9 +46,10 @@ public class Ivy implements Runnable, IvyApplicationListener {
*/
public static final String DEFAULT_DOMAIN = "127.255.255.255:"+DEFAULT_PORT;
/**
- * the library version
+ * the library version, useful for development purposes only, when java is
+ * invoked with -DIVY_DEBUG
*/
- public static String libVersion ="1.0.11";
+ public static final String libVersion ="1.0.12";
private boolean debug;
private static int serial=0; /* an unique ID for each regexp */
@@ -139,7 +145,7 @@ public class Ivy implements Runnable, IvyApplicationListener {
*/
public int sendMsg( String message ) {
int count = 0;
- // TODO ? an alternate implementation is one sender thread per client
+ // an alternate implementation would one sender thread per client
// instead of one for all the clients. It might be a performance issue
for ( int i = 0 ; i < clients.size(); i++ ) {
IvyClient client = (IvyClient)clients.elementAt(i);
@@ -230,7 +236,6 @@ public class Ivy implements Runnable, IvyApplicationListener {
for ( int i = 0 ; i < ivyApplicationListenerList.size(); i++ ) {
((IvyApplicationListener)ivyApplicationListenerList.elementAt(i)).disconnect(client);
}
- stop();
}
/* invokes the application listeners upon death of an Ivy client
@@ -296,7 +301,7 @@ public class Ivy implements Runnable, IvyApplicationListener {
}
- static String getDomain(String domainbus) throws IvyException {
+ public static String getDomain(String domainbus) throws IvyException {
if ( domainbus == null ) domainbus = System.getProperty("IVYBUS");
if ( domainbus == null ) domainbus = DEFAULT_DOMAIN;
return domainbus;
@@ -318,7 +323,7 @@ public class Ivy implements Runnable, IvyApplicationListener {
}
/*
- * TODO prevents two clients from connecting to each other at the same time
+ * prevents two clients from connecting to each other at the same time
* there might still be a lingering bug here, that we could avoid with the
* SchizoToken.
*/
@@ -358,12 +363,7 @@ public class Ivy implements Runnable, IvyApplicationListener {
private void traceDebug(String s){
if (debug) System.out.println("-->ivy<-- "+s);
}
-
- // TODO find out if this is useful or not ...
- private void classes( String msg_classes[] ) {
- messages_classes = msg_classes;
- }
-
+
} // class Ivy
/* EOF */
diff --git a/src/IvyClient.java b/src/IvyClient.java
index 9555d8a..18a50f2 100755
--- a/src/IvyClient.java
+++ b/src/IvyClient.java
@@ -19,6 +19,9 @@ import gnu.regexp.*;
* created for each remote client.
*
* CHANGELOG:
+ * 1.0.12:
+ * - right handling of IOExceptions in sendBuffer, the Client is removed from
+ * the bus
* 1.0.10:
* - removed the timeout bug eating all the CPU resources
*/
@@ -91,10 +94,13 @@ public class IvyClient implements Runnable {
* allow the notification of regexp addition and deletion
*/
Enumeration getRegexps() { return regexp_text.elements(); }
+
int getAppPort() { return appPort ; }
- /* perhaps we should perform some checking here */
- void sendRegexp(int id,String regexp) {send(AddRegexp,id,regexp);}
+ void sendRegexp(int id,String regexp) {
+ send(AddRegexp,id,regexp); /* perhaps we should perform some checking here */
+ }
+
public void delRegexp(int id) {send( DelRegexp,id,"");}
/**
@@ -154,9 +160,7 @@ public class IvyClient implements Runnable {
} catch (IvyException ie) {
ie.printStackTrace();
} catch (InterruptedIOException ioe) {
- // okay, nothing on the line
- // do nothing but loop. It might be a bit resource-eating ...
- System.out.println("DEBUG IvyClient: I have been interrupted");
+ System.out.println("I have been interrupted. I'm about to leave my thread loop");
if (!gardefou) break;
}
}
@@ -178,7 +182,12 @@ public class IvyClient implements Runnable {
out.write(buffer.getBytes() );
out.flush();
} catch ( IOException e ) {
- throw new IvyException("IvyClient.sendBuffer.write failed: "+e.getMessage());
+ traceDebug("I can't send my message to this client. He probably left");
+ try {
+ close("IO Exception");
+ } catch (IOException ioe) {
+ throw new IvyException("close failed"+ioe.getMessage());
+ }
}
}
@@ -186,7 +195,6 @@ public class IvyClient implements Runnable {
try {
sendBuffer(type+" "+id+StartArg+arg);
} catch (IvyException ie ) {
- // TODO shoud fix the exception Handling here ...
System.err.println("received an exception: " + ie.getMessage());
ie.printStackTrace();
}
@@ -203,7 +211,6 @@ public class IvyClient implements Runnable {
try {
sendBuffer(buffer);
} catch (IvyException ie ) {
- // TODO shoud fix the exception Handling here ...
System.err.println("received an exception: " + ie.getMessage());
ie.printStackTrace();
}
@@ -274,7 +281,7 @@ public class IvyClient implements Runnable {
break;
case EndRegexp:
bus.connect(this);
- /* TODO ?
+ /*
* the peer is perhaps not ready to handle this message
* an assymetric processing should be written
*/
@@ -293,6 +300,7 @@ public class IvyClient implements Runnable {
String[] tab = new String[v.size()];
for (int i=0;i<v.size();i++) {
tab[i]=(String)v.elementAt(i);
+ // for developpemnt purposes
// System.out.println(" *"+tab[i]+"* "+(tab[i]).length());
}
bus.callCallback(this,msgId,tab);
diff --git a/src/IvyDaemon.java b/src/IvyDaemon.java
index 09367c6..db4623e 100644
--- a/src/IvyDaemon.java
+++ b/src/IvyDaemon.java
@@ -17,8 +17,12 @@ import gnu.getopt.Getopt;
*
* @author Yannick Jestin
* @author <a href="http://www.tls.cena.fr/products/ivy/">http://www.tls.cena.fr/products/ivy/</a>
+ *
+ * changelog:
+ * 1.0.12
+ * - class goes public access !
*/
-class IvyDaemon implements Runnable {
+public class IvyDaemon implements Runnable {
public static int DEFAULT_SERVICE_PORT = 3456 ;
ServerSocket serviceSocket;
@@ -51,7 +55,7 @@ class IvyDaemon implements Runnable {
IvyDaemon d = new IvyDaemon(domain,servicePort);
}
- IvyDaemon(String domain,int servicePort) {
+ public IvyDaemon(String domain,int servicePort) {
// connexion to the Bus
try {
bus=new Ivy("IvyDaemon","IvyDaemon ready",null);
diff --git a/src/IvyWatcher.java b/src/IvyWatcher.java
index e371ea6..14fee3d 100755
--- a/src/IvyWatcher.java
+++ b/src/IvyWatcher.java
@@ -39,7 +39,7 @@ class IvyWatcher implements Runnable {
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
+ // it can also be a MulticastSocket, which inherits from the previous
/**
* creates an Ivy watcher.
* @param bus the bus
@@ -176,7 +176,6 @@ class IvyWatcher implements Runnable {
}
/*
- * TODO
* deprecated since we use Multicast. How to check when we are in UDP
* broadcast ?
private boolean isInDomain( InetAddress host ){
diff --git a/src/Probe.java b/src/Probe.java
index be2275e..fdb102e 100644
--- a/src/Probe.java
+++ b/src/Probe.java
@@ -12,8 +12,8 @@ import gnu.getopt.Getopt;
*
* Changelog:
* 1.0.10
- * Should exit on end of user input
- * Should handle multiple domains - it was a IvyWatcher problem -
+ * exits on end of user input
+ * handles multiple domains - it was a IvyWatcher problem -
*/
class Probe implements IvyApplicationListener, IvyMessageListener {
@@ -100,5 +100,4 @@ class Probe implements IvyApplicationListener, IvyMessageListener {
System.out.println(s);
}
-} // class Probe
-// EOF
+}