diff options
author | Benoit Foucher <benoit@zeroc.com> | 2012-11-13 10:17:27 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2012-11-13 10:17:27 +0100 |
commit | 99b44d083eeee5583adfe642081a827224fa1309 (patch) | |
tree | 46bb3af634cbd5d90b9e5d46099f4e0e85f70ec6 /cpp | |
parent | Cosmetic updates to IceGrid Admin connection wizard (diff) | |
download | ice-99b44d083eeee5583adfe642081a827224fa1309.tar.bz2 ice-99b44d083eeee5583adfe642081a827224fa1309.tar.xz ice-99b44d083eeee5583adfe642081a827224fa1309.zip |
Fixed ICE-4927: fixed proxy encoding to marshal protocol/encoding version instead of encoding it in endpoints
Diffstat (limited to 'cpp')
36 files changed, 373 insertions, 640 deletions
diff --git a/cpp/config/Make.rules.MINGW b/cpp/config/Make.rules.MINGW index 29d9c3dba4e..63d2a6a524f 100644 --- a/cpp/config/Make.rules.MINGW +++ b/cpp/config/Make.rules.MINGW @@ -29,7 +29,6 @@ ifeq ($(OPTIMIZE),yes) CXXFLAGS += -O2 -DNDEBUG else CXXFLAGS += -g -D_DEBUG - LIBSUFFIX = d endif COMPSUFFIX = mingw_ diff --git a/cpp/src/Ice/EndpointI.cpp b/cpp/src/Ice/EndpointI.cpp index e9762fe2eec..0115a5f31cc 100644 --- a/cpp/src/Ice/EndpointI.cpp +++ b/cpp/src/Ice/EndpointI.cpp @@ -46,18 +46,6 @@ Init init; Ice::LocalObject* IceInternal::upCast(EndpointI* p) { return p; } IceUtil::Shared* IceInternal::upCast(EndpointHostResolver* p) { return p; } -const Ice::EncodingVersion& -IceInternal::EndpointI::encodingVersion() const -{ - return _encoding; -} - -const Ice::ProtocolVersion& -IceInternal::EndpointI::protocolVersion() const -{ - return _protocol; -} - const string& IceInternal::EndpointI::connectionId() const { @@ -86,74 +74,17 @@ IceInternal::EndpointI::connectors(const vector<Address>& addrs) const return vector<ConnectorPtr>(); } -IceInternal::EndpointI::EndpointI(const Ice::ProtocolVersion& protocol, - const Ice::EncodingVersion& encoding, - const std::string& connectionId) : - _protocol(protocol), - _encoding(encoding), +IceInternal::EndpointI::EndpointI(const std::string& connectionId) : _connectionId(connectionId), _hashInitialized(false) { } IceInternal::EndpointI::EndpointI() : - _protocol(Ice::currentProtocol), - _encoding(Ice::currentEncoding), _hashInitialized(false) { } -void -IceInternal::EndpointI::parseOption(const string& option, const string& arg, const string& desc, const string& str) -{ - if(option == "-v") - { - if(arg.empty()) - { - Ice::EndpointParseException ex(__FILE__, __LINE__); - ex.str = "no argument provided for -v option in endpoint `" + desc + " " + str + "'"; - throw ex; - } - - try - { - const_cast<Ice::ProtocolVersion&>(_protocol) = Ice::stringToProtocolVersion(arg); - } - catch(const Ice::VersionParseException& e) - { - Ice::EndpointParseException ex(__FILE__, __LINE__); - ex.str = "invalid protocol version `" + arg + "' in endpoint `" + desc + " " + str + "':\n" + e.str; - throw ex; - } - } - else if(option == "-e") - { - if(arg.empty()) - { - Ice::EndpointParseException ex(__FILE__, __LINE__); - ex.str = "no argument provided for -e option in endpoint `" + desc + " " + str + "'"; - throw ex; - } - - try - { - const_cast<Ice::EncodingVersion&>(_encoding) = Ice::stringToEncodingVersion(arg); - } - catch(const Ice::VersionParseException& e) - { - Ice::EndpointParseException ex(__FILE__, __LINE__); - ex.str = "invalid encoding version `" + arg + "' in endpoint `" + desc + " " + str + "':\n" + e.str; - throw ex; - } - } - else - { - Ice::EndpointParseException ex(__FILE__, __LINE__); - ex.str = "unknown option `" + option + "' in `" + desc + " " + str + "'"; - throw ex; - } -} - #ifndef ICE_OS_WINRT IceInternal::EndpointHostResolver::EndpointHostResolver(const InstancePtr& instance) : diff --git a/cpp/src/Ice/EndpointI.h b/cpp/src/Ice/EndpointI.h index 17f079d1c1e..e7e1a208f19 100644 --- a/cpp/src/Ice/EndpointI.h +++ b/cpp/src/Ice/EndpointI.h @@ -105,16 +105,6 @@ public: virtual bool secure() const = 0; // - // Returns the encoding version supported by this endpoint. - // - const ::Ice::EncodingVersion& encodingVersion() const; - - // - // Returns the encoding version supported by this endpoint. - // - const ::Ice::ProtocolVersion& protocolVersion() const; - - // // Return a server side transceiver for this endpoint, or null if a // transceiver can only be created by an acceptor. In case a // transceiver is created, this operation also returns a new @@ -165,15 +155,11 @@ protected: virtual std::vector<ConnectorPtr> connectors(const std::vector<Address>&) const; friend class EndpointHostResolver; - EndpointI(const Ice::ProtocolVersion&, const Ice::EncodingVersion&, const std::string&); + EndpointI(const std::string&); EndpointI(); - void parseOption(const std::string&, const std::string&, const std::string&, const std::string&); - virtual ::Ice::Int hashInit() const = 0; - const Ice::ProtocolVersion _protocol; - const Ice::EncodingVersion _encoding; const std::string _connectionId; private: diff --git a/cpp/src/Ice/InstrumentationI.h b/cpp/src/Ice/InstrumentationI.h index d8f9641c76c..035aed387cc 100644 --- a/cpp/src/Ice/InstrumentationI.h +++ b/cpp/src/Ice/InstrumentationI.h @@ -24,8 +24,6 @@ void addEndpointAttributes(typename Helper::Attributes& attrs) attrs.add("endpointType", &Helper::getEndpointInfo, &Ice::EndpointInfo::type); attrs.add("endpointIsDatagram", &Helper::getEndpointInfo, &Ice::EndpointInfo::datagram); attrs.add("endpointIsSecure", &Helper::getEndpointInfo, &Ice::EndpointInfo::secure); - attrs.add("endpointProtocolVersion", &Helper::getEndpointInfo, &Ice::EndpointInfo::protocol); - attrs.add("endpointEncodingVersion", &Helper::getEndpointInfo, &Ice::EndpointInfo::encoding); attrs.add("endpointTimeout", &Helper::getEndpointInfo, &Ice::EndpointInfo::timeout); attrs.add("endpointCompress", &Helper::getEndpointInfo, &Ice::EndpointInfo::compress); diff --git a/cpp/src/Ice/LocatorInfo.cpp b/cpp/src/Ice/LocatorInfo.cpp index ac693041b2e..0acf9db3f90 100644 --- a/cpp/src/Ice/LocatorInfo.cpp +++ b/cpp/src/Ice/LocatorInfo.cpp @@ -156,16 +156,17 @@ IceInternal::LocatorManager::get(const LocatorPrx& loc) // have only one table per locator (not one per locator // proxy). // - map<Identity, LocatorTablePtr>::iterator t = _locatorTables.find(locator->ice_getIdentity()); + pair<Identity, EncodingVersion> locatorKey(locator->ice_getIdentity(), locator->ice_getEncodingVersion()); + map<pair<Identity, EncodingVersion>, LocatorTablePtr>::iterator t = _locatorTables.find(locatorKey); if(t == _locatorTables.end()) { t = _locatorTables.insert(_locatorTables.begin(), - pair<const Identity, LocatorTablePtr>(locator->ice_getIdentity(), - new LocatorTable())); + pair<const pair<Identity, EncodingVersion>, LocatorTablePtr>( + locatorKey, new LocatorTable())); } - _tableHint = _table.insert(_tableHint, - pair<const LocatorPrx, LocatorInfoPtr>(locator, + _tableHint = _table.insert(_tableHint, + pair<const LocatorPrx, LocatorInfoPtr>(locator, new LocatorInfo(locator, t->second, _background))); } @@ -536,15 +537,6 @@ IceInternal::LocatorInfo::operator<(const LocatorInfo& rhs) const return _locator < rhs._locator; } -LocatorPrx -IceInternal::LocatorInfo::getLocator() const -{ - // - // No mutex lock necessary, _locator is immutable. - // - return _locator; -} - LocatorRegistryPrx IceInternal::LocatorInfo::getLocatorRegistry() { diff --git a/cpp/src/Ice/LocatorInfo.h b/cpp/src/Ice/LocatorInfo.h index 9a863107e38..15d4ad3075a 100644 --- a/cpp/src/Ice/LocatorInfo.h +++ b/cpp/src/Ice/LocatorInfo.h @@ -20,6 +20,7 @@ #include <Ice/Identity.h> #include <Ice/EndpointIF.h> #include <Ice/PropertiesF.h> +#include <Ice/Version.h> #include <IceUtil/UniquePtr.h> @@ -47,7 +48,7 @@ private: std::map<Ice::LocatorPrx, LocatorInfoPtr> _table; std::map<Ice::LocatorPrx, LocatorInfoPtr>::iterator _tableHint; - std::map<Ice::Identity, LocatorTablePtr> _locatorTables; + std::map<std::pair<Ice::Identity, Ice::EncodingVersion>, LocatorTablePtr> _locatorTables; }; class LocatorTable : public IceUtil::Shared, public IceUtil::Mutex @@ -143,7 +144,13 @@ public: bool operator!=(const LocatorInfo&) const; bool operator<(const LocatorInfo&) const; - Ice::LocatorPrx getLocator() const; + const Ice::LocatorPrx& getLocator() const + { + // + // No mutex lock necessary, _locator is immutable. + // + return _locator; + } Ice::LocatorRegistryPrx getLocatorRegistry(); std::vector<EndpointIPtr> getEndpoints(const ReferencePtr& ref, int ttl, bool& cached) diff --git a/cpp/src/Ice/OpaqueEndpointI.cpp b/cpp/src/Ice/OpaqueEndpointI.cpp index 5b3bedbaedd..10b16984b56 100644 --- a/cpp/src/Ice/OpaqueEndpointI.cpp +++ b/cpp/src/Ice/OpaqueEndpointI.cpp @@ -25,7 +25,7 @@ const Ice::EncodingVersion Encoding_0_0 = { 0, 0 }; } IceInternal::OpaqueEndpointI::OpaqueEndpointI(const string& str) : - EndpointI(Protocol_0_0, Encoding_0_0, ""), + EndpointI(""), _rawEncoding(Ice::currentEncoding) { const string delim = " \t\n\r"; @@ -183,7 +183,7 @@ IceInternal::OpaqueEndpointI::OpaqueEndpointI(const string& str) : } IceInternal::OpaqueEndpointI::OpaqueEndpointI(Short type, BasicStream* s) : - EndpointI(Protocol_0_0, Encoding_0_0, ""), + EndpointI(""), _type(type) { _rawEncoding = s->startReadEncaps(); @@ -247,7 +247,7 @@ private: // COMPILERFIX: inlining this constructor causes crashes with gcc 4.0.1. // InfoI::InfoI(Ice::Short type, const Ice::EncodingVersion& rawEncoding, const Ice::ByteSeq& rawBytes) : - Ice::OpaqueEndpointInfo(Protocol_0_0, Encoding_0_0, -1, false, rawEncoding, rawBytes), + Ice::OpaqueEndpointInfo(-1, false, rawEncoding, rawBytes), _type(type) { } diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp index c46b95bad14..85e15a53509 100644 --- a/cpp/src/Ice/Outgoing.cpp +++ b/cpp/src/Ice/Outgoing.cpp @@ -92,6 +92,8 @@ IceInternal::Outgoing::Outgoing(RequestHandler* handler, const string& operation _os(handler->getReference()->getInstance().get(), Ice::currentProtocolEncoding), _sent(false) { + checkSupportedProtocol(handler->getReference()->getProtocol()); + switch(_handler->getReference()->getMode()) { case Reference::ModeTwoway: @@ -561,6 +563,7 @@ IceInternal::BatchOutgoing::BatchOutgoing(RequestHandler* handler, InvocationObs _os(handler->getReference()->getInstance().get(), Ice::currentProtocolEncoding), _observer(observer) { + checkSupportedProtocol(handler->getReference()->getProtocol()); } IceInternal::BatchOutgoing::BatchOutgoing(ConnectionI* connection, Instance* instance, InvocationObserver& observer) : diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp index 5dd2238944f..33ac9dee0f5 100644 --- a/cpp/src/Ice/OutgoingAsync.cpp +++ b/cpp/src/Ice/OutgoingAsync.cpp @@ -438,6 +438,8 @@ IceInternal::OutgoingAsync::__prepare(const std::string& operation, OperationMod _mode = mode; _sentSynchronously = false; + checkSupportedProtocol(_proxy->__reference()->getProtocol()); + _observer.attach(_proxy.get(), operation, context); // @@ -935,6 +937,8 @@ IceInternal::ProxyBatchOutgoingAsync::ProxyBatchOutgoingAsync(const Ice::ObjectP void IceInternal::ProxyBatchOutgoingAsync::__send() { + checkSupportedProtocol(_proxy->__reference()->getProtocol()); + // // We don't automatically retry if ice_flushBatchRequests fails. Otherwise, if some batch // requests were queued with the connection, they would be lost without being noticed. diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp index e9e05239474..62d94b80fa7 100644 --- a/cpp/src/Ice/PropertyNames.cpp +++ b/cpp/src/Ice/PropertyNames.cpp @@ -8,7 +8,7 @@ // ********************************************************************** // -// Generated by makeprops.py from file ../config/PropertyNames.xml, Mon Oct 22 18:48:40 2012 +// Generated by makeprops.py from file ./config/PropertyNames.xml, Mon Nov 12 21:17:34 2012 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -27,7 +27,6 @@ const IceInternal::Property IcePropsData[] = IceInternal::Property("Ice.Admin.Locator.LocatorCacheTimeout", false, 0), IceInternal::Property("Ice.Admin.Locator.Locator", false, 0), IceInternal::Property("Ice.Admin.Locator.Router", false, 0), - IceInternal::Property("Ice.Admin.Locator.EncodingVersion", false, 0), IceInternal::Property("Ice.Admin.Locator.CollocationOptimized", false, 0), IceInternal::Property("Ice.Admin.Locator", false, 0), IceInternal::Property("Ice.Admin.PublishedEndpoints", false, 0), @@ -38,7 +37,6 @@ const IceInternal::Property IcePropsData[] = IceInternal::Property("Ice.Admin.Router.LocatorCacheTimeout", false, 0), IceInternal::Property("Ice.Admin.Router.Locator", false, 0), IceInternal::Property("Ice.Admin.Router.Router", false, 0), - IceInternal::Property("Ice.Admin.Router.EncodingVersion", false, 0), IceInternal::Property("Ice.Admin.Router.CollocationOptimized", false, 0), IceInternal::Property("Ice.Admin.Router", false, 0), IceInternal::Property("Ice.Admin.ProxyOptions", false, 0), @@ -69,7 +67,6 @@ const IceInternal::Property IcePropsData[] = IceInternal::Property("Ice.Default.Locator.LocatorCacheTimeout", false, 0), IceInternal::Property("Ice.Default.Locator.Locator", false, 0), IceInternal::Property("Ice.Default.Locator.Router", false, 0), - IceInternal::Property("Ice.Default.Locator.EncodingVersion", false, 0), IceInternal::Property("Ice.Default.Locator.CollocationOptimized", false, 0), IceInternal::Property("Ice.Default.Locator", false, 0), IceInternal::Property("Ice.Default.LocatorCacheTimeout", false, 0), @@ -82,7 +79,6 @@ const IceInternal::Property IcePropsData[] = IceInternal::Property("Ice.Default.Router.LocatorCacheTimeout", false, 0), IceInternal::Property("Ice.Default.Router.Locator", false, 0), IceInternal::Property("Ice.Default.Router.Router", false, 0), - IceInternal::Property("Ice.Default.Router.EncodingVersion", false, 0), IceInternal::Property("Ice.Default.Router.CollocationOptimized", false, 0), IceInternal::Property("Ice.Default.Router", false, 0), IceInternal::Property("Ice.Default.SlicedFormat", false, 0), @@ -188,7 +184,6 @@ const IceInternal::Property IceBoxPropsData[] = IceInternal::Property("IceBox.ServiceManager.Locator.LocatorCacheTimeout", false, 0), IceInternal::Property("IceBox.ServiceManager.Locator.Locator", false, 0), IceInternal::Property("IceBox.ServiceManager.Locator.Router", false, 0), - IceInternal::Property("IceBox.ServiceManager.Locator.EncodingVersion", false, 0), IceInternal::Property("IceBox.ServiceManager.Locator.CollocationOptimized", false, 0), IceInternal::Property("IceBox.ServiceManager.Locator", false, 0), IceInternal::Property("IceBox.ServiceManager.PublishedEndpoints", false, 0), @@ -199,7 +194,6 @@ const IceInternal::Property IceBoxPropsData[] = IceInternal::Property("IceBox.ServiceManager.Router.LocatorCacheTimeout", false, 0), IceInternal::Property("IceBox.ServiceManager.Router.Locator", false, 0), IceInternal::Property("IceBox.ServiceManager.Router.Router", false, 0), - IceInternal::Property("IceBox.ServiceManager.Router.EncodingVersion", false, 0), IceInternal::Property("IceBox.ServiceManager.Router.CollocationOptimized", false, 0), IceInternal::Property("IceBox.ServiceManager.Router", false, 0), IceInternal::Property("IceBox.ServiceManager.ProxyOptions", false, 0), @@ -226,7 +220,6 @@ const IceInternal::Property IceBoxAdminPropsData[] = IceInternal::Property("IceBoxAdmin.ServiceManager.Proxy.LocatorCacheTimeout", false, 0), IceInternal::Property("IceBoxAdmin.ServiceManager.Proxy.Locator", false, 0), IceInternal::Property("IceBoxAdmin.ServiceManager.Proxy.Router", false, 0), - IceInternal::Property("IceBoxAdmin.ServiceManager.Proxy.EncodingVersion", false, 0), IceInternal::Property("IceBoxAdmin.ServiceManager.Proxy.CollocationOptimized", false, 0), IceInternal::Property("IceBoxAdmin.ServiceManager.Proxy", false, 0), }; @@ -261,7 +254,6 @@ const IceInternal::Property IceGridPropsData[] = IceInternal::Property("IceGrid.Node.Locator.LocatorCacheTimeout", false, 0), IceInternal::Property("IceGrid.Node.Locator.Locator", false, 0), IceInternal::Property("IceGrid.Node.Locator.Router", false, 0), - IceInternal::Property("IceGrid.Node.Locator.EncodingVersion", false, 0), IceInternal::Property("IceGrid.Node.Locator.CollocationOptimized", false, 0), IceInternal::Property("IceGrid.Node.Locator", false, 0), IceInternal::Property("IceGrid.Node.PublishedEndpoints", false, 0), @@ -272,7 +264,6 @@ const IceInternal::Property IceGridPropsData[] = IceInternal::Property("IceGrid.Node.Router.LocatorCacheTimeout", false, 0), IceInternal::Property("IceGrid.Node.Router.Locator", false, 0), IceInternal::Property("IceGrid.Node.Router.Router", false, 0), - IceInternal::Property("IceGrid.Node.Router.EncodingVersion", false, 0), IceInternal::Property("IceGrid.Node.Router.CollocationOptimized", false, 0), IceInternal::Property("IceGrid.Node.Router", false, 0), IceInternal::Property("IceGrid.Node.ProxyOptions", false, 0), @@ -306,7 +297,6 @@ const IceInternal::Property IceGridPropsData[] = IceInternal::Property("IceGrid.Node.UserAccountMapper.LocatorCacheTimeout", false, 0), IceInternal::Property("IceGrid.Node.UserAccountMapper.Locator", false, 0), IceInternal::Property("IceGrid.Node.UserAccountMapper.Router", false, 0), - IceInternal::Property("IceGrid.Node.UserAccountMapper.EncodingVersion", false, 0), IceInternal::Property("IceGrid.Node.UserAccountMapper.CollocationOptimized", false, 0), IceInternal::Property("IceGrid.Node.UserAccountMapper", false, 0), IceInternal::Property("IceGrid.Node.WaitTime", false, 0), @@ -317,7 +307,6 @@ const IceInternal::Property IceGridPropsData[] = IceInternal::Property("IceGrid.Registry.AdminPermissionsVerifier.LocatorCacheTimeout", false, 0), IceInternal::Property("IceGrid.Registry.AdminPermissionsVerifier.Locator", false, 0), IceInternal::Property("IceGrid.Registry.AdminPermissionsVerifier.Router", false, 0), - IceInternal::Property("IceGrid.Registry.AdminPermissionsVerifier.EncodingVersion", false, 0), IceInternal::Property("IceGrid.Registry.AdminPermissionsVerifier.CollocationOptimized", false, 0), IceInternal::Property("IceGrid.Registry.AdminPermissionsVerifier", false, 0), IceInternal::Property("IceGrid.Registry.AdminSessionFilters", false, 0), @@ -330,7 +319,6 @@ const IceInternal::Property IceGridPropsData[] = IceInternal::Property("IceGrid.Registry.AdminSessionManager.Locator.LocatorCacheTimeout", false, 0), IceInternal::Property("IceGrid.Registry.AdminSessionManager.Locator.Locator", false, 0), IceInternal::Property("IceGrid.Registry.AdminSessionManager.Locator.Router", false, 0), - IceInternal::Property("IceGrid.Registry.AdminSessionManager.Locator.EncodingVersion", false, 0), IceInternal::Property("IceGrid.Registry.AdminSessionManager.Locator.CollocationOptimized", false, 0), IceInternal::Property("IceGrid.Registry.AdminSessionManager.Locator", false, 0), IceInternal::Property("IceGrid.Registry.AdminSessionManager.PublishedEndpoints", false, 0), @@ -341,7 +329,6 @@ const IceInternal::Property IceGridPropsData[] = IceInternal::Property("IceGrid.Registry.AdminSessionManager.Router.LocatorCacheTimeout", false, 0), IceInternal::Property("IceGrid.Registry.AdminSessionManager.Router.Locator", false, 0), IceInternal::Property("IceGrid.Registry.AdminSessionManager.Router.Router", false, 0), - IceInternal::Property("IceGrid.Registry.AdminSessionManager.Router.EncodingVersion", false, 0), IceInternal::Property("IceGrid.Registry.AdminSessionManager.Router.CollocationOptimized", false, 0), IceInternal::Property("IceGrid.Registry.AdminSessionManager.Router", false, 0), IceInternal::Property("IceGrid.Registry.AdminSessionManager.ProxyOptions", false, 0), @@ -358,7 +345,6 @@ const IceInternal::Property IceGridPropsData[] = IceInternal::Property("IceGrid.Registry.AdminSSLPermissionsVerifier.LocatorCacheTimeout", false, 0), IceInternal::Property("IceGrid.Registry.AdminSSLPermissionsVerifier.Locator", false, 0), IceInternal::Property("IceGrid.Registry.AdminSSLPermissionsVerifier.Router", false, 0), - IceInternal::Property("IceGrid.Registry.AdminSSLPermissionsVerifier.EncodingVersion", false, 0), IceInternal::Property("IceGrid.Registry.AdminSSLPermissionsVerifier.CollocationOptimized", false, 0), IceInternal::Property("IceGrid.Registry.AdminSSLPermissionsVerifier", false, 0), IceInternal::Property("IceGrid.Registry.Client.ACM", false, 0), @@ -370,7 +356,6 @@ const IceInternal::Property IceGridPropsData[] = IceInternal::Property("IceGrid.Registry.Client.Locator.LocatorCacheTimeout", false, 0), IceInternal::Property("IceGrid.Registry.Client.Locator.Locator", false, 0), IceInternal::Property("IceGrid.Registry.Client.Locator.Router", false, 0), - IceInternal::Property("IceGrid.Registry.Client.Locator.EncodingVersion", false, 0), IceInternal::Property("IceGrid.Registry.Client.Locator.CollocationOptimized", false, 0), IceInternal::Property("IceGrid.Registry.Client.Locator", false, 0), IceInternal::Property("IceGrid.Registry.Client.PublishedEndpoints", false, 0), @@ -381,7 +366,6 @@ const IceInternal::Property IceGridPropsData[] = IceInternal::Property("IceGrid.Registry.Client.Router.LocatorCacheTimeout", false, 0), IceInternal::Property("IceGrid.Registry.Client.Router.Locator", false, 0), IceInternal::Property("IceGrid.Registry.Client.Router.Router", false, 0), - IceInternal::Property("IceGrid.Registry.Client.Router.EncodingVersion", false, 0), IceInternal::Property("IceGrid.Registry.Client.Router.CollocationOptimized", false, 0), IceInternal::Property("IceGrid.Registry.Client.Router", false, 0), IceInternal::Property("IceGrid.Registry.Client.ProxyOptions", false, 0), @@ -405,7 +389,6 @@ const IceInternal::Property IceGridPropsData[] = IceInternal::Property("IceGrid.Registry.Internal.Locator.LocatorCacheTimeout", false, 0), IceInternal::Property("IceGrid.Registry.Internal.Locator.Locator", false, 0), IceInternal::Property("IceGrid.Registry.Internal.Locator.Router", false, 0), - IceInternal::Property("IceGrid.Registry.Internal.Locator.EncodingVersion", false, 0), IceInternal::Property("IceGrid.Registry.Internal.Locator.CollocationOptimized", false, 0), IceInternal::Property("IceGrid.Registry.Internal.Locator", false, 0), IceInternal::Property("IceGrid.Registry.Internal.PublishedEndpoints", false, 0), @@ -416,7 +399,6 @@ const IceInternal::Property IceGridPropsData[] = IceInternal::Property("IceGrid.Registry.Internal.Router.LocatorCacheTimeout", false, 0), IceInternal::Property("IceGrid.Registry.Internal.Router.Locator", false, 0), IceInternal::Property("IceGrid.Registry.Internal.Router.Router", false, 0), - IceInternal::Property("IceGrid.Registry.Internal.Router.EncodingVersion", false, 0), IceInternal::Property("IceGrid.Registry.Internal.Router.CollocationOptimized", false, 0), IceInternal::Property("IceGrid.Registry.Internal.Router", false, 0), IceInternal::Property("IceGrid.Registry.Internal.ProxyOptions", false, 0), @@ -434,7 +416,6 @@ const IceInternal::Property IceGridPropsData[] = IceInternal::Property("IceGrid.Registry.PermissionsVerifier.LocatorCacheTimeout", false, 0), IceInternal::Property("IceGrid.Registry.PermissionsVerifier.Locator", false, 0), IceInternal::Property("IceGrid.Registry.PermissionsVerifier.Router", false, 0), - IceInternal::Property("IceGrid.Registry.PermissionsVerifier.EncodingVersion", false, 0), IceInternal::Property("IceGrid.Registry.PermissionsVerifier.CollocationOptimized", false, 0), IceInternal::Property("IceGrid.Registry.PermissionsVerifier", false, 0), IceInternal::Property("IceGrid.Registry.ReplicaName", false, 0), @@ -450,7 +431,6 @@ const IceInternal::Property IceGridPropsData[] = IceInternal::Property("IceGrid.Registry.Server.Locator.LocatorCacheTimeout", false, 0), IceInternal::Property("IceGrid.Registry.Server.Locator.Locator", false, 0), IceInternal::Property("IceGrid.Registry.Server.Locator.Router", false, 0), - IceInternal::Property("IceGrid.Registry.Server.Locator.EncodingVersion", false, 0), IceInternal::Property("IceGrid.Registry.Server.Locator.CollocationOptimized", false, 0), IceInternal::Property("IceGrid.Registry.Server.Locator", false, 0), IceInternal::Property("IceGrid.Registry.Server.PublishedEndpoints", false, 0), @@ -461,7 +441,6 @@ const IceInternal::Property IceGridPropsData[] = IceInternal::Property("IceGrid.Registry.Server.Router.LocatorCacheTimeout", false, 0), IceInternal::Property("IceGrid.Registry.Server.Router.Locator", false, 0), IceInternal::Property("IceGrid.Registry.Server.Router.Router", false, 0), - IceInternal::Property("IceGrid.Registry.Server.Router.EncodingVersion", false, 0), IceInternal::Property("IceGrid.Registry.Server.Router.CollocationOptimized", false, 0), IceInternal::Property("IceGrid.Registry.Server.Router", false, 0), IceInternal::Property("IceGrid.Registry.Server.ProxyOptions", false, 0), @@ -482,7 +461,6 @@ const IceInternal::Property IceGridPropsData[] = IceInternal::Property("IceGrid.Registry.SessionManager.Locator.LocatorCacheTimeout", false, 0), IceInternal::Property("IceGrid.Registry.SessionManager.Locator.Locator", false, 0), IceInternal::Property("IceGrid.Registry.SessionManager.Locator.Router", false, 0), - IceInternal::Property("IceGrid.Registry.SessionManager.Locator.EncodingVersion", false, 0), IceInternal::Property("IceGrid.Registry.SessionManager.Locator.CollocationOptimized", false, 0), IceInternal::Property("IceGrid.Registry.SessionManager.Locator", false, 0), IceInternal::Property("IceGrid.Registry.SessionManager.PublishedEndpoints", false, 0), @@ -493,7 +471,6 @@ const IceInternal::Property IceGridPropsData[] = IceInternal::Property("IceGrid.Registry.SessionManager.Router.LocatorCacheTimeout", false, 0), IceInternal::Property("IceGrid.Registry.SessionManager.Router.Locator", false, 0), IceInternal::Property("IceGrid.Registry.SessionManager.Router.Router", false, 0), - IceInternal::Property("IceGrid.Registry.SessionManager.Router.EncodingVersion", false, 0), IceInternal::Property("IceGrid.Registry.SessionManager.Router.CollocationOptimized", false, 0), IceInternal::Property("IceGrid.Registry.SessionManager.Router", false, 0), IceInternal::Property("IceGrid.Registry.SessionManager.ProxyOptions", false, 0), @@ -511,7 +488,6 @@ const IceInternal::Property IceGridPropsData[] = IceInternal::Property("IceGrid.Registry.SSLPermissionsVerifier.LocatorCacheTimeout", false, 0), IceInternal::Property("IceGrid.Registry.SSLPermissionsVerifier.Locator", false, 0), IceInternal::Property("IceGrid.Registry.SSLPermissionsVerifier.Router", false, 0), - IceInternal::Property("IceGrid.Registry.SSLPermissionsVerifier.EncodingVersion", false, 0), IceInternal::Property("IceGrid.Registry.SSLPermissionsVerifier.CollocationOptimized", false, 0), IceInternal::Property("IceGrid.Registry.SSLPermissionsVerifier", false, 0), IceInternal::Property("IceGrid.Registry.Trace.Application", false, 0), @@ -551,7 +527,6 @@ const IceInternal::Property IcePatch2PropsData[] = IceInternal::Property("IcePatch2.Locator.LocatorCacheTimeout", false, 0), IceInternal::Property("IcePatch2.Locator.Locator", false, 0), IceInternal::Property("IcePatch2.Locator.Router", false, 0), - IceInternal::Property("IcePatch2.Locator.EncodingVersion", false, 0), IceInternal::Property("IcePatch2.Locator.CollocationOptimized", false, 0), IceInternal::Property("IcePatch2.Locator", false, 0), IceInternal::Property("IcePatch2.PublishedEndpoints", false, 0), @@ -562,7 +537,6 @@ const IceInternal::Property IcePatch2PropsData[] = IceInternal::Property("IcePatch2.Router.LocatorCacheTimeout", false, 0), IceInternal::Property("IcePatch2.Router.Locator", false, 0), IceInternal::Property("IcePatch2.Router.Router", false, 0), - IceInternal::Property("IcePatch2.Router.EncodingVersion", false, 0), IceInternal::Property("IcePatch2.Router.CollocationOptimized", false, 0), IceInternal::Property("IcePatch2.Router", false, 0), IceInternal::Property("IcePatch2.ProxyOptions", false, 0), @@ -658,7 +632,6 @@ const IceInternal::Property Glacier2PropsData[] = IceInternal::Property("Glacier2.Client.Locator.LocatorCacheTimeout", false, 0), IceInternal::Property("Glacier2.Client.Locator.Locator", false, 0), IceInternal::Property("Glacier2.Client.Locator.Router", false, 0), - IceInternal::Property("Glacier2.Client.Locator.EncodingVersion", false, 0), IceInternal::Property("Glacier2.Client.Locator.CollocationOptimized", false, 0), IceInternal::Property("Glacier2.Client.Locator", false, 0), IceInternal::Property("Glacier2.Client.PublishedEndpoints", false, 0), @@ -669,7 +642,6 @@ const IceInternal::Property Glacier2PropsData[] = IceInternal::Property("Glacier2.Client.Router.LocatorCacheTimeout", false, 0), IceInternal::Property("Glacier2.Client.Router.Locator", false, 0), IceInternal::Property("Glacier2.Client.Router.Router", false, 0), - IceInternal::Property("Glacier2.Client.Router.EncodingVersion", false, 0), IceInternal::Property("Glacier2.Client.Router.CollocationOptimized", false, 0), IceInternal::Property("Glacier2.Client.Router", false, 0), IceInternal::Property("Glacier2.Client.ProxyOptions", false, 0), @@ -702,7 +674,6 @@ const IceInternal::Property Glacier2PropsData[] = IceInternal::Property("Glacier2.PermissionsVerifier.LocatorCacheTimeout", false, 0), IceInternal::Property("Glacier2.PermissionsVerifier.Locator", false, 0), IceInternal::Property("Glacier2.PermissionsVerifier.Router", false, 0), - IceInternal::Property("Glacier2.PermissionsVerifier.EncodingVersion", false, 0), IceInternal::Property("Glacier2.PermissionsVerifier.CollocationOptimized", false, 0), IceInternal::Property("Glacier2.PermissionsVerifier", false, 0), IceInternal::Property("Glacier2.ReturnClientProxy", false, 0), @@ -712,7 +683,6 @@ const IceInternal::Property Glacier2PropsData[] = IceInternal::Property("Glacier2.SSLPermissionsVerifier.LocatorCacheTimeout", false, 0), IceInternal::Property("Glacier2.SSLPermissionsVerifier.Locator", false, 0), IceInternal::Property("Glacier2.SSLPermissionsVerifier.Router", false, 0), - IceInternal::Property("Glacier2.SSLPermissionsVerifier.EncodingVersion", false, 0), IceInternal::Property("Glacier2.SSLPermissionsVerifier.CollocationOptimized", false, 0), IceInternal::Property("Glacier2.SSLPermissionsVerifier", false, 0), IceInternal::Property("Glacier2.RoutingTable.MaxSize", false, 0), @@ -725,7 +695,6 @@ const IceInternal::Property Glacier2PropsData[] = IceInternal::Property("Glacier2.Server.Locator.LocatorCacheTimeout", false, 0), IceInternal::Property("Glacier2.Server.Locator.Locator", false, 0), IceInternal::Property("Glacier2.Server.Locator.Router", false, 0), - IceInternal::Property("Glacier2.Server.Locator.EncodingVersion", false, 0), IceInternal::Property("Glacier2.Server.Locator.CollocationOptimized", false, 0), IceInternal::Property("Glacier2.Server.Locator", false, 0), IceInternal::Property("Glacier2.Server.PublishedEndpoints", false, 0), @@ -736,7 +705,6 @@ const IceInternal::Property Glacier2PropsData[] = IceInternal::Property("Glacier2.Server.Router.LocatorCacheTimeout", false, 0), IceInternal::Property("Glacier2.Server.Router.Locator", false, 0), IceInternal::Property("Glacier2.Server.Router.Router", false, 0), - IceInternal::Property("Glacier2.Server.Router.EncodingVersion", false, 0), IceInternal::Property("Glacier2.Server.Router.CollocationOptimized", false, 0), IceInternal::Property("Glacier2.Server.Router", false, 0), IceInternal::Property("Glacier2.Server.ProxyOptions", false, 0), @@ -759,7 +727,6 @@ const IceInternal::Property Glacier2PropsData[] = IceInternal::Property("Glacier2.SessionManager.LocatorCacheTimeout", false, 0), IceInternal::Property("Glacier2.SessionManager.Locator", false, 0), IceInternal::Property("Glacier2.SessionManager.Router", false, 0), - IceInternal::Property("Glacier2.SessionManager.EncodingVersion", false, 0), IceInternal::Property("Glacier2.SessionManager.CollocationOptimized", false, 0), IceInternal::Property("Glacier2.SessionManager", false, 0), IceInternal::Property("Glacier2.SSLSessionManager.EndpointSelection", false, 0), @@ -768,7 +735,6 @@ const IceInternal::Property Glacier2PropsData[] = IceInternal::Property("Glacier2.SSLSessionManager.LocatorCacheTimeout", false, 0), IceInternal::Property("Glacier2.SSLSessionManager.Locator", false, 0), IceInternal::Property("Glacier2.SSLSessionManager.Router", false, 0), - IceInternal::Property("Glacier2.SSLSessionManager.EncodingVersion", false, 0), IceInternal::Property("Glacier2.SSLSessionManager.CollocationOptimized", false, 0), IceInternal::Property("Glacier2.SSLSessionManager", false, 0), IceInternal::Property("Glacier2.SessionTimeout", false, 0), diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h index f8f09b5a81c..f460865f279 100644 --- a/cpp/src/Ice/PropertyNames.h +++ b/cpp/src/Ice/PropertyNames.h @@ -8,7 +8,7 @@ // ********************************************************************** // -// Generated by makeprops.py from file ../config/PropertyNames.xml, Mon Oct 22 18:48:40 2012 +// Generated by makeprops.py from file ./config/PropertyNames.xml, Mon Nov 12 21:17:34 2012 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -27,9 +27,9 @@ struct Property const char* deprecatedBy; Property(const char* n, bool d, const char* b) : - pattern(n), - deprecated(d), - deprecatedBy(b) + pattern(n), + deprecated(d), + deprecatedBy(b) { } diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index 8f519f5ca55..7b5b6781867 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -870,7 +870,6 @@ IceProxy::Ice::Object::ice_encodingVersion(const ::Ice::EncodingVersion& encodin } else { - checkSupportedEncoding(encoding); ObjectPrx proxy = __newInstance(); proxy->setup(_reference->changeEncoding(encoding)); return proxy; diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp index dadbdf8af0d..a3d9f9478ca 100644 --- a/cpp/src/Ice/Reference.cpp +++ b/cpp/src/Ice/Reference.cpp @@ -143,7 +143,7 @@ IceInternal::Reference::changeEncoding(const Ice::EncodingVersion& encoding) con r->_encoding = encoding; return r; } - + ReferencePtr IceInternal::Reference::changeCompress(bool newCompress) const { @@ -193,6 +193,12 @@ IceInternal::Reference::streamWrite(BasicStream* s) const s->write(_secure); + if(s->getWriteEncoding() != Ice::Encoding_1_0) + { + s->write(_protocol); + s->write(_encoding); + } + // Derived class writes the remainder of the reference. } @@ -282,6 +288,16 @@ IceInternal::Reference::toString() const s << " -s"; } + if(_protocol != Ice::Protocol_1_0) + { + s << " -p " << _protocol; + } + + if(_encoding != Ice::Encoding_1_0) + { + s << " -e " << _encoding; + } + return s.str(); // Derived class writes the remainder of the string. @@ -324,7 +340,12 @@ IceInternal::Reference::operator==(const Reference& r) const return false; } - if(_encoding != r._encoding) + if(_protocol != r._protocol) + { + return false; + } + + if(_encoding != r._encoding) { return false; } @@ -410,11 +431,20 @@ IceInternal::Reference::operator<(const Reference& r) const return false; } - if(_encoding < r._encoding) + if(_protocol < r._protocol) { return true; - } - else if(r._encoding > _encoding) + } + else if(r._protocol < _protocol) + { + return false; + } + + if(_encoding < r._encoding) + { + return true; + } + else if(r._encoding < _encoding) { return false; } @@ -450,6 +480,7 @@ IceInternal::Reference::Reference(const InstancePtr& instance, const string& facet, Mode mode, bool secure, + const ProtocolVersion& protocol, const EncodingVersion& encoding) : _hashInitialized(false), _instance(instance), @@ -459,6 +490,7 @@ IceInternal::Reference::Reference(const InstancePtr& instance, _identity(id), _context(new SharedContext), _facet(facet), + _protocol(protocol), _encoding(encoding), _overrideCompress(false), _compress(false) @@ -474,6 +506,7 @@ IceInternal::Reference::Reference(const Reference& r) : _identity(r._identity), _context(r._context), _facet(r._facet), + _protocol(r._protocol), _encoding(r._encoding), _overrideCompress(r._overrideCompress), _compress(r._compress) @@ -495,6 +528,8 @@ IceInternal::Reference::hashInit() const { hashAdd(h, _compress); } + hashAdd(h, _protocol.major); + hashAdd(h, _protocol.minor); hashAdd(h, _encoding.major); hashAdd(h, _encoding.minor); return h; @@ -510,7 +545,7 @@ IceInternal::FixedReference::FixedReference(const InstancePtr& instance, bool secure, const EncodingVersion& encoding, const ConnectionIPtr& fixedConnection) : - Reference(instance, communicator, id, facet, mode, secure, encoding), + Reference(instance, communicator, id, facet, mode, secure, Ice::Protocol_1_0, encoding), _fixedConnection(fixedConnection) { } @@ -820,7 +855,8 @@ IceInternal::RoutableReference::RoutableReference(const InstancePtr& instance, const string& facet, Mode mode, bool secure, - const EncodingVersion& version, + const ProtocolVersion& protocol, + const EncodingVersion& encoding, const vector<EndpointIPtr>& endpoints, const string& adapterId, const LocatorInfoPtr& locatorInfo, @@ -830,7 +866,7 @@ IceInternal::RoutableReference::RoutableReference(const InstancePtr& instance, bool preferSecure, EndpointSelectionType endpointSelection, int locatorCacheTimeout) : - Reference(instance, communicator, id, facet, mode, secure, version), + Reference(instance, communicator, id, facet, mode, secure, protocol, encoding), _endpoints(endpoints), _adapterId(adapterId), _locatorInfo(locatorInfo), @@ -907,6 +943,21 @@ IceInternal::RoutableReference::getConnectionId() const } ReferencePtr +IceInternal::RoutableReference::changeEncoding(const Ice::EncodingVersion& encoding) const +{ + ReferencePtr r = Reference::changeEncoding(encoding); + if(r.get() != const_cast<RoutableReference*>(this)) + { + LocatorInfoPtr& locInfo = RoutableReferencePtr::dynamicCast(r)->_locatorInfo; + if(locInfo && locInfo->getLocator()->ice_getEncodingVersion() != encoding) + { + locInfo = getInstance()->locatorManager()->get(locInfo->getLocator()->ice_encodingVersion(encoding)); + } + } + return r; +} + +ReferencePtr IceInternal::RoutableReference::changeCompress(bool newCompress) const { ReferencePtr r = Reference::changeCompress(newCompress); @@ -1175,7 +1226,6 @@ IceInternal::RoutableReference::toProperty(const string& prefix) const properties[prefix + ".ConnectionCached"] = _cacheConnection ? "1" : "0"; properties[prefix + ".PreferSecure"] = _preferSecure ? "1" : "0"; properties[prefix + ".EndpointSelection"] = _endpointSelection == Random ? "Random" : "Ordered"; - properties[prefix + ".EncodingVersion"] = versionToString(getEncoding()); ostringstream s; s << _locatorCacheTimeout; @@ -1888,20 +1938,14 @@ IceInternal::RoutableReference::RoutableReference(const RoutableReference& r) : namespace { -struct EndpointIsIncompatible : public unary_function<EndpointIPtr, bool> +struct EndpointIsOpaque : public unary_function<EndpointIPtr, bool> { - const Reference* _reference; - - EndpointIsIncompatible(const Reference* reference) : _reference(reference) - { - } +public: bool - operator()(const EndpointIPtr& p) const + operator()(EndpointIPtr p) const { - // If the enpoint doesn't support the proxy encoding or protocol, it's incompatible. - return !(isSupported(_reference->getEncoding(), p->encodingVersion()) && - isSupported(currentProtocol, p->protocolVersion())); + return dynamic_cast<OpaqueEndpointI*>(p.get()) != 0; } }; @@ -1913,10 +1957,9 @@ IceInternal::RoutableReference::filterEndpoints(const vector<EndpointIPtr>& allE vector<EndpointIPtr> endpoints = allEndpoints; // - // Filter out incompatible endpoints (whose encoding/protocol - // versions aren't supported by this runtime, or are opaque). + // Filter out unknown endpoints. // - endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), EndpointIsIncompatible(this)), endpoints.end()); + endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), EndpointIsOpaque()), endpoints.end()); // // Filter out endpoints according to the mode of the reference. diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h index 4fad67eab08..ceff28a7c01 100644 --- a/cpp/src/Ice/Reference.h +++ b/cpp/src/Ice/Reference.h @@ -55,6 +55,7 @@ public: Mode getMode() const { return _mode; } bool getSecure() const { return _secure; } + const Ice::ProtocolVersion& getProtocol() const { return _protocol; } const Ice::EncodingVersion& getEncoding() const { return _encoding; } const Ice::Identity& getIdentity() const { return _identity; } const std::string& getFacet() const { return _facet; } @@ -85,7 +86,7 @@ public: ReferencePtr changeSecure(bool) const; ReferencePtr changeIdentity(const Ice::Identity&) const; ReferencePtr changeFacet(const std::string&) const; - ReferencePtr changeEncoding(const Ice::EncodingVersion&) const; + virtual ReferencePtr changeEncoding(const Ice::EncodingVersion&) const; virtual ReferencePtr changeCompress(bool) const; virtual ReferencePtr changeEndpoints(const std::vector<EndpointIPtr>&) const = 0; @@ -139,7 +140,7 @@ public: protected: Reference(const InstancePtr&, const Ice::CommunicatorPtr&, const Ice::Identity&, const std::string&, Mode, bool, - const Ice::EncodingVersion&); + const Ice::ProtocolVersion&, const Ice::EncodingVersion&); Reference(const Reference&); virtual Ice::Int hashInit() const; @@ -157,6 +158,7 @@ private: Ice::Identity _identity; SharedContextPtr _context; std::string _facet; + Ice::ProtocolVersion _protocol; Ice::EncodingVersion _encoding; protected: @@ -222,8 +224,9 @@ class RoutableReference : public Reference public: RoutableReference(const InstancePtr&, const Ice::CommunicatorPtr&, const Ice::Identity&, const std::string&, Mode, - bool, const Ice::EncodingVersion&, const std::vector<EndpointIPtr>&, const std::string&, - const LocatorInfoPtr&, const RouterInfoPtr&, bool, bool, bool, Ice::EndpointSelectionType, int); + bool, const Ice::ProtocolVersion&, const Ice::EncodingVersion&, const std::vector<EndpointIPtr>&, + const std::string&, const LocatorInfoPtr&, const RouterInfoPtr&, bool, bool, bool, + Ice::EndpointSelectionType, int); virtual std::vector<EndpointIPtr> getEndpoints() const; virtual std::string getAdapterId() const; @@ -236,6 +239,7 @@ public: virtual int getLocatorCacheTimeout() const; virtual std::string getConnectionId() const; + virtual ReferencePtr changeEncoding(const Ice::EncodingVersion&) const; virtual ReferencePtr changeCompress(bool) const; virtual ReferencePtr changeEndpoints(const std::vector<EndpointIPtr>&) const; virtual ReferencePtr changeAdapterId(const std::string&) const; diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp index 37ccafa1976..b4193f3a374 100644 --- a/cpp/src/Ice/ReferenceFactory.cpp +++ b/cpp/src/Ice/ReferenceFactory.cpp @@ -55,7 +55,8 @@ IceInternal::ReferenceFactory::create(const Identity& ident, return 0; } - return create(ident, facet, tmpl->getMode(), tmpl->getSecure(), endpoints, "", ""); + return create(ident, facet, tmpl->getMode(), tmpl->getSecure(), tmpl->getProtocol(), tmpl->getEncoding(), + endpoints, "", ""); } ReferencePtr @@ -69,7 +70,8 @@ IceInternal::ReferenceFactory::create(const Identity& ident, return 0; } - return create(ident, facet, tmpl->getMode(), tmpl->getSecure(), vector<EndpointIPtr>(), adapterId, ""); + return create(ident, facet, tmpl->getMode(), tmpl->getSecure(), tmpl->getProtocol(), tmpl->getEncoding(), + vector<EndpointIPtr>(), adapterId, ""); } ReferencePtr @@ -80,8 +82,6 @@ IceInternal::ReferenceFactory::create(const Identity& ident, const Ice::Connecti return 0; } - DefaultsAndOverridesPtr defaultsAndOverrides = _instance->defaultsAndOverrides(); - // // Create new reference // @@ -91,7 +91,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, const Ice::Connecti "", // Facet connection->endpoint()->datagram() ? Reference::ModeDatagram : Reference::ModeTwoway, connection->endpoint()->secure(), - defaultsAndOverrides->defaultEncoding, + _instance->defaultsAndOverrides()->defaultEncoding, connection); } @@ -189,6 +189,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP string facet; Reference::Mode mode = Reference::ModeTwoway; bool secure = false; + Ice::EncodingVersion encoding = _instance->defaultsAndOverrides()->defaultEncoding; string adapter; while(true) @@ -362,6 +363,28 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP break; } + case 'e': + { + if(argument.empty()) + { + Ice::ProxyParseException ex(__FILE__, __LINE__); + ex.str = "no argument provided for -e option in `" + s + "'"; + throw ex; + } + + try + { + encoding = Ice::stringToEncodingVersion(argument); + } + catch(const Ice::VersionParseException& e) + { + Ice::ProxyParseException ex(__FILE__, __LINE__); + ex.str = "invalid encoding version `" + argument + "' in `" + s + "':\n" + e.str; + throw ex; + } + break; + } + default: { ProxyParseException ex(__FILE__, __LINE__); @@ -371,14 +394,12 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP } } - if(beg == string::npos) { - return create(ident, facet, mode, secure, vector<EndpointIPtr>(), "", propertyPrefix); + return create(ident, facet, mode, secure, Protocol_1_0, encoding, vector<EndpointIPtr>(), "", propertyPrefix); } vector<EndpointIPtr> endpoints; - switch(s[beg]) { case ':': @@ -463,7 +484,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP } } - return create(ident, facet, mode, secure, endpoints, "", propertyPrefix); + return create(ident, facet, mode, secure, Protocol_1_0, encoding, endpoints, "", propertyPrefix); break; } case '@': @@ -527,7 +548,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP adapter = Ice::UTF8ToNative(_instance->initializationData().stringConverter, adapter); - return create(ident, facet, mode, secure, vector<EndpointIPtr>(), adapter, propertyPrefix); + return create(ident, facet, mode, secure, Protocol_1_0, encoding, endpoints, adapter, propertyPrefix); break; } default: @@ -580,6 +601,19 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) bool secure; s->read(secure); + Ice::ProtocolVersion protocol; + Ice::EncodingVersion encoding; + if(s->getReadEncoding() != Ice::Encoding_1_0) + { + s->read(protocol); + s->read(encoding); + } + else + { + protocol = Ice::Protocol_1_0; + encoding = Ice::Encoding_1_0; + } + vector<EndpointIPtr> endpoints; string adapterId; @@ -599,7 +633,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) s->read(adapterId); } - return create(ident, facet, mode, secure, endpoints, adapterId, ""); + return create(ident, facet, mode, secure, protocol, encoding, endpoints, adapterId, ""); } ReferenceFactoryPtr @@ -656,7 +690,6 @@ IceInternal::ReferenceFactory::checkForUnknownProperties(const string& prefix) "EndpointSelection", "ConnectionCached", "PreferSecure", - "EncodingVersion", "LocatorCacheTimeout", "Locator", "Router", @@ -711,6 +744,8 @@ IceInternal::ReferenceFactory::create(const Identity& ident, const string& facet, Reference::Mode mode, bool secure, + const Ice::ProtocolVersion& protocol, + const Ice::EncodingVersion& encoding, const vector<EndpointIPtr>& endpoints, const string& adapterId, const string& propertyPrefix) @@ -720,12 +755,22 @@ IceInternal::ReferenceFactory::create(const Identity& ident, // // Default local proxy options. // - LocatorInfoPtr locatorInfo = _instance->locatorManager()->get(_defaultLocator); + LocatorInfoPtr locatorInfo; + if(_defaultLocator) + { + if(_defaultLocator->ice_getEncodingVersion() != encoding) + { + locatorInfo = _instance->locatorManager()->get(_defaultLocator->ice_encodingVersion(encoding)); + } + else + { + locatorInfo = _instance->locatorManager()->get(_defaultLocator); + } + } RouterInfoPtr routerInfo = _instance->routerManager()->get(_defaultRouter); bool collocationOptimized = defaultsAndOverrides->defaultCollocationOptimization; bool cacheConnection = true; bool preferSecure = defaultsAndOverrides->defaultPreferSecure; - EncodingVersion encoding = defaultsAndOverrides->defaultEncoding; Ice::EndpointSelectionType endpointSelection = defaultsAndOverrides->defaultEndpointSelection; int locatorCacheTimeout = defaultsAndOverrides->defaultLocatorCacheTimeout; @@ -746,7 +791,14 @@ IceInternal::ReferenceFactory::create(const Identity& ident, LocatorPrx locator = LocatorPrx::uncheckedCast(_communicator->propertyToProxy(property)); if(locator) { - locatorInfo = _instance->locatorManager()->get(locator); + if(locator->ice_getEncodingVersion() != encoding) + { + locatorInfo = _instance->locatorManager()->get(locator->ice_encodingVersion(encoding)); + } + else + { + locatorInfo = _instance->locatorManager()->get(locator); + } } property = propertyPrefix + ".Router"; @@ -774,14 +826,6 @@ IceInternal::ReferenceFactory::create(const Identity& ident, property = propertyPrefix + ".PreferSecure"; preferSecure = properties->getPropertyAsIntWithDefault(property, preferSecure) > 0; - property = propertyPrefix + ".EncodingVersion"; - string encodingStr = properties->getProperty(property); - if(!encodingStr.empty()) - { - encoding = stringToEncodingVersion(encodingStr); - checkSupportedEncoding(encoding); - } - property = propertyPrefix + ".EndpointSelection"; if(!properties->getProperty(property).empty()) { @@ -815,6 +859,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, facet, mode, secure, + protocol, encoding, endpoints, adapterId, diff --git a/cpp/src/Ice/ReferenceFactory.h b/cpp/src/Ice/ReferenceFactory.h index dd1982f96de..6542b062887 100644 --- a/cpp/src/Ice/ReferenceFactory.h +++ b/cpp/src/Ice/ReferenceFactory.h @@ -67,6 +67,7 @@ private: void checkForUnknownProperties(const std::string&); RoutableReferencePtr create(const ::Ice::Identity&, const ::std::string&, Reference::Mode, bool, + const Ice::ProtocolVersion&, const Ice::EncodingVersion&, const std::vector<EndpointIPtr>&, const std::string&, const std::string&); const InstancePtr _instance; diff --git a/cpp/src/Ice/RouterInfo.cpp b/cpp/src/Ice/RouterInfo.cpp index 291e0ec03d9..84feadb9869 100644 --- a/cpp/src/Ice/RouterInfo.cpp +++ b/cpp/src/Ice/RouterInfo.cpp @@ -142,15 +142,6 @@ IceInternal::RouterInfo::operator<(const RouterInfo& rhs) const return _router < rhs._router; } -RouterPrx -IceInternal::RouterInfo::getRouter() const -{ - // - // No mutex lock necessary, _router is immutable. - // - return _router; -} - vector<EndpointIPtr> IceInternal::RouterInfo::getClientEndpoints() { diff --git a/cpp/src/Ice/RouterInfo.h b/cpp/src/Ice/RouterInfo.h index c1b1077a73b..7caaafc97cf 100644 --- a/cpp/src/Ice/RouterInfo.h +++ b/cpp/src/Ice/RouterInfo.h @@ -76,7 +76,13 @@ public: bool operator!=(const RouterInfo&) const; bool operator<(const RouterInfo&) const; - Ice::RouterPrx getRouter() const; + const Ice::RouterPrx& getRouter() const + { + // + // No mutex lock necessary, _router is immutable. + // + return _router; + } void getClientProxyResponse(const Ice::ObjectPrx&, const GetClientEndpointsCallbackPtr&); void getClientProxyException(const Ice::Exception&, const GetClientEndpointsCallbackPtr&); std::vector<EndpointIPtr> getClientEndpoints(); diff --git a/cpp/src/Ice/TcpConnector.cpp b/cpp/src/Ice/TcpConnector.cpp index a3211c28eb7..7c4dedb9cf2 100644 --- a/cpp/src/Ice/TcpConnector.cpp +++ b/cpp/src/Ice/TcpConnector.cpp @@ -77,16 +77,6 @@ IceInternal::TcpConnector::operator==(const Connector& r) const return false; } - if(_protocol != p->_protocol) - { - return false; - } - - if(_encoding != p->_encoding) - { - return false; - } - if(_connectionId != p->_connectionId) { return false; @@ -119,24 +109,6 @@ IceInternal::TcpConnector::operator<(const Connector& r) const return false; } - if(_protocol < p->_protocol) - { - return true; - } - else if(p->_protocol < _protocol) - { - return false; - } - - if(_encoding < p->_encoding) - { - return true; - } - else if(p->_encoding < _encoding) - { - return false; - } - if(_connectionId < p->_connectionId) { return true; @@ -149,15 +121,12 @@ IceInternal::TcpConnector::operator<(const Connector& r) const } IceInternal::TcpConnector::TcpConnector(const InstancePtr& instance, const Address& addr, - Ice::Int timeout, const Ice::ProtocolVersion& protocol, - const Ice::EncodingVersion& encoding, const string& connectionId) : + Ice::Int timeout, const string& connectionId) : _instance(instance), _traceLevels(instance->traceLevels()), _logger(instance->initializationData().logger), _addr(addr), _timeout(timeout), - _protocol(protocol), - _encoding(encoding), _connectionId(connectionId) { } diff --git a/cpp/src/Ice/TcpConnector.h b/cpp/src/Ice/TcpConnector.h index 341696087ef..6a1d5fdab50 100644 --- a/cpp/src/Ice/TcpConnector.h +++ b/cpp/src/Ice/TcpConnector.h @@ -36,8 +36,7 @@ public: private: - TcpConnector(const InstancePtr&, const Address&, Ice::Int, const Ice::ProtocolVersion&, - const Ice::EncodingVersion&, const std::string&); + TcpConnector(const InstancePtr&, const Address&, Ice::Int, const std::string&); virtual ~TcpConnector(); friend class TcpEndpointI; @@ -46,8 +45,6 @@ private: const ::Ice::LoggerPtr _logger; const Address _addr; const Ice::Int _timeout; - const Ice::ProtocolVersion _protocol; - const Ice::EncodingVersion _encoding; const std::string _connectionId; }; diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp index 1eac94a8988..f69cfb1094b 100644 --- a/cpp/src/Ice/TcpEndpointI.cpp +++ b/cpp/src/Ice/TcpEndpointI.cpp @@ -23,9 +23,8 @@ using namespace Ice; using namespace IceInternal; IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const string& ho, Int po, Int ti, - const Ice::ProtocolVersion& protocol, const Ice::EncodingVersion& encoding, const string& conId, bool co) : - EndpointI(protocol, encoding, conId), + EndpointI(conId), _instance(instance), _host(ho), _port(po), @@ -35,7 +34,7 @@ IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const strin } IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const string& str, bool oaEndpoint) : - EndpointI(Ice::currentProtocol, instance->defaultsAndOverrides()->defaultEncoding, ""), + EndpointI(""), _instance(instance), _port(0), _timeout(-1), @@ -155,7 +154,9 @@ IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const strin default: { - parseOption(option, argument, "tcp", str); + Ice::EndpointParseException ex(__FILE__, __LINE__); + ex.str = "unknown option `" + option + "' in endpoint `tcp " + str + "'"; + throw ex; } } } @@ -190,16 +191,6 @@ IceInternal::TcpEndpointI::TcpEndpointI(BasicStream* s) : s->read(const_cast<Int&>(_port)); s->read(const_cast<Int&>(_timeout)); s->read(const_cast<bool&>(_compress)); - if(s->getReadEncoding() > Ice::Encoding_1_0) - { - s->read(const_cast<Ice::ProtocolVersion&>(_protocol)); - s->read(const_cast<Ice::EncodingVersion&>(_encoding)); - } - else - { - const_cast<ProtocolVersion&>(_protocol) = Ice::Protocol_1_0; - const_cast<EncodingVersion&>(_encoding) = Ice::Encoding_1_0; - } s->endReadEncaps(); } @@ -212,11 +203,6 @@ IceInternal::TcpEndpointI::streamWrite(BasicStream* s) const s->write(_port); s->write(_timeout); s->write(_compress); - if(s->getWriteEncoding() > Ice::Encoding_1_0) - { - s->write(_protocol); - s->write(_encoding); - } s->endWriteEncaps(); } @@ -233,16 +219,6 @@ IceInternal::TcpEndpointI::toString() const ostringstream s; s << "tcp"; - if(_protocol != Ice::Protocol_1_0) - { - s << " -v " << _protocol; - } - - if(_encoding != Ice::Encoding_1_0) - { - s << " -e " << _encoding; - } - if(!_host.empty()) { s << " -h "; @@ -277,9 +253,8 @@ IceInternal::TcpEndpointI::getInfo() const { public: - InfoI(const ProtocolVersion& pv, const EncodingVersion& ev, Ice::Int to, bool comp, const string& host, - Ice::Int port) : - TCPEndpointInfo(pv, ev, to, comp, host, port) + InfoI(Ice::Int to, bool comp, const string& host, Ice::Int port) : + TCPEndpointInfo(to, comp, host, port) { } @@ -302,7 +277,7 @@ IceInternal::TcpEndpointI::getInfo() const } }; - return new InfoI(_protocol, _encoding, _timeout, _compress, _host, _port); + return new InfoI(_timeout, _compress, _host, _port); } Short @@ -332,7 +307,7 @@ IceInternal::TcpEndpointI::timeout(Int timeout) const } else { - return new TcpEndpointI(_instance, _host, _port, timeout, _protocol, _encoding, _connectionId, _compress); + return new TcpEndpointI(_instance, _host, _port, timeout, _connectionId, _compress); } } @@ -345,7 +320,7 @@ IceInternal::TcpEndpointI::connectionId(const string& connectionId) const } else { - return new TcpEndpointI(_instance, _host, _port, _timeout, _protocol, _encoding, connectionId, _compress); + return new TcpEndpointI(_instance, _host, _port, _timeout, connectionId, _compress); } } @@ -364,7 +339,7 @@ IceInternal::TcpEndpointI::compress(bool compress) const } else { - return new TcpEndpointI(_instance, _host, _port, _timeout, _protocol, _encoding, _connectionId, compress); + return new TcpEndpointI(_instance, _host, _port, _timeout, _connectionId, compress); } } @@ -403,8 +378,8 @@ AcceptorPtr IceInternal::TcpEndpointI::acceptor(EndpointIPtr& endp, const string&) const { TcpAcceptor* p = new TcpAcceptor(_instance, _host, _port, _instance->protocolSupport()); - endp = new TcpEndpointI(_instance, _host, p->effectivePort(), _timeout, _protocol, _encoding, _connectionId, - _compress); + + endp = new TcpEndpointI(_instance, _host, p->effectivePort(), _timeout, _connectionId, _compress); return p; } @@ -422,8 +397,7 @@ IceInternal::TcpEndpointI::expand() const { for(vector<string>::const_iterator p = hosts.begin(); p != hosts.end(); ++p) { - endps.push_back(new TcpEndpointI(_instance, *p, _port, _timeout, _protocol, _encoding, _connectionId, - _compress)); + endps.push_back(new TcpEndpointI(_instance, *p, _port, _timeout, _connectionId, _compress)); } } return endps; @@ -454,16 +428,6 @@ IceInternal::TcpEndpointI::operator==(const LocalObject& r) const return true; } - if(_protocol != p->_protocol) - { - return false; - } - - if(_encoding != p->_encoding) - { - return false; - } - if(_host != p->_host) { return false; @@ -511,24 +475,6 @@ IceInternal::TcpEndpointI::operator<(const LocalObject& r) const return false; } - if(_protocol < p->_protocol) - { - return true; - } - else if(p->_protocol < _protocol) - { - return false; - } - - if(_encoding < p->_encoding) - { - return true; - } - else if(p->_encoding < _encoding) - { - return false; - } - if(_host < p->_host) { return true; @@ -585,10 +531,6 @@ IceInternal::TcpEndpointI::hashInit() const hashAdd(h, _host); hashAdd(h, _port); hashAdd(h, _timeout); - hashAdd(h, _protocol.major); - hashAdd(h, _protocol.minor); - hashAdd(h, _encoding.major); - hashAdd(h, _encoding.minor); hashAdd(h, _connectionId); hashAdd(h, _compress); return h; @@ -600,7 +542,7 @@ IceInternal::TcpEndpointI::connectors(const vector<Address>& addresses) const vector<ConnectorPtr> connectors; for(unsigned int i = 0; i < addresses.size(); ++i) { - connectors.push_back(new TcpConnector(_instance, addresses[i], _timeout, _protocol, _encoding, _connectionId)); + connectors.push_back(new TcpConnector(_instance, addresses[i], _timeout, _connectionId)); } return connectors; } diff --git a/cpp/src/Ice/TcpEndpointI.h b/cpp/src/Ice/TcpEndpointI.h index feaba9879a2..c1d410ebacd 100644 --- a/cpp/src/Ice/TcpEndpointI.h +++ b/cpp/src/Ice/TcpEndpointI.h @@ -22,8 +22,7 @@ class TcpEndpointI : public EndpointI { public: - TcpEndpointI(const InstancePtr&, const std::string&, Ice::Int, Ice::Int, const Ice::ProtocolVersion&, - const Ice::EncodingVersion&, const std::string&, bool); + TcpEndpointI(const InstancePtr&, const std::string&, Ice::Int, Ice::Int, const std::string&, bool); TcpEndpointI(const InstancePtr&, const std::string&, bool); TcpEndpointI(BasicStream*); diff --git a/cpp/src/Ice/UdpConnector.cpp b/cpp/src/Ice/UdpConnector.cpp index 29782122b53..b52c5a44bd6 100644 --- a/cpp/src/Ice/UdpConnector.cpp +++ b/cpp/src/Ice/UdpConnector.cpp @@ -48,16 +48,6 @@ IceInternal::UdpConnector::operator==(const Connector& r) const return false; } - if(_protocol != p->_protocol) - { - return false; - } - - if(_encoding != p->_encoding) - { - return false; - } - if(_connectionId != p->_connectionId) { return false; @@ -91,24 +81,6 @@ IceInternal::UdpConnector::operator<(const Connector& r) const return type() < r.type(); } - if(_protocol < p->_protocol) - { - return true; - } - else if(p->_protocol < _protocol) - { - return false; - } - - if(_encoding < p->_encoding) - { - return true; - } - else if(p->_encoding < _encoding) - { - return false; - } - if(_connectionId < p->_connectionId) { return true; @@ -139,15 +111,11 @@ IceInternal::UdpConnector::operator<(const Connector& r) const } IceInternal::UdpConnector::UdpConnector(const InstancePtr& instance, const Address& addr, - const string& mcastInterface, int mcastTtl, - const Ice::ProtocolVersion& protocol, const Ice::EncodingVersion& encoding, - const std::string& connectionId) : + const string& mcastInterface, int mcastTtl, const std::string& connectionId) : _instance(instance), _addr(addr), _mcastInterface(mcastInterface), _mcastTtl(mcastTtl), - _protocol(protocol), - _encoding(encoding), _connectionId(connectionId) { } diff --git a/cpp/src/Ice/UdpConnector.h b/cpp/src/Ice/UdpConnector.h index 148c767407b..e325e5007b6 100644 --- a/cpp/src/Ice/UdpConnector.h +++ b/cpp/src/Ice/UdpConnector.h @@ -34,8 +34,7 @@ public: private: - UdpConnector(const InstancePtr&, const Address&, const std::string&, int, - const Ice::ProtocolVersion&, const Ice::EncodingVersion&, const std::string&); + UdpConnector(const InstancePtr&, const Address&, const std::string&, int, const std::string&); virtual ~UdpConnector(); friend class UdpEndpointI; @@ -44,8 +43,6 @@ private: const Address _addr; const std::string _mcastInterface; const int _mcastTtl; - const Ice::ProtocolVersion _protocol; - const Ice::EncodingVersion _encoding; const std::string _connectionId; }; diff --git a/cpp/src/Ice/UdpEndpointI.cpp b/cpp/src/Ice/UdpEndpointI.cpp index 8f508a98c0d..8d812e591dc 100644 --- a/cpp/src/Ice/UdpEndpointI.cpp +++ b/cpp/src/Ice/UdpEndpointI.cpp @@ -17,15 +17,15 @@ #include <Ice/DefaultsAndOverrides.h> #include <Ice/Protocol.h> #include <Ice/HashUtil.h> +#include <Ice/Logger.h> using namespace std; using namespace Ice; using namespace IceInternal; IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const string& ho, Int po, const string& mif, - Int mttl, const Ice::ProtocolVersion& protocol, - const Ice::EncodingVersion& encoding, bool conn, const string& conId, bool co) : - EndpointI(protocol, encoding, conId), + Int mttl, bool conn, const string& conId, bool co) : + EndpointI(conId), _instance(instance), _host(ho), _port(po), @@ -37,7 +37,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin } IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const string& str, bool oaEndpoint) : - EndpointI(Ice::currentProtocol, instance->defaultsAndOverrides()->defaultEncoding, ""), + EndpointI(""), _instance(instance), _port(0), _mcastTtl(-1), @@ -157,6 +157,14 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin } const_cast<bool&>(_compress) = true; } + else if(option == "-v") + { + _instance->initializationData().logger->warning("deprecated udp endpoint option: -v"); + } + else if(option == "-e") + { + _instance->initializationData().logger->warning("deprecated udp endpoint option: -e"); + } else if(option == "--interface") { if(argument.empty()) @@ -185,7 +193,9 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin } else { - parseOption(option, argument, "udp", str); + Ice::EndpointParseException ex(__FILE__, __LINE__); + ex.str = "unknown option `" + option + "' in endpoint `udp " + str + "'"; + throw ex; } } @@ -218,8 +228,14 @@ IceInternal::UdpEndpointI::UdpEndpointI(BasicStream* s) : s->startReadEncaps(); s->read(const_cast<string&>(_host), false); s->read(const_cast<Int&>(_port)); - s->read(const_cast<Ice::ProtocolVersion&>(_protocol)); - s->read(const_cast<Ice::EncodingVersion&>(_encoding)); + if(s->getReadEncoding() == Ice::Encoding_1_0) + { + Ice::Byte b; + s->read(b); + s->read(b); + s->read(b); + s->read(b); + } // Not transmitted. //s->read(const_cast<bool&>(_connect)); s->read(const_cast<bool&>(_compress)); @@ -233,8 +249,11 @@ IceInternal::UdpEndpointI::streamWrite(BasicStream* s) const s->startWriteEncaps(); s->write(_host, false); s->write(_port); - s->write(_protocol); - s->write(_encoding); + if(s->getWriteEncoding() == Ice::Encoding_1_0) + { + s->write(Ice::Protocol_1_0); + s->write(Ice::Encoding_1_0); + } // Not transmitted. //s->write(_connect); s->write(_compress); @@ -255,16 +274,6 @@ IceInternal::UdpEndpointI::toString() const s << "udp"; - if(_protocol != Ice::Protocol_1_0) - { - s << " -v " << _protocol; - } - - if(_encoding != Ice::Encoding_1_0) - { - s << " -e " << _encoding; - } - if(!_host.empty()) { s << " -h "; @@ -312,9 +321,8 @@ IceInternal::UdpEndpointI::getInfo() const { public: - InfoI(const ProtocolVersion& pv, const EncodingVersion& ev, bool comp, const string& host, Ice::Int port, - const std::string& mcastInterface, Ice::Int mcastTtl) : - UDPEndpointInfo(pv, ev, -1, comp, host, port, mcastInterface, mcastTtl) + InfoI(bool comp, const string& host, Ice::Int port, const std::string& mcastInterface, Ice::Int mcastTtl) : + UDPEndpointInfo(-1, comp, host, port, mcastInterface, mcastTtl) { } @@ -337,7 +345,7 @@ IceInternal::UdpEndpointI::getInfo() const } }; - return new InfoI(_protocol, _encoding, _compress, _host, _port, _mcastInterface, _mcastTtl); + return new InfoI(_compress, _host, _port, _mcastInterface, _mcastTtl); } Short @@ -373,8 +381,7 @@ IceInternal::UdpEndpointI::connectionId(const string& connectionId) const } else { - return new UdpEndpointI(_instance, _host, _port, _mcastInterface, _mcastTtl, _protocol, _encoding, _connect, - connectionId, _compress); + return new UdpEndpointI(_instance, _host, _port, _mcastInterface, _mcastTtl, _connect, connectionId, _compress); } } @@ -393,8 +400,7 @@ IceInternal::UdpEndpointI::compress(bool compress) const } else { - return new UdpEndpointI(_instance, _host, _port, _mcastInterface, _mcastTtl, _protocol, _encoding, _connect, - _connectionId, compress); + return new UdpEndpointI(_instance, _host, _port, _mcastInterface, _mcastTtl, _connect, _connectionId, compress); } } @@ -414,8 +420,8 @@ TransceiverPtr IceInternal::UdpEndpointI::transceiver(EndpointIPtr& endp) const { UdpTransceiver* p = new UdpTransceiver(_instance, _host, _port, _mcastInterface, _connect); - endp = new UdpEndpointI(_instance, _host, p->effectivePort(), _mcastInterface, _mcastTtl, _protocol, _encoding, - _connect, _connectionId, _compress); + endp = new UdpEndpointI(_instance, _host, p->effectivePort(), _mcastInterface, _mcastTtl, _connect, _connectionId, + _compress); return p; } @@ -451,8 +457,8 @@ IceInternal::UdpEndpointI::expand() const { for(vector<string>::const_iterator p = hosts.begin(); p != hosts.end(); ++p) { - endps.push_back(new UdpEndpointI(_instance, *p, _port, _mcastInterface, _mcastTtl, _protocol, _encoding, - _connect, _connectionId, _compress)); + endps.push_back(new UdpEndpointI(_instance, *p, _port, _mcastInterface, _mcastTtl, _connect, _connectionId, + _compress)); } } return endps; @@ -483,16 +489,6 @@ IceInternal::UdpEndpointI::operator==(const LocalObject& r) const return true; } - if(_protocol != p->_protocol) - { - return false; - } - - if(_encoding != p->_encoding) - { - return false; - } - if(_host != p->_host) { return false; @@ -550,24 +546,6 @@ IceInternal::UdpEndpointI::operator<(const LocalObject& r) const return false; } - if(_protocol < p->_protocol) - { - return true; - } - else if(p->_protocol < _protocol) - { - return false; - } - - if(_encoding < p->_encoding) - { - return true; - } - else if(p->_encoding < _encoding) - { - return false; - } - if(_host < p->_host) { return true; @@ -644,10 +622,6 @@ IceInternal::UdpEndpointI::hashInit() const hashAdd(h, _mcastInterface); hashAdd(h, _mcastTtl); hashAdd(h, _connect); - hashAdd(h, _protocol.major); - hashAdd(h, _protocol.minor); - hashAdd(h, _encoding.major); - hashAdd(h, _encoding.minor); hashAdd(h, _connectionId); hashAdd(h, _compress); return h; @@ -659,8 +633,7 @@ IceInternal::UdpEndpointI::connectors(const vector<Address>& addresses) const vector<ConnectorPtr> connectors; for(unsigned int i = 0; i < addresses.size(); ++i) { - connectors.push_back(new UdpConnector(_instance, addresses[i], _mcastInterface, _mcastTtl, _protocol, _encoding, - _connectionId)); + connectors.push_back(new UdpConnector(_instance, addresses[i], _mcastInterface, _mcastTtl, _connectionId)); } return connectors; } diff --git a/cpp/src/Ice/UdpEndpointI.h b/cpp/src/Ice/UdpEndpointI.h index dccdf28e796..765396cc436 100644 --- a/cpp/src/Ice/UdpEndpointI.h +++ b/cpp/src/Ice/UdpEndpointI.h @@ -22,8 +22,8 @@ class UdpEndpointI : public EndpointI { public: - UdpEndpointI(const InstancePtr&, const std::string&, Ice::Int, const std::string&, Ice::Int, - const Ice::ProtocolVersion&, const Ice::EncodingVersion&, bool, const std::string&, bool); + UdpEndpointI(const InstancePtr&, const std::string&, Ice::Int, const std::string&, Ice::Int, bool, + const std::string&, bool); UdpEndpointI(const InstancePtr&, const std::string&, bool); UdpEndpointI(BasicStream*); diff --git a/cpp/src/IceSSL/ConnectorI.cpp b/cpp/src/IceSSL/ConnectorI.cpp index 8c9857880fa..c881e5574f6 100644 --- a/cpp/src/IceSSL/ConnectorI.cpp +++ b/cpp/src/IceSSL/ConnectorI.cpp @@ -86,16 +86,6 @@ IceSSL::ConnectorI::operator==(const IceInternal::Connector& r) const return false; } - if(_protocol != p->_protocol) - { - return false; - } - - if(_encoding != p->_encoding) - { - return false; - } - if(_connectionId != p->_connectionId) { return false; @@ -128,24 +118,6 @@ IceSSL::ConnectorI::operator<(const IceInternal::Connector& r) const return false; } - if(_protocol < p->_protocol) - { - return true; - } - else if(p->_protocol < _protocol) - { - return false; - } - - if(_encoding < p->_encoding) - { - return true; - } - else if(p->_encoding < _encoding) - { - return false; - } - if(_connectionId < p->_connectionId) { return true; @@ -159,15 +131,12 @@ IceSSL::ConnectorI::operator<(const IceInternal::Connector& r) const } IceSSL::ConnectorI::ConnectorI(const InstancePtr& instance, const string& host, const struct sockaddr_storage& addr, - Ice::Int timeout, const Ice::ProtocolVersion& protocol, - const Ice::EncodingVersion& encoding, const string& connectionId) : + Ice::Int timeout, const string& connectionId) : _instance(instance), _logger(instance->communicator()->getLogger()), _host(host), _addr(addr), _timeout(timeout), - _protocol(protocol), - _encoding(encoding), _connectionId(connectionId) { } diff --git a/cpp/src/IceSSL/ConnectorI.h b/cpp/src/IceSSL/ConnectorI.h index 5e00e714678..8a32689aeb7 100644 --- a/cpp/src/IceSSL/ConnectorI.h +++ b/cpp/src/IceSSL/ConnectorI.h @@ -42,8 +42,7 @@ public: private: - ConnectorI(const InstancePtr&, const std::string&, const struct sockaddr_storage&, Ice::Int, - const Ice::ProtocolVersion&, const Ice::EncodingVersion&, const std::string&); + ConnectorI(const InstancePtr&, const std::string&, const struct sockaddr_storage&, Ice::Int, const std::string&); virtual ~ConnectorI(); friend class EndpointI; @@ -52,8 +51,6 @@ private: const std::string _host; struct sockaddr_storage _addr; const Ice::Int _timeout; - const Ice::ProtocolVersion _protocol; - const Ice::EncodingVersion _encoding; const std::string _connectionId; }; diff --git a/cpp/src/IceSSL/EndpointI.cpp b/cpp/src/IceSSL/EndpointI.cpp index 5c15d89fdd3..a433b3259d1 100644 --- a/cpp/src/IceSSL/EndpointI.cpp +++ b/cpp/src/IceSSL/EndpointI.cpp @@ -23,10 +23,9 @@ using namespace std; using namespace Ice; using namespace IceSSL; -IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& ho, Int po, Int ti, - const Ice::ProtocolVersion& protocol, const Ice::EncodingVersion& encoding, - const string& conId, bool co) : - IceInternal::EndpointI(protocol, encoding, conId), +IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& ho, Int po, Int ti, const string& conId, + bool co) : + IceInternal::EndpointI(conId), _instance(instance), _host(ho), _port(po), @@ -36,7 +35,7 @@ IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& ho, Int } IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& str, bool oaEndpoint) : - IceInternal::EndpointI(Ice::currentProtocol, instance->defaultEncoding(), ""), + IceInternal::EndpointI(""), _instance(instance), _port(0), _timeout(-1), @@ -156,7 +155,9 @@ IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& str, boo default: { - parseOption(option, argument, "ssl", str); + Ice::EndpointParseException ex(__FILE__, __LINE__); + ex.str = "unknown option `" + option + "' in endpoint `ssl " + str + "'"; + throw ex; } } } @@ -191,16 +192,6 @@ IceSSL::EndpointI::EndpointI(const InstancePtr& instance, IceInternal::BasicStre s->read(const_cast<Int&>(_port)); s->read(const_cast<Int&>(_timeout)); s->read(const_cast<bool&>(_compress)); - if(s->getReadEncoding() > Ice::Encoding_1_0) - { - s->read(const_cast<Ice::ProtocolVersion&>(_protocol)); - s->read(const_cast<Ice::EncodingVersion&>(_encoding)); - } - else - { - const_cast<ProtocolVersion&>(_protocol) = Ice::Protocol_1_0; - const_cast<EncodingVersion&>(_encoding) = Ice::Encoding_1_0; - } s->endReadEncaps(); } @@ -213,11 +204,6 @@ IceSSL::EndpointI::streamWrite(IceInternal::BasicStream* s) const s->write(_port); s->write(_timeout); s->write(_compress); - if(s->getWriteEncoding() > Ice::Encoding_1_0) - { - s->write(_protocol); - s->write(_encoding); - } s->endWriteEncaps(); } @@ -234,16 +220,6 @@ IceSSL::EndpointI::toString() const ostringstream s; s << "ssl"; - if(_protocol != Ice::Protocol_1_0) - { - s << " -v " << _protocol; - } - - if(_encoding != Ice::Encoding_1_0) - { - s << " -e " << _encoding; - } - if(!_host.empty()) { s << " -h "; @@ -278,8 +254,7 @@ IceSSL::EndpointI::getInfo() const { public: - InfoI(const ProtocolVersion& pv, const EncodingVersion& ev, Int to, bool comp, const string& host, Int port) : - IceSSL::EndpointInfo(pv, ev, to, comp, host, port) + InfoI(Int to, bool comp, const string& host, Int port) : IceSSL::EndpointInfo(to, comp, host, port) { } @@ -301,7 +276,7 @@ IceSSL::EndpointI::getInfo() const return true; } }; - return new InfoI(_protocol, _encoding, _timeout, _compress, _host, _port); + return new InfoI(_timeout, _compress, _host, _port); } Short @@ -331,7 +306,7 @@ IceSSL::EndpointI::timeout(Int timeout) const } else { - return new EndpointI(_instance, _host, _port, timeout, _protocol, _encoding, _connectionId, _compress); + return new EndpointI(_instance, _host, _port, timeout, _connectionId, _compress); } } @@ -344,7 +319,7 @@ IceSSL::EndpointI::connectionId(const string& connectionId) const } else { - return new EndpointI(_instance, _host, _port, _timeout, _protocol, _encoding, connectionId, _compress); + return new EndpointI(_instance, _host, _port, _timeout, connectionId, _compress); } } @@ -363,7 +338,7 @@ IceSSL::EndpointI::compress(bool compress) const } else { - return new EndpointI(_instance, _host, _port, _timeout, _protocol, _encoding, _connectionId, compress); + return new EndpointI(_instance, _host, _port, _timeout, _connectionId, compress); } } @@ -402,8 +377,7 @@ IceInternal::AcceptorPtr IceSSL::EndpointI::acceptor(IceInternal::EndpointIPtr& endp, const string& adapterName) const { AcceptorI* p = new AcceptorI(_instance, adapterName, _host, _port); - endp = new EndpointI(_instance, _host, p->effectivePort(), _timeout, _protocol, _encoding, _connectionId, - _compress); + endp = new EndpointI(_instance, _host, p->effectivePort(), _timeout, _connectionId, _compress); return p; } @@ -420,8 +394,7 @@ IceSSL::EndpointI::expand() const { for(vector<string>::const_iterator p = hosts.begin(); p != hosts.end(); ++p) { - endps.push_back(new EndpointI(_instance, *p, _port, _timeout, _protocol, _encoding, _connectionId, - _compress)); + endps.push_back(new EndpointI(_instance, *p, _port, _timeout, _connectionId, _compress)); } } return endps; @@ -452,16 +425,6 @@ IceSSL::EndpointI::operator==(const Ice::LocalObject& r) const return true; } - if(_protocol != p->_protocol) - { - return false; - } - - if(_encoding != p->_encoding) - { - return false; - } - if(_host != p->_host) { return false; @@ -509,24 +472,6 @@ IceSSL::EndpointI::operator<(const Ice::LocalObject& r) const return false; } - if(_protocol < p->_protocol) - { - return true; - } - else if(p->_protocol < _protocol) - { - return false; - } - - if(_encoding < p->_encoding) - { - return true; - } - else if(p->_encoding < _encoding) - { - return false; - } - if(_host < p->_host) { return true; @@ -583,10 +528,6 @@ IceSSL::EndpointI::hashInit() const IceInternal::hashAdd(h, _host); IceInternal::hashAdd(h, _port); IceInternal::hashAdd(h, _timeout); - IceInternal::hashAdd(h, _protocol.major); - IceInternal::hashAdd(h, _protocol.minor); - IceInternal::hashAdd(h, _encoding.major); - IceInternal::hashAdd(h, _encoding.minor); IceInternal::hashAdd(h, _connectionId); IceInternal::hashAdd(h, _compress); return h; @@ -598,8 +539,7 @@ IceSSL::EndpointI::connectors(const vector<struct sockaddr_storage>& addresses) vector<IceInternal::ConnectorPtr> connectors; for(unsigned int i = 0; i < addresses.size(); ++i) { - connectors.push_back(new ConnectorI(_instance, _host, addresses[i], _timeout, _protocol, _encoding, - _connectionId)); + connectors.push_back(new ConnectorI(_instance, _host, addresses[i], _timeout, _connectionId)); } return connectors; } diff --git a/cpp/src/IceSSL/EndpointI.h b/cpp/src/IceSSL/EndpointI.h index 4eec180dfa8..14787ae1b0a 100644 --- a/cpp/src/IceSSL/EndpointI.h +++ b/cpp/src/IceSSL/EndpointI.h @@ -22,8 +22,7 @@ class EndpointI : public IceInternal::EndpointI { public: - EndpointI(const InstancePtr&, const std::string&, Ice::Int, Ice::Int, const Ice::ProtocolVersion&, - const Ice::EncodingVersion&, const std::string&, bool); + EndpointI(const InstancePtr&, const std::string&, Ice::Int, Ice::Int, const std::string&, bool); EndpointI(const InstancePtr&, const std::string&, bool); EndpointI(const InstancePtr&, IceInternal::BasicStream*); diff --git a/cpp/test/Ice/info/AllTests.cpp b/cpp/test/Ice/info/AllTests.cpp index b7527f182fb..8640bc0d291 100644 --- a/cpp/test/Ice/info/AllTests.cpp +++ b/cpp/test/Ice/info/AllTests.cpp @@ -20,7 +20,7 @@ allTests(const Ice::CommunicatorPtr& communicator) { cout << "testing proxy endpoint information... " << flush; { - Ice::ObjectPrx p1 = communicator->stringToProxy("test -t:default -v 1.4 -e 1.3 -h tcphost -p 10000 -t 1200 -z:" + Ice::ObjectPrx p1 = communicator->stringToProxy("test -t:default -h tcphost -p 10000 -t 1200 -z:" "udp -h udphost -p 10001 --interface eth0 --ttl 5:" "opaque -e 1.8 -t 100 -v ABCD"); @@ -28,14 +28,6 @@ allTests(const Ice::CommunicatorPtr& communicator) Ice::IPEndpointInfoPtr ipEndpoint = Ice::IPEndpointInfoPtr::dynamicCast(endps[0]->getInfo()); test(ipEndpoint); - Ice::ProtocolVersion pv; - pv.major = 1; - pv.minor = 4; - test(ipEndpoint->protocol == pv); - Ice::EncodingVersion ev; - ev.major = 1; - ev.minor = 3; - test(ipEndpoint->encoding == ev); test(ipEndpoint->host == "tcphost"); test(ipEndpoint->port == 10000); test(ipEndpoint->timeout == 1200); @@ -48,8 +40,6 @@ allTests(const Ice::CommunicatorPtr& communicator) Ice::UDPEndpointInfoPtr udpEndpoint = Ice::UDPEndpointInfoPtr::dynamicCast(endps[1]->getInfo()); test(udpEndpoint); - test(udpEndpoint->protocol == Ice::currentProtocol); - test(udpEndpoint->encoding == Ice::currentEncoding); test(udpEndpoint->host == "udphost"); test(udpEndpoint->port == 10001); test(udpEndpoint->mcastInterface == "eth0"); diff --git a/cpp/test/Ice/info/TestI.cpp b/cpp/test/Ice/info/TestI.cpp index 306b6493690..183d39018f9 100644 --- a/cpp/test/Ice/info/TestI.cpp +++ b/cpp/test/Ice/info/TestI.cpp @@ -48,10 +48,6 @@ TestI::getEndpointInfoAsContext(const Ice::Current& c) if(Ice::UDPEndpointInfoPtr::dynamicCast(ipinfo)) { Ice::UDPEndpointInfoPtr udp = Ice::UDPEndpointInfoPtr::dynamicCast(ipinfo); - ctx["protocolMajor"] = udp->protocol.major; - ctx["protocolMinor"] = udp->protocol.minor; - ctx["encodingMajor"] = udp->encoding.major; - ctx["encodingMinor"] = udp->encoding.minor; ctx["mcastInterface"] = udp->mcastInterface; ctx["mcastTtl"] = udp->mcastTtl; } diff --git a/cpp/test/Ice/location/AllTests.cpp b/cpp/test/Ice/location/AllTests.cpp index 1c6a73461d2..53751798b20 100644 --- a/cpp/test/Ice/location/AllTests.cpp +++ b/cpp/test/Ice/location/AllTests.cpp @@ -577,6 +577,19 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref) hello->sayHello(); cout << "ok" << endl; + cout << "testing locator encoding resolution... " << flush; + + hello = HelloPrx::checkedCast(communicator->stringToProxy("hello")); + count = locator->getRequestCount(); + communicator->stringToProxy("test@TestAdapter")->ice_encodingVersion(Ice::Encoding_1_1)->ice_ping(); + test(count == locator->getRequestCount()); + communicator->stringToProxy("test@TestAdapter10")->ice_encodingVersion(Ice::Encoding_1_0)->ice_ping(); + test(++count == locator->getRequestCount()); + communicator->stringToProxy("test -e 1.0@TestAdapter10-2")->ice_ping(); + test(++count == locator->getRequestCount()); + + cout << "ok" << endl; + cout << "shutdown server... " << flush; obj->shutdown(); cout << "ok" << endl; diff --git a/cpp/test/Ice/location/ServerLocator.cpp b/cpp/test/Ice/location/ServerLocator.cpp index 75f403e83fc..efb4e9b71b7 100644 --- a/cpp/test/Ice/location/ServerLocator.cpp +++ b/cpp/test/Ice/location/ServerLocator.cpp @@ -9,6 +9,7 @@ #include <Ice/Ice.h> #include <Ice/BuiltinSequences.h> +#include <TestCommon.h> #include <ServerLocator.h> using namespace std; @@ -117,6 +118,13 @@ ServerLocator::findAdapterById_async(const Ice::AMD_Locator_findAdapterByIdPtr& const Ice::Current& current) const { ++const_cast<int&>(_requestCount); + if(id == "TestAdapter10" || id == "TestAdapter10-2") + { + test(current.encoding == Ice::Encoding_1_0); + response->ice_response(_registry->getAdapter("TestAdapter")); + return; + } + // We add a small delay to make sure locator request queuing gets tested when // running the test on a fast machine IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1)); diff --git a/cpp/test/Ice/metrics/AllTests.cpp b/cpp/test/Ice/metrics/AllTests.cpp index 215dab04312..3c1bfa42822 100644 --- a/cpp/test/Ice/metrics/AllTests.cpp +++ b/cpp/test/Ice/metrics/AllTests.cpp @@ -488,7 +488,8 @@ allTests(const Ice::CommunicatorPtr& communicator) cm2 = IceMX::ConnectionMetricsPtr::dynamicCast(clientMetrics->getMetricsView("View", timestamp)["Connection"][0]); sm2 = IceMX::ConnectionMetricsPtr::dynamicCast(serverMetrics->getMetricsView("View", timestamp)["Connection"][0]); - test(cm2->sentBytes - cm1->sentBytes == requestSz + static_cast<int>(bs.size()) + 4); // 4 is for the seq variable size + // 4 is for the seq variable size + test(cm2->sentBytes - cm1->sentBytes == requestSz + static_cast<int>(bs.size()) + 4); test(cm2->receivedBytes - cm1->receivedBytes == replySz); test(sm2->receivedBytes - sm1->receivedBytes == requestSz + static_cast<int>(bs.size()) + 4); if(sm2->sentBytes - sm1->sentBytes != replySz) @@ -498,7 +499,8 @@ allTests(const Ice::CommunicatorPtr& communicator) // to the operation is sent and getMetricsView can be dispatched before the metric is really // updated. IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(100)); - sm2 = IceMX::ConnectionMetricsPtr::dynamicCast(serverMetrics->getMetricsView("View", timestamp)["Connection"][0]); + sm2 = IceMX::ConnectionMetricsPtr::dynamicCast( + serverMetrics->getMetricsView("View", timestamp)["Connection"][0]); } test(sm2->sentBytes - sm1->sentBytes == replySz); @@ -511,7 +513,8 @@ allTests(const Ice::CommunicatorPtr& communicator) cm2 = IceMX::ConnectionMetricsPtr::dynamicCast(clientMetrics->getMetricsView("View", timestamp)["Connection"][0]); sm2 = IceMX::ConnectionMetricsPtr::dynamicCast(serverMetrics->getMetricsView("View", timestamp)["Connection"][0]); - test(cm2->sentBytes - cm1->sentBytes == requestSz + static_cast<int>(bs.size()) + 4); // 4 is for the seq variable size + // 4 is for the seq variable size + test(cm2->sentBytes - cm1->sentBytes == requestSz + static_cast<int>(bs.size()) + 4); test(cm2->receivedBytes - cm1->receivedBytes == replySz); test(sm2->receivedBytes - sm1->receivedBytes == requestSz + static_cast<int>(bs.size()) + 4); if(sm2->sentBytes - sm1->sentBytes != replySz) @@ -521,7 +524,8 @@ allTests(const Ice::CommunicatorPtr& communicator) // to the operation is sent and getMetricsView can be dispatched before the metric is really // updated. IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(100)); - sm2 = IceMX::ConnectionMetricsPtr::dynamicCast(serverMetrics->getMetricsView("View", timestamp)["Connection"][0]); + sm2 = IceMX::ConnectionMetricsPtr::dynamicCast( + serverMetrics->getMetricsView("View", timestamp)["Connection"][0]); } test(sm2->sentBytes - sm1->sentBytes == replySz); @@ -574,7 +578,8 @@ allTests(const Ice::CommunicatorPtr& communicator) cm1 = IceMX::ConnectionMetricsPtr::dynamicCast(clientMetrics->getMetricsView("View", timestamp)["Connection"][0]); while(true) { - sm1 = IceMX::ConnectionMetricsPtr::dynamicCast(serverMetrics->getMetricsView("View", timestamp)["Connection"][0]); + sm1 = IceMX::ConnectionMetricsPtr::dynamicCast( + serverMetrics->getMetricsView("View", timestamp)["Connection"][0]); if(sm1-> failures >= 2) { break; @@ -593,14 +598,11 @@ allTests(const Ice::CommunicatorPtr& communicator) testAttribute(clientMetrics, clientProps, update, "Connection", "parent", "Communicator"); //testAttribute(clientMetrics, clientProps, update, "Connection", "id", ""); - testAttribute(clientMetrics, clientProps, update, "Connection", "endpoint", - "tcp -e 1.1 -h 127.0.0.1 -p 12010 -t 500"); + testAttribute(clientMetrics, clientProps, update, "Connection", "endpoint", "tcp -h 127.0.0.1 -p 12010 -t 500"); testAttribute(clientMetrics, clientProps, update, "Connection", "endpointType", "1"); testAttribute(clientMetrics, clientProps, update, "Connection", "endpointIsDatagram", "false"); testAttribute(clientMetrics, clientProps, update, "Connection", "endpointIsSecure", "false"); - testAttribute(clientMetrics, clientProps, update, "Connection", "endpointProtocolVersion", "1.0"); - testAttribute(clientMetrics, clientProps, update, "Connection", "endpointEncodingVersion", "1.1"); testAttribute(clientMetrics, clientProps, update, "Connection", "endpointTimeout", "500"); testAttribute(clientMetrics, clientProps, update, "Connection", "endpointCompress", "false"); testAttribute(clientMetrics, clientProps, update, "Connection", "endpointHost", "127.0.0.1"); @@ -660,13 +662,11 @@ allTests(const Ice::CommunicatorPtr& communicator) testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "parent", "Communicator", c); testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "id", "127.0.0.1:12010", c); testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpoint", - "tcp -e 1.1 -h 127.0.0.1 -p 12010", c); + "tcp -h 127.0.0.1 -p 12010", c); testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointType", "1", c); testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointIsDatagram", "false", c); testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointIsSecure", "false", c); - testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointProtocolVersion", "1.0", c); - testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointEncodingVersion", "1.1", c); testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointTimeout", "-1", c); testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointCompress", "false", c); testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointHost", "127.0.0.1", c); @@ -691,7 +691,7 @@ allTests(const Ice::CommunicatorPtr& communicator) test(clientMetrics->getMetricsView("View", timestamp)["EndpointLookup"].size() == 1); m1 = clientMetrics->getMetricsView("View", timestamp)["EndpointLookup"][0]; - test(m1->current <= 1 && m1->total == 1 && m1->id == "tcp -e 1.1 -h localhost -p 12010"); + test(m1->current <= 1 && m1->total == 1 && m1->id == "tcp -h localhost -p 12010"); prx->ice_getConnection()->close(false); @@ -709,22 +709,20 @@ allTests(const Ice::CommunicatorPtr& communicator) } test(clientMetrics->getMetricsView("View", timestamp)["EndpointLookup"].size() == 2); m1 = clientMetrics->getMetricsView("View", timestamp)["EndpointLookup"][1]; - test(m1->id == "tcp -e 1.1 -h unknownfoo.zeroc.com -p 12010" && m1->total == 2 && m1->failures == 2); + test(m1->id == "tcp -h unknownfoo.zeroc.com -p 12010" && m1->total == 2 && m1->failures == 2); checkFailure(clientMetrics, "EndpointLookup", m1->id, "Ice::DNSException", 2); c = Connect(prx); testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "parent", "Communicator", c); - testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "id", "tcp -e 1.1 -h localhost -p 12010", c); + testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "id", "tcp -h localhost -p 12010", c); testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpoint", - "tcp -e 1.1 -h localhost -p 12010", c); + "tcp -h localhost -p 12010", c); testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointType", "1", c); testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointIsDatagram", "false", c); testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointIsSecure", "false", c); - testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointProtocolVersion", "1.0", c); - testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointEncodingVersion", "1.1", c); testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointTimeout", "-1", c); testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointCompress", "false", c); testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointHost", "localhost", c); @@ -806,14 +804,12 @@ allTests(const Ice::CommunicatorPtr& communicator) testAttribute(serverMetrics, serverProps, update, "Dispatch", "parent", "TestAdapter", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "id", "metrics [op]", op); - testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpoint", "tcp -e 1.1 -h 127.0.0.1 -p 12010", op); + testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpoint", "tcp -h 127.0.0.1 -p 12010", op); //testAttribute(serverMetrics, serverProps, update, "Dispatch", "connection", "", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointType", "1", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointIsDatagram", "false", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointIsSecure", "false", op); - testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointProtocolVersion", "1.0", op); - testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointEncodingVersion", "1.1", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointTimeout", "-1", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointCompress", "false", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointHost", "127.0.0.1", op); @@ -997,7 +993,7 @@ allTests(const Ice::CommunicatorPtr& communicator) testAttribute(clientMetrics, clientProps, update, "Invocation", "parent", "Communicator", op); testAttribute(clientMetrics, clientProps, update, "Invocation", "id", - "metrics -t:tcp -e 1.1 -h 127.0.0.1 -p 12010 [op]", op); + "metrics -t -e 1.1:tcp -h 127.0.0.1 -p 12010 [op]", op); testAttribute(clientMetrics, clientProps, update, "Invocation", "operation", "op", op); testAttribute(clientMetrics, clientProps, update, "Invocation", "identity", "metrics", op); @@ -1005,7 +1001,7 @@ allTests(const Ice::CommunicatorPtr& communicator) testAttribute(clientMetrics, clientProps, update, "Invocation", "encoding", "1.1", op); testAttribute(clientMetrics, clientProps, update, "Invocation", "mode", "twoway", op); testAttribute(clientMetrics, clientProps, update, "Invocation", "proxy", - "metrics -t:tcp -e 1.1 -h 127.0.0.1 -p 12010", op); + "metrics -t -e 1.1:tcp -h 127.0.0.1 -p 12010", op); testAttribute(clientMetrics, clientProps, update, "Invocation", "context.entry1", "test", op); testAttribute(clientMetrics, clientProps, update, "Invocation", "context.entry2", "", op); diff --git a/cpp/test/Ice/proxy/AllTests.cpp b/cpp/test/Ice/proxy/AllTests.cpp index 4773088850d..9f6428f111b 100644 --- a/cpp/test/Ice/proxy/AllTests.cpp +++ b/cpp/test/Ice/proxy/AllTests.cpp @@ -212,6 +212,14 @@ allTests(const Ice::CommunicatorPtr& communicator) b1 = communicator->stringToProxy("test -s"); test(b1->ice_isSecure()); + test(b1->ice_getEncodingVersion() == Ice::currentEncoding); + + b1 = communicator->stringToProxy("test -e 1.0"); + test(b1->ice_getEncodingVersion().major == 1 && b1->ice_getEncodingVersion().minor == 0); + + b1 = communicator->stringToProxy("test -e 6.5"); + test(b1->ice_getEncodingVersion().major == 6 && b1->ice_getEncodingVersion().minor == 5); + try { b1 = communicator->stringToProxy("test:tcp@adapterId"); @@ -327,31 +335,6 @@ allTests(const Ice::CommunicatorPtr& communicator) test(!b1->ice_isCollocationOptimized()); prop->setProperty(property, ""); - property = propertyPrefix + ".EncodingVersion"; - test(b1->ice_getEncodingVersion() == Ice::currentEncoding); - prop->setProperty(property, "1.0"); - b1 = communicator->propertyToProxy(propertyPrefix); - test(b1->ice_getEncodingVersion().major == 1 && b1->ice_getEncodingVersion().minor == 0); - prop->setProperty(property, "6.5"); - try - { - communicator->propertyToProxy(propertyPrefix); - test(false); - } - catch(const Ice::UnsupportedEncodingException&) - { - } - prop->setProperty(property, "1.2"); - try - { - communicator->propertyToProxy(propertyPrefix); - test(false); - } - catch(const Ice::UnsupportedEncodingException&) - { - } - prop->setProperty(property, ""); - cout << "ok" << endl; cout << "testing proxyToProperty... " << flush; @@ -382,42 +365,29 @@ allTests(const Ice::CommunicatorPtr& communicator) b1 = b1->ice_locator(Ice::LocatorPrx::uncheckedCast(locator)); Ice::PropertyDict proxyProps = communicator->proxyToProperty(b1, "Test"); - test(proxyProps.size() == 21); + test(proxyProps.size() == 18); test(proxyProps["Test"] == "test -t"); - test(proxyProps["Test.EncodingVersion"] == "1.0"); test(proxyProps["Test.CollocationOptimized"] == "1"); test(proxyProps["Test.ConnectionCached"] == "1"); test(proxyProps["Test.PreferSecure"] == "0"); test(proxyProps["Test.EndpointSelection"] == "Ordered"); test(proxyProps["Test.LocatorCacheTimeout"] == "100"); - test(proxyProps["Test.Locator"] == "locator -t"); - test(proxyProps["Test.Locator.EncodingVersion"] == Ice::encodingVersionToString(Ice::currentEncoding)); + test(proxyProps["Test.Locator"] == "locator -t -e " + Ice::encodingVersionToString(Ice::currentEncoding)); test(proxyProps["Test.Locator.CollocationOptimized"] == "1"); test(proxyProps["Test.Locator.ConnectionCached"] == "0"); test(proxyProps["Test.Locator.PreferSecure"] == "1"); test(proxyProps["Test.Locator.EndpointSelection"] == "Random"); test(proxyProps["Test.Locator.LocatorCacheTimeout"] == "300"); - test(proxyProps["Test.Locator.Router"] == "router -t"); - test(proxyProps["Test.Locator.Router.EncodingVersion"] == Ice::encodingVersionToString(Ice::currentEncoding)); + test(proxyProps["Test.Locator.Router"] == "router -t -e " + Ice::encodingVersionToString(Ice::currentEncoding)); test(proxyProps["Test.Locator.Router.CollocationOptimized"] == "0"); test(proxyProps["Test.Locator.Router.ConnectionCached"] == "1"); test(proxyProps["Test.Locator.Router.PreferSecure"] == "1"); test(proxyProps["Test.Locator.Router.EndpointSelection"] == "Random"); test(proxyProps["Test.Locator.Router.LocatorCacheTimeout"] == "200"); - try - { - Ice::EncodingVersion v = { 3, 4 }; - b1->ice_encodingVersion(v); - test(false); - } - catch(const Ice::UnsupportedEncodingException&) - { - } - cout << "ok" << endl; cout << "testing ice_getCommunicator... " << flush; @@ -653,35 +623,74 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "ok" << endl; + cout << "testing protocol versioning... " << flush; + { + Ice::OutputStreamPtr out = Ice::createOutputStream(communicator); + out->write(cl); + vector<Ice::Byte> inBytes; + out->finished(inBytes); + + // Protocol version 1.1 + inBytes[9] = 1; + inBytes[10] = 1; + + Ice::InputStreamPtr in = Ice::createInputStream(communicator, inBytes); + Test::MyClassPrx cl11; + in->read(cl11); + cl11 = cl11->ice_collocationOptimized(false); + test(cl11->ice_toString() == "test -t -p 1.1 -e 1.1:tcp -h 127.0.0.1 -p 12010"); + try + { + cl11->ice_ping(); + test(false); + } + catch(const Ice::UnsupportedProtocolException&) + { + } + try + { + cl11->end_ice_ping(cl11->begin_ice_ping()); + test(false); + } + catch(const Ice::UnsupportedProtocolException&) + { + } + try + { + cl11->ice_flushBatchRequests(); + test(false); + } + catch(const Ice::UnsupportedProtocolException&) + { + } + try + { + cl11->end_ice_flushBatchRequests(cl11->begin_ice_flushBatchRequests()); + test(false); + } + catch(const Ice::UnsupportedProtocolException&) + { + } + } + cout << "ok" << endl; + cout << "testing encoding versioning... " << flush; - string ref20 = "test:default -p 12010 -e 2.0"; + string ref20 = "test -e 2.0:default -p 12010"; Test::MyClassPrx cl20 = Test::MyClassPrx::uncheckedCast(communicator->stringToProxy(ref20)); try { cl20->ice_collocationOptimized(false)->ice_ping(); test(false); } - catch(const Ice::NoEndpointException&) + catch(const Ice::UnsupportedEncodingException&) { // Server 2.0 endpoint doesn't support 1.1 version. } - string ref10 = "test:default -p 12010 -e 1.0"; + string ref10 = "test -e 1.0:default -p 12010"; Test::MyClassPrx cl10 = Test::MyClassPrx::uncheckedCast(communicator->stringToProxy(ref10)); - try - { - cl10->ice_collocationOptimized(false)->ice_ping(); // Can't send request with 1.1 encoding on 1.0 endpoint. - test(false); - } - catch(const Ice::NoEndpointException&) - { - // Server 1.0 endpoint doesn't support 1.1 version. - } - - // Server with 1.0 endpoint supports 1.0 encoding. + cl10->ice_ping(); cl10->ice_encodingVersion(Ice::Encoding_1_0)->ice_ping(); - - // Server with 1.1 endpoint supports 1.0 encoding. cl->ice_collocationOptimized(false)->ice_encodingVersion(Ice::Encoding_1_0)->ice_ping(); try @@ -841,17 +850,13 @@ allTests(const Ice::CommunicatorPtr& communicator) } // Legal TCP endpoint expressed as opaque endpoint - Ice::ObjectPrx p1 = communicator->stringToProxy("test:opaque -e 1.0 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA=="); + Ice::ObjectPrx p1 = communicator->stringToProxy("test -e 1.1:opaque -e 1.0 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA=="); string pstr = communicator->proxyToString(p1); - test(pstr == "test -t:tcp -h 127.0.0.1 -p 12010 -t 10000"); - - // 1.1 TCP endpoint encoded with 1.1 encoding. - Ice::ObjectPrx p2 = communicator->stringToProxy("test:opaque -e 1.1 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAAEAAQE="); - test(communicator->proxyToString(p2) == "test -t:tcp -e 1.1 -h 127.0.0.1 -p 12010 -t 10000"); + test(pstr == "test -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 10000"); - // 1.0 TCP endpoint encoded with 1.1 encoding. - p2 = communicator->stringToProxy("test: opaque -t 1 -e 1.1 -v CTEyNy4wLjAuMeouAAAQJwAAAAEAAQA="); - test(communicator->proxyToString(p2) == "test -t:tcp -h 127.0.0.1 -p 12010 -t 10000"); + // Opaque endpoint encoded with 1.1 encoding. + Ice::ObjectPrx p2 = communicator->stringToProxy("test -e 1.1:opaque -e 1.1 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA=="); + test(communicator->proxyToString(p2) == "test -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 10000"); if(communicator->getProperties()->getPropertyAsInt("Ice.IPv6") == 0) { @@ -867,7 +872,7 @@ allTests(const Ice::CommunicatorPtr& communicator) } // Two legal TCP endpoints expressed as opaque endpoints - p1 = communicator->stringToProxy("test:opaque -e 1.0 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA==:opaque -e 1.0 -t 1 -v CTEyNy4wLjAuMusuAAAQJwAAAA=="); + p1 = communicator->stringToProxy("test -e 1.0:opaque -e 1.0 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA==:opaque -e 1.0 -t 1 -v CTEyNy4wLjAuMusuAAAQJwAAAA=="); pstr = communicator->proxyToString(p1); test(pstr == "test -t:tcp -h 127.0.0.1 -p 12010 -t 10000:tcp -h 127.0.0.2 -p 12011 -t 10000"); @@ -875,7 +880,7 @@ allTests(const Ice::CommunicatorPtr& communicator) // Test that an SSL endpoint and a nonsense endpoint get written // back out as an opaque endpoint. // - p1 = communicator->stringToProxy("test:opaque -e 1.0 -t 2 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -e 1.0 -t 99 -v abch"); + p1 = communicator->stringToProxy("test -e 1.0:opaque -e 1.0 -t 2 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -e 1.0 -t 99 -v abch"); pstr = communicator->proxyToString(p1); if(!ssl) { |