Skip to content

Commit 6dca4b5

Browse files
authored
Merge pull request #171 from picodata/add_raft_failover
Add raft failover
2 parents b52e221 + 5eaa976 commit 6dca4b5

35 files changed

Lines changed: 65 additions & 87 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ hosts:
177177

178178
# failover parameters
179179
failover:
180-
mode: stateful # (optional) failover mode (stateful, eventual, disabled)
180+
mode: stateful # (optional) failover mode (stateful, eventual, disabled, raft)
181181
state_provider: stateboard # (optional) what is serve failover (stateboard, stateful)
182182
failover_timeout: 60 # (optional) timeout (in seconds), used by membership to mark `suspect` members as `dead`
183183
fencing_enabled: true # (optional) abandon leadership when both the state provider quorum and at least one

README.ru.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ hosts:
193193

194194
# параметры фейловера
195195
failover:
196-
mode: stateful # (опционально) вариант работы фейловера (stateful, eventual, disabled)
196+
mode: stateful # (опционально) вариант работы фейловера (stateful, eventual, disabled, raft)
197197
state_provider: stateboard # (опционально) провайдер предоставляющий фейловер (stateboard, stateful)
198198
failover_timeout: 60 # (опционально) время (в секундах), определяет время перевода инстанса со статусом `suspect` в статус `dead`
199199
fencing_enabled: true # (опционально) если `true`, инстансы будут снимать с себя роль лидера при потере связи с провайдером состояния

configs/cluster.genin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ hosts:
4747
address: 192.168.16.12
4848
# Failover management options
4949
failover:
50-
# Failover mode (stateful, eventual, disabled)
50+
# Failover mode (stateful, eventual, disabled, raft)
5151
mode: stateful
5252
# What is serve failover (stateboard, stateful)
5353
state_provider: stateboard

docs/examples/cluster.genin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ hosts:
3939
config:
4040
address: <<host_address>> # Host or instance address (maybe IP or URI)
4141
failover:
42-
mode: stateful # Failover mode (stateful, eventual, disabled)
42+
mode: stateful # Failover mode (stateful, eventual, disabled, raft)
4343
state_provider: stateboard # What is serve failover (stateboard, stateful)
4444
stateboard_params:
4545
uri: <<host_address_and_port>> # Uri on which the stateboard will be available (ip:port)

docs/examples/fd-cluster.genin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ hosts:
2525
config:
2626
address: <<host_address>> # Host or instance address (maybe IP or URI)
2727
failover:
28-
mode: stateful # Failover mode (stateful, eventual, disabled)
28+
mode: stateful # Failover mode (stateful, eventual, disabled, raft)
2929
state_provider: stateboard # What is serve failover (stateboard, stateful)
3030
stateboard_params:
3131
uri: <<host_address_and_port>> # Uri on which the stateboard will be available (ip:port)

src/task.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ pub struct ErrSeqMapping<'a> {
233233
pub value: &'a Vec<Value>,
234234
}
235235

236-
impl<'a> std::fmt::Debug for ErrSeqMapping<'a> {
236+
impl std::fmt::Debug for ErrSeqMapping<'_> {
237237
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
238238
formatter.write_str("\n")?;
239239
self.value.iter().try_for_each(|value| match value {
@@ -271,7 +271,7 @@ pub struct ErrConfMapping<'a> {
271271
pub value: &'a Mapping,
272272
}
273273

274-
impl<'a> std::fmt::Debug for ErrConfMapping<'a> {
274+
impl std::fmt::Debug for ErrConfMapping<'_> {
275275
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
276276
self.value
277277
.iter()

src/task/args.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub(super) fn read() -> ArgMatches {
6262
.short('m')
6363
.action(ArgAction::Set)
6464
.default_value("stateful")
65-
.help("(string): failover mode (statefull, eventual, disabled)"),
65+
.help("(string): failover mode (statefull, eventual, disabled, raft)"),
6666
Arg::new("failover-state-provider")
6767
.long("failover-state-provider")
6868
.short('F')
@@ -245,7 +245,7 @@ pub(super) fn read() -> ArgMatches {
245245
.short('m')
246246
.action(ArgAction::Set)
247247
.default_value("stateful")
248-
.help("(string): failover mode (statefull, eventual, disabled)"),
248+
.help("(string): failover mode (statefull, eventual, disabled, raft)"),
249249
Arg::new("failover-state-provider")
250250
.long("failover-state-provider")
251251
.short('F')

src/task/cluster.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ impl<'a> TryFrom<&'a Inventory> for Cluster {
287287
roles: Vec::new(),
288288
cartridge_extra_env: instance.vars.clone(),
289289
config: InstanceConfig::from_inventory_host(
290-
&instance,
290+
instance,
291291
),
292292
vars: instance.vars.clone(),
293293
view: View::default(),
@@ -355,7 +355,7 @@ impl<'de> Deserialize<'de> for Cluster {
355355
hosts: Vec<Host>,
356356
#[serde(default)]
357357
failover: Failover,
358-
vars: Vars,
358+
vars: Box<Vars>,
359359
},
360360
InvalidCluster(Value),
361361
}
@@ -373,7 +373,7 @@ impl<'de> Deserialize<'de> for Cluster {
373373
.with_binary_port(DEFAULT_BINARY_PORT),
374374
topology: topology.check_unique().map_err(serde::de::Error::custom)?,
375375
failover,
376-
vars,
376+
vars: *vars,
377377
metadata: ClusterMetadata {
378378
paths: Default::default(),
379379
},
@@ -627,7 +627,7 @@ impl Cluster {
627627
("failover".into(), "# Failover management options".into()),
628628
(
629629
"mode".to_string(),
630-
"# Failover mode (stateful, eventual, disabled)".to_string(),
630+
"# Failover mode (stateful, eventual, disabled, raft)".to_string(),
631631
),
632632
(
633633
"state_provider".to_string(),

src/task/cluster/host/hst.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,7 @@ impl WithHosts<Vec<Host>> for Host {
108108

109109
impl PartialOrd for Host {
110110
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
111-
match self.instances.len().partial_cmp(&other.instances.len()) {
112-
Some(Ordering::Equal) => self.name.partial_cmp(&other.name),
113-
ord => ord,
114-
}
111+
Some(self.cmp(other))
115112
}
116113
}
117114

@@ -131,7 +128,7 @@ impl Display for Host {
131128

132129
self.form_structure(depth, &collector);
133130

134-
let mut table = Builder::from_iter(collector.take().into_iter()).build();
131+
let mut table = Builder::from_iter(collector.take()).build();
135132
table.with(Merge::horizontal());
136133
table.with(Alignment::center());
137134

@@ -685,7 +682,7 @@ impl Host {
685682
}
686683
}
687684

688-
lvl = lvl + 1;
685+
lvl += 1;
689686
for sub_host in self.hosts.iter_mut() {
690687
sub_host.set_zone(lvl, dc_lvl, zone.clone())
691688
}
@@ -1009,7 +1006,7 @@ impl From<String> for DomainMember {
10091006
}
10101007
}
10111008

1012-
impl<'a> From<DomainMember> for Cow<'a, str> {
1009+
impl From<DomainMember> for Cow<'_, str> {
10131010
fn from(val: DomainMember) -> Self {
10141011
match val {
10151012
DomainMember::Domain(name) => Cow::Owned(name),

src/task/cluster/host/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ impl Default for IP {
7979
}
8080
}
8181

82-
impl ToString for IP {
83-
fn to_string(&self) -> String {
82+
impl std::fmt::Display for IP {
83+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8484
match self {
85-
Self::Server(ip) => ip.to_string(),
86-
Self::None => String::new(),
85+
Self::Server(ip) => write!(f, "{}", ip),
86+
Self::None => write!(f, ""),
8787
}
8888
}
8989
}

0 commit comments

Comments
 (0)