ApplicationNetworkStats.h
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5*
6* ArmarX is free software; you can redistribute it and/or modify
7* it under the terms of the GNU General Public License version 2 as
8* published by the Free Software Foundation.
9*
10* ArmarX is distributed in the hope that it will be useful, but
11* WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17*
18* @package ArmarXCore::core::application
19* @author Manfred Kroehnert (manfred dot kroehnert at kit dot edu)
20* @date 2015
21* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22* GNU General Public License
23*/
24
25#pragma once
26
27#include <ArmarXCore/interface/core/Profiler.h>
28
29namespace armarx
30{
31 template <class Functor>
33}
34
35namespace armarx::detail
36{
38}
39
40namespace armarx
41{
42 /**
43 * \brief The ApplicationNetworkStats class implements the Ice::Instrumentation::CommunicatorObserver interface to meassure network traffic.
44 *
45 * It accumulates the amount of bytes received and sent over network and periodically publishes them
46 * over the IceStorm topic set via ApplicationNetworkStats::setProfilerTopic().
47 *
48 * The Stats object must be added to the Ice::InitializationData object used during Ice initialization.
49 * This is done in armarx::Application::doMain()
50 */
51 class ApplicationNetworkStats : public Ice::Instrumentation::CommunicatorObserver
52 {
53 public:
55 ~ApplicationNetworkStats() override;
56
59 void start(ProfilerListenerPrx profiler, const std::string& applicationName);
60 void stopTask();
61
62 Ice::Instrumentation::ConnectionObserverPtr
63 getConnectionObserver(const Ice::ConnectionInfoPtr& c,
64 const Ice::EndpointPtr& e,
65 Ice::Instrumentation::ConnectionState s,
66 const Ice::Instrumentation::ConnectionObserverPtr& previous) override;
67
68 Ice::Instrumentation::ObserverPtr
69 getConnectionEstablishmentObserver(const Ice::EndpointPtr&, const std::string&) override;
70 Ice::Instrumentation::ObserverPtr
71 getEndpointLookupObserver(const Ice::EndpointPtr&) override;
72 Ice::Instrumentation::ThreadObserverPtr
73 getThreadObserver(const std::string&,
74 const std::string&,
75 Ice::Instrumentation::ThreadState,
76 const Ice::Instrumentation::ThreadObserverPtr&) override;
77 Ice::Instrumentation::InvocationObserverPtr
78 getInvocationObserver(const Ice::ObjectPrx&,
79 const std::string&,
80 const Ice::Context&) override;
81 Ice::Instrumentation::DispatchObserverPtr getDispatchObserver(const Ice::Current&,
82 Ice::Int) override;
83 void setObserverUpdater(const Ice::Instrumentation::ObserverUpdaterPtr& upd) override;
84
85 private:
86 IceUtil::Handle<SimplePeriodicTask<std::function<void(void)>>> reportNetworkTrafficTask;
87 const int REPORT_TIME_MS{1000};
88
89 //we need to manually list every protocol since ice only tells us an id as protocol type and no string
94 };
95
97} // namespace armarx
constexpr T c
void start(ProfilerListenerPrx profiler, const std::string &applicationName)
Ice::Instrumentation::DispatchObserverPtr getDispatchObserver(const Ice::Current &, Ice::Int) override
Ice::Instrumentation::ThreadObserverPtr getThreadObserver(const std::string &, const std::string &, Ice::Instrumentation::ThreadState, const Ice::Instrumentation::ThreadObserverPtr &) override
Ice::Instrumentation::InvocationObserverPtr getInvocationObserver(const Ice::ObjectPrx &, const std::string &, const Ice::Context &) override
Ice::Instrumentation::ObserverPtr getConnectionEstablishmentObserver(const Ice::EndpointPtr &, const std::string &) override
Ice::Instrumentation::ConnectionObserverPtr getConnectionObserver(const Ice::ConnectionInfoPtr &c, const Ice::EndpointPtr &e, Ice::Instrumentation::ConnectionState s, const Ice::Instrumentation::ConnectionObserverPtr &previous) override
Ice::Instrumentation::ObserverPtr getEndpointLookupObserver(const Ice::EndpointPtr &) override
void setObserverUpdater(const Ice::Instrumentation::ObserverUpdaterPtr &upd) override
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceUtil::Handle< ApplicationNetworkStats > ApplicationNetworkStatsPtr
Definition Application.h:78