memgraph/include/snapshot/snapshoter.hpp

36 lines
714 B
C++
Raw Normal View History

2016-09-08 20:25:52 +08:00
#pragma once
#include <unordered_map>
#include "database/db.hpp"
#include "logging/default.hpp"
2016-09-09 23:14:20 +08:00
#include "threading/thread.hpp"
2016-09-08 20:25:52 +08:00
class SnapshotEncoder;
class SnapshotDecoder;
// Captures snapshots.
class Snapshoter
{
public:
// How much sec is between snapshots
// snapshot_folder is path to common folder for all snapshots.
Snapshoter(ConcurrentMap<std::string, Db> &dbs, size_t snapshot_cycle);
2016-09-08 20:25:52 +08:00
~Snapshoter();
private:
void run();
2016-09-08 20:25:52 +08:00
// Makes snapshot of given type
void make_snapshots();
2016-09-08 20:25:52 +08:00
Logger logger;
const size_t snapshot_cycle;
std::unique_ptr<Thread> thread = {nullptr};
ConcurrentMap<std::string, Db> &dbms;
std::atomic<bool> snapshoting = {true};
};