aboutsummaryrefslogtreecommitdiff
path: root/src/Ivy.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ivy.java')
-rwxr-xr-xsrc/Ivy.java48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/Ivy.java b/src/Ivy.java
index 1fa812d..c127449 100755
--- a/src/Ivy.java
+++ b/src/Ivy.java
@@ -15,8 +15,9 @@
*</pre>
*
* CHANGELOG:
- * 1.2.17b
- * - sets the bufferSize for both outbound *and* inbound connexions, fixes performance issues
+ * 1.2.18
+ * - patch G.Alligier, it all passes lotsa tests !
+ * - disable ipv6 (because you know ...)
* 1.2.16
* - uses a ThreadPoolExecutor
* - sendMsg goes synchronized
@@ -133,23 +134,22 @@
*/
package fr.dgac.ivy;
-import gnu.getopt.Getopt;
-import java.io.*;
import java.net.*;
-import java.util.ArrayList;
-import java.util.Collection;
+import java.io.*;
+import gnu.getopt.Getopt;
+import java.util.regex.*;
+import java.util.Vector;
import java.util.Collections;
-import java.util.HashMap;
+import java.util.Collection;
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.Vector;
-import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.regex.*;
public class Ivy implements Runnable {
@@ -165,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.17b";
+ private static final String LIBVERSION ="1.2.18~pre1";
/*
* private fields
@@ -204,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 AtomicLong current = new AtomicLong(System.currentTimeMillis());
- private static java.util.Random generator;// = new java.util.Random(current*(serial + 1));
+ private static long current = 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;
@@ -226,7 +226,6 @@ 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 =
@@ -327,9 +326,11 @@ public class Ivy implements Runnable {
/**
* connects the Ivy bus to a domain or list of domains.
*
+ * <ul>
* <li>One thread (IvyWatcher) for each traffic rendezvous (either UDP broadcast or TCPMulticast)
* <li>One thread (serverThread/Ivy) to accept incoming connexions on server socket
* <li>a thread for each IvyClient when the connexion has been done
+ * </ul>
* @throws IvyException if there is a problem joining the bus
* @param domainbus a domain of the form 10.0.0:1234, A good practice is to
* sick to a null value, so that your agent will honor the IVY_BUS parameter
@@ -346,6 +347,7 @@ public class Ivy implements Runnable {
public final void start(final String domainbus) throws IvyException {
if (!stopped) throw new IvyException("cannot start a bus that's already started");
+ System.setProperty("java.net.preferIPv4Stack" , "true");
pool = Executors.newCachedThreadPool();
stopped=false;
String db = domainbus;
@@ -487,7 +489,7 @@ public class Ivy implements Runnable {
*
* since 1.2.16 goes synchronized to avoid concurrent access
*/
- public final int sendMsg(final String message) throws IvyException {
+ synchronized public final int sendMsg(final String message) throws IvyException {
int count = 0;
waitForRemote("sending");
synchronized (lock) {
@@ -820,7 +822,7 @@ public class Ivy implements Runnable {
return "bus <"+appName+">[port:"+applicationPort+",serial:"+myserial+"]";
}
- private synchronized long nextId() { return current.incrementAndGet(); }
+ private synchronized long nextId() { return current++; }
/////////////////////////////////////////////////////////////////:
//
@@ -832,8 +834,6 @@ 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);
@@ -846,7 +846,7 @@ public class Ivy implements Runnable {
}
- protected void removeClient(IvyClient c) {
+ protected synchronized void removeClient(IvyClient c) {
synchronized(lock) {
synchronized (clients) {
clients.remove(c.getClientKey());
@@ -855,7 +855,7 @@ public class Ivy implements Runnable {
}
}
- protected void handShake(IvyClient c) {
+ protected synchronized void handShake(IvyClient c) {
synchronized(lock) {
removeHalf(c);
if (clients == null||c == null) return;
@@ -942,20 +942,20 @@ public class Ivy implements Runnable {
String getReadyMessage() { return ready_message; }
boolean getProtectNewlines() { return doProtectNewlines; }
String getWatcherId() { return watcherId; }
- private int getBufferSize() { return bufferSize; }
+ int getBufferSize() { return bufferSize; }
int getSerial() { return myserial; }
ExecutorService getPool() { return pool; }
protected void pushThread(String reason) {
synchronized(readyToSend) {
- nbThreads++ ;
+ // nbThreads++ ;
//System.out.println("DEBUG PUSH "+this+" -- threads: "+nbThreads + "; reason: "+reason);
}
}
protected void popThread(String reason) {
synchronized(readyToSend) {
- nbThreads-- ;
+ // nbThreads-- ;
//System.out.println("DEBUG POP "+this+" -- threads: "+nbThreads + "reason: "+reason);
}
}