Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
picodata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
picodata
Commits
d6b08414
Commit
d6b08414
authored
2 years ago
by
Georgy Moshkin
Committed by
Yaroslav Dynnikov
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor(topology): Topology::from_instances -> Topology::new
parent
f1065d93
No related branches found
No related tags found
1 merge request
!409
Resolve "Follow-up from "refactor: pico.space.raft_group -> pico.space.instance""
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/traft/node.rs
+1
-1
1 addition, 1 deletion
src/traft/node.rs
src/traft/topology.rs
+10
-10
10 additions, 10 deletions
src/traft/topology.rs
with
11 additions
and
11 deletions
src/traft/node.rs
+
1
−
1
View file @
d6b08414
...
...
@@ -392,7 +392,7 @@ impl NodeImpl {
.state
.get
(
PropertyName
::
ReplicationFactor
)
?
.ok_or_else
(||
Error
::
other
(
"missing replication_factor value in storage"
))
?
;
Topology
::
from_instances
(
instances
)
.with_replication_factor
(
replication_factor
)
Topology
::
new
(
instances
)
.with_replication_factor
(
replication_factor
)
}
};
...
...
This diff is collapsed.
Click to expand it.
src/traft/topology.rs
+
10
−
10
View file @
d6b08414
...
...
@@ -21,7 +21,7 @@ pub struct Topology {
impl
Topology
{
#[inline(always)]
pub
fn
from_instances
(
instances
:
impl
IntoIterator
<
Item
=
(
Instance
,
Address
)
>
)
->
Self
{
pub
fn
new
(
instances
:
impl
IntoIterator
<
Item
=
(
Instance
,
Address
)
>
)
->
Self
{
let
mut
ret
=
Self
{
replication_factor
:
1
,
max_raft_id
:
0
,
...
...
@@ -219,7 +219,7 @@ pub fn initial_instance(
advertise
:
Address
,
failure_domain
:
FailureDomain
,
)
->
Result
<
(
Instance
,
Address
),
String
>
{
let
mut
topology
=
Topology
::
from_instances
(
vec!
[]);
let
mut
topology
=
Topology
::
new
(
vec!
[]);
topology
.join
(
instance_id
,
replicaset_id
,
advertise
,
failure_domain
)
}
...
...
@@ -368,7 +368,7 @@ mod tests {
#[test]
fn
test_simple
()
{
let
mut
topology
=
Topology
::
from_instances
(
vec!
[])
.with_replication_factor
(
1
);
let
mut
topology
=
Topology
::
new
(
vec!
[])
.with_replication_factor
(
1
);
assert_eq!
(
join!
(
topology
,
None
,
None
,
"addr:1"
)
.unwrap
(),
...
...
@@ -390,7 +390,7 @@ mod tests {
(
instance!
(
4
,
"I4"
,
"r3"
,
CurrentGrade
::
offline
(
0
),
TargetGrade
::
offline
(
0
)),
"addr:1"
.into
()),
);
let
mut
topology
=
Topology
::
from_instances
(
let
mut
topology
=
Topology
::
new
(
instances!
[(
1
,
"i1"
,
"r1"
,
CurrentGrade
::
offline
(
0
),
TargetGrade
::
offline
(
0
))]
)
.with_replication_factor
(
1
);
...
...
@@ -402,7 +402,7 @@ mod tests {
#[test]
fn
test_override
()
{
let
mut
topology
=
Topology
::
from_instances
(
instances!
[
let
mut
topology
=
Topology
::
new
(
instances!
[
(
1
,
"i1"
,
"r1"
,
CurrentGrade
::
online
(
1
),
TargetGrade
::
online
(
1
)),
(
2
,
"i2"
,
"r2-original"
,
CurrentGrade
::
offline
(
0
),
TargetGrade
::
offline
(
0
)),
])
...
...
@@ -453,7 +453,7 @@ mod tests {
#[test]
fn
test_instance_id_collision
()
{
let
mut
topology
=
Topology
::
from_instances
(
instances!
[
let
mut
topology
=
Topology
::
new
(
instances!
[
(
1
,
"i1"
,
"r1"
,
CurrentGrade
::
online
(
1
),
TargetGrade
::
online
(
1
)),
(
2
,
"i3"
,
"r3"
,
CurrentGrade
::
online
(
1
),
TargetGrade
::
online
(
1
)),
// Attention: i3 has raft_id=2
...
...
@@ -467,7 +467,7 @@ mod tests {
#[test]
fn
test_replication_factor
()
{
let
mut
topology
=
Topology
::
from_instances
(
instances!
[
let
mut
topology
=
Topology
::
new
(
instances!
[
(
9
,
"i9"
,
"r9"
,
CurrentGrade
::
online
(
1
),
TargetGrade
::
online
(
1
)),
(
10
,
"i10"
,
"r9"
,
CurrentGrade
::
online
(
1
),
TargetGrade
::
online
(
1
)),
])
...
...
@@ -493,7 +493,7 @@ mod tests {
#[test]
fn
test_update_grade
()
{
let
mut
topology
=
Topology
::
from_instances
(
instances!
[
let
mut
topology
=
Topology
::
new
(
instances!
[
(
1
,
"i1"
,
"r1"
,
CurrentGrade
::
online
(
1
),
TargetGrade
::
online
(
1
)),
])
.with_replication_factor
(
1
);
...
...
@@ -550,7 +550,7 @@ mod tests {
#[test]
fn
failure_domain
()
{
let
mut
t
=
Topology
::
from_instances
(
instances!
[])
.with_replication_factor
(
3
);
let
mut
t
=
Topology
::
new
(
instances!
[])
.with_replication_factor
(
3
);
assert_eq!
(
join!
(
t
,
None
,
None
,
"-"
,
faildoms!
{
planet
:
Earth
})
...
...
@@ -633,7 +633,7 @@ mod tests {
#[test]
fn
reconfigure_failure_domain
()
{
let
mut
t
=
Topology
::
from_instances
(
instances!
[])
.with_replication_factor
(
3
);
let
mut
t
=
Topology
::
new
(
instances!
[])
.with_replication_factor
(
3
);
// first instance
let
(
instance
,
..
)
=
join!
(
t
,
Some
(
"i1"
),
None
,
"-"
,
faildoms!
{
planet
:
Earth
})
.unwrap
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment