Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
dcdb
dcdb
Commits
901c105d
Commit
901c105d
authored
Oct 03, 2019
by
Carla Guillen
Browse files
Small bugfix when reading the severity configuration. Rearranging output messages in printConfig.
parent
e80db3b5
Changes
3
Hide whitespace changes
Inline
Side-by-side
analytics/operators/persystsql/PerSystSqlConfigurator.cpp
View file @
901c105d
...
...
@@ -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
.
setSeverity
Threshold
(
exponent
);
double
exponent
=
std
::
stod
(
val
.
second
.
data
());
op
.
setSeverity
Exponent
(
exponent
);
}
else
if
(
boost
::
iequals
(
val
.
first
,
"severity_formula"
)){
std
::
string
formula
=
val
.
second
.
data
();
if
(
formula
==
"formula1"
){
...
...
analytics/operators/persystsql/PerSystSqlOperator.cpp
View file @
901c105d
...
...
@@ -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
)
<<
"
\t
Host="
<<
_conn
.
host
;
LOG_VAR
(
ll
)
<<
"
\t
User="
<<
_conn
.
user
;
LOG_VAR
(
ll
)
<<
"
\t
Database="
<<
_conn
.
database_name
;
LOG_VAR
(
ll
)
<<
"
\t
Port="
<<
_conn
.
port
;
LOG_VAR
(
ll
)
<<
"
\t
Rotation="
<<
_conn
.
rotation
;
LOG_VAR
(
ll
)
<<
"
\t
Every_X_days="
<<
_conn
.
every_x_days
;
}
LOG_VAR
(
ll
)
<<
"Property Configuration:"
;
LOG_VAR
(
ll
)
<<
"
\t
number_of_even_quantiles="
<<
_number_of_even_quantiles
;
LOG_VAR
(
ll
)
<<
"
\t
property_id="
<<
_property_id
;
LOG_VAR
(
ll
)
<<
"
\t
scaling_factor="
<<
_scaling_factor
;
LOG_VAR
(
ll
)
<<
"Severity Configuration:"
;
LOG_VAR
(
ll
)
<<
"
\t
severity_formula="
<<
_severity_formula
;
LOG_VAR
(
ll
)
<<
"
\t
severity_exponent="
<<
_severity_exponent
;
LOG_VAR
(
ll
)
<<
"
\t
severity_threshold="
<<
_severity_threshold
;
LOG_VAR
(
ll
)
<<
"
\t
severity_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
)
<<
"
\t
Host="
<<
_conn
.
host
;
LOG
(
debug
)
<<
"
\t
User="
<<
_conn
.
user
;
LOG
(
debug
)
<<
"
\t
Database="
<<
_conn
.
database_name
;
LOG
(
debug
)
<<
"
\t
Port="
<<
_conn
.
port
;
LOG
(
debug
)
<<
"
\t
Rotation="
<<
_conn
.
rotation
;
LOG
(
debug
)
<<
"
\t
Every_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
,
...
...
analytics/operators/persystsql/PerSystSqlOperator.h
View file @
901c105d
...
...
@@ -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
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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