diff options
author | Benoit Foucher <benoit@zeroc.com> | 2014-06-27 10:31:41 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2014-06-27 10:31:41 +0200 |
commit | a4f93259dc3494d98addf38e69b87eb557d432b3 (patch) | |
tree | d2b78bb5cea24e33dc1b46be22dba6167e96c9ed /cpp/src/Ice/InstrumentationI.cpp | |
parent | Fix for ICE-5515 (ice_staticId on proxies) in Java, C#, Python, Ruby and PHP ... (diff) | |
download | ice-a4f93259dc3494d98addf38e69b87eb557d432b3.tar.bz2 ice-a4f93259dc3494d98addf38e69b87eb557d432b3.tar.xz ice-a4f93259dc3494d98addf38e69b87eb557d432b3.zip |
Better collocation optimization, fix for ICE-5489, ICE-5484
Diffstat (limited to 'cpp/src/Ice/InstrumentationI.cpp')
-rw-r--r-- | cpp/src/Ice/InstrumentationI.cpp | 98 |
1 files changed, 95 insertions, 3 deletions
diff --git a/cpp/src/Ice/InstrumentationI.cpp b/cpp/src/Ice/InstrumentationI.cpp index 87bdee12d84..6ff70f8aafb 100644 --- a/cpp/src/Ice/InstrumentationI.cpp +++ b/cpp/src/Ice/InstrumentationI.cpp @@ -274,13 +274,21 @@ public: ConnectionInfoPtr getConnectionInfo() const { - return _current.con->getInfo(); + if(_current.con) + { + return _current.con->getInfo(); + } + return 0; } EndpointPtr getEndpoint() const { - return _current.con->getEndpoint(); + if(_current.con) + { + return _current.con->getEndpoint(); + } + return 0; } const ConnectionPtr& @@ -292,7 +300,7 @@ public: const EndpointInfoPtr& getEndpointInfo() const { - if(!_endpointInfo) + if(_current.con && !_endpointInfo) { _endpointInfo = _current.con->getEndpoint()->getInfo(); } @@ -575,6 +583,70 @@ private: RemoteInvocationHelper::Attributes RemoteInvocationHelper::attributes; +class CollocatedInvocationHelper : public MetricsHelperT<RemoteMetrics> +{ +public: + + class Attributes : public AttributeResolverT<CollocatedInvocationHelper> + { + public: + + Attributes() + { + add("parent", &CollocatedInvocationHelper::getParent); + add("id", &CollocatedInvocationHelper::getId); + add("requestId", &CollocatedInvocationHelper::_requestId); + } + }; + static Attributes attributes; + + CollocatedInvocationHelper(int requestId, int size) : _requestId(requestId), _size(size) + { + } + + virtual string operator()(const string& attribute) const + { + return attributes(this, attribute); + } + + virtual void initMetrics(const RemoteMetricsPtr& v) const + { + v->size += _size; + } + + const string& + getId() const + { + if(_id.empty()) + { + ostringstream os; + os << _requestId; + _id = os.str(); + } + return _id; + } + + string + getParent() const + { + return "Communicator"; + } + +protected: + // + // COMPILERFIX: Clang 4.2 reports unused-private-field for the _requestId + // field that is only used in the nested Attributes class. + // + const int _requestId; + +private: + + const int _size; + mutable string _id; +}; + +CollocatedInvocationHelper::Attributes CollocatedInvocationHelper::attributes; + class ThreadHelper : public MetricsHelperT<ThreadMetrics> { public: @@ -794,6 +866,26 @@ InvocationObserverI::getRemoteObserver(const ConnectionInfoPtr& connection, return 0; } +RemoteObserverPtr +InvocationObserverI::getCollocatedObserver(int requestId, int size) +{ + try + { + RemoteObserverPtr delegate; + if(_delegate) + { + delegate = _delegate->getCollocatedObserver(requestId, size); + } + return getObserverWithDelegate<RemoteObserverI>("Collocated", + CollocatedInvocationHelper(requestId, size), + delegate); + } + catch(const exception&) + { + } + return 0; +} + CommunicatorObserverI::CommunicatorObserverI(const IceInternal::MetricsAdminIPtr& metrics, const Ice::Instrumentation::CommunicatorObserverPtr& delegate) : _metrics(metrics), |