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:
54 
56  ~ApplicationNetworkStats() override;
57 
58  void setProfilerTopic();
59  void setApplicationName();
60  void start(ProfilerListenerPrx profiler, const std::string& applicationName);
61  void stopTask();
62 
63  Ice::Instrumentation::ConnectionObserverPtr
64  getConnectionObserver(const Ice::ConnectionInfoPtr& c, const Ice::EndpointPtr& e,
65  Ice::Instrumentation::ConnectionState s,
66  const Ice::Instrumentation::ConnectionObserverPtr& previous) override;
67 
68  Ice::Instrumentation::ObserverPtr getConnectionEstablishmentObserver(const Ice::EndpointPtr&, const std::string&) override;
69  Ice::Instrumentation::ObserverPtr getEndpointLookupObserver(const Ice::EndpointPtr&) override;
70  Ice::Instrumentation::ThreadObserverPtr getThreadObserver(
71  const std::string&,
72  const std::string&,
73  Ice::Instrumentation::ThreadState,
74  const Ice::Instrumentation::ThreadObserverPtr&) override;
75  Ice::Instrumentation::InvocationObserverPtr getInvocationObserver(const Ice::ObjectPrx&, const std::string&, const Ice::Context&) override;
76  Ice::Instrumentation::DispatchObserverPtr getDispatchObserver(const Ice::Current&, Ice::Int) override;
78  private:
79  IceUtil::Handle<SimplePeriodicTask<std::function<void(void)>> > reportNetworkTrafficTask;
80  const int REPORT_TIME_MS
81  {
82  1000
83  };
84 
85  //we need to manually list every protocol since ice only tells us an id as protocol type and no string
90  };
92 }
93 
armarx::ApplicationNetworkStats::getDispatchObserver
Ice::Instrumentation::DispatchObserverPtr getDispatchObserver(const Ice::Current &, Ice::Int) override
Definition: ApplicationNetworkStats.cpp:145
armarx::ApplicationNetworkStats::getConnectionEstablishmentObserver
Ice::Instrumentation::ObserverPtr getConnectionEstablishmentObserver(const Ice::EndpointPtr &, const std::string &) override
Definition: ApplicationNetworkStats.cpp:125
armarx::ApplicationNetworkStats::getEndpointLookupObserver
Ice::Instrumentation::ObserverPtr getEndpointLookupObserver(const Ice::EndpointPtr &) override
Definition: ApplicationNetworkStats.cpp:130
armarx::ApplicationNetworkStats::ApplicationNetworkStats
ApplicationNetworkStats()
Definition: ApplicationNetworkStats.cpp:67
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::ApplicationNetworkStats::setObserverUpdater
void setObserverUpdater(const Ice::Instrumentation::ObserverUpdaterPtr &upd) override
Definition: ApplicationNetworkStats.cpp:150
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::ApplicationNetworkStats
The ApplicationNetworkStats class implements the Ice::Instrumentation::CommunicatorObserver interface...
Definition: ApplicationNetworkStats.h:51
IceStorm::Instrumentation::ObserverUpdaterPtr
::IceInternal::Handle< ::IceStorm::Instrumentation::ObserverUpdater > ObserverUpdaterPtr
Definition: Instrumentation.h:190
armarx::ApplicationNetworkStats::getInvocationObserver
Ice::Instrumentation::InvocationObserverPtr getInvocationObserver(const Ice::ObjectPrx &, const std::string &, const Ice::Context &) override
Definition: ApplicationNetworkStats.cpp:140
armarx::detail
Definition: ApplicationNetworkStats.cpp:34
armarx::ApplicationNetworkStats::getThreadObserver
Ice::Instrumentation::ThreadObserverPtr getThreadObserver(const std::string &, const std::string &, Ice::Instrumentation::ThreadState, const Ice::Instrumentation::ThreadObserverPtr &) override
Definition: ApplicationNetworkStats.cpp:135
IceUtil::Handle
Definition: forward_declarations.h:29
armarx::ApplicationNetworkStats::start
void start(ProfilerListenerPrx profiler, const std::string &applicationName)
Definition: ApplicationNetworkStats.cpp:75
armarx::ApplicationNetworkStats::stopTask
void stopTask()
Definition: ApplicationNetworkStats.cpp:93
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:916
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:103
armarx::ApplicationNetworkStats::~ApplicationNetworkStats
~ApplicationNetworkStats() override
Definition: ApplicationNetworkStats.cpp:98
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:28
armarx::ApplicationNetworkStats::setProfilerTopic
void setProfilerTopic()
armarx::SimplePeriodicTask
Usage:
Definition: ApplicationNetworkStats.h:32