summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/Ice/src/main/java/IceInternal/BufSizeWarnInfo.java25
-rw-r--r--java/src/Ice/src/main/java/IceInternal/Instance.java45
-rw-r--r--java/src/Ice/src/main/java/IceInternal/Network.java54
-rw-r--r--java/src/Ice/src/main/java/IceInternal/ProtocolInstance.java15
-rw-r--r--java/src/Ice/src/main/java/IceInternal/StreamSocket.java18
-rw-r--r--java/src/Ice/src/main/java/IceInternal/TcpAcceptor.java2
-rw-r--r--java/src/Ice/src/main/java/IceInternal/UdpTransceiver.java32
-rw-r--r--java/src/Ice/src/main/java/IceSSL/AcceptorI.java2
8 files changed, 162 insertions, 31 deletions
diff --git a/java/src/Ice/src/main/java/IceInternal/BufSizeWarnInfo.java b/java/src/Ice/src/main/java/IceInternal/BufSizeWarnInfo.java
new file mode 100644
index 00000000000..4b85092a71c
--- /dev/null
+++ b/java/src/Ice/src/main/java/IceInternal/BufSizeWarnInfo.java
@@ -0,0 +1,25 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+package IceInternal;
+
+class BufSizeWarnInfo
+{
+ // Whether send size warning has been emitted
+ public boolean sndWarn;
+
+ // The send size for which the warning wwas emitted
+ public int sndSize;
+
+ // Whether receive size warning has been emitted
+ public boolean rcvWarn;
+
+ // The receive size for which the warning wwas emitted
+ public int rcvSize;
+}
diff --git a/java/src/Ice/src/main/java/IceInternal/Instance.java b/java/src/Ice/src/main/java/IceInternal/Instance.java
index a28e914844c..30698fc060d 100644
--- a/java/src/Ice/src/main/java/IceInternal/Instance.java
+++ b/java/src/Ice/src/main/java/IceInternal/Instance.java
@@ -1471,6 +1471,50 @@ public final class Instance
}
}
+ public BufSizeWarnInfo getBufSizeWarn(short type)
+ {
+ synchronized(_setBufSizeWarn)
+ {
+ BufSizeWarnInfo info;
+ if(!_setBufSizeWarn.containsKey(type))
+ {
+ info = new BufSizeWarnInfo();
+ info.sndWarn = false;
+ info.sndSize = -1;
+ info.rcvWarn = false;
+ info.rcvSize = -1;
+ _setBufSizeWarn.put(type, info);
+ }
+ else
+ {
+ info = _setBufSizeWarn.get(type);
+ }
+ return info;
+ }
+ }
+
+ public void setSndBufSizeWarn(short type, int size)
+ {
+ synchronized(_setBufSizeWarn)
+ {
+ BufSizeWarnInfo info = getBufSizeWarn(type);
+ info.sndWarn = true;
+ info.sndSize = size;
+ _setBufSizeWarn.put(type, info);
+ }
+ }
+
+ public void setRcvBufSizeWarn(short type, int size)
+ {
+ synchronized(_setBufSizeWarn)
+ {
+ BufSizeWarnInfo info = getBufSizeWarn(type);
+ info.rcvWarn = true;
+ info.rcvSize = size;
+ _setBufSizeWarn.put(type, info);
+ }
+ }
+
private void
updateConnectionObservers()
{
@@ -1698,6 +1742,7 @@ public final class Instance
private java.util.Map<String, Ice.Object> _adminFacets = new java.util.HashMap<String, Ice.Object>();
private java.util.Set<String> _adminFacetFilter = new java.util.HashSet<String>();
private Ice.Identity _adminIdentity;
+ private java.util.Map<Short, BufSizeWarnInfo> _setBufSizeWarn = new java.util.HashMap<Short, BufSizeWarnInfo>();
private java.util.Map<String, String> _typeToClassMap = new java.util.HashMap<String, String>();
final private String[] _packages;
diff --git a/java/src/Ice/src/main/java/IceInternal/Network.java b/java/src/Ice/src/main/java/IceInternal/Network.java
index ae551e30a1a..f2e521af2dd 100644
--- a/java/src/Ice/src/main/java/IceInternal/Network.java
+++ b/java/src/Ice/src/main/java/IceInternal/Network.java
@@ -117,7 +117,7 @@ public final class Network
return false;
}
- public static boolean
+ public static boolean
isIPv6Supported()
{
try
@@ -797,7 +797,7 @@ public final class Network
}
public static java.util.List<java.net.InetSocketAddress>
- getAddresses(String host, int port, int protocol, Ice.EndpointSelectionType selType, boolean preferIPv6,
+ getAddresses(String host, int port, int protocol, Ice.EndpointSelectionType selType, boolean preferIPv6,
boolean blocking)
{
if(!blocking)
@@ -988,7 +988,7 @@ public final class Network
}
public static void
- setTcpBufSize(java.nio.channels.SocketChannel socket, Ice.Properties properties, Ice.Logger logger)
+ setTcpBufSize(java.nio.channels.SocketChannel socket, ProtocolInstance instance)
{
//
// By default, on Windows we use a 128KB buffer size. On Unix
@@ -1000,7 +1000,9 @@ public final class Network
dfltBufSize = 128 * 1024;
}
- int sizeRequested = properties.getPropertyAsIntWithDefault("Ice.TCP.RcvSize", dfltBufSize);
+ System.err.println("XXX");
+
+ int sizeRequested = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.RcvSize", dfltBufSize);
if(sizeRequested > 0)
{
//
@@ -1010,13 +1012,21 @@ public final class Network
//
setRecvBufferSize(socket, sizeRequested);
int size = getRecvBufferSize(socket);
- if(size < sizeRequested) // Warn if the size that was set is less than the requested size.
+ //if(size < sizeRequested)
{
- logger.warning("TCP receive buffer size: requested size of " + sizeRequested + " adjusted to " + size);
+ // Warn if the size that was set is less than the requested size and
+ // we have not already warned.
+ BufSizeWarnInfo winfo = instance.getBufSizeWarn(Ice.TCPEndpointType.value);
+ if(!winfo.rcvWarn || sizeRequested != winfo.rcvSize)
+ {
+ instance.logger().warning("TCP receive buffer size: requested size of " + sizeRequested +
+ " adjusted to " + size);
+ instance.setRcvBufSizeWarn(Ice.TCPEndpointType.value, sizeRequested);
+ }
}
}
- sizeRequested = properties.getPropertyAsIntWithDefault("Ice.TCP.SndSize", dfltBufSize);
+ sizeRequested = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.SndSize", dfltBufSize);
if(sizeRequested > 0)
{
//
@@ -1026,15 +1036,23 @@ public final class Network
//
setSendBufferSize(socket, sizeRequested);
int size = getSendBufferSize(socket);
- if(size < sizeRequested) // Warn if the size that was set is less than the requested size.
+ //if(size < sizeRequested)
{
- logger.warning("TCP send buffer size: requested size of " + sizeRequested + " adjusted to " + size);
+ // Warn if the size that was set is less than the requested size and
+ // we have not already warned.
+ BufSizeWarnInfo winfo = instance.getBufSizeWarn(Ice.TCPEndpointType.value);
+ if(!winfo.sndWarn || sizeRequested != winfo.sndSize)
+ {
+ instance.logger().warning("TCP send buffer size: requested size of " + sizeRequested +
+ " adjusted to " + size);
+ instance.setSndBufSizeWarn(Ice.TCPEndpointType.value, sizeRequested);
+ }
}
}
}
public static void
- setTcpBufSize(java.nio.channels.ServerSocketChannel socket, Ice.Properties properties, Ice.Logger logger)
+ setTcpBufSize(java.nio.channels.ServerSocketChannel socket, ProtocolInstance instance)
{
//
// By default, on Windows we use a 128KB buffer size. On Unix
@@ -1046,10 +1064,12 @@ public final class Network
dfltBufSize = 128 * 1024;
}
+ System.err.println("YYY");
+
//
// Get property for buffer size.
//
- int sizeRequested = properties.getPropertyAsIntWithDefault("Ice.TCP.RcvSize", dfltBufSize);
+ int sizeRequested = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.RcvSize", dfltBufSize);
if(sizeRequested > 0)
{
//
@@ -1059,9 +1079,17 @@ public final class Network
//
setRecvBufferSize(socket, sizeRequested);
int size = getRecvBufferSize(socket);
- if(size < sizeRequested) // Warn if the size that was set is less than the requested size.
+ //if(size < sizeRequested)
{
- logger.warning("TCP receive buffer size: requested size of " + sizeRequested + " adjusted to " + size);
+ // Warn if the size that was set is less than the requested size and
+ // we have not already warned.
+ BufSizeWarnInfo winfo = instance.getBufSizeWarn(Ice.TCPEndpointType.value);
+ if(!winfo.rcvWarn || sizeRequested != winfo.rcvSize)
+ {
+ instance.logger().warning("TCP receive buffer size: requested size of " + sizeRequested +
+ " adjusted to " + size);
+ instance.setRcvBufSizeWarn(Ice.TCPEndpointType.value, sizeRequested);
+ }
}
}
}
diff --git a/java/src/Ice/src/main/java/IceInternal/ProtocolInstance.java b/java/src/Ice/src/main/java/IceInternal/ProtocolInstance.java
index 195a554892e..b6c133863f1 100644
--- a/java/src/Ice/src/main/java/IceInternal/ProtocolInstance.java
+++ b/java/src/Ice/src/main/java/IceInternal/ProtocolInstance.java
@@ -104,6 +104,21 @@ public class ProtocolInstance
_instance.endpointHostResolver().resolve(host, port, type, endpt, callback);
}
+ public BufSizeWarnInfo getBufSizeWarn(short type)
+ {
+ return _instance.getBufSizeWarn(type);
+ }
+
+ public void setSndBufSizeWarn(short type, int size)
+ {
+ _instance.setSndBufSizeWarn(type, size);
+ }
+
+ public void setRcvBufSizeWarn(short type, int size)
+ {
+ _instance.setRcvBufSizeWarn(type, size);
+ }
+
ProtocolInstance(Instance instance, short type, String protocol, boolean secure)
{
_instance = instance;
diff --git a/java/src/Ice/src/main/java/IceInternal/StreamSocket.java b/java/src/Ice/src/main/java/IceInternal/StreamSocket.java
index 4079519ee48..61b546400b0 100644
--- a/java/src/Ice/src/main/java/IceInternal/StreamSocket.java
+++ b/java/src/Ice/src/main/java/IceInternal/StreamSocket.java
@@ -12,8 +12,8 @@ package IceInternal;
public class StreamSocket
{
public StreamSocket(ProtocolInstance instance,
- NetworkProxy proxy,
- java.net.InetSocketAddress addr,
+ NetworkProxy proxy,
+ java.net.InetSocketAddress addr,
java.net.InetSocketAddress sourceAddr)
{
_instance = instance;
@@ -106,10 +106,10 @@ public class StreamSocket
else if(_state == StateProxyConnected)
{
_proxy.finish(readBuffer, writeBuffer);
-
+
readBuffer.clear();
writeBuffer.clear();
-
+
_state = StateConnected;
}
@@ -121,7 +121,7 @@ public class StreamSocket
{
return _state == StateConnected;
}
-
+
public java.nio.channels.SocketChannel fd()
{
return _fd;
@@ -203,8 +203,8 @@ public class StreamSocket
}
}
return read;
- }
-
+ }
+
public int write(java.nio.ByteBuffer buf)
{
assert(_fd != null);
@@ -226,7 +226,7 @@ public class StreamSocket
{
ret = _fd.write(buf);
}
-
+
if(ret == -1)
{
throw new Ice.ConnectionLostException();
@@ -275,7 +275,7 @@ public class StreamSocket
private void init()
{
Network.setBlock(_fd, false);
- Network.setTcpBufSize(_fd, _instance.properties(), _instance.logger());
+ Network.setTcpBufSize(_fd, _instance);
if(System.getProperty("os.name").startsWith("Windows"))
{
diff --git a/java/src/Ice/src/main/java/IceInternal/TcpAcceptor.java b/java/src/Ice/src/main/java/IceInternal/TcpAcceptor.java
index 7b69f8986ba..493a7b42184 100644
--- a/java/src/Ice/src/main/java/IceInternal/TcpAcceptor.java
+++ b/java/src/Ice/src/main/java/IceInternal/TcpAcceptor.java
@@ -92,7 +92,7 @@ class TcpAcceptor implements Acceptor
{
_fd = Network.createTcpServerSocket();
Network.setBlock(_fd, false);
- Network.setTcpBufSize(_fd, instance.properties(), _instance.logger());
+ Network.setTcpBufSize(_fd, instance);
if(!System.getProperty("os.name").startsWith("Windows"))
{
//
diff --git a/java/src/Ice/src/main/java/IceInternal/UdpTransceiver.java b/java/src/Ice/src/main/java/IceInternal/UdpTransceiver.java
index cead447dda2..bffbeb3ce82 100644
--- a/java/src/Ice/src/main/java/IceInternal/UdpTransceiver.java
+++ b/java/src/Ice/src/main/java/IceInternal/UdpTransceiver.java
@@ -356,7 +356,7 @@ final class UdpTransceiver implements Transceiver
try
{
_fd = Network.createUdpSocket(_addr);
- setBufSize(instance.properties());
+ setBufSize();
Network.setBlock(_fd, false);
//
// NOTE: setting the multicast interface before performing the
@@ -393,7 +393,7 @@ final class UdpTransceiver implements Transceiver
{
_addr = Network.getAddressForServer(host, port, instance.protocolSupport(), instance.preferIPv6());
_fd = Network.createUdpSocket(_addr);
- setBufSize(instance.properties());
+ setBufSize();
Network.setBlock(_fd, false);
}
catch(Ice.LocalException ex)
@@ -403,17 +403,19 @@ final class UdpTransceiver implements Transceiver
}
}
- private synchronized void setBufSize(Ice.Properties properties)
+ private synchronized void setBufSize()
{
assert(_fd != null);
for(int i = 0; i < 2; ++i)
{
+ boolean isSnd;
String direction;
String prop;
int dfltSize;
if(i == 0)
{
+ isSnd = false;
direction = "receive";
prop = "Ice.UDP.RcvSize";
dfltSize = Network.getRecvBufferSize(_fd);
@@ -421,6 +423,7 @@ final class UdpTransceiver implements Transceiver
}
else
{
+ isSnd = true;
direction = "send";
prop = "Ice.UDP.SndSize";
dfltSize = Network.getSendBufferSize(_fd);
@@ -430,7 +433,7 @@ final class UdpTransceiver implements Transceiver
//
// Get property for buffer size and check for sanity.
//
- int sizeRequested = properties.getPropertyAsIntWithDefault(prop, dfltSize);
+ int sizeRequested = _instance.properties().getPropertyAsIntWithDefault(prop, dfltSize);
if(sizeRequested < (_udpOverhead + IceInternal.Protocol.headerSize))
{
_instance.logger().warning("Invalid " + prop + " value of " + sizeRequested + " adjusted to " +
@@ -460,12 +463,27 @@ final class UdpTransceiver implements Transceiver
}
//
- // Warn if the size that was set is less than the requested size.
+ // Warn if the size that was set is less than the requested size
+ // and we have not already warned
//
if(sizeSet < sizeRequested)
{
- _instance.logger().warning("UDP " + direction + " buffer size: requested size of "
- + sizeRequested + " adjusted to " + sizeSet);
+ BufSizeWarnInfo winfo = _instance.getBufSizeWarn(Ice.UDPEndpointType.value);
+ if((isSnd && (!winfo.sndWarn || winfo.sndSize != sizeRequested)) ||
+ (!isSnd && (!winfo.rcvWarn || winfo.rcvSize != sizeRequested)))
+ {
+ _instance.logger().warning("UDP " + direction + " buffer size: requested size of "
+ + sizeRequested + " adjusted to " + sizeSet);
+
+ if(isSnd)
+ {
+ _instance.setSndBufSizeWarn(Ice.UDPEndpointType.value, sizeRequested);
+ }
+ else
+ {
+ _instance.setRcvBufSizeWarn(Ice.UDPEndpointType.value, sizeRequested);
+ }
+ }
}
}
}
diff --git a/java/src/Ice/src/main/java/IceSSL/AcceptorI.java b/java/src/Ice/src/main/java/IceSSL/AcceptorI.java
index 55be3f583c6..ce158e9c872 100644
--- a/java/src/Ice/src/main/java/IceSSL/AcceptorI.java
+++ b/java/src/Ice/src/main/java/IceSSL/AcceptorI.java
@@ -115,7 +115,7 @@ final class AcceptorI implements IceInternal.Acceptor
{
_fd = IceInternal.Network.createTcpServerSocket();
IceInternal.Network.setBlock(_fd, false);
- IceInternal.Network.setTcpBufSize(_fd, _instance.properties(), _instance.logger());
+ IceInternal.Network.setTcpBufSize(_fd, _instance);
if(!System.getProperty("os.name").startsWith("Windows"))
{
//