aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjestin2016-02-14 16:08:22 +0000
committerjestin2016-02-14 16:08:22 +0000
commit1e03020739271f2b6a37ca7010d42d1d4499330a (patch)
treef30238db8abf4a3f78ec6d3622b56b3bc74b3976
parent94e8bb452f6c698f0aa48e2a0267c605471577fe (diff)
downloadivy-java-1e03020739271f2b6a37ca7010d42d1d4499330a.zip
ivy-java-1e03020739271f2b6a37ca7010d42d1d4499330a.tar.gz
ivy-java-1e03020739271f2b6a37ca7010d42d1d4499330a.tar.bz2
ivy-java-1e03020739271f2b6a37ca7010d42d1d4499330a.tar.xz
-rw-r--r--build.xml3
-rw-r--r--doc/ivy-java.18
-rw-r--r--doc/ivy-java.sgml31
-rw-r--r--doc/jafter.12
-rw-r--r--doc/jprobe.12
-rwxr-xr-xsrc/Ivy.java38
-rwxr-xr-xsrc/IvyWatcher.java8
-rw-r--r--src/SelfIvyClient.java12
-rwxr-xr-xtools/jafter4
-rwxr-xr-xtools/jdaemon3
-rwxr-xr-xtools/jprobe3
11 files changed, 61 insertions, 53 deletions
diff --git a/build.xml b/build.xml
index aff2a28..908297c 100644
--- a/build.xml
+++ b/build.xml
@@ -20,7 +20,7 @@
-->
<property name="docbook-xsl" value="/opt/local/share/xsl/docbook-xsl" />
<property name="jars.home" value="/opt/local/share/java/"/>
- <property name="fop.home" value="${jars.home}/fop/1.0/"/>
+ <property name="fop.home" value="${jars.home}/fop/1.1/"/>
<property name="xslt.jar" value="${jars.home}/xalan.jar"/>
<property name="jsch.jar" value="${jars.home}/jsch.jar"/>
<property name="servlet.jar" value="servlet25-api.jar "/>
@@ -159,6 +159,7 @@
<target name="run" depends="jar">
<java fork="true" classname="${main-class}">
<jvmarg value="${defaultbus}"/>
+ <jvmarg value="-Djava.net.preferIPv4Stack=true"/>
<arg value="(.*)"/>
<classpath>
<path refid="classpath"/>
diff --git a/doc/ivy-java.1 b/doc/ivy-java.1
index 0056891..7438076 100644
--- a/doc/ivy-java.1
+++ b/doc/ivy-java.1
@@ -8,7 +8,7 @@
.\" '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
.\" '\"
.\" '\"
-.TH "Ivy-java" "" "" "Yannick Jestin <jestin@cena.fr>" ""
+.TH "Ivy-java" "" "" "Yannick Jestin <yannick.jestin@enac.fr>" ""
.SH "NAME"
ivy\-java \- a software bus library java implementation
.SH "SYNOPSIS"
@@ -88,7 +88,7 @@ See the BUGS files for details.
.SH "AUTHORS"
.nf
-Yannick Jestin <jestin@cena.fr>
+Yannick Jestin <yannick.jestin@enac.fr>
.nf
Francois\-Regis Colin <fcolin@cena.fr>
.SH "SEE ALSO"
@@ -102,10 +102,10 @@ ivyprobe (1)
.nf
pcrepattern (3)
.sp
-For further details, please refer to the Ivy html page at http://www.tls.cena.fr/products/ivy/
+For further details, please refer to the Ivy html page at http://www.eei.cena.fr/products/ivy/
.SH "NOTES"
-In case of any comment or bug report on this library, please contact jestin@cena.fr
+In case of any comment or bug report on this library, please contact the author
.nf
Special thanks to Michelle Jacomi for her kind support and
documentation writing.
diff --git a/doc/ivy-java.sgml b/doc/ivy-java.sgml
index fb94b29..406de91 100644
--- a/doc/ivy-java.sgml
+++ b/doc/ivy-java.sgml
@@ -32,9 +32,9 @@
<abstract>
<para>This document is a programmer's guide that describes how to use
the Ivy Java library to connect applications to an Ivy bus. This guide
- describes version 1.2.13 of the library. This document itself is part
- of the Java package, available on the <link xlink:href="http://www2.tls.cena.fr/products/ivy/">Ivy web site</link>, and
- on the <link xlink:href="http://www.lii-enac.fr/~jestin/ivy-java/">maintainer's
+ describes version 1.2.17 of the library. This document itself is part
+ of the Java package, available on the <link xlink:href="http://www.eei.cena.fr/products/ivy/">Ivy web site</link>, and
+ on the <link xlink:href="http://www.lii-enac.fr/~jestin/">maintainer's
web page</link>.</para>
</abstract>
</info>
@@ -50,7 +50,7 @@ incomplete, is quite ugly.
</para></sect1>
<sect1> <title>What is Ivy?</title> <para>
-Ivy is a software bus initially initially designed at <link xlink:href="http://www.cena.fr/">CENA</link>. A software bus is a system that
+Ivy is a software bus initially initially designed at CENA. A software bus is a system that
allows software applications to exchange information with the illusion of
broadcasting that information, selection being performed by the receiving
applications. Using a software bus is very similar to dealing with events in a
@@ -74,7 +74,7 @@ if you are more interested in other languages, refer to other guides such as
<citetitle>The Ivy Perl library guide</citetitle>
(not yet written), or
<citetitle>The Ivy C library guide</citetitle>
- . All those documents should be available from <link xlink:href="http://www2.tls.cena.fr/products/ivy/">the Ivy Web site </link>
+ . All those documents should be available from <link xlink:href="http://www.eei.cena.fr/products/ivy/">the Ivy Web site </link>
.
</para>
</sect1>
@@ -87,20 +87,19 @@ The Ivy Java library (aka fr.dgac.ivy) is a Java package that
allows you to connect applications to an Ivy bus.
You can also use it to connect any Java
application to an Ivy bus. So far, this library has been tested and used on a variety of
-Java virtual machines (from 1.1.7 to 1.6.0), a variety of vendors (kaffe+gcj,
-sun jdk, blackdown) and on a variety of architectures (GNU/Linux, Solaris,
-Windows NT,XP,2000, MacOSX). It used to be developped and maintained on a Debian
-GNU/Linux ox, but the maintainer got lazy, and enjoys a MacOSX snow leopard powered macbook.
+Java virtual machines (from 1.1.7 to 1.8), a variety of vendors (kaffe+gcj,
+sun jdk, blackdown, apple, and now oracle) and on a variety of architectures (GNU/Linux, Windows, MacOSX). It used to be developped and maintained on a Debian
+GNU/Linux os, but the maintainer got lazy, and enjoys a MacOSX powered ultimate development machine.
</para>
<para>
The Ivy Java library was originally developed by François-Régis Colin and
Yannick Jestin within a group at CENA (Toulouse, France). It is now maintained
-by Yannick.
+by Yannick and contributors.
</para>
</sect2>
<sect2>
<title>Getting and installing the Ivy Java library</title>
- <para>You can get the latest versions of the Ivy Java library from <link xlink:href="http://www.tls.cena.fr/products/ivy/">the Ivy web site</link>. It is packaged either as a jar file or as a debian package. We plan to package it according to different distribution formats, such as .msi (Windows) .deb or .rpm package (Debian, Redhat and Mandrake linux). Contributors are welcome for package management.</para>
+ <para>You can get the latest versions of the Ivy Java library from <link xlink:href="http://www.eei.cena.fr/products/ivy/">the Ivy web site</link>. It is packaged either as a jar file or as a debian package. We used to package it according to different distribution formats, such as .msi (Windows) .deb or .rpm packages, but due to the essence of Java programming, the jar file should be self sufficient.</para>
<para>For most people, the simplest way is to install the
ivy-java.jar jar file, containing both ivy java and its
@@ -115,7 +114,7 @@ by Yannick.
</itemizedlist>
</para>
<para>
-The numbered packages (ivy-1.2.14.jar ivy-1.2.14.tar.gz) also contain documentation, sources code alongside with examples and a small set of tools (IvyDaemon, jprobe, jafter). You may need to install the <link xlink:href="http://www.urbanophile.com/arenn/coding/download.html">gnu getopt library</link>, included in the jar file but not in the debian package.
+The numbered jar files (ivy-1.2.17.jar) also contain documentation, sources code alongside with examples and a small set of tools (IvyDaemon, jprobe, jafter). You may need to install the <link xlink:href="http://www.urbanophile.com/arenn/coding/download.html">gnu getopt library</link>, included in the jar file but not in the debian package.
</para>
<para>
In order to test the presence of Ivy jar on your system once installed, run the following command:
@@ -245,7 +244,7 @@ $
<sect1>
<title>Basic functions</title>
<para>
-The javadoc generated files are available on line on the ivy web site, and should be included in your ivy-1.2.14.jar java package (or in /usr/share/doc/libivy-java, alongside with this very manual, if you used a debian package). Here are more details on those functions.
+The javadoc generated files are available on line on the ivy web site, and should be included in your ivy-1.2.17.jar java package (or in /usr/share/doc/libivy-java, alongside with this very manual, if you used a debian package). Here are more details on those functions.
</para>
<sect2>
<title>Initialization an Ivy object and joining the bus</title>
@@ -393,7 +392,7 @@ bindMsg("^a*(.*)c*$", new IvyMessageListener() {
The processing of the ivy protocol and the execution of the callback are
performed within an unique thread per remote client. Thus, the callback will
be performed sequentially. If you want an asynchronous handling of callbacks,
-see in the advanced functions.
+see in the advanced functions. In order to understand the heavily threaded model of a java Ivy agent, feel free to use jvisualvm to see the spawning of threads.
</para>
</sect2>
@@ -502,7 +501,7 @@ won't be much documented, in order to make it harder to use.
Swing requires the code to run in the main swing thread. In order to avoid
problems, be sure tu use the SwingUtilities.invokeLater() or
SwingUtilities.invokeAndWait() methods if you Ivy callbacks impact swing
-components.
+components. You can also use the new BindType.SWING api.
</para>
</sect2>
<sect2>
@@ -1004,7 +1003,7 @@ public class EndApp extends IvyApplicationAdapter {
For bug reports or comments on the library itself or about this document,
please me an email at <email>yannick.jestin@enac.fr</email>
. For comments and ideas about Ivy itself (protocol, applications, etc), please join and use the
-<link xlink:href="http://www.tls.cena.fr/products/ivy/contact.html">Ivy mailing list</link>
+<link xlink:href="http://www.eei.cena.fr/products/ivy/contact.html">Ivy mailing list</link>
</para>
<para>
If you report a bug, try to identify the causal path leading to the
diff --git a/doc/jafter.1 b/doc/jafter.1
index 806027c..b34a407 100644
--- a/doc/jafter.1
+++ b/doc/jafter.1
@@ -54,7 +54,7 @@ jprobe (1)
.nf
pcrepattern (3)
.sp
-For further details, please refer to the Ivy html page at http://www.tls.cena.fr/products/ivy/
+For further details, please refer to the Ivy html page at http://www.eei.cena.fr/products/ivy/
.SH "NOTES"
In case of any comment or bug report on this library, please contact yannick.jestin@enac.fr
diff --git a/doc/jprobe.1 b/doc/jprobe.1
index e5a3d2d..f77d729 100644
--- a/doc/jprobe.1
+++ b/doc/jprobe.1
@@ -99,7 +99,7 @@ ivyprobe (1)
.nf
pcrepattern (3)
.sp
-For further details, please refer to the Ivy html page at http://www.tls.cena.fr/products/ivy/
+For further details, please refer to the Ivy html page at http://www.eei.cena.fr/products/ivy/
.SH "NOTES"
In case of any comment or bug report on this library, please contact yannick.jestin@enac.fr
diff --git a/src/Ivy.java b/src/Ivy.java
index 4c6f8ff..1fa812d 100755
--- a/src/Ivy.java
+++ b/src/Ivy.java
@@ -15,6 +15,8 @@
*</pre>
*
* CHANGELOG:
+ * 1.2.17b
+ * - sets the bufferSize for both outbound *and* inbound connexions, fixes performance issues
* 1.2.16
* - uses a ThreadPoolExecutor
* - sendMsg goes synchronized
@@ -131,22 +133,23 @@
*/
package fr.dgac.ivy;
-import java.net.*;
-import java.io.*;
import gnu.getopt.Getopt;
-import java.util.regex.*;
-import java.util.Vector;
-import java.util.Collections;
+import java.io.*;
+import java.net.*;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.HashMap;
-import java.util.ArrayList;
import java.util.Properties;
import java.util.StringTokenizer;
-import java.util.concurrent.Executors;
+import java.util.Vector;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.regex.*;
public class Ivy implements Runnable {
@@ -162,7 +165,7 @@ public class Ivy implements Runnable {
* the library version, useful for development purposes only, when java is
* invoked with -DIVY_DEBUG
*/
- private static final String LIBVERSION ="1.2.17";
+ private static final String LIBVERSION ="1.2.17b";
/*
* private fields
@@ -201,8 +204,8 @@ public class Ivy implements Runnable {
// FIXME should not be static ? (findbugs)
private static int serial = 0;
private int myserial = serial++;
- private static long current = System.currentTimeMillis();
- private static java.util.Random generator = new java.util.Random(current*(serial + 1));
+ private static AtomicLong current = new AtomicLong(System.currentTimeMillis());
+ private static java.util.Random generator;// = new java.util.Random(current*(serial + 1));
private String watcherId = null;
private static Pattern rangeRE; // tcp range min and max
private static Pattern bounded;
@@ -223,6 +226,7 @@ public class Ivy implements Runnable {
* disconnections, (may be null for most agents)
*/
public Ivy(final String name, final String message, final IvyApplicationListener appcb) {
+ generator = new java.util.Random(current.get() * (serial + 1));
appName = name;
ready_message = (message == null) ? name + " READY" : message;
debug =
@@ -483,7 +487,7 @@ public class Ivy implements Runnable {
*
* since 1.2.16 goes synchronized to avoid concurrent access
*/
- synchronized public final int sendMsg(final String message) throws IvyException {
+ public final int sendMsg(final String message) throws IvyException {
int count = 0;
waitForRemote("sending");
synchronized (lock) {
@@ -816,7 +820,7 @@ public class Ivy implements Runnable {
return "bus <"+appName+">[port:"+applicationPort+",serial:"+myserial+"]";
}
- private synchronized long nextId() { return current++; }
+ private synchronized long nextId() { return current.incrementAndGet(); }
/////////////////////////////////////////////////////////////////:
//
@@ -828,6 +832,8 @@ public class Ivy implements Runnable {
* @return false if the client has not been created, true otherwise
*/
protected boolean createIvyClient(Socket s , int port, boolean domachin) throws IOException {
+ s.setReceiveBufferSize(getBufferSize());
+ s.setTcpNoDelay(true);
IvyClient i = new IvyClient(this , s , port , domachin);
try {
pool.execute(i);
@@ -840,7 +846,7 @@ public class Ivy implements Runnable {
}
- protected synchronized void removeClient(IvyClient c) {
+ protected void removeClient(IvyClient c) {
synchronized(lock) {
synchronized (clients) {
clients.remove(c.getClientKey());
@@ -849,7 +855,7 @@ public class Ivy implements Runnable {
}
}
- protected synchronized void handShake(IvyClient c) {
+ protected void handShake(IvyClient c) {
synchronized(lock) {
removeHalf(c);
if (clients == null||c == null) return;
@@ -936,7 +942,7 @@ public class Ivy implements Runnable {
String getReadyMessage() { return ready_message; }
boolean getProtectNewlines() { return doProtectNewlines; }
String getWatcherId() { return watcherId; }
- int getBufferSize() { return bufferSize; }
+ private int getBufferSize() { return bufferSize; }
int getSerial() { return myserial; }
ExecutorService getPool() { return pool; }
diff --git a/src/IvyWatcher.java b/src/IvyWatcher.java
index c9a661f..b95af97 100755
--- a/src/IvyWatcher.java
+++ b/src/IvyWatcher.java
@@ -190,13 +190,13 @@ class IvyWatcher implements Runnable {
Matcher m = recoucou.matcher(msg);
// is it a correct broadcast packet ?
if (!m.matches()) {
- System.err.println("Ignoring bad format broadcast from "+ remotehostname+":"+packet.getPort());
+ System.err.println("nomatch - Ignoring bad format broadcast from "+ remotehostname+":"+packet.getPort()+" ["+msg+"]");
return true;
}
// is it the correct protocol version ?
int version = Integer.parseInt(m.group(1));
if ( version < Protocol.PROTOCOLMINIMUM ) {
- System.err.println("Ignoring bad format broadcast from "+
+ System.err.println("too old - Ignoring bad format broadcast from "+
remotehostname+":"+packet.getPort()
+" protocol version "+remotehost+" we need "+Protocol.PROTOCOLMINIMUM+" minimum");
return true;
@@ -242,8 +242,6 @@ class IvyWatcher implements Runnable {
traceDebug("no known agent originating from " + remotehost + ":" + remotePort);
try {
Socket s = new Socket(remotehost,remotePort);
- s.setReceiveBufferSize(bus.getBufferSize());
- s.setTcpNoDelay(true);
if (!bus.createIvyClient(s,remotePort,false)) return false ;
} catch ( java.net.ConnectException jnc ) {
traceDebug("cannot connect to "+remotehostname+":"+remotePort+", he probably stopped his bus");
@@ -252,7 +250,7 @@ class IvyWatcher implements Runnable {
traceDebug("there is already a request originating from " + remotehost + ":" + remotePort);
}
} catch (NumberFormatException nfe) {
- System.err.println("Ignoring bad format broadcast from "+remotehostname);
+ System.err.println("nfe: Ignoring bad format broadcast from "+remotehostname);
return true;
} catch ( UnknownHostException e ) {
System.err.println("Unkonwn host "+remotehost +","+e.getMessage());
diff --git a/src/SelfIvyClient.java b/src/SelfIvyClient.java
index 2751c92..fbf4927 100644
--- a/src/SelfIvyClient.java
+++ b/src/SelfIvyClient.java
@@ -65,7 +65,7 @@ public class SelfIvyClient extends IvyClient {
synchronized (threadedFlag) {
threadedFlag.put(key,type); // use autoboxing of boolean
}
- return key.intValue();
+ return key;
} catch (PatternSyntaxException ree) {
throw new IvyException("Invalid regexp " + sregexp);
}
@@ -73,14 +73,14 @@ public class SelfIvyClient extends IvyClient {
protected synchronized void unBindMsg(int id) throws IvyException {
Integer key = id;
- synchronized (regexps) { synchronized (callbacks) { synchronized (threadedFlag) {
+ /*synchronized (regexps) { synchronized (callbacks) { synchronized (threadedFlag) {*/
if ( ( regexps.remove(key) == null )
|| (regexpsText.remove(key) == null )
|| (callbacks.remove(key) == null )
|| (threadedFlag.remove(key) == null )
)
throw new IvyException("client wants to remove an unexistant regexp "+id);
- } } }
+ /*} } }*/
}
// unbinds to the first regexp
@@ -90,7 +90,7 @@ public class SelfIvyClient extends IvyClient {
for (Map.Entry<Integer,String> me : regexpsText.entrySet()) {
if ( me.getValue().equals(re) ) {
try {
- bus.unBindMsg(me.getKey().intValue());
+ bus.unBindMsg(me.getKey());
} catch (IvyException ie) {
return false;
}
@@ -101,7 +101,7 @@ public class SelfIvyClient extends IvyClient {
return false;
}
- protected int sendSelfMsg(String message) {
+ protected synchronized int sendSelfMsg(String message) {
int count = 0;
traceDebug("trying to send to self the message <"+message+">");
for (Integer key : regexps.keySet() ) {
@@ -128,7 +128,7 @@ public class SelfIvyClient extends IvyClient {
callback=callbacks.get(key);
}
if (callback==null) {
- traceDebug("Not regexp matching id "+key.intValue()+", it must have been unsubscribed concurrently");
+ traceDebug("Not regexp matching id "+key+", it must have been unsubscribed concurrently");
return;
// DONE check that nasty synchro issue, test suite: Request
}
diff --git a/tools/jafter b/tools/jafter
index 113a8a9..bf99dee 100755
--- a/tools/jafter
+++ b/tools/jafter
@@ -9,8 +9,10 @@ re=/usr/share/java/regexp.jar
go=/usr/share/java/gnu-getopt.jar
bus=
+NOIPV6=-Djava.net.preferIPv4Stack=true
+
if [ "$IVYBUS" ]; then
bus="-DIVYBUS=${IVYBUS}"
fi
-java -classpath ${jar}:${re}:${go} $bus fr.dgac.ivy.tools.After "$@"
+java ${NOIPV6} -classpath ${jar}:${re}:${go} $bus fr.dgac.ivy.tools.After "$@"
diff --git a/tools/jdaemon b/tools/jdaemon
index 6635857..693ceb7 100755
--- a/tools/jdaemon
+++ b/tools/jdaemon
@@ -9,9 +9,10 @@ re=/usr/share/java/regexp.jar
go=/usr/share/java/gnu-getopt.jar
#jar=../lib/ivy-java-1.2.6.jar
bus=
+NOIPV6=-Djava.net.preferIPv4Stack=true
if [ "$IVYBUS" ]; then
bus="-DIVYBUS=${IVYBUS}"
fi
-java -classpath ${jar}:${re}:${go} $bus fr.dgac.ivy.tools.IvyDaemon "$@"
+java ${NOIPV6} -classpath ${jar}:${re}:${go} $bus fr.dgac.ivy.tools.IvyDaemon "$@"
diff --git a/tools/jprobe b/tools/jprobe
index fa34ce6..25c1d4f 100755
--- a/tools/jprobe
+++ b/tools/jprobe
@@ -9,9 +9,10 @@ re=/usr/share/java/regexp.jar
go=/usr/share/java/gnu-getopt.jar
#jar=../lib/ivy-java-1.2.6.jar
bus=
+NOIPV6=-Djava.net.preferIPv4Stack=true
if [ "$IVYBUS" ]; then
bus="-DIVYBUS=${IVYBUS}"
fi
-java -classpath ${jar}:${re}:${go} $bus fr.dgac.ivy.tools.Probe "$@"
+java ${NOIPV6} -classpath ${jar}:${re}:${go} $bus fr.dgac.ivy.tools.Probe "$@"