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
9ac4e9de
Commit
9ac4e9de
authored
2 years ago
by
Georgy Moshkin
Browse files
Options
Downloads
Patches
Plain Diff
refactor: pico.space.raft_group -> pico.space.instance
parent
1a3fa2bd
No related branches found
No related tags found
No related merge requests found
Pipeline
#13990
passed
2 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/storage.rs
+14
-15
14 additions, 15 deletions
src/storage.rs
src/traft/mod.rs
+0
-2
0 additions, 2 deletions
src/traft/mod.rs
test/int/test_joining.py
+4
-4
4 additions, 4 deletions
test/int/test_joining.py
with
18 additions
and
21 deletions
src/storage.rs
+
14
−
15
View file @
9ac4e9de
...
...
@@ -19,7 +19,7 @@ use std::marker::PhantomData;
::
tarantool
::
define_str_enum!
{
/// An enumeration of builtin cluster-wide spaces
pub
enum
ClusterwideSpace
{
Group
=
"_picodata_
raft_group
"
,
Instance
=
"_picodata_
instance
"
,
Address
=
"_picodata_peer_address"
,
State
=
"_picodata_cluster_state"
,
Replicaset
=
"_picodata_replicaset"
,
...
...
@@ -352,8 +352,7 @@ impl Iterator for PeerAddressIter {
// Peers
////////////////////////////////////////////////////////////////////////////////
/// A struct for accessing storage of all the cluster peers
/// (currently raft_group).
/// A struct for accessing storage of all the cluster peers.
#[derive(Clone,
Debug)]
pub
struct
Peers
{
space
:
Space
,
...
...
@@ -363,7 +362,7 @@ pub struct Peers {
}
impl
Peers
{
const
SPACE_NAME
:
&
'static
str
=
ClusterwideSpace
::
Group
.as_str
();
const
SPACE_NAME
:
&
'static
str
=
ClusterwideSpace
::
Instance
.as_str
();
const
INDEX_INSTANCE_ID
:
&
'static
str
=
"instance_id"
;
const
INDEX_RAFT_ID
:
&
'static
str
=
"raft_id"
;
const
INDEX_REPLICASET_ID
:
&
'static
str
=
"replicaset_id"
;
...
...
@@ -798,7 +797,7 @@ inventory::submit!(crate::InnerTest {
use
traft
::{
CurrentGradeVariant
as
CurrentGrade
,
TargetGradeVariant
as
TargetGrade
,
InstanceId
};
let
storage_peers
=
Peers
::
new
()
.unwrap
();
let
raft_group
=
storage_peers
.space
.clone
();
let
space_peers
=
storage_peers
.space
.clone
();
let
storage_peer_addresses
=
PeerAddresses
::
new
()
.unwrap
();
let
space_peer_addresses
=
storage_peer_addresses
.space
.clone
();
...
...
@@ -814,7 +813,7 @@ inventory::submit!(crate::InnerTest {
// r3
(
"i5"
,
"i5-uuid"
,
5u64
,
"r3"
,
"r3-uuid"
,
(
CurrentGrade
::
Online
,
0
),
(
TargetGrade
::
Online
,
0
),
&
faildom
,),
]
{
raft_group
.put
(
&
peer
)
.unwrap
();
space_peers
.put
(
&
peer
)
.unwrap
();
let
(
_
,
_
,
raft_id
,
..
)
=
peer
;
space_peer_addresses
.put
(
&
(
raft_id
,
format!
(
"addr:{raft_id}"
)))
.unwrap
();
}
...
...
@@ -836,7 +835,7 @@ inventory::submit!(crate::InnerTest {
"Tarantool error:"
,
" TupleFound: Duplicate key exists"
,
" in unique index
\"
raft_id
\"
"
,
" in space
\"
_picodata_
raft_group
\"
"
,
" in space
\"
_picodata_
instance
\"
"
,
" with old tuple"
,
r#" - ["i1", "i1-uuid", 1, "r1", "r1-uuid", ["{gon}", 0], ["{tgon}", 0], {{"A": "B"}}]"#
,
" and new tuple"
,
...
...
@@ -892,43 +891,43 @@ inventory::submit!(crate::InnerTest {
assert_eq!
(
box_replication
(
"r3"
),
[
"addr:5"
]);
}
raft_group
.index
(
"raft_id"
)
.unwrap
()
.drop
()
.unwrap
();
space_peers
.index
(
"raft_id"
)
.unwrap
()
.drop
()
.unwrap
();
assert_err!
(
storage_peers
.get
(
&
1
),
concat!
(
"Tarantool error: NoSuchIndexID: No index #1 is defined"
,
" in space '_picodata_
raft_group
'"
,
" in space '_picodata_
instance
'"
,
)
);
raft_group
.index
(
"replicaset_id"
)
.unwrap
()
.drop
()
.unwrap
();
space_peers
.index
(
"replicaset_id"
)
.unwrap
()
.drop
()
.unwrap
();
assert_err!
(
storage_peers
.replicaset_peers
(
""
),
concat!
(
"Tarantool error: NoSuchIndexID: No index #2 is defined"
,
" in space '_picodata_
raft_group
'"
,
" in space '_picodata_
instance
'"
,
)
);
raft_group
.primary_key
()
.drop
()
.unwrap
();
space_peers
.primary_key
()
.drop
()
.unwrap
();
assert_err!
(
storage_peers
.get
(
&
InstanceId
::
from
(
"i1"
)),
concat!
(
"Tarantool error: NoSuchIndexID: No index #0 is defined"
,
" in space '_picodata_
raft_group
'"
,
" in space '_picodata_
instance
'"
,
)
);
raft_group
.drop
()
.unwrap
();
space_peers
.drop
()
.unwrap
();
assert_err!
(
storage_peers
.all_peers
(),
format!
(
"Tarantool error: NoSuchSpace: Space '{}' does not exist"
,
raft_group
.id
(),
space_peers
.id
(),
)
);
}
...
...
This diff is collapsed.
Click to expand it.
src/traft/mod.rs
+
0
−
2
View file @
9ac4e9de
...
...
@@ -423,8 +423,6 @@ pub struct Peer {
/// Instance failure domains. Instances with overlapping failure domains
/// must not be in the same replicaset.
// TODO: raft_group space is kinda bloated, maybe we should store some data
// in different spaces/not deserialize the whole tuple every time?
pub
failure_domain
:
FailureDomain
,
}
impl
Encode
for
Peer
{}
...
...
This diff is collapsed.
Click to expand it.
test/int/test_joining.py
+
4
−
4
View file @
9ac4e9de
...
...
@@ -46,7 +46,7 @@ def raft_join(
def
replicaset_id
(
instance
:
Instance
):
return
instance
.
eval
(
"
return pico.space.
raft_group
:get(...).replicaset_id
"
,
instance
.
instance_id
"
return pico.space.
instance
:get(...).replicaset_id
"
,
instance
.
instance_id
)
...
...
@@ -129,7 +129,7 @@ def test_replication(cluster: Cluster):
for
instance
in
cluster
.
instances
:
with
instance
.
connect
(
1
)
as
conn
:
raft_peer
=
conn
.
eval
(
"
return pico.space.
raft_group
:get(...):tomap()
"
,
"
return pico.space.
instance
:get(...):tomap()
"
,
instance
.
instance_id
,
)[
0
]
space_cluster
=
conn
.
select
(
"
_cluster
"
)
...
...
@@ -190,7 +190,7 @@ def test_init_replication_factor(cluster: Cluster):
replicaset_ids
=
i1
.
eval
(
"""
return pico.space.
raft_group
:pairs()
return pico.space.
instance
:pairs()
:map(function(peer)
return peer.replicaset_id
end)
...
...
@@ -346,7 +346,7 @@ def test_fail_to_join(cluster: Cluster):
joined_instances
=
i1
.
eval
(
"""
return pico.space.
raft_group
:pairs()
return pico.space.
instance
:pairs()
:map(function(peer)
return { peer.instance_id, peer.raft_id }
end)
...
...
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