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
30
33#include <MemoryX/interface/components/CommonStorageInterface.h>
34#include <MemoryX/interface/components/LongtermMemoryInterface.h>
35#include <MemoryX/interface/components/ProfilerStorageInterface.h>
36#include <MemoryX/interface/components/WorkingMemoryInterface.h>
37
38namespace memoryx
39{
45
46 /**
47 * @class ProfilerStorage
48 * @brief A brief description
49 *
50 * Detailed Description
51 */
53 virtual public armarx::Component,
54 virtual public ProfilerStorageInterface
55 {
56 public:
57 /**
58 * @see armarx::ManagedIceObject::getDefaultName()
59 */
60 std::string getDefaultName() const override;
61
62 /**
63 * @see PropertyUser::createPropertyDefinitions()
64 */
66
68 CreateProfilerMemorySnapshot(const std::string& stateName,
69 const WorkingMemoryInterfacePrx& workingMemoryProxy);
70
71 protected:
72 /**
73 * @see armarx::ManagedIceObject::onInitComponent()
74 */
75 void onInitComponent() override;
76
77 /**
78 * @see armarx::ManagedIceObject::onConnectComponent()
79 */
80 void onConnectComponent() override;
81
82 /**
83 * @see armarx::ManagedIceObject::onDisconnectComponent()
84 */
85 void onDisconnectComponent() override;
86
87 /**
88 * @see armarx::ManagedIceObject::onExitComponent()
89 */
90 void onExitComponent() override;
91
92 std::string getCommonStorageName();
93
94 std::string getWorkingMemoryName();
95
96 std::string getLongtermMemoryName();
97
98 /**
99 * @brief reportNetworkTraffic
100 * @param context
101 */
102 void reportNetworkTraffic(const std::string&,
103 const std::string&,
104 Ice::Int,
105 Ice::Int,
106 const Ice::Current& context = Ice::emptyCurrent) override;
107 void reportEvent(const armarx::ProfilerEvent& profilerEvent,
108 const Ice::Current& context = Ice::emptyCurrent) override;
109
110 void reportStatechartTransition(const armarx::ProfilerStatechartTransition& transition,
111 const ::Ice::Current& context = Ice::emptyCurrent) override;
112 void
113 reportStatechartInputParameters(const armarx::ProfilerStatechartParameters& inputParameters,
114 const Ice::Current& = Ice::emptyCurrent) override;
115 void
116 reportStatechartLocalParameters(const armarx::ProfilerStatechartParameters& localParameters,
117 const Ice::Current& = Ice::emptyCurrent) override;
119 const armarx::ProfilerStatechartParameters& outputParameters,
120 const Ice::Current& = Ice::emptyCurrent) override;
121
122 void reportProcessCpuUsage(const armarx::ProfilerProcessCpuUsage& process,
123 const Ice::Current& context = Ice::emptyCurrent) override;
124 void reportProcessMemoryUsage(const armarx::ProfilerProcessMemoryUsage& memoryUsage,
125 const Ice::Current& context = Ice::emptyCurrent) override;
126
127
128 void reportEventList(const armarx::ProfilerEventList& events,
129 const Ice::Current& = Ice::emptyCurrent) override;
130
131 void
132 reportStatechartTransitionList(const armarx::ProfilerStatechartTransitionList& transitions,
133 const Ice::Current& = Ice::emptyCurrent) override;
135 const armarx::ProfilerStatechartParametersList& inputParametersList,
136 const Ice::Current& = Ice::emptyCurrent) override;
138 const armarx::ProfilerStatechartParametersList& localParametesList,
139 const Ice::Current& = Ice::emptyCurrent) override;
141 const armarx::ProfilerStatechartParametersList& outputParametersList,
142 const Ice::Current& = Ice::emptyCurrent) override;
143
144 void reportProcessCpuUsageList(const armarx::ProfilerProcessCpuUsageList& processes,
145 const Ice::Current& = Ice::emptyCurrent) override;
146 void
147 reportProcessMemoryUsageList(const armarx::ProfilerProcessMemoryUsageList& memoryUsages,
148 const Ice::Current& = Ice::emptyCurrent) override;
149
151 const armarx::ProfilerStatechartTransitionWithParameters& transition,
152 const ::Ice::Current& context = Ice::emptyCurrent) override;
154 const armarx::ProfilerStatechartTransitionWithParametersList& transitions,
155 const Ice::Current& = Ice::emptyCurrent) override;
156
157 private:
158 void saveToLongtermMemory();
159 void saveTransitionsToLongtermMemory();
160
161 struct TransitionSnapshot
162 {
163 armarx::ProfilerStatechartTransition transition;
164 ProfilerMemorySnapshotPtr sourceStateMemorySnapshot;
165 ProfilerMemorySnapshotPtr targetStateMemorySnapshot;
166 };
167
168 using TransitionSnapshotList = std::vector<TransitionSnapshot>;
169
170 CommonStorageInterfacePrx commonStoragePrx;
171 WorkingMemoryInterfacePrx workingMemoryPrx;
172 LongtermMemoryInterfacePrx longtermMemoryPrx;
173 PersistentProfilerDataSegmentBasePrx profilerDataSegmentPrx;
174
176 armarx::RunningTask<ProfilerStorage>::pointer_type saveTransitionsToLongtermMemoryTask;
177
178 std::mutex entityLogMutex;
179 memoryx::EntityBaseList entityLog;
180 std::mutex transitionSnapshotListMutex;
181 TransitionSnapshotList transitionSnapshotList;
182
183 ProfilerMemorySnapshotPtr memorySnapshot;
184
185 bool enabled;
186 int saveTimeout;
187 };
188} // namespace memoryx
Default component property definition container.
Definition Component.h:70
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
A brief description.
void reportProcessCpuUsage(const armarx::ProfilerProcessCpuUsage &process, const Ice::Current &context=Ice::emptyCurrent) override
void reportStatechartOutputParametersList(const armarx::ProfilerStatechartParametersList &outputParametersList, const Ice::Current &=Ice::emptyCurrent) override
void onInitComponent() override
void reportStatechartTransitionWithParameters(const armarx::ProfilerStatechartTransitionWithParameters &transition, const ::Ice::Current &context=Ice::emptyCurrent) override
void reportProcessMemoryUsage(const armarx::ProfilerProcessMemoryUsage &memoryUsage, const Ice::Current &context=Ice::emptyCurrent) override
void reportStatechartTransitionWithParametersList(const armarx::ProfilerStatechartTransitionWithParametersList &transitions, const Ice::Current &=Ice::emptyCurrent) override
void onDisconnectComponent() override
void reportStatechartInputParametersList(const armarx::ProfilerStatechartParametersList &inputParametersList, const Ice::Current &=Ice::emptyCurrent) override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void reportStatechartOutputParameters(const armarx::ProfilerStatechartParameters &outputParameters, const Ice::Current &=Ice::emptyCurrent) override
void reportStatechartTransitionList(const armarx::ProfilerStatechartTransitionList &transitions, const Ice::Current &=Ice::emptyCurrent) override
void reportStatechartLocalParametersList(const armarx::ProfilerStatechartParametersList &localParametesList, const Ice::Current &=Ice::emptyCurrent) override
void reportStatechartTransition(const armarx::ProfilerStatechartTransition &transition, const ::Ice::Current &context=Ice::emptyCurrent) override
void reportNetworkTraffic(const std::string &, const std::string &, Ice::Int, Ice::Int, const Ice::Current &context=Ice::emptyCurrent) override
reportNetworkTraffic
void reportEventList(const armarx::ProfilerEventList &events, const Ice::Current &=Ice::emptyCurrent) override
void onConnectComponent() override
static ProfilerMemorySnapshotPtr CreateProfilerMemorySnapshot(const std::string &stateName, const WorkingMemoryInterfacePrx &workingMemoryProxy)
void reportProcessMemoryUsageList(const armarx::ProfilerProcessMemoryUsageList &memoryUsages, const Ice::Current &=Ice::emptyCurrent) override
void reportEvent(const armarx::ProfilerEvent &profilerEvent, const Ice::Current &context=Ice::emptyCurrent) override
void onExitComponent() override
void reportStatechartInputParameters(const armarx::ProfilerStatechartParameters &inputParameters, const Ice::Current &=Ice::emptyCurrent) override
void reportStatechartLocalParameters(const armarx::ProfilerStatechartParameters &localParameters, const Ice::Current &=Ice::emptyCurrent) override
void reportProcessCpuUsageList(const armarx::ProfilerProcessCpuUsageList &processes, const Ice::Current &=Ice::emptyCurrent) override
std::string getDefaultName() const override
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
VirtualRobot headers.
IceInternal::Handle< ProfilerMemorySnapshot > ProfilerMemorySnapshotPtr