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
da98af6d
Commit
da98af6d
authored
Aug 08, 2016
by
Michael Ott
Browse files
Introduce SensorCache object to cache the most current reading of each sensor
parent
6be3b8de
Changes
1
Hide whitespace changes
Inline
Side-by-side
CollectAgent/collectagent.cpp
View file @
da98af6d
...
...
@@ -39,6 +39,8 @@
#include
"abrt.h"
#include
"dcdbdaemon.h"
#include
"sensorcache.h"
#define __STDC_FORMAT_MACROS
#include
<inttypes.h>
...
...
@@ -50,6 +52,7 @@ uint64_t msgCtr;
uint64_t
pmsgCtr
;
DCDB
::
SensorDataStore
*
mySensorDataStore
;
std
::
string
listenHost
,
cassandraHost
,
ttl
;
DCDB
::
SensorCache
mySensorCache
;
/* Normal termination (SIGINT, CTRL+C) */
void
sigHandler
(
int
sig
)
...
...
@@ -79,13 +82,14 @@ void mqttCallback(SimpleMQTTMessage *msg)
uint64_t
val
;
uint64_t
ts
;
uint64_t
msgTs
=
Messaging
::
calculateTimestamp
();
//In the 64 bit message case, the collect agent provides a timestamp
if
(
msg
->
getPayloadLength
()
==
sizeof
(
uint64_t
))
{
//printf("Providing timestamp...\n");
val
=
*
((
uint64_t
*
)
msg
->
getPayload
());
ts
=
Messaging
::
calculateTimestamp
()
;
ts
=
msgTs
;
//printf("Val = %" PRIu64 ", timestamp = %" PRIu64 "\n", val, ts);
}
...
...
@@ -129,6 +133,7 @@ void mqttCallback(SimpleMQTTMessage *msg)
<< "\n";
#endif
mySensorDataStore
->
insert
(
&
sid
,
ts
,
val
);
mySensorCache
.
storeSensor
(
sid
,
ts
,
val
);
}
#if 1
else
{
...
...
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