blob: fbd97fd00ff8472aa34e2c1e8f89506fb73ed9e0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#pragma once
#include <Common/ZooKeeper/ZooKeeper.h>
#include <Core/BackgroundSchedulePool.h>
#include <chrono>
namespace DB
{
template <typename TStorage>
class AsyncBlockIDsCache
{
struct Cache;
using CachePtr = std::shared_ptr<Cache>;
std::vector<String> getChildren();
void update();
public:
explicit AsyncBlockIDsCache(TStorage & storage_);
void start();
void stop() { task->deactivate(); }
Strings detectConflicts(const Strings & paths, UInt64 & last_version);
private:
TStorage & storage;
std::atomic<std::chrono::steady_clock::time_point> last_updatetime;
const std::chrono::milliseconds update_min_interval;
std::mutex mu;
CachePtr cache_ptr;
std::condition_variable cv;
UInt64 version = 0;
const String path;
BackgroundSchedulePool::TaskHolder task;
const String log_name;
Poco::Logger * log;
};
}
|