diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/ConnectionI.java | 62 | ||||
-rw-r--r-- | java/src/Ice/ObjectAdapterI.java | 78 | ||||
-rw-r--r-- | java/src/Ice/ObjectPrx.java | 3 | ||||
-rw-r--r-- | java/src/Ice/ObjectPrxHelperBase.java | 22 | ||||
-rw-r--r-- | java/src/IceInternal/FixedReference.java | 12 | ||||
-rw-r--r-- | java/src/IceInternal/IncomingConnectionFactory.java | 44 | ||||
-rw-r--r-- | java/src/IceInternal/OutgoingConnectionFactory.java | 14 | ||||
-rw-r--r-- | java/src/IceInternal/PropertyNames.java | 4 | ||||
-rw-r--r-- | java/src/IceInternal/Reference.java | 2 | ||||
-rw-r--r-- | java/src/IceInternal/RoutableReference.java | 77 | ||||
-rw-r--r-- | java/src/IceInternal/ThreadPool.java | 10 |
11 files changed, 221 insertions, 107 deletions
diff --git a/java/src/Ice/ConnectionI.java b/java/src/Ice/ConnectionI.java index 0e167ea100f..88d49113a31 100644 --- a/java/src/Ice/ConnectionI.java +++ b/java/src/Ice/ConnectionI.java @@ -33,7 +33,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne synchronized(this) { - if(_instance.threadPerConnection() && _threadPerConnection != Thread.currentThread()) + if(_thread != null && _thread != Thread.currentThread()) { // // In thread per connection mode, this connection's thread @@ -319,16 +319,15 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne synchronized(this) { - if(_transceiver != null || _dispatchCount != 0 || - (_threadPerConnection != null && _threadPerConnection.isAlive())) + if(_transceiver != null || _dispatchCount != 0 || (_thread != null && _thread.isAlive())) { return false; } assert(_state == StateClosed); - threadPerConnection = _threadPerConnection; - _threadPerConnection = null; + threadPerConnection = _thread; + _thread = null; } if(threadPerConnection != null) @@ -450,8 +449,13 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne assert(_state == StateClosed); - threadPerConnection = _threadPerConnection; - _threadPerConnection = null; + threadPerConnection = _thread; + _thread = null; + + // + // Clear the OA. See bug 1673 for the details of why this is necessary. + // + _adapter = null; } if(threadPerConnection != null) @@ -1201,6 +1205,12 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne return _endpoint; } + public boolean + threadPerConnection() + { + return _threadPerConnection; // No mutex protection necessary, _threadPerConnection is immutable. + } + public synchronized void setAdapter(ObjectAdapter adapter) { @@ -1261,21 +1271,21 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne public boolean datagram() { - assert(!_instance.threadPerConnection()); // Only for use with a thread pool. + assert(!_threadPerConnection); // Only for use with a thread pool. return _endpoint.datagram(); // No mutex protection necessary, _endpoint is immutable. } public boolean readable() { - assert(!_instance.threadPerConnection()); // Only for use with a thread pool. + assert(!_threadPerConnection); // Only for use with a thread pool. return true; } public boolean read(IceInternal.BasicStream stream) { - assert(!_instance.threadPerConnection()); // Only for use with a thread pool. + assert(!_threadPerConnection); // Only for use with a thread pool. return _transceiver.read(stream, 0); @@ -1290,7 +1300,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne public void message(IceInternal.BasicStream stream, IceInternal.ThreadPool threadPool) { - assert(!_instance.threadPerConnection()); // Only for use with a thread pool. + assert(!_threadPerConnection); // Only for use with a thread pool. MessageInfo info = new MessageInfo(stream); @@ -1338,7 +1348,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne public void finished(IceInternal.ThreadPool threadPool) { - assert(!_instance.threadPerConnection()); // Only for use with a thread pool. + assert(!_threadPerConnection); // Only for use with a thread pool. threadPool.promoteFollower(); @@ -1475,9 +1485,10 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne } public ConnectionI(IceInternal.Instance instance, IceInternal.Transceiver transceiver, - IceInternal.EndpointI endpoint, ObjectAdapter adapter) + IceInternal.EndpointI endpoint, ObjectAdapter adapter, boolean threadPerConnection) { super(instance); + _threadPerConnection = threadPerConnection; _transceiver = transceiver; _desc = transceiver.toString(); _type = transceiver.type(); @@ -1541,7 +1552,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne try { - if(!_instance.threadPerConnection()) + if(!threadPerConnection) { // // Only set _threadPool if we really need it, i.e., if we are @@ -1566,13 +1577,13 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne // If we are in thread per connection mode, create the thread // for this connection. // - _threadPerConnection = new ThreadPerConnection(); - _threadPerConnection.start(); + _thread = new ThreadPerConnection(); + _thread.start(); } } catch(java.lang.Exception ex) { - if(_instance.threadPerConnection()) + if(threadPerConnection) { java.io.StringWriter sw = new java.io.StringWriter(); java.io.PrintWriter pw = new java.io.PrintWriter(sw); @@ -1606,7 +1617,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne IceUtil.Assert.FinalizerAssert(_state == StateClosed); IceUtil.Assert.FinalizerAssert(_transceiver == null); IceUtil.Assert.FinalizerAssert(_dispatchCount == 0); - IceUtil.Assert.FinalizerAssert(_threadPerConnection == null); + IceUtil.Assert.FinalizerAssert(_thread == null); super.finalize(); } @@ -1709,7 +1720,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne { return; } - if(!_instance.threadPerConnection()) + if(!_threadPerConnection) { registerWithPool(); } @@ -1726,7 +1737,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne { return; } - if(!_instance.threadPerConnection()) + if(!_threadPerConnection) { unregisterWithPool(); } @@ -1742,7 +1753,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne { return; } - if(!_instance.threadPerConnection()) + if(!_threadPerConnection) { registerWithPool(); // We need to continue to read in closing state. } @@ -1751,7 +1762,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne case StateClosed: { - if(_instance.threadPerConnection()) + if(_threadPerConnection) { // // If we are in thread per connection mode, we @@ -1898,7 +1909,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne private void registerWithPool() { - assert(!_instance.threadPerConnection()); // Only for use with a thread pool. + assert(!_threadPerConnection); // Only for use with a thread pool. if(!_registeredWithPool) { @@ -1910,7 +1921,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne private void unregisterWithPool() { - assert(!_instance.threadPerConnection()); // Only for use with a thread pool. + assert(!_threadPerConnection); // Only for use with a thread pool. if(_registeredWithPool) { @@ -2661,7 +2672,8 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne } } } - private Thread _threadPerConnection; + private Thread _thread; + private final boolean _threadPerConnection; private IceInternal.Transceiver _transceiver; private final String _desc; diff --git a/java/src/Ice/ObjectAdapterI.java b/java/src/Ice/ObjectAdapterI.java index dd6f27698e4..92ff5e0e308 100644 --- a/java/src/Ice/ObjectAdapterI.java +++ b/java/src/Ice/ObjectAdapterI.java @@ -714,6 +714,15 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt return _servantManager; } + public boolean + getThreadPerConnection() + { + // + // No mutex lock necessary, _threadPerConnection is immutable. + // + return _threadPerConnection; + } + // // Only for use by IceInternal.ObjectAdapterFactory // @@ -766,7 +775,7 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt _incomingConnectionFactories = null; InitializationException ex = new InitializationException(); - ex.reason = "Object adapter \"" + _name + "\" requires configuration."; + ex.reason = "object adapter \"" + _name + "\" requires configuration."; throw ex; } } @@ -788,6 +797,45 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt try { + _threadPerConnection = properties.getPropertyAsInt(_propertyPrefix + _name + ".ThreadPerConnection") > 0; + + int threadPoolSize = properties.getPropertyAsInt(_propertyPrefix + _name + ".ThreadPool.Size"); + if(threadPoolSize == 0) + { + threadPoolSize = properties.getPropertyAsInt(_name + ".ThreadPool.Size"); + } + int threadPoolSizeMax = properties.getPropertyAsInt(_propertyPrefix + _name + ".ThreadPool.SizeMax"); + if(threadPoolSizeMax == 0) + { + threadPoolSizeMax = properties.getPropertyAsInt(_name + ".ThreadPool.SizeMax"); + } + + if(_threadPerConnection && (threadPoolSize > 0 || threadPoolSizeMax > 0)) + { + InitializationException ex = new InitializationException(); + ex.reason = "object adapter \"" + _name + "\" cannot be configured for both\n" + + "thread pool and thread per connection"; + throw ex; + } + + if(!_threadPerConnection && threadPoolSize == 0 && threadPoolSizeMax == 0) + { + _threadPerConnection = _instance.threadPerConnection(); + } + + if(threadPoolSize > 0 || threadPoolSizeMax > 0) + { + if(properties.getProperty(_propertyPrefix + _name + ".ThreadPool.Size").length() != 0 || + properties.getProperty(_propertyPrefix + _name + ".ThreadPool.SizeMax").length() != 0) + { + _threadPool = new IceInternal.ThreadPool(_instance, _propertyPrefix + _name + ".ThreadPool", 0); + } + else + { + _threadPool = new IceInternal.ThreadPool(_instance, _name + ".ThreadPool", 0); + } + } + if(router == null) { router = RouterPrxHelper.uncheckedCast( @@ -876,8 +924,8 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt for(int i = 0; i < endpoints.size(); ++i) { IceInternal.EndpointI endp = (IceInternal.EndpointI)endpoints.get(i); - _incomingConnectionFactories.add(new IceInternal.IncomingConnectionFactory( - instance, endp, this, _name)); + _incomingConnectionFactories.add( + new IceInternal.IncomingConnectionFactory(instance, endp, this, _name)); } if(endpoints.size() == 0) { @@ -934,29 +982,6 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt { setLocator(_instance.referenceFactory().getDefaultLocator()); } - - if(!_instance.threadPerConnection()) - { - if(properties.getProperty(_propertyPrefix + _name + ".ThreadPool.Size").length() != 0 || - properties.getProperty(_propertyPrefix + _name + ".ThreadPool.SizeMax").length() != 0) - { - int size = properties.getPropertyAsInt(_propertyPrefix + _name + ".ThreadPool.Size"); - int sizeMax = properties.getPropertyAsInt(_propertyPrefix + _name + ".ThreadPool.SizeMax"); - if(size > 0 || sizeMax > 0) - { - _threadPool = new IceInternal.ThreadPool(_instance, _propertyPrefix + _name + ".ThreadPool", 0); - } - } - else - { - int size = properties.getPropertyAsInt(_name + ".ThreadPool.Size"); - int sizeMax = properties.getPropertyAsInt(_name + ".ThreadPool.SizeMax"); - if(size > 0 || sizeMax > 0) - { - _threadPool = new IceInternal.ThreadPool(_instance, _name + ".ThreadPool", 0); - } - } - } } catch(LocalException ex) { @@ -1315,5 +1340,6 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt private boolean _destroying; private boolean _destroyed; private boolean _noConfig; + private boolean _threadPerConnection; static private String _propertyPrefix = "Ice.OA."; } diff --git a/java/src/Ice/ObjectPrx.java b/java/src/Ice/ObjectPrx.java index 19cea314e1e..7771f385503 100644 --- a/java/src/Ice/ObjectPrx.java +++ b/java/src/Ice/ObjectPrx.java @@ -125,6 +125,9 @@ public interface ObjectPrx ObjectPrx ice_timeout(int t); ObjectPrx ice_connectionId(String connectionId); + boolean ice_isThreadPerConnection(); + ObjectPrx ice_threadPerConnection(boolean tpc); + /** * @deprecated This method has been replaced with ice_getConnection. **/ diff --git a/java/src/Ice/ObjectPrxHelperBase.java b/java/src/Ice/ObjectPrxHelperBase.java index 151e80885d6..313dbb3bc71 100644 --- a/java/src/Ice/ObjectPrxHelperBase.java +++ b/java/src/Ice/ObjectPrxHelperBase.java @@ -784,6 +784,28 @@ public class ObjectPrxHelperBase implements ObjectPrx } } + public boolean + ice_isThreadPerConnection() + { + return _reference.getThreadPerConnection(); + } + + public ObjectPrx + ice_threadPerConnection(boolean tpc) + { + IceInternal.Reference ref = _reference.changeThreadPerConnection(tpc); + if(ref.equals(_reference)) + { + return this; + } + else + { + ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); + proxy.setup(ref); + return proxy; + } + } + /** * @deprecated This method has been replaced with ice_collocationOptimized. **/ diff --git a/java/src/IceInternal/FixedReference.java b/java/src/IceInternal/FixedReference.java index 8c986875375..fca9ee84b3b 100644 --- a/java/src/IceInternal/FixedReference.java +++ b/java/src/IceInternal/FixedReference.java @@ -78,6 +78,12 @@ public class FixedReference extends Reference return Ice.EndpointSelectionType.Random; } + public boolean + getThreadPerConnection() + { + return false; + } + public Reference changeSecure(boolean sec) { @@ -138,6 +144,12 @@ public class FixedReference extends Reference throw new Ice.FixedProxyException(); } + public final Reference + changeThreadPerConnection(boolean newTpc) + { + throw new Ice.FixedProxyException(); + } + public Reference changeCompress(boolean newCompress) { diff --git a/java/src/IceInternal/IncomingConnectionFactory.java b/java/src/IceInternal/IncomingConnectionFactory.java index 6599bf15872..4c57ff4c51a 100644 --- a/java/src/IceInternal/IncomingConnectionFactory.java +++ b/java/src/IceInternal/IncomingConnectionFactory.java @@ -95,6 +95,11 @@ public final class IncomingConnectionFactory extends EventHandler threadPerIncomingConnectionFactory = _threadPerIncomingConnectionFactory; _threadPerIncomingConnectionFactory = null; + // + // Clear the OA. See bug 1673 for the details of why this is necessary. + // + _adapter = null; + // // We want to wait until all connections are finished outside the // thread synchronization. @@ -199,21 +204,21 @@ public final class IncomingConnectionFactory extends EventHandler public boolean datagram() { - assert(!_instance.threadPerConnection()); // Only for use with a thread pool. + assert(!_threadPerConnection); // Only for use with a thread pool. return _endpoint.datagram(); } public boolean readable() { - assert(!_instance.threadPerConnection()); // Only for use with a thread pool. + assert(!_threadPerConnection); // Only for use with a thread pool. return false; } public boolean read(BasicStream unused) { - assert(!_instance.threadPerConnection()); // Only for use with a thread pool. + assert(!_threadPerConnection); // Only for use with a thread pool. assert(false); // Must not be called. return false; } @@ -221,7 +226,7 @@ public final class IncomingConnectionFactory extends EventHandler public void message(BasicStream unused, ThreadPool threadPool) { - assert(!_instance.threadPerConnection()); // Only for use with a thread pool. + assert(!_threadPerConnection); // Only for use with a thread pool. Ice.ConnectionI connection = null; @@ -275,7 +280,7 @@ public final class IncomingConnectionFactory extends EventHandler try { - connection = new Ice.ConnectionI(_instance, transceiver, _endpoint, _adapter); + connection = new Ice.ConnectionI(_instance, transceiver, _endpoint, _adapter, _threadPerConnection); } catch(Ice.LocalException ex) { @@ -321,11 +326,13 @@ public final class IncomingConnectionFactory extends EventHandler public synchronized void finished(ThreadPool threadPool) { - assert(!_instance.threadPerConnection()); // Only for use with a thread pool. + assert(!_threadPerConnection); // Only for use with a thread pool. threadPool.promoteFollower(); + assert(threadPool == ((Ice.ObjectAdapterI)_adapter).getThreadPool()); --_finishedCount; + if(_finishedCount == 0 && _state == StateClosed) { _acceptor.close(); @@ -375,6 +382,9 @@ public final class IncomingConnectionFactory extends EventHandler _endpoint = _endpoint.compress(defaultsAndOverrides.overrideCompressValue); } + Ice.ObjectAdapterI adapterImpl = (Ice.ObjectAdapterI)_adapter; + _threadPerConnection = adapterImpl.getThreadPerConnection(); + EndpointIHolder h = new EndpointIHolder(); h.value = _endpoint; _transceiver = _endpoint.serverTransceiver(h); @@ -389,7 +399,8 @@ public final class IncomingConnectionFactory extends EventHandler try { - connection = new Ice.ConnectionI(_instance, _transceiver, _endpoint, _adapter); + connection = new Ice.ConnectionI(_instance, _transceiver, _endpoint, _adapter, + _threadPerConnection); connection.validate(); } catch(Ice.LocalException ex) @@ -416,7 +427,7 @@ public final class IncomingConnectionFactory extends EventHandler assert(_acceptor != null); _acceptor.listen(); - if(_instance.threadPerConnection()) + if(_threadPerConnection) { // // If we are in thread per connection mode, we also use @@ -500,7 +511,7 @@ public final class IncomingConnectionFactory extends EventHandler { return; } - if(!_instance.threadPerConnection() && _acceptor != null) + if(!_threadPerConnection && _acceptor != null) { registerWithPool(); } @@ -520,7 +531,7 @@ public final class IncomingConnectionFactory extends EventHandler { return; } - if(!_instance.threadPerConnection() && _acceptor != null) + if(!_threadPerConnection && _acceptor != null) { unregisterWithPool(); } @@ -538,7 +549,7 @@ public final class IncomingConnectionFactory extends EventHandler { if(_acceptor != null) { - if(_instance.threadPerConnection()) + if(_threadPerConnection) { // // If we are in thread per connection mode, we connect @@ -576,7 +587,7 @@ public final class IncomingConnectionFactory extends EventHandler private void registerWithPool() { - assert(!_instance.threadPerConnection()); // Only for use with a thread pool. + assert(!_threadPerConnection); // Only for use with a thread pool. assert(_acceptor != null); if(!_registeredWithPool) @@ -589,7 +600,7 @@ public final class IncomingConnectionFactory extends EventHandler private void unregisterWithPool() { - assert(!_instance.threadPerConnection()); // Only for use with a thread pool. + assert(!_threadPerConnection); // Only for use with a thread pool. assert(_acceptor != null); if(_registeredWithPool) @@ -723,7 +734,8 @@ public final class IncomingConnectionFactory extends EventHandler { try { - connection = new Ice.ConnectionI(_instance, transceiver, _endpoint, _adapter); + connection = new Ice.ConnectionI(_instance, transceiver, _endpoint, _adapter, + _threadPerConnection); } catch(Ice.LocalException ex) { @@ -769,7 +781,7 @@ public final class IncomingConnectionFactory extends EventHandler private final Transceiver _transceiver; private EndpointI _endpoint; - private final Ice.ObjectAdapter _adapter; + private Ice.ObjectAdapter _adapter; private boolean _registeredWithPool; private int _finishedCount; @@ -779,4 +791,6 @@ public final class IncomingConnectionFactory extends EventHandler private java.util.LinkedList _connections = new java.util.LinkedList(); private int _state; + + private boolean _threadPerConnection; } diff --git a/java/src/IceInternal/OutgoingConnectionFactory.java b/java/src/IceInternal/OutgoingConnectionFactory.java index ea7fd51ae42..9d9a54fb606 100644 --- a/java/src/IceInternal/OutgoingConnectionFactory.java +++ b/java/src/IceInternal/OutgoingConnectionFactory.java @@ -91,7 +91,7 @@ public final class OutgoingConnectionFactory } public Ice.ConnectionI - create(EndpointI[] endpts, boolean hasMore, Ice.BooleanHolder compress) + create(EndpointI[] endpts, boolean hasMore, boolean threadPerConnection, Ice.BooleanHolder compress) { assert(endpts.length > 0); EndpointI[] endpoints = new EndpointI[endpts.length]; @@ -168,9 +168,10 @@ public final class OutgoingConnectionFactory // // Don't return connections for which destruction has - // been initiated. + // been initiated. The connection must also match the + // requested thread-per-connection setting. // - if(!connection.isDestroyed()) + if(!connection.isDestroyed() && connection.threadPerConnection() == threadPerConnection) { if(defaultsAndOverrides.overrideCompress) { @@ -245,9 +246,10 @@ public final class OutgoingConnectionFactory // // Don't return connections for which destruction has - // been initiated. + // been initiated. The connection must also match the + // requested thread-per-connection setting. // - if(!connection.isDestroyed()) + if(!connection.isDestroyed() && connection.threadPerConnection() == threadPerConnection) { if(defaultsAndOverrides.overrideCompress) { @@ -308,7 +310,7 @@ public final class OutgoingConnectionFactory transceiver = connector.connect(timeout); assert(transceiver != null); } - connection = new Ice.ConnectionI(_instance, transceiver, endpoint, null); + connection = new Ice.ConnectionI(_instance, transceiver, endpoint, null, threadPerConnection); connection.validate(); if(defaultsAndOverrides.overrideCompress) diff --git a/java/src/IceInternal/PropertyNames.java b/java/src/IceInternal/PropertyNames.java index 0b766d00024..5e9653cef50 100644 --- a/java/src/IceInternal/PropertyNames.java +++ b/java/src/IceInternal/PropertyNames.java @@ -7,7 +7,7 @@ // // ********************************************************************** -// Generated by makeprops.py from file `/Users/matthew/cvs/ice/config/PropertyNames.def', Thu Jan 25 15:15:44 2007 +// Generated by makeprops.py from file `../config/PropertyNames.def', Thu Jan 25 08:38:23 2007 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -61,6 +61,8 @@ public final class PropertyNames "^Ice\\.OA\\.[^\\s]+\\.RegisterProcess$", "^Ice\\.OA\\.[^\\s]+\\.ReplicaGroupId$", "^Ice\\.OA\\.[^\\s]+\\.Router$", + "^Ice\\.OA\\.[^\\s]+\\.ThreadPerConnection$", + "^Ice\\.OA\\.[^\\s]+\\.ThreadPerConnection\\.StackSize$", "^Ice\\.OA\\.[^\\s]+\\.ThreadPool\\.Size$", "^Ice\\.OA\\.[^\\s]+\\.ThreadPool\\.SizeMax$", "^Ice\\.OA\\.[^\\s]+\\.ThreadPool\\.SizeWarn$", diff --git a/java/src/IceInternal/Reference.java b/java/src/IceInternal/Reference.java index 125317f0a07..e586a8715fb 100644 --- a/java/src/IceInternal/Reference.java +++ b/java/src/IceInternal/Reference.java @@ -82,6 +82,7 @@ public abstract class Reference implements Cloneable public abstract int getLocatorCacheTimeout(); public abstract boolean getCacheConnection(); public abstract Ice.EndpointSelectionType getEndpointSelection(); + public abstract boolean getThreadPerConnection(); // // The change* methods (here and in derived classes) create @@ -156,6 +157,7 @@ public abstract class Reference implements Cloneable public abstract Reference changeLocatorCacheTimeout(int newTimeout); public abstract Reference changeCacheConnection(boolean newCache); public abstract Reference changeEndpointSelection(Ice.EndpointSelectionType newType); + public abstract Reference changeThreadPerConnection(boolean newTpc); public synchronized int hashCode() diff --git a/java/src/IceInternal/RoutableReference.java b/java/src/IceInternal/RoutableReference.java index d1047c7e90a..fe7f8bd208a 100644 --- a/java/src/IceInternal/RoutableReference.java +++ b/java/src/IceInternal/RoutableReference.java @@ -61,6 +61,12 @@ public abstract class RoutableReference extends Reference return _endpointSelection; } + public final boolean + getThreadPerConnection() + { + return _threadPerConnection; + } + public Reference changeSecure(boolean newSecure) { @@ -110,30 +116,6 @@ public abstract class RoutableReference extends Reference return r; } - public final Reference - changeCacheConnection(boolean newCache) - { - if(newCache == _cacheConnection) - { - return this; - } - RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this); - r._cacheConnection = newCache; - return r; - } - - public final Reference - changeEndpointSelection(Ice.EndpointSelectionType newType) - { - if(newType == _endpointSelection) - { - return this; - } - RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this); - r._endpointSelection = newType; - return r; - } - public Reference changeCompress(boolean newCompress) { @@ -172,6 +154,42 @@ public abstract class RoutableReference extends Reference return r; } + public final Reference + changeCacheConnection(boolean newCache) + { + if(newCache == _cacheConnection) + { + return this; + } + RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this); + r._cacheConnection = newCache; + return r; + } + + public final Reference + changeEndpointSelection(Ice.EndpointSelectionType newType) + { + if(newType == _endpointSelection) + { + return this; + } + RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this); + r._endpointSelection = newType; + return r; + } + + public Reference + changeThreadPerConnection(boolean newTpc) + { + if(newTpc == _threadPerConnection) + { + return this; + } + RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this); + r._threadPerConnection = newTpc; + return r; + } + public synchronized int hashCode() { @@ -230,6 +248,10 @@ public abstract class RoutableReference extends Reference { return false; } + if(_threadPerConnection != rhs._threadPerConnection) + { + return false; + } return _routerInfo == null ? rhs._routerInfo == null : _routerInfo.equals(rhs._routerInfo); } @@ -256,6 +278,7 @@ public abstract class RoutableReference extends Reference _compress = false; _overrideTimeout = false; _timeout = -1; + _threadPerConnection = inst.threadPerConnection(); } protected void @@ -404,7 +427,8 @@ public abstract class RoutableReference extends Reference // Get an existing connection or create one if there's no // existing connection to one of the given endpoints. // - return factory.create((EndpointI[])endpoints.toArray(new EndpointI[endpoints.size()]), false, compress); + return factory.create((EndpointI[])endpoints.toArray( + new EndpointI[endpoints.size()]), false, _threadPerConnection, compress); } else { @@ -425,7 +449,7 @@ public abstract class RoutableReference extends Reference try { endpoint[0] = (EndpointI)i.next(); - return factory.create(endpoint, i.hasNext(), compress); + return factory.create(endpoint, i.hasNext(), _threadPerConnection, compress); } catch(Ice.LocalException ex) { @@ -497,4 +521,5 @@ public abstract class RoutableReference extends Reference private boolean _compress; // Only used if _overrideCompress == true private boolean _overrideTimeout; private int _timeout; // Only used if _overrideTimeout == true + private boolean _threadPerConnection; } diff --git a/java/src/IceInternal/ThreadPool.java b/java/src/IceInternal/ThreadPool.java index 1edbd267dc0..948c56d4418 100644 --- a/java/src/IceInternal/ThreadPool.java +++ b/java/src/IceInternal/ThreadPool.java @@ -33,12 +33,6 @@ public final class ThreadPool _promote = true; _warnUdp = _instance.initializationData().properties.getPropertyAsInt("Ice.Warn.Datagrams") > 0; - // - // If we are in thread per connection mode, no thread pool should - // ever be created. - // - assert(!_instance.threadPerConnection()); - String programName = _instance.initializationData().properties.getProperty("Ice.ProgramName"); if(programName.length() > 0) { @@ -74,7 +68,7 @@ public final class ThreadPool // // We use just one thread as the default. This is the fastest - // psossible setting, still allows one level of nesting, and + // possible setting, still allows one level of nesting, and // doesn't require to make the servants thread safe. // int size = _instance.initializationData().properties.getPropertyAsIntWithDefault(_prefix + ".Size", 1); @@ -617,7 +611,7 @@ public final class ThreadPool // java.nio.channels.SelectionKey k = (java.nio.channels.SelectionKey)iter.next(); iter.remove(); - if(k.isValid() && key != _fdIntrReadKey) + if(k.isValid() && k != _fdIntrReadKey) { if(TRACE_SELECT) { |