Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
dcdb
dcdb
Commits
fe6c230e
Commit
fe6c230e
authored
Oct 21, 2019
by
Alessio Netti
Browse files
Analytics: job operators now use string job IDs
parent
0f38456f
Changes
6
Show whitespace changes
Inline
Side-by-side
analytics/includes/JobOperatorTemplate.h
View file @
fe6c230e
...
...
@@ -138,7 +138,7 @@ public:
try
{
// Getting exclusive access to the operator
while
(
this
->
_onDemandLock
.
exchange
(
true
)
)
{}
uint32_t
jobId
=
MQTTChecker
::
topicToJob
(
node
);
std
::
string
jobId
=
MQTTChecker
::
topicToJob
(
node
);
_jobDataVec
.
clear
();
if
(
this
->
_queryEngine
.
queryJob
(
jobId
,
0
,
0
,
_jobDataVec
,
true
,
false
)
&&
!
_jobDataVec
.
empty
())
{
U_Ptr
jobUnit
=
jobDataToUnit
(
_jobDataVec
[
0
]);
...
...
@@ -262,7 +262,7 @@ protected:
virtual
void
computeAsync
()
override
{
try
{
_jobDataVec
.
clear
();
if
(
this
->
_queryEngine
.
queryJob
(
0
,
this
->
_interval
*
1000000
,
0
,
_jobDataVec
,
true
,
true
))
{
if
(
this
->
_queryEngine
.
queryJob
(
""
,
this
->
_interval
*
1000000
,
0
,
_jobDataVec
,
true
,
true
))
{
_tempUnits
.
clear
();
// Producing units from the job data, discarding invalid jobs in the process
for
(
auto
&
job
:
_jobDataVec
)
{
...
...
analytics/includes/QueryEngine.h
View file @
fe6c230e
...
...
@@ -36,8 +36,8 @@
using
namespace
std
;
struct
qeJobData
{
uint32_t
jobId
;
uint32_t
userId
;
std
::
string
jobId
;
std
::
string
userId
;
uint64_t
startTime
;
uint64_t
endTime
;
std
::
list
<
std
::
string
>
nodes
;
...
...
@@ -46,7 +46,7 @@ struct qeJobData {
//Typedef for the callback used to retrieve sensors
typedef
bool
(
*
QueryEngineCallback
)(
const
string
&
,
const
uint64_t
,
const
uint64_t
,
vector
<
reading_t
>&
,
const
bool
);
//Typedef for the job retrieval callback
typedef
bool
(
*
QueryEngineJobCallback
)(
const
uint32_t
,
const
uint64_t
,
const
uint64_t
,
vector
<
qeJobData
>&
,
const
bool
,
const
bool
);
typedef
bool
(
*
QueryEngineJobCallback
)(
const
string
&
,
const
uint64_t
,
const
uint64_t
,
vector
<
qeJobData
>&
,
const
bool
,
const
bool
);
//Typedef for the metadata retrieval callback
typedef
bool
(
*
QueryEngineMetadataCallback
)(
const
string
&
,
SensorMetadata
&
);
...
...
@@ -257,7 +257,7 @@ public:
* @param range If true, the jobId parameter is ignored, and all jobs in the given time range are returned
* @return True if successful, false otherwise
*/
bool
queryJob
(
const
uint32_t
jobId
,
const
uint64_t
startTs
,
const
uint64_t
endTs
,
vector
<
qeJobData
>&
buffer
,
const
bool
rel
=
true
,
const
bool
range
=
false
)
{
bool
queryJob
(
const
string
&
jobId
,
const
uint64_t
startTs
,
const
uint64_t
endTs
,
vector
<
qeJobData
>&
buffer
,
const
bool
rel
=
true
,
const
bool
range
=
false
)
{
if
(
!
_jCallback
)
throw
runtime_error
(
"Query Engine: job callback not set!"
);
if
((
startTs
>
endTs
&&
!
rel
)
||
(
startTs
<
endTs
&&
rel
))
...
...
analytics/operators/persystsql/PerSystDB.cpp
View file @
fe6c230e
...
...
@@ -219,11 +219,11 @@ bool PerSystDB::getCurrentSuffixAggregateTable(std::string & suffix){
}
bool
PerSystDB
::
insertIntoJob
(
const
std
::
string
&
job_id_string
,
unsigned
long
lo
ng
uid
,
int
&
job_id_db
,
const
std
::
string
&
suffix
){
bool
PerSystDB
::
insertIntoJob
(
const
std
::
string
&
job_id_string
,
const
std
::
stri
ng
&
uid
,
int
&
job_id_db
,
const
std
::
string
&
suffix
){
std
::
lock_guard
<
std
::
mutex
>
lock
(
mut
);
std
::
stringstream
build_insert
;
build_insert
<<
"INSERT INTO Accounting (job_id_string, user, aggregate_first_suffix, aggregate_last_suffix) VALUES (
\'
"
<<
job_id_string
<<
"
\'
,
\'
"
;
auto
*
pass
=
getpwuid
(
static_cast
<
uid_t
>
(
uid
));
auto
*
pass
=
getpwuid
(
static_cast
<
uid_t
>
(
std
::
stoull
(
uid
))
)
;
if
(
pass
==
nullptr
)
{
LOG
(
error
)
<<
"User "
<<
uid
<<
" not found in system."
;
return
false
;
...
...
analytics/operators/persystsql/PerSystDB.h
View file @
fe6c230e
...
...
@@ -113,7 +113,7 @@ public:
/**
* Insert job in the accounting table.
*/
bool
insertIntoJob
(
const
std
::
string
&
job_id_string
,
unsigned
long
lo
ng
uid
,
int
&
job_id_db
,
const
std
::
string
&
suffix
);
bool
insertIntoJob
(
const
std
::
string
&
job_id_string
,
const
std
::
stri
ng
&
uid
,
int
&
job_id_db
,
const
std
::
string
&
suffix
);
/**
* Insert performance data into the aggregate table (Aggregate_<suffix>
...
...
collectagent/collectagent.cpp
View file @
fe6c230e
...
...
@@ -92,7 +92,7 @@ DCDB::SCError err;
QueryEngine
&
queryEngine
=
QueryEngine
::
getInstance
();
logger_t
lg
;
bool
jobQueryCallback
(
const
uint32_t
jobId
,
const
uint64_t
startTs
,
const
uint64_t
endTs
,
vector
<
qeJobData
>&
buffer
,
const
bool
rel
,
const
bool
range
)
{
bool
jobQueryCallback
(
const
string
&
jobId
,
const
uint64_t
startTs
,
const
uint64_t
endTs
,
vector
<
qeJobData
>&
buffer
,
const
bool
rel
,
const
bool
range
)
{
std
::
list
<
JobData
>
tempList
;
JobData
tempData
;
qeJobData
tempQeData
;
...
...
common/include/mqttchecker.h
View file @
fe6c230e
...
...
@@ -68,8 +68,8 @@ public:
* @param jobId The job ID value to be processed
* @return The processed MQTT topic
*/
static
std
::
string
jobToTopic
(
uint32_t
jobId
)
{
return
"/job"
+
std
::
to_string
(
jobId
)
+
"/"
;
static
std
::
string
jobToTopic
(
std
::
string
jobId
)
{
return
"/job"
+
jobId
+
"/"
;
}
/**
...
...
@@ -78,13 +78,13 @@ public:
* @param topic The topic to be processed
* @return The numerical job ID
*/
static
uint32_t
topicToJob
(
const
std
::
string
&
topic
)
{
static
std
::
string
topicToJob
(
const
std
::
string
&
topic
)
{
std
::
string
jobKey
(
JOB_STR
),
jobId
=
topic
;
jobId
.
erase
(
std
::
remove
(
jobId
.
begin
(),
jobId
.
end
(),
MQTT_SEP
),
jobId
.
end
());
size_t
pos
=
jobId
.
find
(
jobKey
);
if
(
pos
!=
std
::
string
::
npos
)
jobId
.
erase
(
pos
,
jobKey
.
length
());
return
std
::
stoull
(
jobId
)
;
return
jobId
;
}
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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