diff options
author | Benoit Foucher <benoit@zeroc.com> | 2008-01-15 10:15:19 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2008-01-15 10:15:19 +0100 |
commit | f00672fd53741dc528b81ed7f53dcca8276c2014 (patch) | |
tree | 3625b90e69b8b3ffefc35567c1eeafb2ef07c276 | |
parent | More documentation changes wrt mcpp usage. (diff) | |
download | ice-f00672fd53741dc528b81ed7f53dcca8276c2014.tar.bz2 ice-f00672fd53741dc528b81ed7f53dcca8276c2014.tar.xz ice-f00672fd53741dc528b81ed7f53dcca8276c2014.zip |
Fixed bug 1359
-rw-r--r-- | cpp/CHANGES | 4 | ||||
-rw-r--r-- | cpp/src/Ice/Reference.cpp | 106 | ||||
-rw-r--r-- | cpp/src/Ice/Reference.h | 9 | ||||
-rw-r--r-- | cs/src/Ice/Reference.cs | 76 | ||||
-rw-r--r-- | java/src/IceInternal/FixedReference.java | 23 | ||||
-rw-r--r-- | java/src/IceInternal/Reference.java | 27 | ||||
-rw-r--r-- | java/src/IceInternal/RoutableReference.java | 24 |
7 files changed, 142 insertions, 127 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES index c1bc255f8e1..5018f3faec9 100644 --- a/cpp/CHANGES +++ b/cpp/CHANGES @@ -1,6 +1,10 @@ Changes since version 3.2.X (binary incompatible) ------------------------------------------------- +- It's now possible to change the compression setting for a fixed + proxy. In previous releases, calling ice_compress on a fixed proxy + would raise Ice::FixedProxyException. + - Fixed IceGrid round-robin load balancing policy to better deal with unreachable servers. It no longer successively returns multiple times the same servers. diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp index a65e6883729..d412d2e9b51 100644 --- a/cpp/src/Ice/Reference.cpp +++ b/cpp/src/Ice/Reference.cpp @@ -104,6 +104,19 @@ IceInternal::Reference::changeFacet(const string& newFacet) const return r; } +ReferencePtr +IceInternal::Reference::changeCompress(bool newCompress) const +{ + if(_overrideCompress && newCompress == _compress) + { + return ReferencePtr(const_cast<Reference*>(this)); + } + ReferencePtr r = _instance->referenceFactory()->copy(this); + r->_compress = newCompress; + r->_overrideCompress = true; + return r; +} + Int Reference::hash() const { @@ -311,6 +324,11 @@ IceInternal::Reference::operator==(const Reference& r) const return false; } + if(_overrideCompress != r._overrideCompress || _overrideCompress && _compress != r._compress) + { + return false; + } + return true; } @@ -363,6 +381,26 @@ IceInternal::Reference::operator<(const Reference& r) const return false; } + if(!_overrideCompress && r._overrideCompress) + { + return true; + } + else if(r._overrideCompress < _overrideCompress) + { + return false; + } + else if(_overrideCompress) + { + if(!_compress && r._compress) + { + return true; + } + else if(r._compress < _compress) + { + return false; + } + } + if(getType() < r.getType()) { return true; @@ -400,6 +438,8 @@ public: IceInternal::Reference::Reference(const InstancePtr& inst, const CommunicatorPtr& com, const Identity& ident, const SharedContextPtr& ctx, const string& fs, Mode md) : _hashInitialized(false), + _overrideCompress(false), + _compress(false), _instance(inst), _communicator(com), _mode(md), @@ -411,6 +451,8 @@ IceInternal::Reference::Reference(const InstancePtr& inst, const CommunicatorPtr IceInternal::Reference::Reference(const Reference& r) : _hashInitialized(false), + _overrideCompress(r._overrideCompress), + _compress(r._compress), _instance(r._instance), _communicator(r._communicator), _mode(r._mode), @@ -526,16 +568,6 @@ IceInternal::FixedReference::changeCollocationOptimization(bool) const } ReferencePtr -IceInternal::FixedReference::changeCompress(bool) const -{ - // TODO: FixedReferences should probably have a _compress flag, - // that gets its default from the fixed connection this reference - // refers to. This should be changable with changeCompress(). - throw FixedProxyException(__FILE__, __LINE__); - return 0; // Keep the compiler happy. -} - -ReferencePtr IceInternal::FixedReference::changeTimeout(int) const { throw FixedProxyException(__FILE__, __LINE__); @@ -620,8 +652,20 @@ IceInternal::FixedReference::getConnection(bool& compress) const ConnectionIPtr connection = filteredConns[0]; assert(connection); connection->throwException(); // Throw in case our connection is already destroyed. - compress = connection->endpoint()->compress(); + DefaultsAndOverridesPtr defaultsAndOverrides = getInstance()->defaultsAndOverrides(); + if(defaultsAndOverrides->overrideCompress) + { + compress = defaultsAndOverrides->overrideCompressValue; + } + else if(_overrideCompress) + { + compress = _compress; + } + else + { + compress = connection->endpoint()->compress(); + } return connection; } @@ -844,19 +888,6 @@ IceInternal::RoutableReference::changeCollocationOptimization(bool newCollocatio } ReferencePtr -IceInternal::RoutableReference::changeCompress(bool newCompress) const -{ - if(_overrideCompress && newCompress == _compress) - { - return RoutableReferencePtr(const_cast<RoutableReference*>(this)); - } - RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this)); - r->_compress = newCompress; - r->_overrideCompress = true; - return r; -} - -ReferencePtr IceInternal::RoutableReference::changeTimeout(int newTimeout) const { if(_overrideTimeout && newTimeout == _timeout) @@ -959,10 +990,6 @@ IceInternal::RoutableReference::operator==(const Reference& r) const { return false; } - if(_overrideCompress != rhs->_overrideCompress || _overrideCompress && _compress != rhs->_compress) - { - return false; - } if(_overrideTimeout != rhs->_overrideTimeout || _overrideTimeout && _timeout != rhs->_timeout) { return false; @@ -1043,25 +1070,6 @@ IceInternal::RoutableReference::operator<(const Reference& r) const { return false; } - if(!_overrideCompress && rhs->_overrideCompress) - { - return true; - } - else if(rhs->_overrideCompress < _overrideCompress) - { - return false; - } - else if(_overrideCompress) - { - if(!_compress && rhs->_compress) - { - return true; - } - else if(rhs->_compress < _compress) - { - return false; - } - } if(!_overrideTimeout && rhs->_overrideTimeout) { return true; @@ -1332,8 +1340,6 @@ IceInternal::RoutableReference::RoutableReference(const InstancePtr& inst, const _collocationOptimization(collocationOpt), _cacheConnection(cacheConnection), _endpointSelection(endpointSelection), - _overrideCompress(false), - _compress(false), _overrideTimeout(false), _timeout(-1), _threadPerConnection(threadPerConnection) @@ -1349,8 +1355,6 @@ IceInternal::RoutableReference::RoutableReference(const RoutableReference& r) : _cacheConnection(r._cacheConnection), _endpointSelection(r._endpointSelection), _connectionId(r._connectionId), - _overrideCompress(r._overrideCompress), - _compress(r._compress), _overrideTimeout(r._overrideTimeout), _timeout(r._timeout), _threadPerConnection(r._threadPerConnection) diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h index 95715300787..e9b862c01df 100644 --- a/cpp/src/Ice/Reference.h +++ b/cpp/src/Ice/Reference.h @@ -92,12 +92,12 @@ public: ReferencePtr changeMode(Mode) const; ReferencePtr changeIdentity(const Ice::Identity&) const; ReferencePtr changeFacet(const std::string&) const; + virtual ReferencePtr changeCompress(bool) const; virtual ReferencePtr changeSecure(bool) const = 0; virtual ReferencePtr changePreferSecure(bool) const = 0; virtual ReferencePtr changeRouter(const Ice::RouterPrx&) const = 0; virtual ReferencePtr changeLocator(const Ice::LocatorPrx&) const = 0; - virtual ReferencePtr changeCompress(bool) const = 0; virtual ReferencePtr changeTimeout(int) const = 0; virtual ReferencePtr changeConnectionId(const std::string&) const = 0; virtual ReferencePtr changeCollocationOptimization(bool) const = 0; @@ -142,6 +142,9 @@ protected: mutable Ice::Int _hashValue; mutable bool _hashInitialized; + bool _overrideCompress; + bool _compress; // Only used if _overrideCompress == true + private: const InstancePtr _instance; @@ -176,7 +179,6 @@ public: virtual ReferencePtr changeRouter(const Ice::RouterPrx&) const; virtual ReferencePtr changeLocator(const Ice::LocatorPrx&) const; virtual ReferencePtr changeCollocationOptimization(bool) const; - virtual ReferencePtr changeCompress(bool) const; virtual ReferencePtr changeTimeout(int) const; virtual ReferencePtr changeConnectionId(const std::string&) const; virtual ReferencePtr changeLocatorCacheTimeout(int) const; @@ -226,7 +228,6 @@ public: virtual ReferencePtr changePreferSecure(bool) const; virtual ReferencePtr changeRouter(const Ice::RouterPrx&) const; virtual ReferencePtr changeCollocationOptimization(bool) const; - virtual ReferencePtr changeCompress(bool) const; virtual ReferencePtr changeTimeout(int) const; virtual ReferencePtr changeConnectionId(const std::string&) const; virtual ReferencePtr changeCacheConnection(bool) const; @@ -264,8 +265,6 @@ private: Ice::EndpointSelectionType _endpointSelection; std::string _connectionId; - bool _overrideCompress; - bool _compress; // Only used if _overrideCompress == true bool _overrideTimeout; int _timeout; // Only used if _overrideTimeout == true bool _threadPerConnection; diff --git a/cs/src/Ice/Reference.cs b/cs/src/Ice/Reference.cs index 84635576949..7cc1fc80cdb 100644 --- a/cs/src/Ice/Reference.cs +++ b/cs/src/Ice/Reference.cs @@ -145,11 +145,23 @@ namespace IceInternal return r; } + public virtual Reference changeCompress(bool newCompress) + { + if(overrideCompress_ && compress_ == newCompress) + { + return this; + } + + Reference r = instance_.referenceFactory().copy(this); + r.compress_ = newCompress; + r.overrideCompress_ = true; + return r; + } + public abstract Reference changeSecure(bool newSecure); public abstract Reference changePreferSecure(bool newPreferSecure); public abstract Reference changeRouter(Ice.RouterPrx newRouter); public abstract Reference changeLocator(Ice.LocatorPrx newLocator); - public abstract Reference changeCompress(bool newCompress); public abstract Reference changeTimeout(int newTimeout); public abstract Reference changeConnectionId(string connectionId); public abstract Reference changeCollocationOptimization(bool newCollocationOptimization); @@ -356,6 +368,15 @@ namespace IceInternal return false; } + if(overrideCompress_ != r.overrideCompress_) + { + return false; + } + if(overrideCompress_ && compress_ != r.compress_) + { + return false; + } + return true; } @@ -377,6 +398,8 @@ namespace IceInternal protected int hashValue_; protected bool hashInitialized_; + protected bool overrideCompress_; + protected bool compress_; // Only used if _overrideCompress == true protected Reference(Instance inst, Ice.Communicator com, @@ -399,6 +422,8 @@ namespace IceInternal context_ = ctx == null ? _emptyContext : ctx; facet_ = fac; hashInitialized_ = false; + overrideCompress_ = false; + compress_ = false; } protected static System.Random rand_ = new System.Random(unchecked((int)System.DateTime.Now.Ticks)); @@ -483,14 +508,6 @@ namespace IceInternal throw new Ice.FixedProxyException(); } - public override Reference changeCompress(bool newCompress) - { - // TODO: FixedReferences should probably have a _compress flag, - // that gets its default from the fixed connection this reference - // refers to. This should be changable with changeCompress(). - throw new Ice.FixedProxyException(); - } - public override Reference changeTimeout(int newTimeout) { throw new Ice.FixedProxyException(); @@ -559,8 +576,20 @@ namespace IceInternal Ice.ConnectionI connection = filteredConns[0]; Debug.Assert(connection != null); connection.throwException(); // Throw in case our connection is already destroyed. - compress = connection.endpoint().compress(); - + + DefaultsAndOverrides defaultsAndOverrides = getInstance().defaultsAndOverrides(); + if(defaultsAndOverrides.overrideCompress) + { + compress = defaultsAndOverrides.overrideCompressValue; + } + else if(overrideCompress_) + { + compress = compress_; + } + else + { + compress = connection.endpoint().compress(); + } return connection; } @@ -832,19 +861,6 @@ namespace IceInternal return r; } - public override Reference changeCompress(bool newCompress) - { - if(overrideCompress_ && compress_ == newCompress) - { - return this; - } - - RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this); - r.compress_ = newCompress; - r.overrideCompress_ = true; - return r; - } - public override Reference changeTimeout(int newTimeout) { if(overrideTimeout_ && timeout_ == newTimeout) @@ -933,14 +949,6 @@ namespace IceInternal { return false; } - if(overrideCompress_ != rhs.overrideCompress_) - { - return false; - } - if(overrideCompress_ && compress_ != rhs.compress_) - { - return false; - } if(overrideTimeout_ != rhs.overrideTimeout_) { return false; @@ -989,8 +997,6 @@ namespace IceInternal _collocationOptimization = collocationOpt; _cacheConnection = cacheConnection; _endpointSelection = endpointSelection; - overrideCompress_ = false; - compress_ = false; overrideTimeout_ = false; timeout_ = -1; _threadPerConnection = threadPerConnection; @@ -1350,8 +1356,6 @@ namespace IceInternal private bool _cacheConnection; private Ice.EndpointSelectionType _endpointSelection; private string connectionId_ = ""; - private bool overrideCompress_; - private bool compress_; private bool overrideTimeout_; private int timeout_; private bool _threadPerConnection; diff --git a/java/src/IceInternal/FixedReference.java b/java/src/IceInternal/FixedReference.java index 64f0818a88b..bc43460b555 100644 --- a/java/src/IceInternal/FixedReference.java +++ b/java/src/IceInternal/FixedReference.java @@ -145,15 +145,6 @@ public class FixedReference extends Reference } public Reference - changeCompress(boolean newCompress) - { - // TODO: FixedReferences should probably have a _compress flag, - // that gets its default from the fixed connection this reference - // refers to. This should be changable with changeCompress(). - throw new Ice.FixedProxyException(); - } - - public Reference changeTimeout(int newTimeout) { throw new Ice.FixedProxyException(); @@ -193,8 +184,20 @@ public class FixedReference extends Reference Ice.ConnectionI connection = filteredConns[0]; assert(connection != null); connection.throwException(); // Throw in case our connection is already destroyed. - compress.value = connection.endpoint().compress(); + DefaultsAndOverrides defaultsAndOverrides = getInstance().defaultsAndOverrides(); + if(defaultsAndOverrides.overrideCompress) + { + compress.value = defaultsAndOverrides.overrideCompressValue; + } + else if(_overrideCompress) + { + compress.value = _compress; + } + else + { + compress.value = connection.endpoint().compress(); + } return connection; } diff --git a/java/src/IceInternal/Reference.java b/java/src/IceInternal/Reference.java index eed4cd7693a..55f947e9880 100644 --- a/java/src/IceInternal/Reference.java +++ b/java/src/IceInternal/Reference.java @@ -150,11 +150,23 @@ public abstract class Reference implements Cloneable return r; } + public Reference + changeCompress(boolean newCompress) + { + if(_overrideCompress && _compress == newCompress) + { + return this; + } + Reference r = _instance.referenceFactory().copy(this); + r._compress = newCompress; + r._overrideCompress = true; + return r; + } + public abstract Reference changeSecure(boolean newSecure); public abstract Reference changePreferSecure(boolean newPreferSecure); public abstract Reference changeRouter(Ice.RouterPrx newRouter); public abstract Reference changeLocator(Ice.LocatorPrx newLocator); - public abstract Reference changeCompress(boolean newCompress); public abstract Reference changeTimeout(int newTimeout); public abstract Reference changeConnectionId(String connectionId); public abstract Reference changeCollocationOptimization(boolean newCollocationOptimization); @@ -362,6 +374,15 @@ public abstract class Reference implements Cloneable return false; } + if(_overrideCompress != r._overrideCompress) + { + return false; + } + if(_overrideCompress && _compress != r._compress) + { + return false; + } + return true; } @@ -392,6 +413,8 @@ public abstract class Reference implements Cloneable protected int _hashValue; protected boolean _hashInitialized; + protected boolean _overrideCompress; + protected boolean _compress; // Only used if _overrideCompress == true protected Reference(Instance inst, @@ -415,5 +438,7 @@ public abstract class Reference implements Cloneable _context = ctx == null ? _emptyContext : ctx; _facet = fac; _hashInitialized = false; + _overrideCompress = false; + _compress = false; } } diff --git a/java/src/IceInternal/RoutableReference.java b/java/src/IceInternal/RoutableReference.java index 213453b71cd..82dde6c8fe7 100644 --- a/java/src/IceInternal/RoutableReference.java +++ b/java/src/IceInternal/RoutableReference.java @@ -103,19 +103,6 @@ public abstract class RoutableReference extends Reference } public Reference - changeCompress(boolean newCompress) - { - if(_overrideCompress && _compress == newCompress) - { - return this; - } - RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this); - r._compress = newCompress; - r._overrideCompress = true; - return r; - } - - public Reference changeTimeout(int newTimeout) { if(_overrideTimeout && _timeout == newTimeout) @@ -218,14 +205,6 @@ public abstract class RoutableReference extends Reference { return false; } - if(_overrideCompress != rhs._overrideCompress) - { - return false; - } - if(_overrideCompress && _compress != rhs._compress) - { - return false; - } if(_overrideTimeout != rhs._overrideTimeout) { return false; @@ -265,7 +244,6 @@ public abstract class RoutableReference extends Reference _cacheConnection = cacheConnection; _endpointSelection = endpointSelection; _overrideCompress = false; - _compress = false; _overrideTimeout = false; _timeout = -1; _threadPerConnection = threadPerConnection; @@ -628,8 +606,6 @@ public abstract class RoutableReference extends Reference private boolean _cacheConnection; private Ice.EndpointSelectionType _endpointSelection; private String _connectionId = ""; - private boolean _overrideCompress; - private boolean _compress; // Only used if _overrideCompress == true private boolean _overrideTimeout; private int _timeout; // Only used if _overrideTimeout == true private boolean _threadPerConnection; |