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 
29 namespace armarx
30 {
31  template <class Functor>
33 }
34 
35 namespace armarx::detail
36 {
37  struct ArmarXConnectionObserver;
38 }
39 
40 namespace 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 
57  void setProfilerTopic();
58  void setApplicationName();
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;
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
armarx::ApplicationNetworkStats::getDispatchObserver
Ice::Instrumentation::DispatchObserverPtr getDispatchObserver(const Ice::Current &, Ice::Int) override
Definition: ApplicationNetworkStats.cpp:177
IceStorm::Instrumentation::ObserverUpdaterPtr
::IceInternal::Handle<::IceStorm::Instrumentation::ObserverUpdater > ObserverUpdaterPtr
Definition: Instrumentation.h:192
armarx::ApplicationNetworkStats::getConnectionEstablishmentObserver
Ice::Instrumentation::ObserverPtr getConnectionEstablishmentObserver(const Ice::EndpointPtr &, const std::string &) override
Definition: ApplicationNetworkStats.cpp:147
armarx::ApplicationNetworkStats::getEndpointLookupObserver
Ice::Instrumentation::ObserverPtr getEndpointLookupObserver(const Ice::EndpointPtr &) override
Definition: ApplicationNetworkStats.cpp:154
armarx::ApplicationNetworkStats::ApplicationNetworkStats
ApplicationNetworkStats()
Definition: ApplicationNetworkStats.cpp:86
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
armarx::ApplicationNetworkStats::setObserverUpdater
void setObserverUpdater(const Ice::Instrumentation::ObserverUpdaterPtr &upd) override
Definition: ApplicationNetworkStats.cpp:183
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::ApplicationNetworkStats
The ApplicationNetworkStats class implements the Ice::Instrumentation::CommunicatorObserver interface...
Definition: ApplicationNetworkStats.h:51
armarx::ApplicationNetworkStats::getInvocationObserver
Ice::Instrumentation::InvocationObserverPtr getInvocationObserver(const Ice::ObjectPrx &, const std::string &, const Ice::Context &) override
Definition: ApplicationNetworkStats.cpp:169
armarx::detail
Definition: ApplicationNetworkStats.cpp:36
armarx::ApplicationNetworkStats::getThreadObserver
Ice::Instrumentation::ThreadObserverPtr getThreadObserver(const std::string &, const std::string &, Ice::Instrumentation::ThreadState, const Ice::Instrumentation::ThreadObserverPtr &) override
Definition: ApplicationNetworkStats.cpp:160
IceUtil::Handle
Definition: forward_declarations.h:30
armarx::ApplicationNetworkStats::start
void start(ProfilerListenerPrx profiler, const std::string &applicationName)
Definition: ApplicationNetworkStats.cpp:95
armarx::ApplicationNetworkStats::stopTask
void stopTask()
Definition: ApplicationNetworkStats.cpp:112
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:917
armarx::ApplicationNetworkStats::getConnectionObserver
Ice::Instrumentation::ConnectionObserverPtr getConnectionObserver(const Ice::ConnectionInfoPtr &c, const Ice::EndpointPtr &e, Ice::Instrumentation::ConnectionState s, const Ice::Instrumentation::ConnectionObserverPtr &previous) override
Definition: ApplicationNetworkStats.cpp:123
armarx::ApplicationNetworkStats::~ApplicationNetworkStats
~ApplicationNetworkStats() override
Definition: ApplicationNetworkStats.cpp:117
armarx::ApplicationNetworkStats::setApplicationName
void setApplicationName()
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::ApplicationNetworkStats::setProfilerTopic
void setProfilerTopic()
armarx::SimplePeriodicTask
Usage:
Definition: ApplicationNetworkStats.h:32