Commit da98af6d authored by Michael Ott's avatar Michael Ott
Browse files

Introduce SensorCache object to cache the most current reading of each sensor

parent 6be3b8de
......@@ -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 {
......
Supports Markdown
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