aboutsummaryrefslogtreecommitdiff
path: root/src/Ivy.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ivy.java')
-rwxr-xr-xsrc/Ivy.java38
1 files changed, 22 insertions, 16 deletions
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; }