diff options
author | Benoit Foucher <benoit@zeroc.com> | 2012-09-13 15:33:46 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2012-09-13 15:33:46 +0200 |
commit | 0ed3e3fff565b80f84ec7e23d821fd30fac89b86 (patch) | |
tree | c9f4157f23727413b34d33f12f67e891879d3a77 /cpp/src | |
parent | Merge remote-tracking branch 'origin/mx' into mx (diff) | |
download | ice-0ed3e3fff565b80f84ec7e23d821fd30fac89b86.tar.bz2 ice-0ed3e3fff565b80f84ec7e23d821fd30fac89b86.tar.xz ice-0ed3e3fff565b80f84ec7e23d821fd30fac89b86.zip |
Added Ice/metrics test
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/InstrumentationI.cpp | 15 | ||||
-rw-r--r-- | cpp/src/Ice/MetricsAdminI.h | 5 | ||||
-rw-r--r-- | cpp/src/Ice/MetricsObserverI.h | 7 | ||||
-rw-r--r-- | cpp/src/Ice/Outgoing.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Ice/PropertiesAdminI.cpp | 179 | ||||
-rw-r--r-- | cpp/src/Ice/PropertiesAdminI.h | 4 |
6 files changed, 122 insertions, 94 deletions
diff --git a/cpp/src/Ice/InstrumentationI.cpp b/cpp/src/Ice/InstrumentationI.cpp index 139e304a673..718d132f053 100644 --- a/cpp/src/Ice/InstrumentationI.cpp +++ b/cpp/src/Ice/InstrumentationI.cpp @@ -257,6 +257,7 @@ public: add("parent", &DispatchHelper::getParent); add("id", &DispatchHelper::getId); add("endpoint", &DispatchHelper::getEndpoint); + add("connection", &DispatchHelper::getConnection); addConnectionAttributes<DispatchHelper>(*this); @@ -333,6 +334,12 @@ public: return _current.con->getEndpoint(); } + const ConnectionPtr& + getConnection() const + { + return _current.con; + } + const EndpointInfoPtr& getEndpointInfo() const { @@ -656,7 +663,7 @@ public: { add("parent", &EndpointHelper::getParent); add("id", &EndpointHelper::getId); - add("endpoint", &EndpointHelper::getId); + add("endpoint", &EndpointHelper::getEndpoint); addEndpointAttributes<EndpointHelper>(*this); } }; @@ -701,6 +708,12 @@ public: return _id; } + string + getEndpoint() const + { + return _endpoint->toString(); + } + private: const EndpointPtr _endpoint; diff --git a/cpp/src/Ice/MetricsAdminI.h b/cpp/src/Ice/MetricsAdminI.h index ffc32850fa2..16f21d9971a 100644 --- a/cpp/src/Ice/MetricsAdminI.h +++ b/cpp/src/Ice/MetricsAdminI.h @@ -144,6 +144,11 @@ public: _subMaps.find(mapName); if(p == _subMaps.end()) { + Lock sync(*this); + if(_map == 0) + { + return 0; + } std::pair<MetricsMapIPtr, SubMapMember> map = _map->createSubMap(mapName); if(map.first) { diff --git a/cpp/src/Ice/MetricsObserverI.h b/cpp/src/Ice/MetricsObserverI.h index e39caf38644..0f04232bca1 100644 --- a/cpp/src/Ice/MetricsObserverI.h +++ b/cpp/src/Ice/MetricsObserverI.h @@ -15,6 +15,7 @@ #include <Ice/Instrumentation.h> #include <Ice/Metrics.h> #include <Ice/Endpoint.h> +#include <Ice/Connection.h> #include <Ice/MetricsAdminI.h> #include <Ice/MetricsFunctional.h> @@ -235,6 +236,12 @@ protected: } static std::string + toString(const Ice::ConnectionPtr& e) + { + return e->toString(); + } + + static std::string toString(bool v) { return v ? "true" : "false"; diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp index 31c706c65a8..53e50da60d1 100644 --- a/cpp/src/Ice/Outgoing.cpp +++ b/cpp/src/Ice/Outgoing.cpp @@ -539,8 +539,12 @@ IceInternal::Outgoing::throwUserException() _is.startReadEncaps(); _is.throwException(); } - catch(const Ice::UserException&) + catch(const Ice::UserException& ex) { + if(_observer) + { + _observer.failed(ex.ice_name()); + } _is.endReadEncaps(); throw; } diff --git a/cpp/src/Ice/PropertiesAdminI.cpp b/cpp/src/Ice/PropertiesAdminI.cpp index 898f0414f13..64d55718568 100644 --- a/cpp/src/Ice/PropertiesAdminI.cpp +++ b/cpp/src/Ice/PropertiesAdminI.cpp @@ -24,14 +24,14 @@ Ice::PropertiesAdminI::PropertiesAdminI(const string& name, const PropertiesPtr& string Ice::PropertiesAdminI::getProperty(const string& name, const Ice::Current&) { - IceUtil::Mutex::Lock sync(*this); + Lock sync(*this); return _properties->getProperty(name); } Ice::PropertyDict Ice::PropertiesAdminI::getPropertiesForPrefix(const string& prefix, const Ice::Current&) { - IceUtil::Mutex::Lock sync(*this); + Lock sync(*this); return _properties->getPropertiesForPrefix(prefix); } @@ -39,122 +39,117 @@ void Ice::PropertiesAdminI::setProperties_async(const AMD_PropertiesAdmin_setPropertiesPtr& cb, const PropertyDict& props, const Ice::Current&) { + Lock sync(*this); + + PropertyDict old = _properties->getPropertiesForPrefix(""); + PropertyDict::const_iterator p; + const int traceLevel = _properties->getPropertyAsInt("Ice.Trace.Admin.Properties"); + + // + // Compute the difference between the new property set and the existing property set: + // + // 1) Any properties in the new set that were not defined in the existing set. + // + // 2) Any properties that appear in both sets but with different values. + // + // 3) Any properties not present in the new set but present in the existing set. + // In other words, the property has been removed. + // PropertyDict added, changed, removed; - vector<PropertiesAdminUpdateCallbackPtr> callbacks; + for(p = props.begin(); p != props.end(); ++p) { - IceUtil::Mutex::Lock sync(*this); - - PropertyDict old = _properties->getPropertiesForPrefix(""); - PropertyDict::const_iterator p; - const int traceLevel = _properties->getPropertyAsInt("Ice.Trace.Admin.Properties"); - - // - // Compute the difference between the new property set and the existing property set: - // - // 1) Any properties in the new set that were not defined in the existing set. - // - // 2) Any properties that appear in both sets but with different values. - // - // 3) Any properties not present in the new set but present in the existing set. - // In other words, the property has been removed. - // - for(p = props.begin(); p != props.end(); ++p) + PropertyDict::iterator q = old.find(p->first); + if(q == old.end()) { - PropertyDict::iterator q = old.find(p->first); - if(q == old.end()) + if(!p->second.empty()) { - if(!p->second.empty()) + // + // This property is new. + // + added.insert(*p); + } + } + else + { + if(p->second != q->second) + { + if(p->second.empty()) { // - // This property is new. + // This property was removed. // - added.insert(*p); + removed.insert(*p); } - } - else - { - if(p->second != q->second) + else { - if(p->second.empty()) - { - // - // This property was removed. - // - removed.insert(*p); - } - else - { - // - // This property has changed. - // - changed.insert(*p); - } + // + // This property has changed. + // + changed.insert(*p); } } } - - if(traceLevel > 0 && (!added.empty() || !changed.empty() || !removed.empty())) + } + + if(traceLevel > 0 && (!added.empty() || !changed.empty() || !removed.empty())) + { + Trace out(_logger, _name); + + out << "Summary of property changes"; + + if(!added.empty()) { - Trace out(_logger, _name); - - out << "Summary of property changes"; - - if(!added.empty()) + out << "\nNew properties:"; + for(p = added.begin(); p != added.end(); ++p) { - out << "\nNew properties:"; - for(p = added.begin(); p != added.end(); ++p) + out << "\n " << p->first; + if(traceLevel > 1) { - out << "\n " << p->first; - if(traceLevel > 1) - { - out << " = " << p->second; - } + out << " = " << p->second; } } + } - if(!changed.empty()) + if(!changed.empty()) + { + out << "\nChanged properties:"; + for(p = changed.begin(); p != changed.end(); ++p) { - out << "\nChanged properties:"; - for(p = changed.begin(); p != changed.end(); ++p) + out << "\n " << p->first; + if(traceLevel > 1) { - out << "\n " << p->first; - if(traceLevel > 1) - { - out << " = " << p->second << " (old value = " << _properties->getProperty(p->first) << ")"; - } + out << " = " << p->second << " (old value = " << _properties->getProperty(p->first) << ")"; } } + } - if(!removed.empty()) + if(!removed.empty()) + { + out << "\nRemoved properties:"; + for(p = removed.begin(); p != removed.end(); ++p) { - out << "\nRemoved properties:"; - for(p = removed.begin(); p != removed.end(); ++p) - { - out << "\n " << p->first; - } + out << "\n " << p->first; } } + } - // - // Update the property set. - // - - for(p = added.begin(); p != added.end(); ++p) - { - _properties->setProperty(p->first, p->second); - } + // + // Update the property set. + // - for(p = changed.begin(); p != changed.end(); ++p) - { - _properties->setProperty(p->first, p->second); - } + for(p = added.begin(); p != added.end(); ++p) + { + _properties->setProperty(p->first, p->second); + } - for(p = removed.begin(); p != removed.end(); ++p) - { - _properties->setProperty(p->first, ""); - } + for(p = changed.begin(); p != changed.end(); ++p) + { + _properties->setProperty(p->first, p->second); + } - callbacks = _updateCallbacks; + for(p = removed.begin(); p != removed.end(); ++p) + { + _properties->setProperty(p->first, ""); } // @@ -163,6 +158,10 @@ Ice::PropertiesAdminI::setProperties_async(const AMD_PropertiesAdmin_setProperti // cb->ice_response(); + // + // Copy the callbacks to allow callbacks to update the callbacks. + // + vector<PropertiesAdminUpdateCallbackPtr> callbacks = _updateCallbacks; if(!callbacks.empty()) { PropertyDict changes = added; @@ -185,13 +184,13 @@ Ice::PropertiesAdminI::setProperties_async(const AMD_PropertiesAdmin_setProperti void Ice::PropertiesAdminI::addUpdateCallback(const PropertiesAdminUpdateCallbackPtr& cb) { - IceUtil::Mutex::Lock sync(*this); + Lock sync(*this); _updateCallbacks.push_back(cb); } void Ice::PropertiesAdminI::removeUpdateCallback(const PropertiesAdminUpdateCallbackPtr& cb) { - IceUtil::Mutex::Lock sync(*this); + Lock sync(*this); _updateCallbacks.erase(remove(_updateCallbacks.begin(), _updateCallbacks.end(), cb), _updateCallbacks.end()); } diff --git a/cpp/src/Ice/PropertiesAdminI.h b/cpp/src/Ice/PropertiesAdminI.h index 17235ddb313..c0c22a9a0ff 100644 --- a/cpp/src/Ice/PropertiesAdminI.h +++ b/cpp/src/Ice/PropertiesAdminI.h @@ -10,14 +10,14 @@ #ifndef ICE_PROPERTIES_ADMIN_I_H #define ICE_PROPERTIES_ADMIN_I_H -#include <IceUtil/Mutex.h> +#include <IceUtil/RecMutex.h> #include <Ice/PropertiesAdmin.h> #include <Ice/LoggerF.h> namespace Ice { -class ICE_API PropertiesAdminI : public PropertiesAdmin, public NativePropertiesAdmin, private IceUtil::Mutex +class ICE_API PropertiesAdminI : public PropertiesAdmin, public NativePropertiesAdmin, private IceUtil::RecMutex { public: |