ProfilerStorage.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-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 MemoryX::component::ProfilerStorage
19  * @author haass ( tobias dot haass at student dot kit dot edu )
20  * @author Manfred Kroehnert ( manfred dot kroehnert at kit dot edu )
21  * @date 2013
22  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
23  * GNU General Public License
24  */
25 
26 #pragma once
27 
28 #include "../../libraries/memorytypes/entity/profiler/ProfilerMemorySnapshot.h"
29 #include "../../libraries/memorytypes/entity/profiler/ProfilerTransition.h"
30 
31 #include <MemoryX/interface/components/ProfilerStorageInterface.h>
32 #include <MemoryX/interface/components/CommonStorageInterface.h>
33 #include <MemoryX/interface/components/WorkingMemoryInterface.h>
34 #include <MemoryX/interface/components/LongtermMemoryInterface.h>
35 
38 
39 
40 namespace memoryx
41 {
44  {
45  public:
47  };
48 
49  /**
50  * @class ProfilerStorage
51  * @brief A brief description
52  *
53  * Detailed Description
54  */
56  virtual public armarx::Component,
57  virtual public ProfilerStorageInterface
58  {
59  public:
60  /**
61  * @see armarx::ManagedIceObject::getDefaultName()
62  */
63  std::string getDefaultName() const override;
64 
65  /**
66  * @see PropertyUser::createPropertyDefinitions()
67  */
69 
70  static ProfilerMemorySnapshotPtr CreateProfilerMemorySnapshot(const std::string& stateName, const WorkingMemoryInterfacePrx& workingMemoryProxy);
71 
72  protected:
73  /**
74  * @see armarx::ManagedIceObject::onInitComponent()
75  */
76  void onInitComponent() override;
77 
78  /**
79  * @see armarx::ManagedIceObject::onConnectComponent()
80  */
81  void onConnectComponent() override;
82 
83  /**
84  * @see armarx::ManagedIceObject::onDisconnectComponent()
85  */
86  void onDisconnectComponent() override;
87 
88  /**
89  * @see armarx::ManagedIceObject::onExitComponent()
90  */
91  void onExitComponent() override;
92 
93  std::string getCommonStorageName();
94 
95  std::string getWorkingMemoryName();
96 
97  std::string getLongtermMemoryName();
98 
99  /**
100  * @brief reportNetworkTraffic
101  * @param context
102  */
103  void reportNetworkTraffic(const std::string&, const std::string&, Ice::Int, Ice::Int, const Ice::Current& context = Ice::emptyCurrent) override;
104  void reportEvent(const armarx::ProfilerEvent& profilerEvent, const Ice::Current& context = Ice::emptyCurrent) override;
105 
106  void reportStatechartTransition(const armarx::ProfilerStatechartTransition& transition, const ::Ice::Current& context = Ice::emptyCurrent) override;
107  void reportStatechartInputParameters(const armarx::ProfilerStatechartParameters& inputParameters, const Ice::Current& = Ice::emptyCurrent) override;
108  void reportStatechartLocalParameters(const armarx::ProfilerStatechartParameters& localParameters, const Ice::Current& = Ice::emptyCurrent) override;
109  void reportStatechartOutputParameters(const armarx::ProfilerStatechartParameters& outputParameters, const Ice::Current& = Ice::emptyCurrent) override;
110 
111  void reportProcessCpuUsage(const armarx::ProfilerProcessCpuUsage& process, const Ice::Current& context = Ice::emptyCurrent) override;
112  void reportProcessMemoryUsage(const armarx::ProfilerProcessMemoryUsage& memoryUsage, const Ice::Current& context = Ice::emptyCurrent) override;
113 
114 
115  void reportEventList(const armarx::ProfilerEventList& events, const Ice::Current& = Ice::emptyCurrent) override;
116 
117  void reportStatechartTransitionList(const armarx::ProfilerStatechartTransitionList& transitions, const Ice::Current& = Ice::emptyCurrent) override;
118  void reportStatechartInputParametersList(const armarx::ProfilerStatechartParametersList& inputParametersList, const Ice::Current& = Ice::emptyCurrent) override;
119  void reportStatechartLocalParametersList(const armarx::ProfilerStatechartParametersList& localParametesList, const Ice::Current& = Ice::emptyCurrent) override;
120  void reportStatechartOutputParametersList(const armarx::ProfilerStatechartParametersList& outputParametersList, const Ice::Current& = Ice::emptyCurrent) override;
121 
122  void reportProcessCpuUsageList(const armarx::ProfilerProcessCpuUsageList& processes, const Ice::Current& = Ice::emptyCurrent) override;
123  void reportProcessMemoryUsageList(const armarx::ProfilerProcessMemoryUsageList& memoryUsages, const Ice::Current& = Ice::emptyCurrent) override;
124 
125  void reportStatechartTransitionWithParameters(const armarx::ProfilerStatechartTransitionWithParameters& transition, const ::Ice::Current& context = Ice::emptyCurrent) override;
126  void reportStatechartTransitionWithParametersList(const armarx::ProfilerStatechartTransitionWithParametersList& transitions, const Ice::Current& = Ice::emptyCurrent) override;
127 
128  private:
129  void saveToLongtermMemory();
130  void saveTransitionsToLongtermMemory();
131 
132  struct TransitionSnapshot
133  {
134  armarx::ProfilerStatechartTransition transition;
135  ProfilerMemorySnapshotPtr sourceStateMemorySnapshot;
136  ProfilerMemorySnapshotPtr targetStateMemorySnapshot;
137  };
138  using TransitionSnapshotList = std::vector<TransitionSnapshot>;
139 
140  CommonStorageInterfacePrx commonStoragePrx;
141  WorkingMemoryInterfacePrx workingMemoryPrx;
142  LongtermMemoryInterfacePrx longtermMemoryPrx;
143  PersistentProfilerDataSegmentBasePrx profilerDataSegmentPrx;
144 
146  armarx::RunningTask<ProfilerStorage>::pointer_type saveTransitionsToLongtermMemoryTask;
147 
148  std::mutex entityLogMutex;
149  memoryx::EntityBaseList entityLog;
150  std::mutex transitionSnapshotListMutex;
151  TransitionSnapshotList transitionSnapshotList;
152 
153  ProfilerMemorySnapshotPtr memorySnapshot;
154 
155  bool enabled;
156  int saveTimeout;
157  };
158 }
159 
memoryx::ProfilerStorage::onExitComponent
void onExitComponent() override
Definition: ProfilerStorage.cpp:91
memoryx::ProfilerStorage::reportStatechartInputParametersList
void reportStatechartInputParametersList(const armarx::ProfilerStatechartParametersList &inputParametersList, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerStorage.cpp:272
memoryx::ProfilerStorage::reportProcessMemoryUsageList
void reportProcessMemoryUsageList(const armarx::ProfilerProcessMemoryUsageList &memoryUsages, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerStorage.cpp:302
memoryx::ProfilerStoragePropertyDefinitions::ProfilerStoragePropertyDefinitions
ProfilerStoragePropertyDefinitions(std::string prefix)
Definition: ProfilerStorage.cpp:390
memoryx::ProfilerStorage::reportStatechartInputParameters
void reportStatechartInputParameters(const armarx::ProfilerStatechartParameters &inputParameters, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerStorage.cpp:195
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
memoryx::ProfilerStorage::reportStatechartTransition
void reportStatechartTransition(const armarx::ProfilerStatechartTransition &transition, const ::Ice::Current &context=Ice::emptyCurrent) override
Definition: ProfilerStorage.cpp:183
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
memoryx::ProfilerStorage::reportProcessMemoryUsage
void reportProcessMemoryUsage(const armarx::ProfilerProcessMemoryUsage &memoryUsage, const Ice::Current &context=Ice::emptyCurrent) override
Definition: ProfilerStorage.cpp:216
RunningTask.h
memoryx::ProfilerStorage::reportStatechartTransitionList
void reportStatechartTransitionList(const armarx::ProfilerStatechartTransitionList &transitions, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerStorage.cpp:241
memoryx::ProfilerStorage::reportProcessCpuUsage
void reportProcessCpuUsage(const armarx::ProfilerProcessCpuUsage &process, const Ice::Current &context=Ice::emptyCurrent) override
Definition: ProfilerStorage.cpp:210
memoryx::ProfilerStorage::onInitComponent
void onInitComponent() override
Definition: ProfilerStorage.cpp:50
memoryx::ProfilerStorage::getWorkingMemoryName
std::string getWorkingMemoryName()
Definition: ProfilerStorage.cpp:361
IceInternal::Handle< ProfilerMemorySnapshot >
memoryx::ProfilerStorage::reportStatechartTransitionWithParametersList
void reportStatechartTransitionWithParametersList(const armarx::ProfilerStatechartTransitionWithParametersList &transitions, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerStorage.cpp:384
memoryx::ProfilerStorage::getLongtermMemoryName
std::string getLongtermMemoryName()
Definition: ProfilerStorage.cpp:366
memoryx::ProfilerStorage::getDefaultName
std::string getDefaultName() const override
Definition: ProfilerStorage.cpp:44
memoryx::ProfilerStorage::reportNetworkTraffic
void reportNetworkTraffic(const std::string &, const std::string &, Ice::Int, Ice::Int, const Ice::Current &context=Ice::emptyCurrent) override
reportNetworkTraffic
Definition: ProfilerStorage.cpp:170
memoryx::ProfilerStoragePropertyDefinitions
Definition: ProfilerStorage.h:42
memoryx::ProfilerStorage::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: ProfilerStorage.cpp:372
memoryx::ProfilerStorage::reportStatechartOutputParameters
void reportStatechartOutputParameters(const armarx::ProfilerStatechartParameters &outputParameters, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerStorage.cpp:205
memoryx::ProfilerStorage::onDisconnectComponent
void onDisconnectComponent() override
Definition: ProfilerStorage.cpp:86
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
memoryx::ProfilerStorage
A brief description.
Definition: ProfilerStorage.h:55
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
memoryx::ProfilerStorage::onConnectComponent
void onConnectComponent() override
Definition: ProfilerStorage.cpp:74
IceUtil::Handle< class PropertyDefinitionContainer >
memoryx::ProfilerStorage::getCommonStorageName
std::string getCommonStorageName()
Definition: ProfilerStorage.cpp:355
memoryx::ProfilerStorage::reportEventList
void reportEventList(const armarx::ProfilerEventList &events, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerStorage.cpp:225
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:916
memoryx::ProfilerStorage::reportStatechartLocalParameters
void reportStatechartLocalParameters(const armarx::ProfilerStatechartParameters &localParameters, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerStorage.cpp:200
memoryx::ProfilerStorage::reportStatechartOutputParametersList
void reportStatechartOutputParametersList(const armarx::ProfilerStatechartParametersList &outputParametersList, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerStorage.cpp:282
memoryx::ProfilerStorage::reportEvent
void reportEvent(const armarx::ProfilerEvent &profilerEvent, const Ice::Current &context=Ice::emptyCurrent) override
Definition: ProfilerStorage.cpp:176
memoryx::ProfilerStorage::reportProcessCpuUsageList
void reportProcessCpuUsageList(const armarx::ProfilerProcessCpuUsageList &processes, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerStorage.cpp:287
memoryx::ProfilerStorage::reportStatechartTransitionWithParameters
void reportStatechartTransitionWithParameters(const armarx::ProfilerStatechartTransitionWithParameters &transition, const ::Ice::Current &context=Ice::emptyCurrent) override
Definition: ProfilerStorage.cpp:379
memoryx::ProfilerStorage::reportStatechartLocalParametersList
void reportStatechartLocalParametersList(const armarx::ProfilerStatechartParametersList &localParametesList, const Ice::Current &=Ice::emptyCurrent) override
Definition: ProfilerStorage.cpp:277
memoryx::ProfilerStorage::CreateProfilerMemorySnapshot
static ProfilerMemorySnapshotPtr CreateProfilerMemorySnapshot(const std::string &stateName, const WorkingMemoryInterfacePrx &workingMemoryProxy)
Definition: ProfilerStorage.cpp:318