diff options
author | Benoit Foucher <benoit@zeroc.com> | 2009-10-16 11:31:59 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2009-10-16 11:31:59 +0200 |
commit | ba0d6f63970277f5ccc3bf6447a5c451d007b36e (patch) | |
tree | 88a7217bec554a95a4ca256bb53d3fa6c08f5db1 /java/src | |
parent | Fixed py and rb to compile again with Enpoint changes (diff) | |
download | ice-ba0d6f63970277f5ccc3bf6447a5c451d007b36e.tar.bz2 ice-ba0d6f63970277f5ccc3bf6447a5c451d007b36e.tar.xz ice-ba0d6f63970277f5ccc3bf6447a5c451d007b36e.zip |
Added support for per-OA ACM and fix for retry on CloseConnectionException
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/ConnectionI.java | 39 | ||||
-rw-r--r-- | java/src/Ice/ObjectAdapterI.java | 29 | ||||
-rw-r--r-- | java/src/IceInternal/ConnectionMonitor.java | 52 | ||||
-rw-r--r-- | java/src/IceInternal/Instance.java | 41 | ||||
-rw-r--r-- | java/src/IceInternal/PropertyNames.java | 13 | ||||
-rw-r--r-- | java/src/IceInternal/ProxyFactory.java | 17 |
6 files changed, 131 insertions, 60 deletions
diff --git a/java/src/Ice/ConnectionI.java b/java/src/Ice/ConnectionI.java index c91ff3a44e0..f03033b8cb9 100644 --- a/java/src/Ice/ConnectionI.java +++ b/java/src/Ice/ConnectionI.java @@ -1292,22 +1292,6 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne _state = StateNotInitialized; _stateTime = IceInternal.Time.currentMonotonicTimeMillis(); - if(_endpoint.datagram()) - { - _acmTimeout = 0; - } - else - { - if(_adapter != null) - { - _acmTimeout = _instance.serverACM(); - } - else - { - _acmTimeout = _instance.clientACM(); - } - } - int compressionLevel = initData.properties.getPropertyAsIntWithDefault("Ice.Compression.Level", 1); if(compressionLevel < 1) { @@ -1330,6 +1314,22 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne try { + if(_endpoint.datagram()) + { + _acmTimeout = 0; + } + else + { + if(_adapter != null) + { + _acmTimeout = ((ObjectAdapterI)_adapter).getACM(); + } + else + { + _acmTimeout = _instance.clientACM(); + } + } + if(_adapter != null) { _threadPool = ((ObjectAdapterI)_adapter).getThreadPool(); @@ -1550,16 +1550,15 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne // monitor, but only if we were registered before, i.e., if our // old state was StateActive. // - IceInternal.ConnectionMonitor connectionMonitor = _instance.connectionMonitor(); - if(connectionMonitor != null) + if(_acmTimeout > 0) { if(state == StateActive) { - connectionMonitor.add(this); + _instance.connectionMonitor().add(this); } else if(_state == StateActive) { - connectionMonitor.remove(this); + _instance.connectionMonitor().remove(this); } } diff --git a/java/src/Ice/ObjectAdapterI.java b/java/src/Ice/ObjectAdapterI.java index 0737878ca27..67229763453 100644 --- a/java/src/Ice/ObjectAdapterI.java +++ b/java/src/Ice/ObjectAdapterI.java @@ -798,6 +798,23 @@ public final class ObjectAdapterI implements ObjectAdapter return _servantManager; } + public int + getACM() + { + // Not check for deactivation here! + + assert(_instance != null); // Must not be called after destroy(). + + if(_hasAcmTimeout) + { + return _acmTimeout; + } + else + { + return _instance.serverACM(); + } + } + // // Only for use by IceInternal.ObjectAdapterFactory // @@ -810,6 +827,8 @@ public final class ObjectAdapterI implements ObjectAdapter _instance = instance; _communicator = communicator; _objectAdapterFactory = objectAdapterFactory; + _hasAcmTimeout = false; + _acmTimeout = 0; _servantManager = new IceInternal.ServantManager(instance, name); _activateOneOffDone = false; _name = name; @@ -899,6 +918,13 @@ public final class ObjectAdapterI implements ObjectAdapter _threadPool = new IceInternal.ThreadPool(_instance, _name + ".ThreadPool", 0); } + _hasAcmTimeout = properties.getProperty(_name + ".ACM").length() > 0; + if(_hasAcmTimeout) + { + _acmTimeout = properties.getPropertyAsInt(_name + ".ACM"); + _instance.connectionMonitor().checkIntervalForACM(_acmTimeout); + } + if(router == null) { router = RouterPrxHelper.uncheckedCast(_instance.proxyFactory().propertyToProxy(name + ".Router")); @@ -1436,6 +1462,7 @@ public final class ObjectAdapterI implements ObjectAdapter static private String[] _suffixes = { + "ACM", "AdapterId", "Endpoints", "Locator", @@ -1508,6 +1535,8 @@ public final class ObjectAdapterI implements ObjectAdapter private Communicator _communicator; private IceInternal.ObjectAdapterFactory _objectAdapterFactory; private IceInternal.ThreadPool _threadPool; + private boolean _hasAcmTimeout; + private int _acmTimeout; private IceInternal.ServantManager _servantManager; private boolean _activateOneOffDone; final private String _name; diff --git a/java/src/IceInternal/ConnectionMonitor.java b/java/src/IceInternal/ConnectionMonitor.java index 927a5ce768f..40d38b4575e 100644 --- a/java/src/IceInternal/ConnectionMonitor.java +++ b/java/src/IceInternal/ConnectionMonitor.java @@ -22,6 +22,51 @@ public final class ConnectionMonitor implements IceInternal.TimerTask _instance = null; _connections = null; } + + public void + checkIntervalForACM(int acmTimeout) + { + if(acmTimeout <= 0) + { + return; + } + + // + // If Ice.MonitorConnections isn't set (_interval == 0), the given ACM is used + // to determine the check interval: 1/10 of the ACM timeout with a minmal value + // of 5 seconds and a maximum value of 5 minutes. + // + // Note: if Ice.MonitorConnections is set, the timer is schedulded only if ACM + // is configured for the communicator or some object adapters. + // + int interval; + if(_interval == 0) + { + interval = java.lang.Math.min(300, java.lang.Math.max(5, (int)acmTimeout / 10)); + } + else if(_scheduledInterval == _interval) + { + return; // Nothing to do, the timer is already scheduled. + } + else + { + interval = _interval; + } + + // + // If no timer is scheduled yet or if the given ACM requires a smaller interval, + // we re-schedule the timer. + // + synchronized(this) + { + if(_scheduledInterval == 0 || _scheduledInterval > interval) + { + _scheduledInterval = interval; + _instance.timer().cancel(this); + _instance.timer().scheduleRepeated(this, interval * 1000); + } + } + } public synchronized void add(Ice.ConnectionI connection) @@ -42,10 +87,9 @@ public final class ConnectionMonitor implements IceInternal.TimerTask // ConnectionMonitor(Instance instance, int interval) { - assert(interval > 0); _instance = instance; - - _instance.timer().scheduleRepeated(this, interval * 1000); + _interval = interval; + _scheduledInterval = 0; } protected synchronized void @@ -102,5 +146,7 @@ public final class ConnectionMonitor implements IceInternal.TimerTask } private Instance _instance; + private final int _interval; + private int _scheduledInterval; private java.util.Set<Ice.ConnectionI> _connections = new java.util.HashSet<Ice.ConnectionI>(); } diff --git a/java/src/IceInternal/Instance.java b/java/src/IceInternal/Instance.java index dc21c30cf2e..151ea12a466 100644 --- a/java/src/IceInternal/Instance.java +++ b/java/src/IceInternal/Instance.java @@ -107,7 +107,7 @@ public final class Instance throw new Ice.CommunicatorDestroyedException(); } - //assert(_connectionMonitor != null); // Optional + assert(_connectionMonitor != null); return _connectionMonitor; } @@ -824,39 +824,14 @@ public final class Instance } // - // Start connection monitor if necessary. Set the check interval to - // 1/10 of the ACM timeout with a minmal value of 1 second and a - // maximum value of 5 minutes. + // Create the connection monitor and ensure the interval for + // monitoring connections is appropriate for client & server + // ACM. // - int interval = 0; - if(_clientACM > 0 && _serverACM > 0) - { - if(_clientACM < _serverACM) - { - interval = _clientACM; - } - else - { - interval = _serverACM; - } - } - else if(_clientACM > 0) - { - interval = _clientACM; - } - else if(_serverACM > 0) - { - interval = _serverACM; - } - if(interval > 0) - { - interval = java.lang.Math.min(300, java.lang.Math.max(5, (int)interval / 10)); - } - interval = _initData.properties.getPropertyAsIntWithDefault("Ice.MonitorConnections", interval); - if(interval > 0) - { - _connectionMonitor = new ConnectionMonitor(this, interval); - } + int interval = _initData.properties.getPropertyAsInt("Ice.MonitorConnections"); + _connectionMonitor = new ConnectionMonitor(this, interval); + _connectionMonitor.checkIntervalForACM(_clientACM); + _connectionMonitor.checkIntervalForACM(_serverACM); // // Server thread pool initialization is lazy in serverThreadPool(). diff --git a/java/src/IceInternal/PropertyNames.java b/java/src/IceInternal/PropertyNames.java index 04cff7858a7..682d7a360d9 100644 --- a/java/src/IceInternal/PropertyNames.java +++ b/java/src/IceInternal/PropertyNames.java @@ -8,7 +8,7 @@ // ********************************************************************** // -// Generated by makeprops.py from file ../config/PropertyNames.xml, Wed Oct 14 16:41:32 2009 +// Generated by makeprops.py from file ../config/PropertyNames.xml, Fri Oct 16 11:27:10 2009 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -20,6 +20,7 @@ public final class PropertyNames { new Property("Ice\\.ACM\\.Client", false, null), new Property("Ice\\.ACM\\.Server", false, null), + new Property("Ice\\.Admin\\.ACM", false, null), new Property("Ice\\.Admin\\.AdapterId", false, null), new Property("Ice\\.Admin\\.Endpoints", false, null), new Property("Ice\\.Admin\\.Locator", false, null), @@ -146,6 +147,7 @@ public final class PropertyNames new Property("IceBox\\.LoadOrder", false, null), new Property("IceBox\\.PrintServicesReady", false, null), new Property("IceBox\\.Service\\.[^\\s]+", false, null), + new Property("IceBox\\.ServiceManager\\.ACM", false, null), new Property("IceBox\\.ServiceManager\\.AdapterId", false, null), new Property("IceBox\\.ServiceManager\\.Endpoints", false, null), new Property("IceBox\\.ServiceManager\\.Locator", false, null), @@ -194,6 +196,7 @@ public final class PropertyNames public static final Property IceGridProps[] = { new Property("IceGrid\\.InstanceName", false, null), + new Property("IceGrid\\.Node\\.ACM", false, null), new Property("IceGrid\\.Node\\.AdapterId", false, null), new Property("IceGrid\\.Node\\.Endpoints", false, null), new Property("IceGrid\\.Node\\.Locator", false, null), @@ -246,6 +249,7 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.AdminPermissionsVerifier\\.CollocationOptimized", false, null), new Property("IceGrid\\.Registry\\.AdminPermissionsVerifier", false, null), new Property("IceGrid\\.Registry\\.AdminSessionFilters", false, null), + new Property("IceGrid\\.Registry\\.AdminSessionManager\\.ACM", false, null), new Property("IceGrid\\.Registry\\.AdminSessionManager\\.AdapterId", false, null), new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Endpoints", false, null), new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Locator", false, null), @@ -270,6 +274,7 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.AdminSSLPermissionsVerifier\\.CollocationOptimization", true, "IceGrid.Registry.AdminSSLPermissionsVerifier.CollocationOptimized"), new Property("IceGrid\\.Registry\\.AdminSSLPermissionsVerifier\\.CollocationOptimized", false, null), new Property("IceGrid\\.Registry\\.AdminSSLPermissionsVerifier", false, null), + new Property("IceGrid\\.Registry\\.Client\\.ACM", false, null), new Property("IceGrid\\.Registry\\.Client\\.AdapterId", false, null), new Property("IceGrid\\.Registry\\.Client\\.Endpoints", false, null), new Property("IceGrid\\.Registry\\.Client\\.Locator", false, null), @@ -289,6 +294,7 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.Data", false, null), new Property("IceGrid\\.Registry\\.DefaultTemplates", false, null), new Property("IceGrid\\.Registry\\.DynamicRegistration", false, null), + new Property("IceGrid\\.Registry\\.Internal\\.ACM", false, null), new Property("IceGrid\\.Registry\\.Internal\\.AdapterId", false, null), new Property("IceGrid\\.Registry\\.Internal\\.Endpoints", false, null), new Property("IceGrid\\.Registry\\.Internal\\.Locator", false, null), @@ -316,6 +322,7 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.PermissionsVerifier", false, null), new Property("IceGrid\\.Registry\\.ReplicaName", false, null), new Property("IceGrid\\.Registry\\.ReplicaSessionTimeout", false, null), + new Property("IceGrid\\.Registry\\.Server\\.ACM", false, null), new Property("IceGrid\\.Registry\\.Server\\.AdapterId", false, null), new Property("IceGrid\\.Registry\\.Server\\.Endpoints", false, null), new Property("IceGrid\\.Registry\\.Server\\.Locator", false, null), @@ -332,6 +339,7 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.Server\\.ThreadPool\\.ThreadIdleTime", false, null), new Property("IceGrid\\.Registry\\.Server\\.ThreadPool\\.ThreadPriority", false, null), new Property("IceGrid\\.Registry\\.SessionFilters", false, null), + new Property("IceGrid\\.Registry\\.SessionManager\\.ACM", false, null), new Property("IceGrid\\.Registry\\.SessionManager\\.AdapterId", false, null), new Property("IceGrid\\.Registry\\.SessionManager\\.Endpoints", false, null), new Property("IceGrid\\.Registry\\.SessionManager\\.Locator", false, null), @@ -381,6 +389,7 @@ public final class PropertyNames public static final Property IcePatch2Props[] = { + new Property("IcePatch2\\.ACM", false, null), new Property("IcePatch2\\.AdapterId", false, null), new Property("IcePatch2\\.Endpoints", false, null), new Property("IcePatch2\\.Locator", false, null), @@ -473,6 +482,7 @@ public final class PropertyNames new Property("Glacier2\\.Admin\\.ThreadPool\\.SizeMax", true, null), new Property("Glacier2\\.Admin\\.ThreadPool\\.SizeWarn", true, null), new Property("Glacier2\\.Admin\\.ThreadPool\\.StackSize", true, null), + new Property("Glacier2\\.Client\\.ACM", false, null), new Property("Glacier2\\.Client\\.AdapterId", false, null), new Property("Glacier2\\.Client\\.Endpoints", false, null), new Property("Glacier2\\.Client\\.Locator", false, null), @@ -524,6 +534,7 @@ public final class PropertyNames new Property("Glacier2\\.SSLPermissionsVerifier\\.CollocationOptimized", false, null), new Property("Glacier2\\.SSLPermissionsVerifier", false, null), new Property("Glacier2\\.RoutingTable\\.MaxSize", false, null), + new Property("Glacier2\\.Server\\.ACM", false, null), new Property("Glacier2\\.Server\\.AdapterId", false, null), new Property("Glacier2\\.Server\\.Endpoints", false, null), new Property("Glacier2\\.Server\\.Locator", false, null), diff --git a/java/src/IceInternal/ProxyFactory.java b/java/src/IceInternal/ProxyFactory.java index b70d70f9511..2bd0d12c98b 100644 --- a/java/src/IceInternal/ProxyFactory.java +++ b/java/src/IceInternal/ProxyFactory.java @@ -189,7 +189,16 @@ public final class ProxyFactory ++cnt; assert(cnt > 0); - if(cnt > _retryIntervals.length) + int interval; + if(cnt == (_retryIntervals.length + 1) && ex instanceof Ice.CloseConnectionException) + { + // + // A close connection exception is always retried at least once, even if the retry + // limit is reached. + // + interval = 0; + } + else if(cnt > _retryIntervals.length) { if(traceLevels.retry >= 1) { @@ -198,8 +207,10 @@ public final class ProxyFactory } throw ex; } - - int interval = _retryIntervals[cnt - 1]; + else + { + interval = _retryIntervals[cnt - 1]; + } if(traceLevels.retry >= 1) { |