diff options
33 files changed, 476 insertions, 235 deletions
@@ -27,6 +27,16 @@ Changes since version 3.5.1 General Changes =============== +- Added Ice.Default.Timeout property to the set the timeout for + stringified proxy endpoint that do not have timeout explicitly set. + The default setting for the property is 60 seconds. It is also now + possible to set an infinite timeout using "-t infinite" in the + endpoint configuration. + +- Added Ice.Default.SourceAddress property and --sourceAddress + endpoint setting to control the interface used for the outgoing + connection. + - The signatures of Ice::OutputStream startSize() and endSize() have been modified. It is now necessary for the caller of startSize() to save the returned position and pass it into endSize(). diff --git a/cpp/src/Ice/DefaultsAndOverrides.cpp b/cpp/src/Ice/DefaultsAndOverrides.cpp index 8df552d9d20..fc4cf920a7f 100644 --- a/cpp/src/Ice/DefaultsAndOverrides.cpp +++ b/cpp/src/Ice/DefaultsAndOverrides.cpp @@ -110,6 +110,15 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro throw ex; } + const_cast<int&>(defaultTimeout) = + properties->getPropertyAsIntWithDefault("Ice.Default.Timeout", 60000); + if(defaultTimeout < 1 && defaultTimeout != -1) + { + InitializationException ex(__FILE__, __LINE__); + ex.reason = "invalid value for Ice.Default.Timeout: `" + properties->getProperty("Ice.Default.Timeout") + "'"; + throw ex; + } + const_cast<int&>(defaultInvocationTimeout) = properties->getPropertyAsIntWithDefault("Ice.Default.InvocationTimeout", -1); diff --git a/cpp/src/Ice/DefaultsAndOverrides.h b/cpp/src/Ice/DefaultsAndOverrides.h index 5ce55469c31..01d6ec345c7 100644 --- a/cpp/src/Ice/DefaultsAndOverrides.h +++ b/cpp/src/Ice/DefaultsAndOverrides.h @@ -33,6 +33,7 @@ public: std::string defaultProtocol; bool defaultCollocationOptimization; Ice::EndpointSelectionType defaultEndpointSelection; + int defaultTimeout; int defaultInvocationTimeout; int defaultLocatorCacheTimeout; bool defaultPreferSecure; diff --git a/cpp/src/Ice/IPEndpointI.h b/cpp/src/Ice/IPEndpointI.h index 06cb405e5da..f63a137f3b3 100644 --- a/cpp/src/Ice/IPEndpointI.h +++ b/cpp/src/Ice/IPEndpointI.h @@ -76,7 +76,7 @@ public: using EndpointI::connectors; using EndpointI::connectionId; - void initWithOptions(std::vector<std::string>&, bool); + virtual void initWithOptions(std::vector<std::string>&, bool); protected: diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp index 44c32e9e96b..78e3ce143ec 100644 --- a/cpp/src/Ice/PropertyNames.cpp +++ b/cpp/src/Ice/PropertyNames.cpp @@ -106,6 +106,7 @@ const IceInternal::Property IcePropsData[] = IceInternal::Property("Ice.Default.Router", false, 0), IceInternal::Property("Ice.Default.SlicedFormat", false, 0), IceInternal::Property("Ice.Default.SourceAddress", false, 0), + IceInternal::Property("Ice.Default.Timeout", false, 0), IceInternal::Property("Ice.IPv4", false, 0), IceInternal::Property("Ice.IPv6", false, 0), IceInternal::Property("Ice.EventLog.Source", false, 0), diff --git a/cpp/src/Ice/ProtocolInstance.cpp b/cpp/src/Ice/ProtocolInstance.cpp index b643a0c7020..363de0cb1b0 100644 --- a/cpp/src/Ice/ProtocolInstance.cpp +++ b/cpp/src/Ice/ProtocolInstance.cpp @@ -72,6 +72,13 @@ IceInternal::ProtocolInstance::defaultEncoding() const return _instance->defaultsAndOverrides()->defaultEncoding; } +int +IceInternal::ProtocolInstance::defaultTimeout() const +{ + return _instance->defaultsAndOverrides()->defaultTimeout; +} + + NetworkProxyPtr IceInternal::ProtocolInstance::networkProxy() const { diff --git a/cpp/src/Ice/ProtocolInstance.h b/cpp/src/Ice/ProtocolInstance.h index 6a356af9a87..9a0ebec59b9 100644 --- a/cpp/src/Ice/ProtocolInstance.h +++ b/cpp/src/Ice/ProtocolInstance.h @@ -65,6 +65,7 @@ public: const Ice::EncodingVersion& defaultEncoding() const; NetworkProxyPtr networkProxy() const; size_t messageSizeMax() const; + int defaultTimeout() const; std::vector<ConnectorPtr> resolve(const std::string&, int, Ice::EndpointSelectionType, const IPEndpointIPtr&) const; void resolve(const std::string&, int, Ice::EndpointSelectionType, const IPEndpointIPtr&, diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp index 7d593d6203a..a47c956c6c2 100644 --- a/cpp/src/Ice/TcpEndpointI.cpp +++ b/cpp/src/Ice/TcpEndpointI.cpp @@ -32,7 +32,7 @@ IceInternal::TcpEndpointI::TcpEndpointI(const ProtocolInstancePtr& instance, con IceInternal::TcpEndpointI::TcpEndpointI(const ProtocolInstancePtr& instance) : IPEndpointI(instance), - _timeout(-1), + _timeout(-2), _compress(false) { } @@ -164,7 +164,11 @@ IceInternal::TcpEndpointI::options() const s << IPEndpointI::options(); - if(_timeout != -1) + if(_timeout == -1) + { + s << " -t infinite"; + } + else { s << " -t " << _timeout; } @@ -277,6 +281,17 @@ IceInternal::TcpEndpointI::fillEndpointInfo(IPEndpointInfo* info) const } } +void +IceInternal::TcpEndpointI::initWithOptions(vector<string>& args, bool oaEndpoint) +{ + IPEndpointI::initWithOptions(args, oaEndpoint); + + if(_timeout == -2) + { + const_cast<Int&>(_timeout) = _instance->defaultTimeout(); + } +} + bool IceInternal::TcpEndpointI::checkOption(const string& option, const string& argument, const string& endpoint) { @@ -295,12 +310,20 @@ IceInternal::TcpEndpointI::checkOption(const string& option, const string& argum ex.str = "no argument provided for -t option in endpoint " + endpoint; throw ex; } - istringstream t(argument); - if(!(t >> const_cast<Int&>(_timeout)) || !t.eof()) + + if(argument == "infinite") + { + const_cast<Int&>(_timeout) = -1; + } + else { - EndpointParseException ex(__FILE__, __LINE__); - ex.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; - throw ex; + istringstream t(argument); + if(!(t >> const_cast<Int&>(_timeout)) || !t.eof() || _timeout < 1) + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; + throw ex; + } } return true; } diff --git a/cpp/src/Ice/TcpEndpointI.h b/cpp/src/Ice/TcpEndpointI.h index 3dba15da6f4..0e94a1d1de7 100644 --- a/cpp/src/Ice/TcpEndpointI.h +++ b/cpp/src/Ice/TcpEndpointI.h @@ -50,6 +50,7 @@ protected: virtual void streamWriteImpl(BasicStream*) const; virtual void hashInit(Ice::Int&) const; virtual void fillEndpointInfo(Ice::IPEndpointInfo*) const; + virtual void initWithOptions(std::vector<std::string>&, bool); virtual bool checkOption(const std::string&, const std::string&, const std::string&); virtual ConnectorPtr createConnector(const Address&, const NetworkProxyPtr&) const; diff --git a/cpp/src/Ice/winrt/StreamEndpointI.cpp b/cpp/src/Ice/winrt/StreamEndpointI.cpp index b58f9e826ce..5bb59dea33b 100644 --- a/cpp/src/Ice/winrt/StreamEndpointI.cpp +++ b/cpp/src/Ice/winrt/StreamEndpointI.cpp @@ -72,7 +72,7 @@ IceInternal::StreamEndpointI::StreamEndpointI(const ProtocolInstancePtr& instanc IceInternal::StreamEndpointI::StreamEndpointI(const ProtocolInstancePtr& instance) : IPEndpointI(instance), - _timeout(-1), + _timeout(-2), _compress(false) { } @@ -193,7 +193,11 @@ IceInternal::StreamEndpointI::options() const s << IPEndpointI::options(); - if(_timeout != -1) + if(_timeout == -1) + { + s << " -t infinite"; + } + else { s << " -t " << _timeout; } @@ -294,6 +298,17 @@ IceInternal::StreamEndpointI::hashInit(Ice::Int& h) const hashAdd(h, _compress); } +void +IceInternal::StreamEndpointI::initWithOptions(vector<string>& args, bool oaEndpoint) +{ + IPEndpointI::initWithOptions(args, oaEndpoint); + + if(_timeout == -2) + { + const_cast<Int&>(_timeout) = _instance->defaultTimeout(); + } +} + bool IceInternal::StreamEndpointI::checkOption(const string& option, const string& argument, const string& endpoint) { @@ -312,12 +327,20 @@ IceInternal::StreamEndpointI::checkOption(const string& option, const string& ar ex.str = "no argument provided for -t option in endpoint " + endpoint; throw ex; } - istringstream t(argument); - if(!(t >> const_cast<Int&>(_timeout)) || !t.eof()) + + if(argument == "infinite") { - EndpointParseException ex(__FILE__, __LINE__); - ex.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; - throw ex; + const_cast<Int&>(_timeout) = -1; + } + else + { + istringstream t(argument); + if(!(t >> const_cast<Int&>(_timeout)) || !t.eof() || _timeout < 1) + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; + throw ex; + } } return true; } diff --git a/cpp/src/Ice/winrt/StreamEndpointI.h b/cpp/src/Ice/winrt/StreamEndpointI.h index 59ebc442417..58de59fd410 100644 --- a/cpp/src/Ice/winrt/StreamEndpointI.h +++ b/cpp/src/Ice/winrt/StreamEndpointI.h @@ -49,6 +49,7 @@ protected: virtual void streamWriteImpl(BasicStream*) const; virtual void hashInit(Ice::Int&) const; + virtual void initWithOptions(std::vector<std::string>&, bool); virtual bool checkOption(const std::string&, const std::string&, const std::string&); virtual ConnectorPtr createConnector(const Address&, const NetworkProxyPtr&) const; diff --git a/cpp/src/IceSSL/EndpointI.cpp b/cpp/src/IceSSL/EndpointI.cpp index 7782e11f517..aab9bb2efc6 100644 --- a/cpp/src/IceSSL/EndpointI.cpp +++ b/cpp/src/IceSSL/EndpointI.cpp @@ -33,7 +33,7 @@ IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& ho, Int IceSSL::EndpointI::EndpointI(const InstancePtr& instance) : IceInternal::IPEndpointI(instance), _instance(instance), - _timeout(-1), + _timeout(-2), _compress(false) { } @@ -165,7 +165,11 @@ IceSSL::EndpointI::options() const ostringstream s; s << IPEndpointI::options(); - if(_timeout != -1) + if(_timeout == -1) + { + s << " -t infinite"; + } + else { s << " -t " << _timeout; } @@ -278,6 +282,17 @@ IceSSL::EndpointI::fillEndpointInfo(IPEndpointInfo* info) const } } +void +IceSSL::EndpointI::initWithOptions(vector<string>& args, bool oaEndpoint) +{ + IPEndpointI::initWithOptions(args, oaEndpoint); + + if(_timeout == -2) + { + const_cast<Int&>(_timeout) = _instance->defaultTimeout(); + } +} + bool IceSSL::EndpointI::checkOption(const string& option, const string& argument, const string& endpoint) { @@ -296,12 +311,20 @@ IceSSL::EndpointI::checkOption(const string& option, const string& argument, con ex.str = "no argument provided for -t option in endpoint " + endpoint; throw ex; } - istringstream t(argument); - if(!(t >> const_cast<Int&>(_timeout)) || !t.eof()) + + if(argument == "infinite") + { + const_cast<Int&>(_timeout) = -1; + } + else { - EndpointParseException ex(__FILE__, __LINE__); - ex.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; - throw ex; + istringstream t(argument); + if(!(t >> const_cast<Int&>(_timeout)) || !t.eof() || _timeout < 1) + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; + throw ex; + } } return true; } diff --git a/cpp/src/IceSSL/EndpointI.h b/cpp/src/IceSSL/EndpointI.h index 5d797d2dfe7..a760e8d3ae8 100644 --- a/cpp/src/IceSSL/EndpointI.h +++ b/cpp/src/IceSSL/EndpointI.h @@ -51,6 +51,7 @@ protected: virtual void streamWriteImpl(IceInternal::BasicStream*) const; virtual void hashInit(Ice::Int&) const; virtual void fillEndpointInfo(Ice::IPEndpointInfo*) const; + virtual void initWithOptions(std::vector<std::string>&, bool); virtual bool checkOption(const std::string&, const std::string&, const std::string&); virtual IceInternal::ConnectorPtr createConnector(const IceInternal::Address&, diff --git a/cpp/test/Glacier2/staticFiltering/run.py b/cpp/test/Glacier2/staticFiltering/run.py index d77870462aa..f1b459a7863 100755 --- a/cpp/test/Glacier2/staticFiltering/run.py +++ b/cpp/test/Glacier2/staticFiltering/run.py @@ -218,8 +218,8 @@ if not limitedTests: [(False, 'hello:tcp -h %s -p 12010:tcp -h 127.0.0.1 -p 12010' % fqdn), (True, 'bar:tcp -h 127.0.0.1 -p 12010')], []), ('testing maximum proxy length rule', - ('', '', '41', '', '', ''), - [(True, 'hello:tcp -h 127.0.0.1 -p 12010'), + ('', '', '53', '', '', ''), + [(True, 'hello:tcp -h 127.0.0.1 -p 12010 -t infinite'), (False, '012345678901234567890123456789012345678901234567890123456789:tcp -h 127.0.0.1 -p 12010')], []), ]) diff --git a/cpp/test/Ice/metrics/AllTests.cpp b/cpp/test/Ice/metrics/AllTests.cpp index cf9904e8dc8..7fb13af91e1 100644 --- a/cpp/test/Ice/metrics/AllTests.cpp +++ b/cpp/test/Ice/metrics/AllTests.cpp @@ -56,7 +56,7 @@ private: typedef IceUtil::Handle<Callback> CallbackPtr; Ice::PropertyDict -getClientProps(const Ice::PropertiesAdminPrx& p, const Ice::PropertyDict& orig, const string& m = string()) +getClientProps(const Ice::PropertiesAdminPrx& p, const Ice::PropertyDict& orig, const string& m = string()) { Ice::PropertyDict props = p->getPropertiesForPrefix("IceMX.Metrics"); for(Ice::PropertyDict::iterator p = props.begin(); p != props.end(); ++p) @@ -137,7 +137,7 @@ public: } if(_serverProps->ice_getConnection()) { - // Ensure that the previous updates were committed, the setProperties call returns before + // Ensure that the previous updates were committed, the setProperties call returns before // notifying the callbacks so to ensure all the update callbacks have be notified we call // a second time, this will block until all the notifications from the first update have // completed. @@ -186,10 +186,10 @@ waitForCurrent(const IceMX::MetricsAdminPrx& metrics, const string& viewName, co } template<typename T> void -testAttribute(const IceMX::MetricsAdminPrx& metrics, - const Ice::PropertiesAdminPrx& props, +testAttribute(const IceMX::MetricsAdminPrx& metrics, + const Ice::PropertiesAdminPrx& props, UpdateCallbackI* update, - const string& map, + const string& map, const string& attr, const string& value, const T& func) @@ -239,7 +239,7 @@ testAttribute(const IceMX::MetricsAdminPrx& metrics, struct Void { - void + void operator()() const { } @@ -293,10 +293,10 @@ struct InvokeOp }; void -testAttribute(const IceMX::MetricsAdminPrx& metrics, - const Ice::PropertiesAdminPrx& props, +testAttribute(const IceMX::MetricsAdminPrx& metrics, + const Ice::PropertiesAdminPrx& props, UpdateCallbackI* update, - const string& map, + const string& map, const string& attr, const string& value) { @@ -304,9 +304,9 @@ testAttribute(const IceMX::MetricsAdminPrx& metrics, } void -updateProps(const Ice::PropertiesAdminPrx& cprops, - const Ice::PropertiesAdminPrx& sprops, - UpdateCallbackI* callback, +updateProps(const Ice::PropertiesAdminPrx& cprops, + const Ice::PropertiesAdminPrx& sprops, + UpdateCallbackI* callback, const Ice::PropertyDict& props, const string& map = string()) { @@ -410,7 +410,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt props["IceMX.Metrics.View.GroupBy"] = "none"; updateProps(clientProps, serverProps, update, props); - + #ifndef ICE_OS_WINRT int threadCount = 3; #else @@ -421,10 +421,10 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt IceMX::MetricsView view = clientMetrics->getMetricsView("View", timestamp); if(!collocated) { - test(view["Connection"].size() == 1 && view["Connection"][0]->current == 1 && + test(view["Connection"].size() == 1 && view["Connection"][0]->current == 1 && view["Connection"][0]->total == 1); } - test(view["Thread"].size() == 1 && view["Thread"][0]->current == threadCount && + test(view["Thread"].size() == 1 && view["Thread"][0]->current == threadCount && view["Thread"][0]->total == threadCount); cout << "ok" << endl; @@ -476,13 +476,13 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt { metrics->ice_getConnection()->close(false); metrics->ice_connectionId("Con1")->ice_getConnection()->close(false); - + waitForCurrent(clientMetrics, "View", "Connection", 0); waitForCurrent(serverMetrics, "View", "Connection", 0); } clearView(clientProps, serverProps, update); - + cout << "ok" << endl; map<string, IceMX::MetricsPtr> map; @@ -555,7 +555,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt test(cm2->receivedBytes - cm1->receivedBytes == replySz); test(sm2->receivedBytes - sm1->receivedBytes == requestSz + static_cast<int>(bs.size()) + 4); test(sm2->sentBytes - sm1->sentBytes == replySz); - + props["IceMX.Metrics.View.Map.Connection.GroupBy"] = "state"; updateProps(clientProps, serverProps, update, props, "Connection"); @@ -643,7 +643,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt testAttribute(clientMetrics, clientProps, update, "Connection", "remotePort", "12010"); testAttribute(clientMetrics, clientProps, update, "Connection", "mcastHost", ""); testAttribute(clientMetrics, clientProps, update, "Connection", "mcastPort", ""); - + m->ice_getConnection()->close(false); waitForCurrent(clientMetrics, "View", "Connection", 0); @@ -658,7 +658,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt test(clientMetrics->getMetricsView("View", timestamp)["ConnectionEstablishment"].empty()); metrics->ice_ping(); - + test(clientMetrics->getMetricsView("View", timestamp)["ConnectionEstablishment"].size() == 1); IceMX::MetricsPtr m1 = clientMetrics->getMetricsView("View", timestamp)["ConnectionEstablishment"][0]; test(m1->current == 0 && m1->total == 1 && m1->id == "127.0.0.1:12010"); @@ -687,13 +687,13 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt Connect c(metrics); 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 -h 127.0.0.1 -p 12010", c); + testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpoint", + "tcp -h 127.0.0.1 -p 12010 -t 60000", 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", "endpointTimeout", "-1", c); + testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointTimeout", "60000", c); testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointCompress", "false", c); testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointHost", "127.0.0.1", c); testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointPort", "12010", c); @@ -711,13 +711,13 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt updateProps(clientProps, serverProps, update, props, "EndpointLookup"); test(clientMetrics->getMetricsView("View", timestamp)["EndpointLookup"].empty()); - Ice::ObjectPrx prx = communicator->stringToProxy("metrics:default -p 12010 -h localhost"); + Ice::ObjectPrx prx = communicator->stringToProxy("metrics:default -p 12010 -h localhost -t infinite"); prx->ice_ping(); - + 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 -h localhost -p 12010"); + test(m1->current <= 1 && m1->total == 1 && m1->id == "tcp -h localhost -p 12010 -t infinite"); prx->ice_getConnection()->close(false); @@ -737,7 +737,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt } test(clientMetrics->getMetricsView("View", timestamp)["EndpointLookup"].size() == 2); m1 = clientMetrics->getMetricsView("View", timestamp)["EndpointLookup"][1]; - test(m1->id == "tcp -h unknownfoo.zeroc.com -p 12010 -t 500" && m1->total == 2 && + test(m1->id == "tcp -h unknownfoo.zeroc.com -p 12010 -t 500" && m1->total == 2 && (!dnsException || m1->failures == 2)); if(dnsException) { @@ -747,9 +747,10 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt c = Connect(prx); testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "parent", "Communicator", c); - testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "id", "tcp -h localhost -p 12010", c); - testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpoint", - "tcp -h localhost -p 12010", c); + testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "id", + "tcp -h localhost -p 12010 -t infinite", c); + testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpoint", + "tcp -h localhost -p 12010 -t infinite", c); testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointType", "1", c); testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointIsDatagram", "false", c); @@ -853,13 +854,14 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt testAttribute(serverMetrics, serverProps, update, "Dispatch", "id", "metrics [op]", op); if(!collocated) { - testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpoint", "tcp -h 127.0.0.1 -p 12010", op); + testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpoint", "tcp -h 127.0.0.1 -p 12010 -t 60000", + 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", "endpointTimeout", "-1", op); + testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointTimeout", "60000", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointCompress", "false", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointHost", "127.0.0.1", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointPort", "12010", op); @@ -1017,7 +1019,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt rim1 = IceMX::ChildInvocationMetricsPtr::dynamicCast(!collocated ? im1->remotes[0] : im1->collocated[0]); test(rim1->current == 0 && rim1->total == 3 && rim1->failures == 0); test(rim1->size == 63 && rim1->replySize == 21); - + im1 = IceMX::InvocationMetricsPtr::dynamicCast(map["opWithUserException"]); test(im1->current <= 1 && im1->total == 3 && im1->failures == 0 && im1->retry == 0); test(!collocated ? (im1->remotes.size() == 1) : (im1->collocated.size() == 1)); @@ -1071,8 +1073,8 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt testAttribute(clientMetrics, clientProps, update, "Invocation", "facet", "", op); 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 -e 1.1:tcp -h 127.0.0.1 -p 12010", op); + testAttribute(clientMetrics, clientProps, update, "Invocation", "proxy", + "metrics -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 60000", 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 ccf635bb3c6..34754f816b7 100644 --- a/cpp/test/Ice/proxy/AllTests.cpp +++ b/cpp/test/Ice/proxy/AllTests.cpp @@ -531,7 +531,7 @@ allTests(const Ice::CommunicatorPtr& communicator) test(!(compObj->ice_locator(loc1) < compObj->ice_locator(0))); test(compObj->ice_locator(loc1) < compObj->ice_locator(loc2)); test(!(compObj->ice_locator(loc2) < compObj->ice_locator(loc1))); - + Ice::RouterPrx rtr1 = Ice::RouterPrx::uncheckedCast(communicator->stringToProxy("rtr1:default -p 10000")); Ice::RouterPrx rtr2 = Ice::RouterPrx::uncheckedCast(communicator->stringToProxy("rtr2:default -p 10000")); test(compObj->ice_router(0) == compObj->ice_router(0)); @@ -543,7 +543,7 @@ allTests(const Ice::CommunicatorPtr& communicator) test(!(compObj->ice_router(rtr1) < compObj->ice_router(0))); test(compObj->ice_router(rtr1) < compObj->ice_router(rtr2)); test(!(compObj->ice_router(rtr2) < compObj->ice_router(rtr1))); - + Ice::Context ctx1; ctx1["ctx1"] = "v1"; Ice::Context ctx2; @@ -555,12 +555,12 @@ allTests(const Ice::CommunicatorPtr& communicator) test(compObj->ice_context(ctx1) != compObj->ice_context(ctx2)); test(compObj->ice_context(ctx1) < compObj->ice_context(ctx2)); test(!(compObj->ice_context(ctx2) < compObj->ice_context(ctx1))); - + test(compObj->ice_preferSecure(true) == compObj->ice_preferSecure(true)); test(compObj->ice_preferSecure(true) != compObj->ice_preferSecure(false)); test(compObj->ice_preferSecure(false) < compObj->ice_preferSecure(true)); test(!(compObj->ice_preferSecure(true) < compObj->ice_preferSecure(false))); - + Ice::ObjectPrx compObj1 = communicator->stringToProxy("foo:tcp -h 127.0.0.1 -p 10000"); Ice::ObjectPrx compObj2 = communicator->stringToProxy("foo:tcp -h 127.0.0.1 -p 10001"); test(compObj1 != compObj2); @@ -610,13 +610,13 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "testing checked cast... " << flush; Test::MyClassPrx cl = Test::MyClassPrx::checkedCast(base); test(cl); - + Test::MyDerivedClassPrx derived = Test::MyDerivedClassPrx::checkedCast(cl); test(derived); test(cl == base); test(derived == base); test(cl == derived); - + Ice::LocatorPrx loc = Ice::LocatorPrx::checkedCast(base); test(loc == 0); @@ -640,7 +640,7 @@ allTests(const Ice::CommunicatorPtr& communicator) test(cl == base); test(derived == base); test(cl == derived); - + loc = checkedCast<Ice::LocatorPrx>(base); test(loc == 0); @@ -679,7 +679,7 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "testing encoding versioning... " << flush; string ref20 = "test -e 2.0:default -p 12010"; Test::MyClassPrx cl20 = Test::MyClassPrx::uncheckedCast(communicator->stringToProxy(ref20)); - try + try { cl20->ice_collocationOptimized(false)->ice_ping(); test(false); @@ -701,7 +701,7 @@ allTests(const Ice::CommunicatorPtr& communicator) Test::MyClassPrx cl13 = Test::MyClassPrx::uncheckedCast(communicator->stringToProxy(ref13)); cl13->ice_ping(); cl13->end_ice_ping(cl13->begin_ice_ping()); - + try { // Send request with bogus 1.2 encoding. @@ -750,7 +750,7 @@ allTests(const Ice::CommunicatorPtr& communicator) ref20 = "test -p 2.0:default -p 12010"; cl20 = Test::MyClassPrx::uncheckedCast(communicator->stringToProxy(ref20)); - try + try { cl20->ice_collocationOptimized(false)->ice_ping(); test(false); @@ -922,7 +922,7 @@ allTests(const Ice::CommunicatorPtr& communicator) pstr = communicator->proxyToString(p1); if(ssl) { - test(pstr == "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001:opaque -t 99 -e 1.0 -v abch"); + test(pstr == "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch"); } else if(tcp) { @@ -957,7 +957,7 @@ allTests(const Ice::CommunicatorPtr& communicator) pstr = communicator->proxyToString(p2); if(ssl) { - test(pstr == "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001:opaque -t 99 -e 1.0 -v abch"); + test(pstr == "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch"); } else if(tcp) { diff --git a/cs/src/Ice/DefaultsAndOverrides.cs b/cs/src/Ice/DefaultsAndOverrides.cs index b45e91feca8..89aee4963c6 100644 --- a/cs/src/Ice/DefaultsAndOverrides.cs +++ b/cs/src/Ice/DefaultsAndOverrides.cs @@ -136,6 +136,12 @@ namespace IceInternal throw ex; } + defaultTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.Timeout", 60000); + if(defaultTimeout < 1 && defaultTimeout != -1) + { + throw new Ice.InitializationException("invalid value for Ice.Default.Timeout: `" + + properties.getProperty("Ice.Default.Timeout") + "'"); + } defaultLocatorCacheTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1); defaultInvocationTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.InvocationTimeout", -1); @@ -155,6 +161,7 @@ namespace IceInternal public string defaultProtocol; public bool defaultCollocationOptimization; public Ice.EndpointSelectionType defaultEndpointSelection; + public int defaultTimeout; public int defaultLocatorCacheTimeout; public int defaultInvocationTimeout; public bool defaultPreferSecure; diff --git a/cs/src/Ice/IPEndpointI.cs b/cs/src/Ice/IPEndpointI.cs index 1cf003cad4a..a47a40bbb64 100644 --- a/cs/src/Ice/IPEndpointI.cs +++ b/cs/src/Ice/IPEndpointI.cs @@ -297,7 +297,7 @@ namespace IceInternal info.sourceAddress = Network.endpointAddressToString(sourceAddr_); } - public void initWithOptions(List<string> args, bool oaEndpoint) + public virtual void initWithOptions(List<string> args, bool oaEndpoint) { base.initWithOptions(args); diff --git a/cs/src/Ice/PropertyNames.cs b/cs/src/Ice/PropertyNames.cs index 4e24899d89f..609521707ec 100644 --- a/cs/src/Ice/PropertyNames.cs +++ b/cs/src/Ice/PropertyNames.cs @@ -108,6 +108,7 @@ namespace IceInternal new Property(@"^Ice\.Default\.Router$", false, null), new Property(@"^Ice\.Default\.SlicedFormat$", false, null), new Property(@"^Ice\.Default\.SourceAddress$", false, null), + new Property(@"^Ice\.Default\.Timeout$", false, null), new Property(@"^Ice\.IPv4$", false, null), new Property(@"^Ice\.IPv6$", false, null), new Property(@"^Ice\.EventLog\.Source$", false, null), diff --git a/cs/src/Ice/ProtocolInstance.cs b/cs/src/Ice/ProtocolInstance.cs index 4d4bdd57671..5b3eedcee59 100644 --- a/cs/src/Ice/ProtocolInstance.cs +++ b/cs/src/Ice/ProtocolInstance.cs @@ -91,6 +91,11 @@ namespace IceInternal return instance_.defaultsAndOverrides().defaultEncoding; } + public int defaultTimeout() + { + return instance_.defaultsAndOverrides().defaultTimeout; + } + public NetworkProxy networkProxy() { return instance_.networkProxy(); diff --git a/cs/src/Ice/TcpEndpointI.cs b/cs/src/Ice/TcpEndpointI.cs index 8f52caefda8..2558ad6b11b 100644 --- a/cs/src/Ice/TcpEndpointI.cs +++ b/cs/src/Ice/TcpEndpointI.cs @@ -28,7 +28,7 @@ namespace IceInternal public TcpEndpointI(ProtocolInstance instance) : base(instance) { - _timeout = -1; + _timeout = -2; _compress = false; } @@ -143,7 +143,11 @@ namespace IceInternal // string s = base.options(); - if(_timeout != -1) + if(_timeout == -1) + { + s += " -t infinite"; + } + else { s += " -t " + _timeout; } @@ -215,6 +219,16 @@ namespace IceInternal } } + public override void initWithOptions(List<string> args, bool oaEndpoint) + { + base.initWithOptions(args, oaEndpoint); + + if(_timeout == -2) + { + _timeout = instance_.defaultTimeout(); + } + } + protected override bool checkOption(string option, string argument, string endpoint) { if(base.checkOption(option, argument, endpoint)) @@ -232,15 +246,28 @@ namespace IceInternal endpoint); } - try + if(argument.Equals("infinite")) { - _timeout = System.Int32.Parse(argument, CultureInfo.InvariantCulture); + _timeout = -1; } - catch(System.FormatException ex) + else { - Ice.EndpointParseException e = new Ice.EndpointParseException(ex); - e.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; - throw e; + try + { + _timeout = System.Int32.Parse(argument, CultureInfo.InvariantCulture); + if(_timeout < 1) + { + Ice.EndpointParseException e = new Ice.EndpointParseException(); + e.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; + throw e; + } + } + catch(System.FormatException ex) + { + Ice.EndpointParseException e = new Ice.EndpointParseException(ex); + e.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; + throw e; + } } return true; diff --git a/cs/src/IceSSL/EndpointI.cs b/cs/src/IceSSL/EndpointI.cs index c5767d367a3..a57c922f4fb 100644 --- a/cs/src/IceSSL/EndpointI.cs +++ b/cs/src/IceSSL/EndpointI.cs @@ -29,7 +29,7 @@ namespace IceSSL base(instance) { _instance = instance; - _timeout = -1; + _timeout = -2; _compress = false; } @@ -183,7 +183,11 @@ namespace IceSSL // string s = base.options(); - if(_timeout != -1) + if(_timeout == -1) + { + s += " -t infinite"; + } + else { s += " -t " + _timeout; } @@ -258,6 +262,16 @@ namespace IceSSL } } + public override void initWithOptions(List<string> args, bool oaEndpoint) + { + base.initWithOptions(args, oaEndpoint); + + if(_timeout == -2) + { + _timeout = _instance.defaultTimeout(); + } + } + protected override bool checkOption(string option, string argument, string endpoint) { if(base.checkOption(option, argument, endpoint)) @@ -276,15 +290,28 @@ namespace IceSSL throw e; } - try + if(argument.Equals("infinite")) { - _timeout = System.Int32.Parse(argument, CultureInfo.InvariantCulture); + _timeout = -1; } - catch(System.FormatException ex) + else { - Ice.EndpointParseException e = new Ice.EndpointParseException(ex); - e.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; - throw e; + try + { + _timeout = System.Int32.Parse(argument, CultureInfo.InvariantCulture); + if(_timeout < 1) + { + Ice.EndpointParseException e = new Ice.EndpointParseException(); + e.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; + throw e; + } + } + catch(System.FormatException ex) + { + Ice.EndpointParseException e = new Ice.EndpointParseException(ex); + e.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; + throw e; + } } return true; diff --git a/cs/test/Ice/metrics/AllTests.cs b/cs/test/Ice/metrics/AllTests.cs index 20360056410..b69acff71f6 100644 --- a/cs/test/Ice/metrics/AllTests.cs +++ b/cs/test/Ice/metrics/AllTests.cs @@ -82,7 +82,7 @@ public class AllTests : TestCommon.TestApp }; static private Dictionary<string, string> - getClientProps(Ice.PropertiesAdminPrx p, Dictionary<string, string> orig, string m) + getClientProps(Ice.PropertiesAdminPrx p, Dictionary<string, string> orig, string m) { Dictionary<string, string> props = p.getPropertiesForPrefix("IceMX.Metrics"); foreach(string e in new List<string>(props.Keys)) @@ -133,7 +133,7 @@ public class AllTests : TestCommon.TestApp _updated = false; _serverProps = serverProps; } - + public void waitForUpdate() { @@ -143,15 +143,15 @@ public class AllTests : TestCommon.TestApp { System.Threading.Monitor.Wait(this); } - // Ensure that the previous updates were committed, the setProperties call returns before + // Ensure that the previous updates were committed, the setProperties call returns before // notifying the callbacks so to ensure all the update callbacks have be notified we call // a second time, this will block until all the notifications from the first update have // completed. - _serverProps.setProperties(new Dictionary<string, string>()); + _serverProps.setProperties(new Dictionary<string, string>()); _updated = false; } } - + public void updated(Dictionary<string, string> dict) { @@ -161,11 +161,11 @@ public class AllTests : TestCommon.TestApp System.Threading.Monitor.Pulse(this); } } - + private bool _updated; private Ice.PropertiesAdminPrx _serverProps; }; - + static void waitForCurrent(IceMX.MetricsAdminPrx metrics, string viewName, string map, int value) { @@ -190,12 +190,12 @@ public class AllTests : TestCommon.TestApp System.Threading.Thread.Sleep(50); } } - + static void - testAttribute(IceMX.MetricsAdminPrx metrics, - Ice.PropertiesAdminPrx props, + testAttribute(IceMX.MetricsAdminPrx metrics, + Ice.PropertiesAdminPrx props, UpdateCallbackI update, - string map, + string map, string attr, string value, #if COMPACT @@ -216,7 +216,7 @@ public class AllTests : TestCommon.TestApp props.setProperties(getServerProps(props, dict, map)); props.setProperties(new Dictionary<string, string>()); } - + func(); long timestamp; Dictionary<string, IceMX.Metrics[]> view = metrics.getMetricsView("View", out timestamp); @@ -233,7 +233,7 @@ public class AllTests : TestCommon.TestApp WriteLine("invalid attribute value: " + attr + " = " + value + " got " + view[map][0].id); test(false); } - + dict.Clear(); if(props.ice_getIdentity().category.Equals("client")) { @@ -253,7 +253,7 @@ public class AllTests : TestCommon.TestApp { proxy.ice_getCachedConnection().close(false); } - + try { proxy.ice_ping(); @@ -261,7 +261,7 @@ public class AllTests : TestCommon.TestApp catch(Ice.LocalException) { } - + if(proxy.ice_getCachedConnection() != null) { proxy.ice_getCachedConnection().close(false); @@ -277,10 +277,10 @@ public class AllTests : TestCommon.TestApp } static void - testAttribute(IceMX.MetricsAdminPrx metrics, - Ice.PropertiesAdminPrx props, + testAttribute(IceMX.MetricsAdminPrx metrics, + Ice.PropertiesAdminPrx props, UpdateCallbackI update, - string map, + string map, string attr, string value) { @@ -288,9 +288,9 @@ public class AllTests : TestCommon.TestApp } static void - updateProps(Ice.PropertiesAdminPrx cprops, - Ice.PropertiesAdminPrx sprops, - UpdateCallbackI callback, + updateProps(Ice.PropertiesAdminPrx cprops, + Ice.PropertiesAdminPrx sprops, + UpdateCallbackI callback, Dictionary<string, string> props, string map) { @@ -314,7 +314,7 @@ public class AllTests : TestCommon.TestApp } callback.waitForUpdate(); } - + static void clearView(Ice.PropertiesAdminPrx cprops, Ice.PropertiesAdminPrx sprops, UpdateCallbackI callback) { @@ -406,7 +406,7 @@ public class AllTests : TestCommon.TestApp Dictionary<string, IceMX.Metrics[]> view = clientMetrics.getMetricsView("View", out timestamp); if(!collocated) { - test(view["Connection"].Length == 1 && view["Connection"][0].current == 1 && + test(view["Connection"].Length == 1 && view["Connection"][0].current == 1 && view["Connection"][0].total == 1); } test(view["Thread"].Length == 1 && view["Thread"][0].current == 4 && view["Thread"][0].total == 4); @@ -468,7 +468,7 @@ public class AllTests : TestCommon.TestApp } clearView(clientProps, serverProps, update); - + WriteLine("ok"); Dictionary<string, IceMX.Metrics> map; @@ -477,7 +477,7 @@ public class AllTests : TestCommon.TestApp { Write("testing connection metrics... "); Flush(); - + props["IceMX.Metrics.View.Map.Connection.GroupBy"] = "none"; updateProps(clientProps, serverProps, update, props, "Connection"); @@ -489,7 +489,7 @@ public class AllTests : TestCommon.TestApp IceMX.ConnectionMetrics cm1, sm1, cm2, sm2; cm1 = (IceMX.ConnectionMetrics)clientMetrics.getMetricsView("View", out timestamp)["Connection"][0]; sm1 = getServerConnectionMetrics(serverMetrics, 25); - + metrics.ice_ping(); cm2 = (IceMX.ConnectionMetrics)clientMetrics.getMetricsView("View", out timestamp)["Connection"][0]; @@ -538,14 +538,14 @@ public class AllTests : TestCommon.TestApp test((cm2.receivedBytes - cm1.receivedBytes) == replySz); test((sm2.receivedBytes - sm1.receivedBytes) == (requestSz + bs.Length + 4)); test((sm2.sentBytes - sm1.sentBytes) == replySz); - + props["IceMX.Metrics.View.Map.Connection.GroupBy"] = "state"; updateProps(clientProps, serverProps, update, props, "Connection"); map = toMap(serverMetrics.getMetricsView("View", out timestamp)["Connection"]); test(map["active"].current == 1); - + ControllerPrx controller = ControllerPrxHelper.checkedCast( communicator.stringToProxy("controller:default -p 12011")); controller.hold(); @@ -625,7 +625,7 @@ public class AllTests : TestCommon.TestApp testAttribute(clientMetrics, clientProps, update, "Connection", "remotePort", "12010"); testAttribute(clientMetrics, clientProps, update, "Connection", "mcastHost", ""); testAttribute(clientMetrics, clientProps, update, "Connection", "mcastPort", ""); - + m.ice_getConnection().close(false); waitForCurrent(clientMetrics, "View", "Connection", 0); @@ -641,7 +641,7 @@ public class AllTests : TestCommon.TestApp test(clientMetrics.getMetricsView("View", out timestamp)["ConnectionEstablishment"].Length == 0); metrics.ice_ping(); - + test(clientMetrics.getMetricsView("View", out timestamp)["ConnectionEstablishment"].Length == 1); IceMX.Metrics m1 = clientMetrics.getMetricsView("View", out timestamp)["ConnectionEstablishment"][0]; test(m1.current == 0 && m1.total == 1 && m1.id.Equals("127.0.0.1:12010")); @@ -675,14 +675,18 @@ public class AllTests : TestCommon.TestApp 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 -h 127.0.0.1 -p 12010", c); + "tcp -h 127.0.0.1 -p 12010 -t 60000", 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", "endpointTimeout", "-1", c); - testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointCompress", "False", c); - testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointHost", "127.0.0.1", c); + testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointIsDatagram", "False", + c); + testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointIsSecure", "False", + c); + testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointTimeout", "60000", c); + testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointCompress", "False", + c); + testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointHost", "127.0.0.1", + c); testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointPort", "12010", c); WriteLine("ok"); @@ -694,12 +698,12 @@ public class AllTests : TestCommon.TestApp updateProps(clientProps, serverProps, update, props, "EndpointLookup"); test(clientMetrics.getMetricsView("View", out timestamp)["EndpointLookup"].Length == 0); - Ice.ObjectPrx prx = communicator.stringToProxy("metrics:default -p 12010 -h localhost"); + Ice.ObjectPrx prx = communicator.stringToProxy("metrics:default -p 12010 -h localhost -t infinite"); prx.ice_ping(); - + test(clientMetrics.getMetricsView("View", out timestamp)["EndpointLookup"].Length == 1); m1 = clientMetrics.getMetricsView("View", out timestamp)["EndpointLookup"][0]; - test(m1.current <= 1 && m1.total == 1 && m1.id.Equals("tcp -h localhost -p 12010")); + test(m1.current <= 1 && m1.total == 1 && m1.id.Equals("tcp -h localhost -p 12010 -t infinite")); prx.ice_getConnection().close(false); @@ -723,7 +727,7 @@ public class AllTests : TestCommon.TestApp { m1 = clientMetrics.getMetricsView("View", out timestamp)["EndpointLookup"][1]; } - test(m1.id.Equals("tcp -h unknownfoo.zeroc.com -p 12010 -t 500") && m1.total == 2 && + test(m1.id.Equals("tcp -h unknownfoo.zeroc.com -p 12010 -t 500") && m1.total == 2 && (!dnsException || m1.failures == 2)); if(dnsException) { @@ -733,10 +737,10 @@ public class AllTests : TestCommon.TestApp c = () => { connect(prx); }; testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "parent", "Communicator", c); - testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "id", "tcp -h localhost -p 12010", - c); - testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpoint", - "tcp -h localhost -p 12010", c); + testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "id", + "tcp -h localhost -p 12010 -t infinite", c); + testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpoint", + "tcp -h localhost -p 12010 -t infinite", c); testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointType", "1", c); testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointIsDatagram", "False", c); @@ -838,18 +842,18 @@ public class AllTests : TestCommon.TestApp if(!collocated) { - testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpoint", - "tcp -h 127.0.0.1 -p 12010", op); + testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpoint", + "tcp -h 127.0.0.1 -p 12010 -t 60000", 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", "endpointTimeout", "-1", op); + testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointTimeout", "60000", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointCompress", "False", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointHost", "127.0.0.1", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointPort", "12010", op); - + testAttribute(serverMetrics, serverProps, update, "Dispatch", "incoming", "True", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "adapterName", "TestAdapter", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "connectionId", "", op); @@ -860,16 +864,16 @@ public class AllTests : TestCommon.TestApp testAttribute(serverMetrics, serverProps, update, "Dispatch", "mcastHost", "", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "mcastPort", "", op); } - + testAttribute(serverMetrics, serverProps, update, "Dispatch", "operation", "op", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "identity", "metrics", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "facet", "", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "mode", "twoway", op); - + testAttribute(serverMetrics, serverProps, update, "Dispatch", "context.entry1", "test", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "context.entry2", "", op); testAttribute(serverMetrics, serverProps, update, "Dispatch", "context.entry3", "", op); - + WriteLine("ok"); Write("testing invocation metrics... "); @@ -1052,7 +1056,7 @@ public class AllTests : TestCommon.TestApp 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 -e 1.1:tcp -h 127.0.0.1 -p 12010", op); + "metrics -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 60000", op); testAttribute(clientMetrics, clientProps, update, "Invocation", "context.entry1", "test", op); testAttribute(clientMetrics, clientProps, update, "Invocation", "context.entry2", "", op); diff --git a/cs/test/Ice/proxy/AllTests.cs b/cs/test/Ice/proxy/AllTests.cs index 259150326db..8f247ededee 100644 --- a/cs/test/Ice/proxy/AllTests.cs +++ b/cs/test/Ice/proxy/AllTests.cs @@ -229,7 +229,7 @@ public class AllTests : TestCommon.TestApp b1 = communicator.stringToProxy("test -p 1.0 -e 1.0"); test(b1.ToString().Equals("test -t -e 1.0")); - + b1 = communicator.stringToProxy("test -p 6.5 -e 1.0"); test(b1.ToString().Equals("test -t -p 6.5 -e 1.0")); @@ -266,11 +266,11 @@ public class AllTests : TestCommon.TestApp Ice.Identity id = new Ice.Identity("test", ",X2QNUAzSBcJ_e$AV;E\\"); Ice.Identity id2 = communicator.stringToIdentity(communicator.identityToString(id)); test(id.Equals(id2)); - + id = new Ice.Identity("test", ",X2QNUAz\\SB\\/cJ_e$AV;E\\\\"); id2 = communicator.stringToIdentity(communicator.identityToString(id)); test(id.Equals(id2)); - + WriteLine("ok"); Write("testing propertyToProxy... "); @@ -442,7 +442,7 @@ public class AllTests : TestCommon.TestApp test(proxyProps["Test.Locator.EndpointSelection"].Equals("Random")); test(proxyProps["Test.Locator.LocatorCacheTimeout"].Equals("300")); test(proxyProps["Test.Locator.InvocationTimeout"].Equals("1500")); - + test(proxyProps["Test.Locator.Router"].Equals( "router -t -e " + Ice.Util.encodingVersionToString(Ice.Util.currentEncoding))); test(proxyProps["Test.Locator.Router.CollocationOptimized"].Equals("0")); @@ -451,7 +451,7 @@ public class AllTests : TestCommon.TestApp test(proxyProps["Test.Locator.Router.EndpointSelection"].Equals("Random")); test(proxyProps["Test.Locator.Router.LocatorCacheTimeout"].Equals("200")); test(proxyProps["Test.Locator.Router.InvocationTimeout"].Equals("1500")); - + WriteLine("ok"); Write("testing ice_getCommunicator... "); @@ -602,7 +602,7 @@ public class AllTests : TestCommon.TestApp Flush(); string ref20 = "test -e 2.0:default -p 12010"; Test.MyClassPrx cl20 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref20)); - try + try { cl20.ice_collocationOptimized(false).ice_ping(); test(false); @@ -657,7 +657,7 @@ public class AllTests : TestCommon.TestApp inEncaps[4] = version.major; inEncaps[5] = version.minor; byte[] outEncaps; - cl.ice_collocationOptimized(false).ice_invoke("ice_ping", Ice.OperationMode.Normal, inEncaps, + cl.ice_collocationOptimized(false).ice_invoke("ice_ping", Ice.OperationMode.Normal, inEncaps, out outEncaps); test(false); } @@ -673,7 +673,7 @@ public class AllTests : TestCommon.TestApp Flush(); ref20 = "test -p 2.0:default -p 12010"; cl20 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref20)); - try + try { cl20.ice_collocationOptimized(false).ice_ping(); test(false); @@ -816,7 +816,7 @@ public class AllTests : TestCommon.TestApp // 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).Equals("test -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 10000")); - + if(communicator.getProperties().getPropertyAsInt("Ice.IPv6") == 0) { // Working? @@ -837,7 +837,7 @@ public class AllTests : TestCommon.TestApp pstr = communicator.proxyToString(p1); if(ssl) { - test(pstr.Equals("test -t -e 1.0:ssl -h 127.0.0.1 -p 10001:opaque -t 99 -e 1.0 -v abch")); + test(pstr.Equals("test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch")); } else if(tcp) { diff --git a/java/src/IceInternal/DefaultsAndOverrides.java b/java/src/IceInternal/DefaultsAndOverrides.java index db876a52c1f..c86c0bc6c5a 100644 --- a/java/src/IceInternal/DefaultsAndOverrides.java +++ b/java/src/IceInternal/DefaultsAndOverrides.java @@ -127,6 +127,12 @@ public final class DefaultsAndOverrides throw ex; } + defaultTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.Timeout", 60000); + if(defaultTimeout < 1 && defaultTimeout != -1) + { + throw new Ice.InitializationException("invalid value for Ice.Default.Timeout: `" + + properties.getProperty("Ice.Default.Timeout") + "'"); + } defaultLocatorCacheTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1); defaultInvocationTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.InvocationTimeout", -1); @@ -146,6 +152,7 @@ public final class DefaultsAndOverrides final public String defaultProtocol; final public boolean defaultCollocationOptimization; final public Ice.EndpointSelectionType defaultEndpointSelection; + final public int defaultTimeout; final public int defaultLocatorCacheTimeout; final public int defaultInvocationTimeout; final public boolean defaultPreferSecure; diff --git a/java/src/IceInternal/PropertyNames.java b/java/src/IceInternal/PropertyNames.java index f27b671e3bc..e0b7dd7b9c9 100644 --- a/java/src/IceInternal/PropertyNames.java +++ b/java/src/IceInternal/PropertyNames.java @@ -109,6 +109,7 @@ public final class PropertyNames new Property("Ice\\.Default\\.Router", false, null), new Property("Ice\\.Default\\.SlicedFormat", false, null), new Property("Ice\\.Default\\.SourceAddress", false, null), + new Property("Ice\\.Default\\.Timeout", false, null), new Property("Ice\\.IPv4", false, null), new Property("Ice\\.IPv6", false, null), new Property("Ice\\.EventLog\\.Source", false, null), diff --git a/java/src/IceInternal/ProtocolInstance.java b/java/src/IceInternal/ProtocolInstance.java index f78060cc172..9e217d9df4a 100644 --- a/java/src/IceInternal/ProtocolInstance.java +++ b/java/src/IceInternal/ProtocolInstance.java @@ -77,6 +77,11 @@ public class ProtocolInstance return _instance.defaultsAndOverrides().defaultEncoding; } + public int defaultTimeout() + { + return _instance.defaultsAndOverrides().defaultTimeout; + } + public NetworkProxy networkProxy() { return _instance.networkProxy(); diff --git a/java/src/IceInternal/TcpEndpointI.java b/java/src/IceInternal/TcpEndpointI.java index 564e5292371..f002f0f4101 100644 --- a/java/src/IceInternal/TcpEndpointI.java +++ b/java/src/IceInternal/TcpEndpointI.java @@ -22,7 +22,7 @@ final class TcpEndpointI extends IPEndpointI public TcpEndpointI(ProtocolInstance instance) { super(instance); - _timeout = -1; + _timeout = -2; _compress = false; } @@ -179,7 +179,11 @@ final class TcpEndpointI extends IPEndpointI // String s = super.options(); - if(_timeout != -1) + if(_timeout == -1) + { + s += " -t infinite"; + } + else { s += " -t " + _timeout; } @@ -260,6 +264,17 @@ final class TcpEndpointI extends IPEndpointI } @Override + public void initWithOptions(java.util.ArrayList<String> args, boolean oaEndpoint) + { + super.initWithOptions(args, oaEndpoint); + + if(_timeout == -2) + { + _timeout = _instance.defaultTimeout(); + } + } + + @Override protected boolean checkOption(String option, String argument, String endpoint) { if(super.checkOption(option, argument, endpoint)) @@ -276,14 +291,26 @@ final class TcpEndpointI extends IPEndpointI throw new Ice.EndpointParseException("no argument provided for -t option in endpoint " + endpoint); } - try + if(argument.equals("infinite")) { - _timeout = Integer.parseInt(argument); + _timeout = -1; } - catch(NumberFormatException ex) + else { - throw new Ice.EndpointParseException("invalid timeout value `" + argument + - "' in endpoint " + endpoint); + try + { + _timeout = Integer.parseInt(argument); + if(_timeout < 1) + { + throw new Ice.EndpointParseException("invalid timeout value `" + argument + + "' in endpoint " + endpoint); + } + } + catch(NumberFormatException ex) + { + throw new Ice.EndpointParseException("invalid timeout value `" + argument + + "' in endpoint " + endpoint); + } } return true; diff --git a/java/src/IceSSL/EndpointI.java b/java/src/IceSSL/EndpointI.java index 0df306e6373..82bb7a82fd6 100644 --- a/java/src/IceSSL/EndpointI.java +++ b/java/src/IceSSL/EndpointI.java @@ -24,7 +24,7 @@ final class EndpointI extends IceInternal.IPEndpointI { super(instance); _instance = instance; - _timeout = -1; + _timeout = -2; _compress = false; } @@ -170,7 +170,11 @@ final class EndpointI extends IceInternal.IPEndpointI // String s = super.options(); - if(_timeout != -1) + if(_timeout == -1) + { + s += " -t infinite"; + } + else { s += " -t " + _timeout; } @@ -246,6 +250,17 @@ final class EndpointI extends IceInternal.IPEndpointI } } + @Override + public void initWithOptions(java.util.ArrayList<String> args, boolean oaEndpoint) + { + super.initWithOptions(args, oaEndpoint); + + if(_timeout == -2) + { + _timeout = _instance.defaultTimeout(); + } + } + protected boolean checkOption(String option, String argument, String endpoint) { if(super.checkOption(option, argument, endpoint)) @@ -262,14 +277,26 @@ final class EndpointI extends IceInternal.IPEndpointI throw new Ice.EndpointParseException("no argument provided for -t option in endpoint " + endpoint); } - try + if(argument.equals("infinite")) { - _timeout = Integer.parseInt(argument); + _timeout = -1; } - catch(NumberFormatException ex) + else { - throw new Ice.EndpointParseException("invalid timeout value `" + argument + "' in endpoint " + - endpoint); + try + { + _timeout = Integer.parseInt(argument); + if(_timeout < 1) + { + throw new Ice.EndpointParseException("invalid timeout value `" + argument + + "' in endpoint " + endpoint); + } + } + catch(NumberFormatException ex) + { + throw new Ice.EndpointParseException("invalid timeout value `" + argument + + "' in endpoint " + endpoint); + } } return true; diff --git a/java/test/Ice/metrics/AllTests.java b/java/test/Ice/metrics/AllTests.java index 0f056a3857f..12db7e2f13e 100644 --- a/java/test/Ice/metrics/AllTests.java +++ b/java/test/Ice/metrics/AllTests.java @@ -90,7 +90,7 @@ public class AllTests }; static private Map<String, String> - getClientProps(Ice.PropertiesAdminPrx p, Map<String, String> orig, String m) + getClientProps(Ice.PropertiesAdminPrx p, Map<String, String> orig, String m) { Map<String, String> props = p.getPropertiesForPrefix("IceMX.Metrics"); for(Map.Entry<String, String> e : props.entrySet()) @@ -141,7 +141,7 @@ public class AllTests _updated = false; _serverProps = serverProps; } - + public synchronized void waitForUpdate() { @@ -155,25 +155,25 @@ public class AllTests { } } - // Ensure that the previous updates were committed, the setProperties call returns before + // Ensure that the previous updates were committed, the setProperties call returns before // notifying the callbacks so to ensure all the update callbacks have be notified we call // a second time, this will block until all the notifications from the first update have // completed. - _serverProps.setProperties(new java.util.HashMap<String, String>()); + _serverProps.setProperties(new java.util.HashMap<String, String>()); _updated = false; } - + public synchronized void updated(Map<String, String> dict) { _updated = true; notify(); } - + private boolean _updated; private Ice.PropertiesAdminPrx _serverProps; }; - + static void waitForCurrent(IceMX.MetricsAdminPrx metrics, String viewName, String map, int value) throws IceMX.UnknownMetricsView @@ -205,15 +205,15 @@ public class AllTests } } } - + static void - testAttribute(IceMX.MetricsAdminPrx metrics, - Ice.PropertiesAdminPrx props, + testAttribute(IceMX.MetricsAdminPrx metrics, + Ice.PropertiesAdminPrx props, UpdateCallbackI update, - String map, + String map, String attr, String value, - Runnable func, + Runnable func, PrintWriter out) throws IceMX.UnknownMetricsView { @@ -229,7 +229,7 @@ public class AllTests props.setProperties(getServerProps(props, dict, map)); props.setProperties(new java.util.HashMap<String, String>()); } - + func.run(); Ice.LongHolder timestamp = new Ice.LongHolder(); Map<String, IceMX.Metrics[]> view = metrics.getMetricsView("View", timestamp); @@ -246,7 +246,7 @@ public class AllTests out.println("invalid attribute value: " + attr + " = " + value + " got " + view.get(map)[0].id); test(false); } - + dict.clear(); if(props.ice_getIdentity().category.equals("client")) { @@ -259,21 +259,21 @@ public class AllTests props.setProperties(new java.util.HashMap<String, String>()); } } - + static class Void implements Runnable { public void run() { } }; - + static class Connect implements Runnable { public Connect(Ice.ObjectPrx proxy) { this.proxy = proxy; } - + public void run() { if(proxy.ice_getCachedConnection() != null) @@ -294,10 +294,10 @@ public class AllTests proxy.ice_getCachedConnection().close(false); } } - + final private Ice.ObjectPrx proxy; }; - + static class InvokeOp implements Runnable { public InvokeOp(MetricsPrx proxy) @@ -317,12 +317,12 @@ public class AllTests }; static void - testAttribute(IceMX.MetricsAdminPrx metrics, - Ice.PropertiesAdminPrx props, + testAttribute(IceMX.MetricsAdminPrx metrics, + Ice.PropertiesAdminPrx props, UpdateCallbackI update, - String map, + String map, String attr, - String value, + String value, PrintWriter out) throws IceMX.UnknownMetricsView { @@ -330,9 +330,9 @@ public class AllTests } static void - updateProps(Ice.PropertiesAdminPrx cprops, - Ice.PropertiesAdminPrx sprops, - UpdateCallbackI callback, + updateProps(Ice.PropertiesAdminPrx cprops, + Ice.PropertiesAdminPrx sprops, + UpdateCallbackI callback, Map<String, String> props, String map) { @@ -350,7 +350,7 @@ public class AllTests } callback.waitForUpdate(); } - + static void clearView(Ice.PropertiesAdminPrx cprops, Ice.PropertiesAdminPrx sprops, UpdateCallbackI callback) { @@ -406,7 +406,7 @@ public class AllTests return m; } - static MetricsPrx + static MetricsPrx allTests(Ice.Communicator communicator, PrintWriter out, CommunicatorObserverI obsv) throws IceMX.UnknownMetricsView { @@ -441,7 +441,7 @@ public class AllTests Map<String, IceMX.Metrics[]> view = clientMetrics.getMetricsView("View", timestamp); if(!collocated) { - test(view.get("Connection").length == 1 && view.get("Connection")[0].current == 1 && + test(view.get("Connection").length == 1 && view.get("Connection")[0].current == 1 && view.get("Connection")[0].total == 1); } test(view.get("Thread").length == 1 && view.get("Thread")[0].current == 3 && view.get("Thread")[0].total == 3); @@ -499,7 +499,7 @@ public class AllTests waitForCurrent(serverMetrics, "View", "Connection", 0); } clearView(clientProps, serverProps, update); - + out.println("ok"); Map<String, IceMX.Metrics> map; @@ -570,7 +570,7 @@ public class AllTests test((cm2.receivedBytes - cm1.receivedBytes) == replySz); test((sm2.receivedBytes - sm1.receivedBytes) == (requestSz + bs.length + 4)); test((sm2.sentBytes - sm1.sentBytes) == replySz); - + props.put("IceMX.Metrics.View.Map.Connection.GroupBy", "state"); updateProps(clientProps, serverProps, update, props, "Connection"); @@ -663,7 +663,7 @@ public class AllTests testAttribute(clientMetrics, clientProps, update, "Connection", "remotePort", "12010", out); testAttribute(clientMetrics, clientProps, update, "Connection", "mcastHost", "", out); testAttribute(clientMetrics, clientProps, update, "Connection", "mcastPort", "", out); - + m.ice_getConnection().close(false); waitForCurrent(clientMetrics, "View", "Connection", 0); @@ -679,7 +679,7 @@ public class AllTests test(clientMetrics.getMetricsView("View", timestamp).get("ConnectionEstablishment").length == 0); metrics.ice_ping(); - + test(clientMetrics.getMetricsView("View", timestamp).get("ConnectionEstablishment").length == 1); IceMX.Metrics m1 = clientMetrics.getMetricsView("View", timestamp).get("ConnectionEstablishment")[0]; test(m1.current == 0 && m1.total == 1 && m1.id.equals("127.0.0.1:12010")); @@ -709,19 +709,19 @@ public class AllTests testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "parent", "Communicator", c, out); testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "id", "127.0.0.1:12010", c, out); testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpoint", - "tcp -h 127.0.0.1 -p 12010", c, out); + "tcp -h 127.0.0.1 -p 12010 -t 60000", c, out); testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointType", "1", c, out); - testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointIsDatagram", "false", c, + testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointIsDatagram", "false", c, out); - testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointIsSecure", "false", c, + testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointIsSecure", "false", c, out); - testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointTimeout", "-1", c, out); - testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointCompress", "false", c, + testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointTimeout", "60000", c, out); + testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointCompress", "false", c, out); - testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointHost", "127.0.0.1", c, + testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointHost", "127.0.0.1", c, out); - testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointPort", "12010", c, + testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointPort", "12010", c, out); out.println("ok"); @@ -733,12 +733,12 @@ public class AllTests updateProps(clientProps, serverProps, update, props, "EndpointLookup"); test(clientMetrics.getMetricsView("View", timestamp).get("EndpointLookup").length == 0); - Ice.ObjectPrx prx = communicator.stringToProxy("metrics:default -p 12010 -h localhost"); + Ice.ObjectPrx prx = communicator.stringToProxy("metrics:default -p 12010 -h localhost -t infinite"); prx.ice_ping(); - + test(clientMetrics.getMetricsView("View", timestamp).get("EndpointLookup").length == 1); m1 = clientMetrics.getMetricsView("View", timestamp).get("EndpointLookup")[0]; - test(m1.current <= 1 && m1.total == 1 && m1.id.equals("tcp -h localhost -p 12010")); + test(m1.current <= 1 && m1.total == 1 && m1.id.equals("tcp -h localhost -p 12010 -t infinite")); prx.ice_getConnection().close(false); @@ -762,7 +762,7 @@ public class AllTests { m1 = clientMetrics.getMetricsView("View", timestamp).get("EndpointLookup")[1]; } - test(m1.id.equals("tcp -h unknownfoo.zeroc.com -p 12010 -t 500") && m1.total == 2 && + test(m1.id.equals("tcp -h unknownfoo.zeroc.com -p 12010 -t 500") && m1.total == 2 && (!dnsException || m1.failures == 2)); if(dnsException) { @@ -772,10 +772,10 @@ public class AllTests c = new Connect(prx); testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "parent", "Communicator", c, out); - testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "id", "tcp -h localhost -p 12010", c, - out); - testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpoint", - "tcp -h localhost -p 12010", c, out); + testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "id", + "tcp -h localhost -p 12010 -t infinite", c, out); + testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpoint", + "tcp -h localhost -p 12010 -t infinite", c, out); testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointType", "1", c, out); testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointIsDatagram", "false", c, out); @@ -849,7 +849,7 @@ public class AllTests dm1 = (IceMX.DispatchMetrics)map.get("opWithUserException"); test(dm1.current <= 1 &dm1.total == 1 && dm1.failures == 0 && dm1.userException == 1); test(dm1.size == 38 && dm1.replySize == 23); - + dm1 = (IceMX.DispatchMetrics)map.get("opWithLocalException"); test(dm1.current <= 1 && dm1.total == 1 && dm1.failures == 1 && dm1.userException == 0); checkFailure(serverMetrics, "Dispatch", dm1.id, "Ice::SyscallException", 1, out); @@ -871,18 +871,18 @@ public class AllTests testAttribute(serverMetrics, serverProps, update, "Dispatch", "id", "metrics [op]", op, out); if(!collocated) { - testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpoint", - "tcp -h 127.0.0.1 -p 12010", op, out); + testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpoint", + "tcp -h 127.0.0.1 -p 12010 -t 60000", op, out); //testAttribute(serverMetrics, serverProps, update, "Dispatch", "connection", "", op); - + testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointType", "1", op, out); testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointIsDatagram", "false", op, out); testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointIsSecure", "false", op, out); - testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointTimeout", "-1", op, out); + testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointTimeout", "60000", op, out); testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointCompress", "false", op, out); testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointHost", "127.0.0.1", op, out); testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointPort", "12010", op, out); - + testAttribute(serverMetrics, serverProps, update, "Dispatch", "incoming", "true", op, out); testAttribute(serverMetrics, serverProps, update, "Dispatch", "adapterName", "TestAdapter", op, out); testAttribute(serverMetrics, serverProps, update, "Dispatch", "connectionId", "", op, out); @@ -1078,21 +1078,21 @@ public class AllTests testAttribute(clientMetrics, clientProps, update, "Invocation", "parent", "Communicator", op, out); testAttribute(clientMetrics, clientProps, update, "Invocation", "id", "metrics -t -e 1.1 [op]", op, out); - + testAttribute(clientMetrics, clientProps, update, "Invocation", "operation", "op", op, out); testAttribute(clientMetrics, clientProps, update, "Invocation", "identity", "metrics", op, out); testAttribute(clientMetrics, clientProps, update, "Invocation", "facet", "", op, out); testAttribute(clientMetrics, clientProps, update, "Invocation", "encoding", "1.1", op, out); testAttribute(clientMetrics, clientProps, update, "Invocation", "mode", "twoway", op, out); testAttribute(clientMetrics, clientProps, update, "Invocation", "proxy", - "metrics -t -e 1.1:tcp -h 127.0.0.1 -p 12010", op, out); + "metrics -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 60000", op, out); testAttribute(clientMetrics, clientProps, update, "Invocation", "context.entry1", "test", op, out); testAttribute(clientMetrics, clientProps, update, "Invocation", "context.entry2", "", op, out); testAttribute(clientMetrics, clientProps, update, "Invocation", "context.entry3", "", op, out); out.println("ok"); - + out.print("testing metrics view enable/disable..."); out.flush(); diff --git a/java/test/Ice/proxy/AllTests.java b/java/test/Ice/proxy/AllTests.java index c05f811d502..4910517c0db 100644 --- a/java/test/Ice/proxy/AllTests.java +++ b/java/test/Ice/proxy/AllTests.java @@ -235,7 +235,7 @@ public class AllTests b1 = communicator.stringToProxy("test -p 1.0 -e 1.0"); test(b1.toString().equals("test -t -e 1.0")); - + b1 = communicator.stringToProxy("test -p 6.5 -e 1.0"); test(b1.toString().equals("test -t -p 6.5 -e 1.0")); @@ -272,11 +272,11 @@ public class AllTests Ice.Identity id = new Ice.Identity("test", ",X2QNUAzSBcJ_e$AV;E\\"); Ice.Identity id2 = communicator.stringToIdentity(communicator.identityToString(id)); test(id.equals(id2)); - + id = new Ice.Identity("test", ",X2QNUAz\\SB\\/cJ_e$AV;E\\\\"); id2 = communicator.stringToIdentity(communicator.identityToString(id)); test(id.equals(id2)); - + out.println("ok"); out.print("testing propertyToProxy... "); @@ -612,7 +612,7 @@ public class AllTests out.flush(); String ref20 = "test -e 2.0:default -p 12010"; MyClassPrx cl20 = MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref20)); - try + try { cl20.ice_collocationOptimized(false).ice_ping(); test(false); @@ -681,7 +681,7 @@ public class AllTests out.flush(); ref20 = "test -p 2.0:default -p 12010"; cl20 = MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref20)); - try + try { cl20.ice_collocationOptimized(false).ice_ping(); test(false); @@ -702,7 +702,7 @@ public class AllTests cl13.ice_ping(); cl13.end_ice_ping(cl13.begin_ice_ping()); out.println("ok"); - + out.print("testing opaque endpoints... "); out.flush(); @@ -848,7 +848,7 @@ public class AllTests pstr = communicator.proxyToString(p1); if(ssl) { - test(pstr.equals("test -t -e 1.0:ssl -h 127.0.0.1 -p 10001:opaque -t 99 -e 1.0 -v abch")); + test(pstr.equals("test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch")); } else if(tcp) { @@ -882,7 +882,7 @@ public class AllTests pstr = communicator.proxyToString(p2); if(ssl) { - test(pstr.equals("test -t -e 1.0:ssl -h 127.0.0.1 -p 10001:opaque -t 99 -e 1.0 -v abch")); + test(pstr.equals("test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch")); } else if(tcp) { diff --git a/py/test/Ice/proxy/AllTests.py b/py/test/Ice/proxy/AllTests.py index cb5c2276d5b..0d0f7468a5a 100644 --- a/py/test/Ice/proxy/AllTests.py +++ b/py/test/Ice/proxy/AllTests.py @@ -699,7 +699,7 @@ def allTests(communicator, collocated): p1 = communicator.stringToProxy("test -e 1.0:opaque -t 2 -e 1.0 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch") pstr = communicator.proxyToString(p1) if ssl: - test(pstr == "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001:opaque -t 99 -e 1.0 -v abch") + test(pstr == "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch") elif tcp: test(pstr == "test -t -e 1.0:opaque -t 2 -e 1.0 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch") @@ -725,7 +725,7 @@ def allTests(communicator, collocated): p2 = derived.echo(p1) pstr = communicator.proxyToString(p2) if ssl: - test(pstr == "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001:opaque -t 99 -e 1.0 -v abch") + test(pstr == "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch") elif tcp: test(pstr == "test -t -e 1.0:opaque -t 2 -e 1.0 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch") diff --git a/rb/test/Ice/proxy/AllTests.rb b/rb/test/Ice/proxy/AllTests.rb index a46666c326b..3b9b0f07b50 100644 --- a/rb/test/Ice/proxy/AllTests.rb +++ b/rb/test/Ice/proxy/AllTests.rb @@ -694,7 +694,7 @@ def allTests(communicator) if !ssl test(pstr == "test -t -e 1.0:opaque -t 2 -e 1.0 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch") else - test(pstr == "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001:opaque -t 99 -e 1.0 -v abch") + test(pstr == "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch") end # @@ -722,7 +722,7 @@ def allTests(communicator) if !ssl test(pstr == "test -t -e 1.0:opaque -t 2 -e 1.0 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch") else - test(pstr == "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001:opaque -t 99 -e 1.0 -v abch") + test(pstr == "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch") end end puts "ok" |