diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/MetricsObserverI.h | 2 | ||||
-rw-r--r-- | cpp/src/Ice/ObserverHelper.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Ice/ObserverI.cpp | 102 |
3 files changed, 60 insertions, 50 deletions
diff --git a/cpp/src/Ice/MetricsObserverI.h b/cpp/src/Ice/MetricsObserverI.h index a30eb4ecd14..f3c1581f2e4 100644 --- a/cpp/src/Ice/MetricsObserverI.h +++ b/cpp/src/Ice/MetricsObserverI.h @@ -314,7 +314,7 @@ public: } template<typename Function> void - forEach(Function func) + forEach(const Function& func) { for(typename SeqType::const_iterator p = _objects.begin(); p != _objects.end(); ++p) { diff --git a/cpp/src/Ice/ObserverHelper.cpp b/cpp/src/Ice/ObserverHelper.cpp index 70f796e9bc9..f4e128ff652 100644 --- a/cpp/src/Ice/ObserverHelper.cpp +++ b/cpp/src/Ice/ObserverHelper.cpp @@ -38,11 +38,13 @@ InvocationObserver::attach(IceProxy::Ice::Object* proxy, const string& operation { if(context) { - ObserverHelperT::attach(obsv->getInvocationObserverWithContext(proxy, operation, *context)); + ObserverHelperT<Ice::Instrumentation::InvocationObserver>::attach( + obsv->getInvocationObserverWithContext(proxy, operation, *context)); } else { - ObserverHelperT::attach(obsv->getInvocationObserver(proxy, operation)); + ObserverHelperT<Ice::Instrumentation::InvocationObserver>::attach( + obsv->getInvocationObserver(proxy, operation)); } } } diff --git a/cpp/src/Ice/ObserverI.cpp b/cpp/src/Ice/ObserverI.cpp index bf1567a7561..57122288a18 100644 --- a/cpp/src/Ice/ObserverI.cpp +++ b/cpp/src/Ice/ObserverI.cpp @@ -36,9 +36,30 @@ getConnectionStateMetric(ConnectionState s) return &ConnectionMetrics::closing; case ConnectionStateClosed: return &ConnectionMetrics::closed; + default: + assert(false); + return 0; } } +struct ConnectionStateChanged +{ + ConnectionStateChanged(ConnectionState oldState, ConnectionState newState) : + oldState(oldState), newState(newState) + { + } + + void operator()(const ConnectionMetricsPtr& v) + { + --(v.get()->*getConnectionStateMetric(oldState)); + ++(v.get()->*getConnectionStateMetric(newState)); + } + + + ConnectionState oldState; + ConnectionState newState; +}; + int ThreadMetrics::* getThreadStateMetric(ThreadState s) { @@ -52,9 +73,35 @@ getThreadStateMetric(ThreadState s) return &ThreadMetrics::inUseForUser; case ThreadStateInUseForOther: return &ThreadMetrics::inUseForOther; + default: + assert(false); + return 0; } } +struct ThreadStateChanged +{ + ThreadStateChanged(ThreadState oldState, ThreadState newState) : oldState(oldState), newState(newState) + { + } + + void operator()(const ThreadMetricsPtr& v) + { + if(oldState != ThreadStateIdle) + { + --(v.get()->*getThreadStateMetric(oldState)); + } + if(newState != ThreadStateIdle) + { + ++(v.get()->*getThreadStateMetric(newState)); + } + } + + + ThreadState oldState; + ThreadState newState; +}; + template<typename Helper> void addEndpointAttributes(typename Helper::Attributes& attrs) { @@ -107,7 +154,7 @@ public: static Attributes attributes; ConnectionHelper(const ConnectionInfoPtr& con, const EndpointInfoPtr& endpt, ConnectionState state) : - MetricsHelperT("Connection"), _connection(con), _endpoint(endpt), _state(state) + MetricsHelperT<ConnectionMetrics>("Connection"), _connection(con), _endpoint(endpt), _state(state) { } @@ -196,7 +243,7 @@ public: }; static Attributes attributes; - DispatchHelper(const Current& current) : MetricsHelperT("Dispatch"), _current(current) + DispatchHelper(const Current& current) : MetricsHelperT<Metrics>("Dispatch"), _current(current) { } @@ -297,7 +344,7 @@ public: static Attributes attributes; InvocationHelper(const Ice::ObjectPrx& proxy, const string& op, const Ice::Context& ctx = Ice::Context()) : - MetricsHelperT("Invocation"), _proxy(proxy), _operation(op), _context(ctx) + MetricsHelperT<InvocationMetrics>("Invocation"), _proxy(proxy), _operation(op), _context(ctx) { } @@ -400,7 +447,7 @@ public: }; static Attributes attributes; - RemoteInvocationHelper(const ConnectionPtr& con) : MetricsHelperT("Remote"), _connection(con) + RemoteInvocationHelper(const ConnectionPtr& con) : MetricsHelperT<Metrics>("Remote"), _connection(con) { } @@ -474,7 +521,7 @@ public: static Attributes attributes; ThreadHelper(const string& parent, const string& id, ThreadState state) : - MetricsHelperT("Thread"), _parent(parent), _id(id), _state(state) + MetricsHelperT<ThreadMetrics>("Thread"), _parent(parent), _id(id), _state(state) { } @@ -519,7 +566,7 @@ public: EndpointHelper(const string& mapName, const EndpointInfoPtr& endpt, - const string& id) : MetricsHelperT(mapName), _id(id), _endpoint(endpt) + const string& id) : MetricsHelperT<Metrics>(mapName), _id(id), _endpoint(endpt) { } @@ -560,24 +607,7 @@ ConnectionObserverI::detach() void ConnectionObserverI::stateChanged(ConnectionState oldState, ConnectionState newState) { - struct StateChanged - { - StateChanged(ConnectionState oldState, ConnectionState newState) : - oldState(oldState), newState(newState) - { - } - - void operator()(const ConnectionMetricsPtr& v) - { - --(v.get()->*getConnectionStateMetric(oldState)); - ++(v.get()->*getConnectionStateMetric(newState)); - } - - - ConnectionState oldState; - ConnectionState newState; - }; - forEach(StateChanged(oldState, newState)); + forEach(ConnectionStateChanged(oldState, newState)); } void @@ -595,29 +625,7 @@ ConnectionObserverI::receivedBytes(Int num, Long duration) void ThreadObserverI::stateChanged(ThreadState oldState, ThreadState newState) { - struct StateChanged - { - StateChanged(ThreadState oldState, ThreadState newState) : oldState(oldState), newState(newState) - { - } - - void operator()(const ThreadMetricsPtr& v) - { - if(oldState != ThreadStateIdle) - { - --(v.get()->*getThreadStateMetric(oldState)); - } - if(newState != ThreadStateIdle) - { - ++(v.get()->*getThreadStateMetric(newState)); - } - } - - - ThreadState oldState; - ThreadState newState; - }; - forEach(StateChanged(oldState, newState)); + forEach(ThreadStateChanged(oldState, newState)); } InvocationObserverI::InvocationObserverI() |