mirror of
https://github.com/Telecominfraproject/wlan-cloud-analytics.git
synced 2026-01-10 01:01:40 +00:00
Added averages and so on to DeviceTimePoint.
This commit is contained in:
@@ -20,18 +20,40 @@ namespace OpenWifi {
|
||||
BoardsDB_->Create();
|
||||
TimePointsDB_ = std::make_unique<OpenWifi::TimePointDB>(dbType_,*Pool_, Logger());
|
||||
TimePointsDB_->Create();
|
||||
PeriodicCleanup_ = MicroService::instance().ConfigGetInt("storage.cleanup.interval", 6*60*60);
|
||||
if(PeriodicCleanup_<1*60*60)
|
||||
PeriodicCleanup_ = 1*60*60;
|
||||
|
||||
Updater_.start(*this);
|
||||
|
||||
TimerCallback_ = std::make_unique<Poco::TimerCallback<Storage>>(*this,&Storage::onTimer);
|
||||
Timer_.setStartInterval( 20 * 1000); // first run in 20 seconds
|
||||
Timer_.setPeriodicInterval(1 * 60 * 60 * 1000); // 1 hours
|
||||
Timer_.setStartInterval( 60 * 1000); // first run in 20 seconds
|
||||
Timer_.setPeriodicInterval((long)PeriodicCleanup_ * 1000); // 1 hours
|
||||
Timer_.start(*TimerCallback_);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Storage::onTimer([[maybe_unused]] Poco::Timer &timer) {
|
||||
BoardsDB::RecordVec BoardList;
|
||||
uint64_t start = 0 ;
|
||||
bool done = false;
|
||||
const uint64_t batch=100;
|
||||
Logger().information("Starting cleanup of TimePoint Database");
|
||||
while(!done) {
|
||||
if(!BoardsDB().GetRecords(start,batch,BoardList)) {
|
||||
for(const auto &board:BoardList) {
|
||||
for(const auto &venue:board.venueList) {
|
||||
auto now = OpenWifi::Now();
|
||||
auto lower_bound = now - venue.retention;
|
||||
Logger().information(fmt::format("Removing old records for board '{}'",board.info.name));
|
||||
BoardsDB().DeleteRecords(fmt::format(" boardId='{}' and timestamp<{}", board.info.id, lower_bound));
|
||||
}
|
||||
}
|
||||
}
|
||||
done = (BoardList.size() < batch);
|
||||
}
|
||||
Logger().information(fmt::format("Done cleanup of TimePoint Database. Next run in {} seconds.", PeriodicCleanup_));
|
||||
}
|
||||
|
||||
void Storage::run() {
|
||||
@@ -50,6 +72,7 @@ namespace OpenWifi {
|
||||
|
||||
void Storage::Stop() {
|
||||
Running_=false;
|
||||
Timer_.stop();
|
||||
Updater_.wakeUp();
|
||||
Updater_.join();
|
||||
Logger().notice("Stopping.");
|
||||
|
||||
Reference in New Issue
Block a user