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 d5beecce authored by Alessio Netti's avatar Alessio Netti
Browse files

SensorMetadata structure now based on std::shared_ptr members

- Allows to encode "not set" states for single members
parent ce5173fc
......@@ -637,7 +637,7 @@ protected:
s->setName(s->getMqtt());
SensorMetadata* sm = s->getMetadata();
if(sm) {
if(sm->isOperation) {
if(sm->getIsOperation() && *sm->getIsOperation()) {
s->clearMetadata();
if(u.getInputs().size() != 1) {
LOG(error) << _operatorName << " " << op.getName() << ": Ambiguous operation field for sensor " << s->getName();
......@@ -645,15 +645,16 @@ protected:
}
// Replacing the metadata to publish the sensor as an operation of its corresponding input
SensorMetadata smNew;
smNew.publicName = u.getInputs()[0]->getMqtt();
smNew.setPublicName(u.getInputs()[0]->getMqtt());
smNew.setPattern(u.getInputs()[0]->getMqtt());
smNew.addOperation(s->getMqtt());
s->setMetadata(smNew);
} else {
sm->publicName = s->getMqtt();
sm->pattern = s->getMqtt();
sm->isVirtual = false;
if (sm->interval == 0)
sm->interval = (unsigned long long) op.getInterval() * 1000000;
sm->setPublicName(s->getMqtt());
sm->setPattern(s->getMqtt());
sm->setIsVirtual(false);
if (!sm->getInterval())
sm->setInterval((uint64_t)op.getInterval() * 1000000);
}
}
}
......
......@@ -152,8 +152,8 @@ void PerSystSqlOperator::compute(U_Ptr unit, qeJobData& jobData) {
for (const auto& in : subUnit->getInputs()) {
if( _scaling_factor == 1){
SensorMetadata buffer;
if(_queryEngine.queryMetadata(in->getName(), buffer)){
_scaling_factor = buffer.scale;
if(_queryEngine.queryMetadata(in->getName(), buffer) && buffer.getScale()){
_scaling_factor = *buffer.getScale();
LOG(debug) << "PerSystSql Operator " << _name << " using scaling factor of " << _scaling_factor;
}
}
......
......@@ -129,7 +129,7 @@ void SMUCNGPerfOperator::compute(U_Ptr unit) {
auto inputs = unit->getInputs();
auto timestamp = getTimestamp() - _go_back_ns;
for(auto& outSensor : unit->getOutputs()){
if(outSensor->getMetadata() == nullptr){
if(outSensor->getMetadata() == nullptr || !outSensor->getMetadata()->getScale()) {
LOG(error) << "No metadata defined, sensor " << outSensor->getName() << " can't compute anything.";
continue;
}
......@@ -180,7 +180,7 @@ void SMUCNGPerfOperator::computeMetricPerSecond(std::vector<SMUCNGPtr> &inputs,
SMUCSensorBase::Metric_t metric = found->second;
query(inputs[_metricToPosition[metric]]->getName(), timestamp, _buffers[0]);
reading_t metricpersec;
if(_buffers[0].size() > 0 && calculateMetricPerSec(_buffers[0][0], _measuring_interval_s, metricpersec, outSensor->getMetadata()->scale)){
if(_buffers[0].size() > 0 && calculateMetricPerSec(_buffers[0][0], _measuring_interval_s, metricpersec, *outSensor->getMetadata()->getScale())){
outSensor->storeReading(metricpersec);
}
}
......@@ -199,7 +199,7 @@ void SMUCNGPerfOperator::computeMetricRatio(std::vector<SMUCNGPtr>& inputs, SMUC
query(inputs[_metricToPosition[metric_divisor]]->getName(), timestamp, divisor);
bool wascalced = false;
reading_t ratio;
if (dividend.size() > 0 && divisor.size() > 0 && calculateMetricRatio(dividend[0], divisor[0], ratio, outSensor->getMetadata()->scale)) {
if (dividend.size() > 0 && divisor.size() > 0 && calculateMetricRatio(dividend[0], divisor[0], ratio, *outSensor->getMetadata()->getScale())) {
outSensor->storeReading(ratio);
}
}
......@@ -217,12 +217,12 @@ void SMUCNGPerfOperator::computeProfileMetric(std::vector<SMUCNGPtr>& inputs, SM
if(queryMetrics.size()==2){ //_buffer[0] and _buffer[1] should have been filled
auto second_value = computeSum(_buffers[1]);
if(second_value != 0){
result.value = value / (outSensor->getMetadata()->scale * static_cast<double>(second_value));
result.value = value / (*outSensor->getMetadata()->getScale() * static_cast<double>(second_value));
result.timestamp = _buffers[0][0].timestamp;
outSensor->storeReading(result);
}
} else { //only one buffer was filled
result.value = value / (outSensor->getMetadata()->scale * (_interval/1000.0));
result.value = value / (*outSensor->getMetadata()->getScale() * (_interval/1000.0));
result.timestamp = _buffers[0][0].timestamp;
outSensor->storeReading(result);
}
......@@ -265,7 +265,7 @@ void SMUCNGPerfOperator::computeFREQUENCY(std::vector<SMUCNGPtr>& inputs, SMUCNG
query(inputs[_metricToPosition[SMUCSensorBase::CLOCKS]]->getName(), timestamp, clocks);
query(inputs[_metricToPosition[SMUCSensorBase::CLOCKS_REF]]->getName(), timestamp, clocks_ref);
reading_t frequency;
if( clocks.size() > 0 && clocks_ref.size() > 0 && calculateFrequency(clocks_ref[0],clocks[0], MIN_FREQ_MHZ, MAX_FREQ_MHZ, frequency, outSensor->getMetadata()->scale)) {
if( clocks.size() > 0 && clocks_ref.size() > 0 && calculateFrequency(clocks_ref[0],clocks[0], MIN_FREQ_MHZ, MAX_FREQ_MHZ, frequency, *outSensor->getMetadata()->getScale())) {
outSensor->storeReading(frequency);
}
}
......@@ -306,31 +306,31 @@ void SMUCNGPerfOperator::computeFLOPS(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr&
if(flop_metric == SMUCSensorBase::FLOPS) {
if (calculateFlopsPerSec(scalar_double, scalar_single, packed128_double,
packed128_single, packed256_double, packed256_single,
packed512_double, packed512_single, result, outSensor->getMetadata()->scale, _measuring_interval_s) ) {
packed512_double, packed512_single, result, *outSensor->getMetadata()->getScale(), _measuring_interval_s) ) {
outSensor->storeReading(result);
}
} else if(flop_metric == SMUCSensorBase::PACKED_FLOPS){
if (calculatePackedFlopsPerSec(packed128_double, packed128_single,
packed256_double, packed256_single, packed512_double,
packed512_single, result, outSensor->getMetadata()->scale, _measuring_interval_s)) {
packed512_single, result, *outSensor->getMetadata()->getScale(), _measuring_interval_s)) {
outSensor->storeReading(result);
}
} else if(flop_metric == SMUCSensorBase::VECTORIZED_RATIO) {
if(calculateVectorizationRatio(scalar_double, scalar_single, packed128_double,
packed128_single, packed256_double, packed256_single,
packed512_double, packed512_single, result, outSensor->getMetadata()->scale)) {
packed512_double, packed512_single, result, *outSensor->getMetadata()->getScale())) {
outSensor->storeReading(result);
}
} else if (flop_metric == SMUCSensorBase::AVX512_TOVECTORIZED_RATIO) {
if (calculateAVX512FlopsToVectorizedRatio(packed128_double,
packed128_single, packed256_double, packed256_single,
packed512_double, packed512_single, result, outSensor->getMetadata()->scale )) {
packed512_double, packed512_single, result, *outSensor->getMetadata()->getScale())) {
outSensor->storeReading(result);
}
} else if (flop_metric == SMUCSensorBase::SINGLE_PRECISION_TO_TOTAL_RATIO) {
if(calculateSP_TO_TOTAL_RATIO(scalar_double, scalar_single, packed128_double,
packed128_single, packed256_double, packed256_single,
packed512_double, packed512_single, result, outSensor->getMetadata()->scale)){
packed512_double, packed512_single, result, *outSensor->getMetadata()->getScale())){
outSensor->storeReading(result);
}
}
......@@ -356,7 +356,7 @@ void SMUCNGPerfOperator::computeL3HIT_TO_L3MISS_RATIO(std::vector<SMUCNGPtr>& in
query(inputs[_metricToPosition[SMUCSensorBase::MEM_LOAD_RETIRED_L3_HIT]]->getName(), timestamp, l3_hits);
query(inputs[_metricToPosition[SMUCSensorBase::MEM_LOAD_RETIRED_L3_MISS]]->getName(), timestamp, l3_load_miss);
reading_t l3hitToMissRatio;
if (l3_misses.size() > 0 && l3_hits.size() > 0 && l3_load_miss.size() > 0 && calculateL3HitToL3MissRatio(l3_misses[0], l3_hits[0], l3_load_miss[0], l3hitToMissRatio, outSensor->getMetadata()->scale)) {
if (l3_misses.size() > 0 && l3_hits.size() > 0 && l3_load_miss.size() > 0 && calculateL3HitToL3MissRatio(l3_misses[0], l3_hits[0], l3_load_miss[0], l3hitToMissRatio, *outSensor->getMetadata()->getScale())) {
outSensor->storeReading(l3hitToMissRatio);
}
}
......@@ -377,7 +377,7 @@ void SMUCNGPerfOperator::computeMEMORY_BANDWIDTH(std::vector<SMUCNGPtr>& inputs,
query(inputs[_metricToPosition[SMUCSensorBase::CAS_COUNT_WRITE3]]->getName(), timestamp, mem_counters);
query(inputs[_metricToPosition[SMUCSensorBase::CAS_COUNT_WRITE4]]->getName(), timestamp, mem_counters);
query(inputs[_metricToPosition[SMUCSensorBase::CAS_COUNT_WRITE5]]->getName(), timestamp, mem_counters);
if(mem_counters.size() > 0 && calculateMemoryBandwidth(mem_counters, memory_bw, _measuring_interval_s, outSensor->getMetadata()->scale)){
if(mem_counters.size() > 0 && calculateMemoryBandwidth(mem_counters, memory_bw, _measuring_interval_s, *outSensor->getMetadata()->getScale())){
outSensor->storeReading(memory_bw);
}
......
......@@ -56,7 +56,8 @@ bool AnalyticsController::initialize(Configuration& settings, const string& conf
if(_manager->probe(_configPath, "collectagent.conf")) {
vector<string> topics;
for(const auto& kv : _metadataStore->getMap())
topics.push_back(kv.second.pattern);
if(kv.second.isValid())
topics.push_back(*kv.second.getPattern());
// Building the sensor navigator
try {
......@@ -163,10 +164,10 @@ bool AnalyticsController::publishSensors() {
for (const auto &u : op->getUnits())
for (const auto &s : u->getBaseOutputs()) {
if (s->getPublish()) {
if (s->getMetadata()) {
if (s->getMetadata() && s->getMetadata()->isValid()) {
DCDB::PublicSensor ps = Configuration::metadataToPublicSensor(*s->getMetadata());
err = _dcdbCfg->publishSensor(ps);
_metadataStore->store(s->getMetadata()->pattern, *s->getMetadata());
_metadataStore->store(*s->getMetadata()->getPattern(), *s->getMetadata());
} else {
err = _dcdbCfg->publishSensor(s->getName().c_str(), s->getMqtt().c_str());
}
......@@ -216,7 +217,8 @@ bool AnalyticsController::rebuildSensorNavigator() {
for (const auto &s : publicSensors)
if (!s.is_virtual) {
sBuf = Configuration::publicSensorToMetadata(s);
topics.push_back(sBuf.pattern);
if(sBuf.isValid())
topics.push_back(*sBuf.getPattern());
}
publicSensors.clear();
......
......@@ -273,9 +273,11 @@ int mqttCallback(SimpleMQTTMessage *msg)
LOG(error) << "Invalid metadata packed received!";
return 1;
}
DCDB::PublicSensor ps = Configuration::metadataToPublicSensor(sm);
err = mySensorConfig->publishSensor(ps);
metadataStore->store(sm.pattern, sm);
if(sm.isValid()) {
DCDB::PublicSensor ps = Configuration::metadataToPublicSensor(sm);
err = mySensorConfig->publishSensor(ps);
metadataStore->store(*sm.getPattern(), sm);
}
} else {
err = mySensorConfig->publishSensor(payload.c_str(), topic + DCDB_MAP_LEN);
}
......@@ -703,7 +705,8 @@ int main(int argc, char* const argv[]) {
for (const auto &s : publicSensors)
if (!s.is_virtual) {
sBuf = Configuration::publicSensorToMetadata(s);
metadataStore->store(sBuf.pattern, sBuf);
if(sBuf.isValid())
metadataStore->store(*sBuf.getPattern(), sBuf);
}
analyticsController = new AnalyticsController(mySensorConfig, mySensorDataStore);
......
......@@ -76,18 +76,26 @@ void Configuration::readAdditionalBlocks(boost::property_tree::iptree& cfg) {
DCDB::PublicSensor Configuration::metadataToPublicSensor(const SensorMetadata& sm) {
DCDB::PublicSensor ps;
ps.name = sm.publicName;
ps.is_virtual = sm.isVirtual;
ps.pattern = sm.pattern;
ps.unit = sm.unit;
ps.scaling_factor = sm.scale;
ps.ttl = sm.ttl;
ps.interval = sm.interval;
ps.operations = sm.operations;
if(sm.getPublicName())
ps.name = *sm.getPublicName();
if(sm.getIsVirtual())
ps.is_virtual = *sm.getIsVirtual();
if(sm.getPattern())
ps.pattern = *sm.getPattern();
if(sm.getUnit())
ps.unit = *sm.getUnit();
if(sm.getScale())
ps.scaling_factor = *sm.getScale();
if(sm.getTTL())
ps.ttl = *sm.getTTL();
if(sm.getInterval())
ps.interval = *sm.getInterval();
if(sm.getOperations())
ps.operations = *sm.getOperations();
uint64_t sensorMask = 0;
if(sm.integrable)
if(sm.getIntegrable() && *sm.getIntegrable())
sensorMask = sensorMask | INTEGRABLE;
if(sm.monotonic)
if(sm.getMonotonic() && *sm.getMonotonic())
sensorMask = sensorMask | MONOTONIC;
ps.sensor_mask = sensorMask;
return ps;
......@@ -95,19 +103,20 @@ DCDB::PublicSensor Configuration::metadataToPublicSensor(const SensorMetadata& s
SensorMetadata Configuration::publicSensorToMetadata(const DCDB::PublicSensor& ps) {
SensorMetadata sm;
sm.publicName = ps.name;
sm.isVirtual = ps.is_virtual;
sm.setPublicName(ps.name);
sm.setIsVirtual(ps.is_virtual);
// Stripping whitespace from the sensor pattern in the SID
sm.pattern = ps.pattern;
boost::algorithm::trim(sm.pattern);
string stripPattern = ps.pattern;
boost::algorithm::trim(stripPattern);
sm.setPattern(stripPattern);
sm.unit = ps.unit;
sm.scale = ps.scaling_factor;
sm.ttl = ps.ttl;
sm.interval = ps.interval;
sm.operations = ps.operations;
sm.integrable = ps.sensor_mask & INTEGRABLE;
sm.monotonic = ps.sensor_mask & MONOTONIC;
sm.setUnit(ps.unit);
sm.setScale(ps.scaling_factor);
sm.setTTL(ps.ttl);
sm.setInterval(ps.interval);
sm.setOperations(ps.operations);
sm.setIntegrable(ps.sensor_mask & INTEGRABLE);
sm.setMonotonic(ps.sensor_mask & MONOTONIC);
return sm;
}
......@@ -47,60 +47,70 @@ class SensorMetadata {
public:
SensorMetadata() :
isOperation(false),
isVirtual(false),
integrable(true),
monotonic(false),
publicName(""),
pattern(""),
unit(""),
scale(1.0),
ttl(0),
interval(0),
operations("") {}
isOperation(nullptr),
isVirtual(nullptr),
integrable(nullptr),
monotonic(nullptr),
publicName(nullptr),
pattern(nullptr),
unit(nullptr),
scale(nullptr),
ttl(nullptr),
interval(nullptr),
operations(nullptr) {}
SensorMetadata(const SensorMetadata& other) {
this->isOperation = other.isOperation;
this->isVirtual = other.isVirtual;
this->integrable = other.integrable;
this->monotonic = other.monotonic;
this->publicName = other.publicName;
this->pattern = other.pattern;
this->unit = other.unit;
this->scale = other.scale;
this->ttl = other.ttl;
this->interval = other.interval;
this->operations = other.operations;
SensorMetadata();
if(other.isOperation)
this->isOperation = std::make_shared<bool>(*other.isOperation);
if(other.isVirtual)
this->isVirtual = std::make_shared<bool>(*other.isVirtual);
if(other.integrable)
this->integrable = std::make_shared<bool>(*other.integrable);
if(other.monotonic)
this->monotonic = std::make_shared<bool>(*other.monotonic);
if(other.publicName)
this->publicName = std::make_shared<string>(*other.publicName);
if(other.pattern)
this->pattern = std::make_shared<string>(*other.pattern);
if(other.unit)
this->unit = std::make_shared<string>(*other.unit);
if(other.scale)
this->scale = std::make_shared<double>(*other.scale);
if(other.ttl)
this->ttl = std::make_shared<uint64_t>(*other.ttl);
if(other.interval)
this->interval = std::make_shared<uint64_t>(*other.interval);
if(other.operations)
this->operations = std::make_shared<string>(*other.operations);
}
SensorMetadata& operator=(const SensorMetadata& other) {
this->isOperation = other.isOperation;
this->isVirtual = other.isVirtual;
this->integrable = other.integrable;
this->monotonic = other.monotonic;
this->publicName = other.publicName;
this->pattern = other.pattern;
this->unit = other.unit;
this->scale = other.scale;
this->ttl = other.ttl;
this->interval = other.interval;
this->operations = other.operations;
if(other.isOperation)
this->isOperation = std::make_shared<bool>(*other.isOperation);
if(other.isVirtual)
this->isVirtual = std::make_shared<bool>(*other.isVirtual);
if(other.integrable)
this->integrable = std::make_shared<bool>(*other.integrable);
if(other.monotonic)
this->monotonic = std::make_shared<bool>(*other.monotonic);
if(other.publicName)
this->publicName = std::make_shared<string>(*other.publicName);
if(other.pattern)
this->pattern = std::make_shared<string>(*other.pattern);
if(other.unit)
this->unit = std::make_shared<string>(*other.unit);
if(other.scale)
this->scale = std::make_shared<double>(*other.scale);
if(other.ttl)
this->ttl = std::make_shared<uint64_t>(*other.ttl);
if(other.interval)
this->interval = std::make_shared<uint64_t>(*other.interval);
if(other.operations)
this->operations = std::make_shared<string>(*other.operations);
return *this;
}
bool addOperation(const string& opName) {
if (publicName.length()>0 && opName.length()>publicName.length() && !opName.compare(0, publicName.length(), publicName)) {
if(operations.length()==0)
operations = opName.substr(publicName.length());
else
operations += "," + opName.substr(publicName.length());
return true;
}
else
return false;
}
/**
* @brief Parses a JSON string and stores the content in this object.
*
......@@ -125,27 +135,27 @@ public:
void parsePTREE(boost::property_tree::iptree& config) {
BOOST_FOREACH(boost::property_tree::iptree::value_type &val, config) {
if (boost::iequals(val.first, "monotonic")) {
this->monotonic = to_bool(val.second.data());
this->monotonic = std::make_shared<bool>(to_bool(val.second.data()));
} else if (boost::iequals(val.first, "isVirtual")) {
this->isVirtual = to_bool(val.second.data());
this->isVirtual = std::make_shared<bool>(to_bool(val.second.data()));
} else if (boost::iequals(val.first, "isOperation")) {
this->isOperation = to_bool(val.second.data());
this->isOperation = std::make_shared<bool>(to_bool(val.second.data()));
} else if (boost::iequals(val.first, "integrable")) {
this->integrable = to_bool(val.second.data());
this->integrable = std::make_shared<bool>(to_bool(val.second.data()));
} else if (boost::iequals(val.first, "unit")) {
this->unit = val.second.data();
this->unit = std::make_shared<string>(val.second.data());
} else if (boost::iequals(val.first, "publicName")) {
this->publicName = val.second.data();
this->publicName = std::make_shared<string>(val.second.data());
} else if (boost::iequals(val.first, "pattern")) {
this->pattern = val.second.data();
this->pattern = std::make_shared<string>(val.second.data());
} else if (boost::iequals(val.first, "scale")) {
this->scale = stod(val.second.data());
this->scale = std::make_shared<double>(stod(val.second.data()));
} else if (boost::iequals(val.first, "interval")) {
this->interval = stoull(val.second.data()) * 1000000;
this->interval = std::make_shared<uint64_t>(stoull(val.second.data()) * 1000000);
} else if (boost::iequals(val.first, "ttl")) {
this->ttl = stoull(val.second.data()) * 1000000;
this->ttl = std::make_shared<uint64_t>(stoull(val.second.data()) * 1000000);
} else if (boost::iequals(val.first, "operations")) {
this->operations = _sanitizeOperations(val.second.data());
this->operations = std::make_shared<string>(_sanitizeOperations(val.second.data()));
}
}
}
......@@ -174,18 +184,46 @@ public:
return config;
}
// Public class members
bool isOperation;
bool isVirtual;
bool integrable;
bool monotonic;
string publicName;
string pattern;
string unit;
double scale;
uint64_t ttl;
uint64_t interval;
string operations;
const bool isValid() const { return publicName && pattern; }
//Getters and setters
const bool* getIsOperation() const { return isOperation.get(); }
const bool* getIsVirtual() const { return isVirtual.get(); }
const bool* getIntegrable() const { return integrable.get(); }
const bool* getMonotonic() const { return monotonic.get(); }
const string* getPublicName() const { return publicName.get(); }
const string* getPattern() const { return pattern.get(); }
const string* getUnit() const { return unit.get(); }
const double* getScale() const { return scale.get(); }
const uint64_t* getTTL() const { return ttl.get(); }
const uint64_t* getInterval() const { return interval.get(); }
const string* getOperations() const { return operations.get(); }
void setIsOperation(bool o) { isOperation = std::make_shared<bool>(o); }
void setIsVirtual(bool v) { isVirtual = std::make_shared<bool>(v); }
void setIntegrable(bool i) { integrable = std::make_shared<bool>(i); }
void setMonotonic(bool m) { monotonic = std::make_shared<bool>(m); }
void setPublicName(string p) { publicName = std::make_shared<string>(p); }
void setPattern(string p) { pattern = std::make_shared<string>(p); }
void setUnit(string u) { unit = std::make_shared<string>(u); }
void setScale(double s) { scale = std::make_shared<double>(s); }
void setTTL(uint64_t t) { ttl = std::make_shared<uint64_t>(t); }
void setInterval(uint64_t i) { interval = std::make_shared<uint64_t>(i); }
void setOperations(const string& o) { operations = std::make_shared<string>(o); }
// Adds a single operation. Requires the publicName field to be set.
bool addOperation(const string& opName) {
if (publicName && publicName->length()>0 && opName.length()>publicName->length()
&& !opName.compare(0, publicName->length(), *publicName)) {
if(!operations || operations->length()==0)
operations = std::make_shared<string>(opName.substr(publicName->length()));
else
*operations += "," + opName.substr(publicName->length());
return true;
}
else
return false;
}
protected:
......@@ -216,21 +254,46 @@ protected:
// Dumps the contents of "s" in "config"
void _dumpPTREE(boost::property_tree::ptree& config) const {
std::ostringstream scaleStream;
scaleStream << this->scale;
config.clear();
config.push_back(boost::property_tree::ptree::value_type("isOperation", boost::property_tree::ptree(this->isOperation ? "true" : "false")));
config.push_back(boost::property_tree::ptree::value_type("isVirtual", boost::property_tree::ptree(this->isVirtual ? "true" : "false")));
config.push_back(boost::property_tree::ptree::value_type("monotonic", boost::property_tree::ptree(this->monotonic ? "true" : "false")));
config.push_back(boost::property_tree::ptree::value_type("integrable", boost::property_tree::ptree(this->integrable ? "true" : "false")));
config.push_back(boost::property_tree::ptree::value_type("unit", boost::property_tree::ptree(this->unit)));
config.push_back(boost::property_tree::ptree::value_type("publicName", boost::property_tree::ptree(this->publicName)));
config.push_back(boost::property_tree::ptree::value_type("pattern", boost::property_tree::ptree(this->pattern)));
config.push_back(boost::property_tree::ptree::value_type("scale", boost::property_tree::ptree(scaleStream.str())));
config.push_back(boost::property_tree::ptree::value_type("interval", boost::property_tree::ptree(to_string(this->interval / 1000000))));
config.push_back(boost::property_tree::ptree::value_type("ttl", boost::property_tree::ptree(to_string(this->ttl / 1000000))));
config.push_back(boost::property_tree::ptree::value_type("operations", boost::property_tree::ptree(this->operations)));
if(scale) {
std::ostringstream scaleStream;
scaleStream << *scale;
config.push_back(boost::property_tree::ptree::value_type("scale", boost::property_tree::ptree(scaleStream.str())));
}
if(isOperation)
config.push_back(boost::property_tree::ptree::value_type("isOperation", boost::property_tree::ptree(*isOperation ? "true" : "false")));
if(isVirtual)
config.push_back(boost::property_tree::ptree::value_type("isVirtual", boost::property_tree::ptree(*isVirtual ? "true" : "false")));
if(monotonic)
config.push_back(boost::property_tree::ptree::value_type("monotonic", boost::property_tree::ptree(*monotonic ? "true" : "false")));
if(integrable)
config.push_back(boost::property_tree::ptree::value_type("integrable", boost::property_tree::ptree(*integrable ? "true" : "false")));
if(unit)
config.push_back(boost::property_tree::ptree::value_type("unit", boost::property_tree::ptree(*unit)));
if(publicName)
config.push_back(boost::property_tree::ptree::value_type("publicName", boost::property_tree::ptree(*publicName)));
if(pattern)
config.push_back(boost::property_tree::ptree::value_type("pattern", boost::property_tree::ptree(*pattern)));
if(interval)
config.push_back(boost::property_tree::ptree::value_type("interval", boost::property_tree::ptree(to_string(*interval / 1000000))));
if(ttl)
config.push_back(boost::property_tree::ptree::value_type("ttl", boost::property_tree::ptree(to_string(*ttl / 1000000))));
if(operations)
config.push_back(boost::property_tree::ptree::value_type("operations", boost::property_tree::ptree(*operations)));
}
// Protected class members
std::shared_ptr<bool> isOperation;
std::shared_ptr<bool> isVirtual;
std::shared_ptr<bool> integrable;
std::shared_ptr<bool> monotonic;
std::shared_ptr<string> publicName;
std::shared_ptr<string> pattern;
std::shared_ptr<string> unit;
std::shared_ptr<double> scale;
std::shared_ptr<uint64_t> ttl;
std::shared_ptr<uint64_t> interval;
std::shared_ptr<string> operations;
};
......@@ -341,7 +404,7 @@ public:
*/
int64_t getTTL(const string& key) {
auto it = _metadata.find(key);
return it==_metadata.end() ? -1 : it->second.ttl/1000000000;
return it==_metadata.end() || !it->second.getTTL() ? -1 : *it->second.getTTL()/1000000000;
}
/**
......