Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 8e877ac4 authored by Micha Müller's avatar Micha Müller
Browse files

Refactor SensorGroups: Introduce method to retrieve plugin-specific Sensor objects

parent 6c5e419a
......@@ -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);
}
......
......@@ -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();
......
......@@ -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.
*
......
......@@ -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->acquireSensors()) {
SB_Ptr sensor = std::dynamic_pointer_cast<MSRSensorBase>(s);
for (auto s : g->getDerivedSensors()) {
SB_Ptr sensor = s;
// Copying the original sensors for reference
original.push_back(std::make_shared<MSRSensorBase>(*sensor));
sensor->setCpu(*it);
......
......@@ -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());
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment