Commit 967a4592 authored by Alessio Netti's avatar Alessio Netti
Browse files

Merge remote-tracking branch 'remotes/origin/development' into metadataManagement

parents 5682c14f 9d18514f
......@@ -51,22 +51,17 @@ void PerSystSqlConfigurator::sensorBase(AggregatorSensorBase& s, CFG_VAL config)
{
if (boost::iequals(val.first, "operation")) {
std::string opName = val.second.data();
if (opName == "sum")
s.setOperation(AggregatorSensorBase::SUM);
else if (opName == "average")
if (opName == "average"){
s.setOperation(AggregatorSensorBase::AVG);
else if (opName == "maximum")
s.setOperation(AggregatorSensorBase::MAX);
else if (opName == "minimum")
s.setOperation(AggregatorSensorBase::MIN);
else if (opName == "std")
s.setOperation(AggregatorSensorBase::STD);
else if (opName == "deciles" || opName == "percentiles" || opName == "quantile")
} else if (opName == "deciles" || opName == "percentiles" || opName == "quantile"){
s.setOperation(AggregatorSensorBase::QTL);
else if (opName == "observations")
} else if (opName == "observations" || opName == "numobs") {
s.setOperation(AggregatorSensorBase::OBS);
else if (opName == "average_severity")
s.setOperation(AggregatorSensorBase::AVG_SEV);
} else if (opName == "average_severity"){
s.setOperation(AggregatorSensorBase::AVG_SEV);
} else {
LOG(error) << "PerSystSqlConfigurator operation " << opName << " not supported!" ;
}
}
}
}
......@@ -80,11 +75,11 @@ void PerSystSqlConfigurator::operatorAttributes(PerSystSqlOperator& op, CFG_VAL
auto go_back_ms = std::stoi(val.second.data());
op.setGoBackInMs(go_back_ms);
} else if (boost::iequals(val.first, "severity_threshold")){
auto threshold = std::stod(val.second.data());
double threshold = std::stod(val.second.data());
op.setSeverityThreshold(threshold);
} else if (boost::iequals(val.first, "severity_exponent")){
auto exponent = std::stod(val.second.data());
op.setSeverityThreshold(exponent);
double exponent = std::stod(val.second.data());
op.setSeverityExponent(exponent);
} else if (boost::iequals(val.first, "severity_formula")){
std::string formula = val.second.data();
if(formula == "formula1"){
......
......@@ -59,6 +59,29 @@ PerSystSqlOperator::PerSystSqlOperator(const std::string& name) :
PerSystSqlOperator::~PerSystSqlOperator() {
}
void PerSystSqlOperator::printConfig(LOG_LEVEL ll) {
LOG_VAR(ll) << "backend=" << _backend;
LOG_VAR(ll) << "go_back_ms=" << _go_back_ns/1e6;
if(_backend == MARIADB){
LOG_VAR(ll) << "PerSystSQL Operator Connection information:";
LOG_VAR(ll) << "\tHost=" << _conn.host;
LOG_VAR(ll) << "\tUser=" << _conn.user;
LOG_VAR(ll) << "\tDatabase=" << _conn.database_name;
LOG_VAR(ll) << "\tPort=" << _conn.port;
LOG_VAR(ll) << "\tRotation=" << _conn.rotation;
LOG_VAR(ll) << "\tEvery_X_days=" << _conn.every_x_days;
}
LOG_VAR(ll) << "Property Configuration:";
LOG_VAR(ll) << "\tnumber_of_even_quantiles=" << _number_of_even_quantiles;
LOG_VAR(ll) << "\tproperty_id=" << _property_id;
LOG_VAR(ll) << "\tscaling_factor=" << _scaling_factor;
LOG_VAR(ll) << "Severity Configuration:";
LOG_VAR(ll) << "\tseverity_formula=" << _severity_formula;
LOG_VAR(ll) << "\tseverity_exponent=" << _severity_exponent;
LOG_VAR(ll) << "\tseverity_threshold=" << _severity_threshold;
LOG_VAR(ll) << "\tseverity_max_memory=" << _severity_max_memory;
}
void PerSystSqlOperator::compute(U_Ptr unit, qeJobData& jobData) {
// Clearing the buffer, if already allocated
_buffer.clear();
......@@ -73,80 +96,67 @@ void PerSystSqlOperator::compute(U_Ptr unit, qeJobData& jobData) {
jobData.startTime : jobEnd - my_timestamp;
// Job units are hierarchical, and thus we iterate over all sub-units associated to each single node
for (const auto& subUnit : unit->getSubUnits()) {
// Getting the most recent values as specified in _window
// Since we do not clear the internal buffer, all sensor readings will be accumulated in the same vector
for (const auto& in : subUnit->getInputs()) {
if (!_queryEngine.querySensor(in->getName(), my_timestamp,
my_timestamp, _buffer, false)) {
if (!_queryEngine.querySensor(in->getName(), my_timestamp, my_timestamp, _buffer, false)) {
LOG(debug)<< "PerSystSql Operator " << _name << " cannot read from sensor " << in->getName() << "!";
return;
}
}
}
static bool persystdb_initialized = false;
if(_backend == MARIADB){
if (!persystdb_initialized) {
LOG(debug)<< "PerSystSQL Operator Connection information:";
LOG(debug) << "\tHost=" << _conn.host;
LOG(debug) << "\tUser=" << _conn.user;
LOG(debug) << "\tDatabase=" << _conn.database_name;
LOG(debug) << "\tPort=" << _conn.port;
LOG(debug) << "\tRotation=" << _conn.rotation;
LOG(debug) << "\tEvery_X_days=" << _conn.every_x_days;
if ( _backend == MARIADB && !persystdb_initialized) {
bool persystdb_initialized = persystdb.initializeConnection(_conn.host, _conn.user, _conn.password, _conn.database_name, _conn.rotation, _conn.port, _conn.every_x_days);
if(!persystdb_initialized) {
LOG(error) << "Unable to establish connection to database";
return;
}
}
}
Aggregate_info_t agg_info;
std::string table_suffix;
if(_backend == MARIADB){
std::stringstream jobidBuilder;
jobidBuilder << jobData.jobId;
if(_backend == MARIADB){
std::stringstream jobidBuilder;
jobidBuilder << jobData.jobId;
std::vector<std::string> job_ids;
job_ids.push_back(jobidBuilder.str());
std::vector<std::string> job_ids;
job_ids.push_back(jobidBuilder.str());
std::map<std::string, std::string> job_map;
if(!persystdb.getTableSuffix(table_suffix)){
LOG(error) << "failed to create table!";
return;
}
if(!persystdb.getDBJobIDs(job_ids, job_map)){
return;
}
std::map<std::string, std::string> job_map;
if(!persystdb.getTableSuffix(table_suffix)){
LOG(error) << "failed to create table!";
return;
}
if(!persystdb.getDBJobIDs(job_ids, job_map)){
return;
}
// handle jobs which are not present
for(auto &job_id_string : job_ids ){
auto search = job_map.find(job_id_string);
if(search == job_map.end()){ //Not found
int job_id_db;
if(persystdb.insertIntoJob(job_id_string, jobData.userId, job_id_db, table_suffix)){
agg_info.job_id_db = std::to_string(job_id_db);
} else {
continue;
}
}
}
agg_info.timestamp = (my_timestamp/1e9);
}
// handle jobs which are not present
for(auto &job_id_string : job_ids ){
auto search = job_map.find(job_id_string);
if(search == job_map.end()){ //Not found
int job_id_db;
if(persystdb.insertIntoJob(job_id_string, jobData.userId, job_id_db, table_suffix)){
agg_info.job_id_db = std::to_string(job_id_db);
} else {
continue;
}
}
}
agg_info.timestamp = (my_timestamp/1e9);
}
compute_internal(unit, _buffer, agg_info);
if(_backend == MARIADB){
persystdb.insertInAggregateTable(table_suffix, agg_info);
if(_number_of_calls % 10 == 0 && persystdb_initialized){
persystdb.finalizeConnection();
persystdb_initialized = false;
if(_backend == MARIADB){
persystdb.insertInAggregateTable(table_suffix, agg_info);
if(_number_of_calls % 10 == 0 && persystdb_initialized){
persystdb.finalizeConnection();
persystdb_initialized = false;
}
_number_of_calls++;
}
_number_of_calls++;
}
}
void PerSystSqlOperator::compute_internal(U_Ptr& unit,
vector<reading_t>& buffer, Aggregate_info_t & agg_info) {
void PerSystSqlOperator::compute_internal(U_Ptr& unit, vector<reading_t>& buffer, Aggregate_info_t & agg_info) {
_quantileSensors.clear();
reading_t reading;
......@@ -162,11 +172,9 @@ void PerSystSqlOperator::compute_internal(U_Ptr& unit,
switch (op) {
case AggregatorSensorBase::AVG:
if (_backend == CASSANDRA) {
reading.value = std::accumulate(douBuffer.begin(),
douBuffer.end(), 0.0) / douBuffer.size()
* _scaling_factor;
reading.value = std::accumulate(douBuffer.begin(), douBuffer.end(), 0.0)/douBuffer.size() * _scaling_factor;
} else {
agg_info.average = std::accumulate(douBuffer.begin(), douBuffer.end(), 0.0) / douBuffer.size();
agg_info.average = std::accumulate(douBuffer.begin(), douBuffer.end(), 0.0)/douBuffer.size();
}
break;
case AggregatorSensorBase::OBS:
......
......@@ -55,6 +55,7 @@ public:
PerSystSqlOperator(const std::string& name);
virtual ~PerSystSqlOperator();
void compute(U_Ptr unit, qeJobData& jobData) override;
void printConfig(LOG_LEVEL ll) override;
unsigned int getNumberOfEvenQuantiles() const {
return _number_of_even_quantiles;
......
......@@ -322,10 +322,16 @@ void SMUCNGPerfOperator::computeMISSBRANCHES_TO_TOTAL_BRANCH_RATIO(std::vector<S
}
}
void SMUCNGPerfOperator::computeMEMORY_BANDWIDTH(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr& outSensor,
const uint64_t timestamp) {
std::vector<reading_t> mem_counters;
//ToDo
void SMUCNGPerfOperator::computeMEMORY_BANDWIDTH(std::vector<SMUCNGPtr>& inputs, SMUCNGPtr& outSensor, const uint64_t timestamp) {
std::vector<reading_t> & mem_counters = _buffers[0];
reading_t memory_bw;
query(inputs[_metricToPosition[SMUCSensorBase::CAS_COUNT_READ]]->getName(), timestamp, mem_counters);
query(inputs[_metricToPosition[SMUCSensorBase::CAS_COUNT_WRITE]]->getName(), timestamp, mem_counters);
if(mem_counters.size() > 0 && calculateMemoryBandwidth(mem_counters, memory_bw, _measuring_interval_s)){
outSensor->storeReading(memory_bw);
}
}
bool SMUCNGPerfOperator::isAMetricPerSecond(SMUCSensorBase::Metric_t comp){
......
......@@ -68,6 +68,8 @@ public:
PERF_COUNT_HW_BRANCH_INSTRUCTIONS=32,
PERF_COUNT_HW_BRANCH_MISSES=33,
CORE_TEMPERATURE=34,
CAS_COUNT_READ=35,
CAS_COUNT_WRITE=36,
//
CPI=50,
FREQUENCY=51,
......
......@@ -43,7 +43,7 @@ public:
IPMISensorGroup(const IPMISensorGroup& other);
virtual ~IPMISensorGroup();
IPMISensorGroup& operator=(const IPMISensorGroup& other);
uint64_t nextReadingTime();
uint64_t nextReadingTime() override;
bool checkConfig();
private:
......
......@@ -58,7 +58,7 @@ FETCH = wget -c --no-check-certificate -O
MD5 = $(if $(shell which md5 2>/dev/null),md5,$(if $(shell md5sum --tag Makefile 2&> /dev/null || true),md5sum --tag,openssl md5))
DISTFILESNAMES = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/;.*//'))
DISTFILESPATHS_FULL = $(foreach f,$(DISTFILES),$(shell echo "$(f)" | sed 's/.tar.gz;.*//; s/.tgz;.*//; s/.zip;.*//' ))
DISTFILESPATHS = apache-cassandra-$(CASSANDRA_VERSION) mosquitto-$(MOSQUITTO_VERSION) boost_$(BOOST_VERSION_U) openssl-$(OPENSSL_VERSION) libuv-v$(LIBUV_VERSION) cpp-driver-$(CPPDRV_VERSION) opencv-$(OPENCV_VERSION)
DISTFILESPATHS = apache-cassandra-$(CASSANDRA_VERSION) mosquitto-$(MOSQUITTO_VERSION) boost_$(BOOST_VERSION_U) openssl-$(OPENSSL_VERSION) libuv-v$(LIBUV_VERSION) cpp-driver-$(CPPDRV_VERSION) opencv-$(OPENCV_VERSION) mariadb-connector-c-$(MARIADBCONNECTOR_VERSION)-src
ifneq (,$(findstring bacnet,$(PLUGINS)))
DISTFILESPATHS += bacnet-stack-$(BACNET-STACK_VERSION)
endif
......
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