Commit 901c105d authored by Carla Guillen's avatar Carla Guillen
Browse files

Small bugfix when reading the severity configuration. Rearranging output messages in printConfig.

parent e80db3b5
......@@ -80,11 +80,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();
......@@ -84,65 +107,56 @@ void PerSystSqlOperator::compute(U_Ptr unit, qeJobData& jobData) {
}
}
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,
......
......@@ -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;
......
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