Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
dcdb
dcdb
Commits
8e877ac4
Commit
8e877ac4
authored
Dec 04, 2019
by
Micha Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor SensorGroups: Introduce method to retrieve plugin-specific Sensor objects
parent
6c5e419a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
84 deletions
+45
-84
dcdbpusher/includes/ConfiguratorTemplate.h
dcdbpusher/includes/ConfiguratorTemplate.h
+6
-22
dcdbpusher/includes/ConfiguratorTemplateEntity.h
dcdbpusher/includes/ConfiguratorTemplateEntity.h
+12
-28
dcdbpusher/includes/SensorGroupTemplate.h
dcdbpusher/includes/SensorGroupTemplate.h
+13
-8
dcdbpusher/sensors/msr/MSRConfigurator.cpp
dcdbpusher/sensors/msr/MSRConfigurator.cpp
+8
-13
dcdbpusher/sensors/perfevent/PerfeventConfigurator.cpp
dcdbpusher/sensors/perfevent/PerfeventConfigurator.cpp
+6
-11
dcdbpusher/sensors/procfs/ProcfsSensorGroup.h
dcdbpusher/sensors/procfs/ProcfsSensorGroup.h
+0
-2
No files found.
dcdbpusher/includes/ConfiguratorTemplate.h
View file @
8e877ac4
...
...
@@ -189,22 +189,14 @@ class ConfiguratorTemplate : public ConfiguratorInterface {
//group which consists of only one sensor
SB_Ptr
sensor
;
//perhaps one sensor is already present because it was copied from the template group
if
(
group
->
acquireSensors
().
size
()
!=
0
)
{
group
->
releaseSensors
();
sensor
=
std
::
dynamic_pointer_cast
<
SBase
>
(
group
->
acquireSensors
()[
0
]);
group
->
releaseSensors
();
//check if cast was successful (sensor != nullptr)
if
(
sensor
)
{
sensor
->
setName
(
val
.
second
.
data
());
if
(
readSensorBase
(
*
sensor
,
val
.
second
))
{
storeSensorGroup
(
group
);
}
else
{
LOG
(
warning
)
<<
"Single "
<<
_baseName
<<
" "
<<
val
.
second
.
data
()
<<
" could not be read! Omitting"
;
}
if
(
group
->
getDerivedSensors
().
size
()
!=
0
)
{
sensor
=
group
->
getDerivedSensors
()[
0
];
sensor
->
setName
(
val
.
second
.
data
());
if
(
readSensorBase
(
*
sensor
,
val
.
second
))
{
storeSensorGroup
(
group
);
}
else
{
LOG
(
warning
)
<<
"Single "
<<
_baseName
<<
" "
<<
val
.
second
.
data
()
<<
"
had a type mismatch when casting
! Omitting"
;
<<
val
.
second
.
data
()
<<
"
could not be read
! Omitting"
;
}
}
else
{
group
->
releaseSensors
();
...
...
@@ -426,14 +418,6 @@ class ConfiguratorTemplate : public ConfiguratorInterface {
* @param sGroup Group to store.
*/
void
storeSensorGroup
(
SG_Ptr
sGroup
)
{
//for (size_t i = 0; i < _sensorGroups.size(); ++i) {
// if (sGroup->getGroupName() == _sensorGroups[i]->getGroupName()) {
// _sensorGroups[i] = sGroup;
// _sensorGroupInterfaces[i] = sGroup;
// return;
// }
//}
_sensorGroups
.
push_back
(
sGroup
);
_sensorGroupInterfaces
.
push_back
(
sGroup
);
}
...
...
dcdbpusher/includes/ConfiguratorTemplateEntity.h
View file @
8e877ac4
...
...
@@ -220,22 +220,14 @@ class ConfiguratorTemplateEntity : public ConfiguratorTemplate<SBase, SGroup> {
//group which consists of only one sensor
SB_Ptr
sensor
;
//perhaps one sensor is already present because it was copied from the template group
if
(
group
->
acquireSensors
().
size
()
!=
0
)
{
group
->
releaseSensors
();
sensor
=
std
::
dynamic_pointer_cast
<
SBase
>
(
group
->
acquireSensors
()[
0
]);
group
->
releaseSensors
();
//check if cast was successful (sensor != nullptr)
if
(
sensor
)
{
sensor
->
setName
(
val
.
second
.
data
());
if
(
readSensorBase
(
*
sensor
,
val
.
second
))
{
storeSensorGroup
(
group
);
}
else
{
LOG
(
warning
)
<<
"Single "
<<
_baseName
<<
" "
<<
val
.
second
.
data
()
<<
" could not be read! Omitting"
;
}
if
(
group
->
getDerivedSensors
().
size
()
!=
0
)
{
sensor
=
group
->
getDerivedSensors
()[
0
];
sensor
->
setName
(
val
.
second
.
data
());
if
(
readSensorBase
(
*
sensor
,
val
.
second
))
{
storeSensorGroup
(
group
);
}
else
{
LOG
(
warning
)
<<
"Single "
<<
_baseName
<<
" "
<<
val
.
second
.
data
()
<<
"
had a type mismatch when casting
! Omitting"
;
<<
val
.
second
.
data
()
<<
"
could not be read
! Omitting"
;
}
}
else
{
group
->
releaseSensors
();
...
...
@@ -431,22 +423,14 @@ class ConfiguratorTemplateEntity : public ConfiguratorTemplate<SBase, SGroup> {
group
->
setEntity
(
&
sEntity
);
SB_Ptr
sensor
;
//perhaps one sensor is already present because it was copied from the template group
if
(
group
->
acquireSensors
().
size
()
!=
0
)
{
group
->
releaseSensors
();
sensor
=
std
::
dynamic_pointer_cast
<
SBase
>
(
group
->
acquireSensors
()[
0
]);
group
->
releaseSensors
();
//check if cast was successful (sensor != nullptr)
if
(
sensor
)
{
sensor
->
setName
(
val
.
second
.
data
());
if
(
readSensorBase
(
*
sensor
,
val
.
second
))
{
storeSensorGroup
(
group
);
}
else
{
LOG
(
warning
)
<<
"Single "
<<
_baseName
<<
" "
<<
val
.
second
.
data
()
<<
" could not be read! Omitting"
;
}
if
(
group
->
getDerivedSensors
().
size
()
!=
0
)
{
sensor
=
group
->
getDerivedSensors
()[
0
];
sensor
->
setName
(
val
.
second
.
data
());
if
(
readSensorBase
(
*
sensor
,
val
.
second
))
{
storeSensorGroup
(
group
);
}
else
{
LOG
(
warning
)
<<
"Single "
<<
_baseName
<<
" "
<<
val
.
second
.
data
()
<<
"
had a type mismatch when casting
! Omitting"
;
<<
val
.
second
.
data
()
<<
"
could not be read
! Omitting"
;
}
}
else
{
group
->
releaseSensors
();
...
...
dcdbpusher/includes/SensorGroupTemplate.h
View file @
8e877ac4
...
...
@@ -191,14 +191,6 @@ class SensorGroupTemplate : public SensorGroupInterface {
virtual
void
pushBackSensor
(
SBasePtr
s
)
final
override
{
//check if dynamic cast returns nullptr
if
(
S_Ptr
dSensor
=
std
::
dynamic_pointer_cast
<
S
>
(
s
))
{
//for (size_t i = 0; i < _sensors.size(); ++i) {
// if (dSensor->getName() == _sensors[i]->getName()) {
// _sensors[i] = dSensor;
// _baseSensors[i] = s;
// return;
// }
//}
_sensors
.
push_back
(
dSensor
);
_baseSensors
.
push_back
(
s
);
}
else
{
...
...
@@ -206,6 +198,19 @@ class SensorGroupTemplate : public SensorGroupInterface {
}
}
/**
* @brief Get access to all sensors of this group.
*
* @details Different from acquireSensors(): returns vector with plugin
* specific sensor pointers instead of general SensorBase pointers.
* Does not allow for thread-safe access. Only intended for
* usage by Configurators.
*
* @return Vector with smart pointers of all sensors associated with this
* group.
*/
std
::
vector
<
S_Ptr
>
&
getDerivedSensors
()
{
return
_sensors
;
}
/**
* @brief Print SensorGroup configuration.
*
...
...
dcdbpusher/sensors/msr/MSRConfigurator.cpp
View file @
8e877ac4
...
...
@@ -156,18 +156,13 @@ bool MSRConfigurator::readConfig(std::string cfgPath) {
//group which consists of only one sensor
SB_Ptr
sensor
;
//perhaps one sensor is already present because it was copied from the template group
if
(
group
->
acquireSensors
().
size
()
!=
0
)
{
sensor
=
std
::
dynamic_pointer_cast
<
MSRSensorBase
>
(
group
->
acquireSensors
()[
0
]);
//check if cast was successful (sensor != nullptr)
if
(
sensor
)
{
sensor
->
setName
(
val
.
second
.
data
());
if
(
readSensorBase
(
*
sensor
,
val
.
second
))
{
customizeAndStore
(
group
);
}
else
{
LOG
(
warning
)
<<
"Single "
<<
_baseName
<<
" "
<<
val
.
second
.
data
()
<<
" could not be read! Omitting"
;
}
if
(
group
->
getDerivedSensors
().
size
()
!=
0
)
{
sensor
=
group
->
getDerivedSensors
()[
0
];
sensor
->
setName
(
val
.
second
.
data
());
if
(
readSensorBase
(
*
sensor
,
val
.
second
))
{
customizeAndStore
(
group
);
}
else
{
LOG
(
warning
)
<<
"Single "
<<
_baseName
<<
" "
<<
val
.
second
.
data
()
<<
"
had a type mismatch when casting
! Omitting"
;
LOG
(
warning
)
<<
"Single "
<<
_baseName
<<
" "
<<
val
.
second
.
data
()
<<
"
could not be read
! Omitting"
;
}
}
else
{
sensor
=
std
::
make_shared
<
MSRSensorBase
>
(
val
.
second
.
data
());
...
...
@@ -199,8 +194,8 @@ void MSRConfigurator::customizeAndStore(SG_Ptr g) {
std
::
vector
<
SB_Ptr
>
original
;
// Initializing the vector of "reference" sensors and configuring the first CPU
for
(
auto
s
:
g
->
acquire
Sensors
())
{
SB_Ptr
sensor
=
s
td
::
dynamic_pointer_cast
<
MSRSensorBase
>
(
s
)
;
for
(
auto
s
:
g
->
getDerived
Sensors
())
{
SB_Ptr
sensor
=
s
;
// Copying the original sensors for reference
original
.
push_back
(
std
::
make_shared
<
MSRSensorBase
>
(
*
sensor
));
sensor
->
setCpu
(
*
it
);
...
...
dcdbpusher/sensors/perfevent/PerfeventConfigurator.cpp
View file @
8e877ac4
...
...
@@ -231,18 +231,13 @@ bool PerfeventConfigurator::readConfig(std::string cfgPath) {
//group which consists of only one sensor
std
::
shared_ptr
<
PerfSensorBase
>
sensor
;
//perhaps one sensor is already present because it was copied from the template group
if
(
group
.
acquireSensors
().
size
()
!=
0
)
{
sensor
=
std
::
dynamic_pointer_cast
<
PerfSensorBase
>
(
group
.
acquireSensors
()[
0
]);
//check if cast was successful (sensor != nullptr)
if
(
sensor
)
{
sensor
->
setName
(
val
.
second
.
data
());
if
(
readSensorBase
(
*
sensor
,
val
.
second
))
{
customizeAndStore
(
group
,
val
.
second
);
}
else
{
LOG
(
warning
)
<<
"Single "
<<
_baseName
<<
" "
<<
val
.
second
.
data
()
<<
" could not be read! Omitting"
;
}
if
(
group
.
getDerivedSensors
().
size
()
!=
0
)
{
sensor
=
group
.
getDerivedSensors
()[
0
];
sensor
->
setName
(
val
.
second
.
data
());
if
(
readSensorBase
(
*
sensor
,
val
.
second
))
{
customizeAndStore
(
group
,
val
.
second
);
}
else
{
LOG
(
warning
)
<<
"Single "
<<
_baseName
<<
" "
<<
val
.
second
.
data
()
<<
"
had a type mismatch when casting
! Omitting"
;
LOG
(
warning
)
<<
"Single "
<<
_baseName
<<
" "
<<
val
.
second
.
data
()
<<
"
could not be read
! Omitting"
;
}
}
else
{
sensor
=
std
::
make_shared
<
PerfSensorBase
>
(
val
.
second
.
data
());
...
...
dcdbpusher/sensors/procfs/ProcfsSensorGroup.h
View file @
8e877ac4
...
...
@@ -74,8 +74,6 @@ class ProcfsSensorGroup : public SensorGroupTemplate<ProcfsSensorBase> {
std
::
set
<
int
>
*
getCpuSet
()
{
return
&
this
->
_cpuSet
;
}
uint64_t
getScalingFactor
()
{
return
this
->
_scalingFactor
;
}
// Method to get the internal sensor vector used by the sensor group (different from getSensors)
std
::
vector
<
ProcfsSBPtr
>
&
getDerivedSensors
()
{
return
this
->
_sensors
;
}
void
replaceSensors
(
std
::
vector
<
ProcfsSBPtr
>
*
newSensors
);
void
printGroupConfig
(
LOG_LEVEL
ll
,
unsigned
leadingSpaces
=
16
)
final
override
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment