-
Notifications
You must be signed in to change notification settings - Fork 8
/
Paxos.hxx
70 lines (68 loc) · 2.32 KB
/
Paxos.hxx
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
namespace memo
{
namespace model
{
namespace doughnut
{
namespace consensus
{
template <typename ... Args>
Paxos::LocalPeer::LocalPeer(
Paxos& paxos,
int factor,
bool rebalance_auto_expand,
bool rebalance_inspect,
std::chrono::system_clock::duration node_timeout,
Doughnut& dht,
Address id,
Args&& ... args)
: doughnut::Peer(dht, id)
, Paxos::Peer(dht, id)
, doughnut::Local(dht, id, std::forward<Args>(args) ...)
, _paxos(paxos)
, _factor(factor)
, _rebalance_auto_expand(rebalance_auto_expand)
, _rebalance_inspect(rebalance_inspect)
, _node_timeout(node_timeout)
, _cleaning_up(false)
, _max_addresses_size(elle::os::getenv("MEMO_PAXOS_CACHE_SIZE", 100))
, _rebalancable()
, _rebalanced()
, _rebalance_thread(elle::sprintf("%s: rebalance", this),
[this] () { this->_rebalance(); })
{}
static constexpr auto default_node_timeout =
std::chrono::duration_cast<std::chrono::system_clock::duration>(
10min);
template <typename ... Args>
Paxos::Paxos(Args&& ... args)
: Paxos(
elle::das::named::prototype(
consensus::doughnut,
consensus::replication_factor,
consensus::lenient_fetch = false,
consensus::rebalance_auto_expand = true,
consensus::rebalance_inspect = true,
consensus::node_timeout = default_node_timeout
).call(
[] (Doughnut& doughnut,
int factor,
bool lenient_fetch,
bool rebalance_auto_expand,
bool rebalance_inspect,
std::chrono::system_clock::duration node_timeout
) -> Paxos
{
return Paxos(doughnut,
factor,
lenient_fetch,
rebalance_auto_expand,
rebalance_inspect,
node_timeout
);
}, std::forward<Args>(args)...))
{}
}
}
}
}