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
e9d70c3b
Commit
e9d70c3b
authored
2 years ago
by
Georgy Moshkin
Browse files
Options
Downloads
Patches
Plain Diff
refactor: pico.space.raft_group -> pico.space.instance
parent
c9c9168f
No related branches found
No related tags found
No related merge requests found
Changes
3
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 @
e9d70c3b
...
@@ -19,7 +19,7 @@ use std::marker::PhantomData;
...
@@ -19,7 +19,7 @@ use std::marker::PhantomData;
::
tarantool
::
define_str_enum!
{
::
tarantool
::
define_str_enum!
{
/// An enumeration of builtin cluster-wide spaces
/// An enumeration of builtin cluster-wide spaces
pub
enum
ClusterwideSpace
{
pub
enum
ClusterwideSpace
{
Group
=
"_picodata_
raft_group
"
,
Instance
=
"_picodata_
instance
"
,
Address
=
"_picodata_peer_address"
,
Address
=
"_picodata_peer_address"
,
Property
=
"_picodata_property"
,
Property
=
"_picodata_property"
,
Replicaset
=
"_picodata_replicaset"
,
Replicaset
=
"_picodata_replicaset"
,
...
@@ -353,8 +353,7 @@ impl Iterator for PeerAddressIter {
...
@@ -353,8 +353,7 @@ impl Iterator for PeerAddressIter {
// Peers
// Peers
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// A struct for accessing storage of all the cluster peers
/// A struct for accessing storage of all the cluster peers.
/// (currently raft_group).
#[derive(Clone,
Debug)]
#[derive(Clone,
Debug)]
pub
struct
Peers
{
pub
struct
Peers
{
space
:
Space
,
space
:
Space
,
...
@@ -364,7 +363,7 @@ pub struct Peers {
...
@@ -364,7 +363,7 @@ pub struct Peers {
}
}
impl
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_INSTANCE_ID
:
&
'static
str
=
"instance_id"
;
const
INDEX_RAFT_ID
:
&
'static
str
=
"raft_id"
;
const
INDEX_RAFT_ID
:
&
'static
str
=
"raft_id"
;
const
INDEX_REPLICASET_ID
:
&
'static
str
=
"replicaset_id"
;
const
INDEX_REPLICASET_ID
:
&
'static
str
=
"replicaset_id"
;
...
@@ -799,7 +798,7 @@ inventory::submit!(crate::InnerTest {
...
@@ -799,7 +798,7 @@ inventory::submit!(crate::InnerTest {
use
traft
::{
CurrentGradeVariant
as
CurrentGrade
,
TargetGradeVariant
as
TargetGrade
,
InstanceId
};
use
traft
::{
CurrentGradeVariant
as
CurrentGrade
,
TargetGradeVariant
as
TargetGrade
,
InstanceId
};
let
storage_peers
=
Peers
::
new
()
.unwrap
();
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
storage_peer_addresses
=
PeerAddresses
::
new
()
.unwrap
();
let
space_peer_addresses
=
storage_peer_addresses
.space
.clone
();
let
space_peer_addresses
=
storage_peer_addresses
.space
.clone
();
...
@@ -815,7 +814,7 @@ inventory::submit!(crate::InnerTest {
...
@@ -815,7 +814,7 @@ inventory::submit!(crate::InnerTest {
// r3
// r3
(
"i5"
,
"i5-uuid"
,
5u64
,
"r3"
,
"r3-uuid"
,
(
CurrentGrade
::
Online
,
0
),
(
TargetGrade
::
Online
,
0
),
&
faildom
,),
(
"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
;
let
(
_
,
_
,
raft_id
,
..
)
=
peer
;
space_peer_addresses
.put
(
&
(
raft_id
,
format!
(
"addr:{raft_id}"
)))
.unwrap
();
space_peer_addresses
.put
(
&
(
raft_id
,
format!
(
"addr:{raft_id}"
)))
.unwrap
();
}
}
...
@@ -837,7 +836,7 @@ inventory::submit!(crate::InnerTest {
...
@@ -837,7 +836,7 @@ inventory::submit!(crate::InnerTest {
"Tarantool error:"
,
"Tarantool error:"
,
" TupleFound: Duplicate key exists"
,
" TupleFound: Duplicate key exists"
,
" in unique index
\"
raft_id
\"
"
,
" in unique index
\"
raft_id
\"
"
,
" in space
\"
_picodata_
raft_group
\"
"
,
" in space
\"
_picodata_
instance
\"
"
,
" with old tuple"
,
" with old tuple"
,
r#" - ["i1", "i1-uuid", 1, "r1", "r1-uuid", ["{gon}", 0], ["{tgon}", 0], {{"A": "B"}}]"#
,
r#" - ["i1", "i1-uuid", 1, "r1", "r1-uuid", ["{gon}", 0], ["{tgon}", 0], {{"A": "B"}}]"#
,
" and new tuple"
,
" and new tuple"
,
...
@@ -893,43 +892,43 @@ inventory::submit!(crate::InnerTest {
...
@@ -893,43 +892,43 @@ inventory::submit!(crate::InnerTest {
assert_eq!
(
box_replication
(
"r3"
),
[
"addr:5"
]);
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!
(
assert_err!
(
storage_peers
.get
(
&
1
),
storage_peers
.get
(
&
1
),
concat!
(
concat!
(
"Tarantool error: NoSuchIndexID: No index #1 is defined"
,
"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!
(
assert_err!
(
storage_peers
.replicaset_peers
(
""
),
storage_peers
.replicaset_peers
(
""
),
concat!
(
concat!
(
"Tarantool error: NoSuchIndexID: No index #2 is defined"
,
"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!
(
assert_err!
(
storage_peers
.get
(
&
InstanceId
::
from
(
"i1"
)),
storage_peers
.get
(
&
InstanceId
::
from
(
"i1"
)),
concat!
(
concat!
(
"Tarantool error: NoSuchIndexID: No index #0 is defined"
,
"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!
(
assert_err!
(
storage_peers
.all_peers
(),
storage_peers
.all_peers
(),
format!
(
format!
(
"Tarantool error: NoSuchSpace: Space '{}' does not exist"
,
"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 @
e9d70c3b
...
@@ -423,8 +423,6 @@ pub struct Peer {
...
@@ -423,8 +423,6 @@ pub struct Peer {
/// Instance failure domains. Instances with overlapping failure domains
/// Instance failure domains. Instances with overlapping failure domains
/// must not be in the same replicaset.
/// 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
,
pub
failure_domain
:
FailureDomain
,
}
}
impl
Encode
for
Peer
{}
impl
Encode
for
Peer
{}
...
...
This diff is collapsed.
Click to expand it.
test/int/test_joining.py
+
4
−
4
View file @
e9d70c3b
...
@@ -46,7 +46,7 @@ def raft_join(
...
@@ -46,7 +46,7 @@ def raft_join(
def
replicaset_id
(
instance
:
Instance
):
def
replicaset_id
(
instance
:
Instance
):
return
instance
.
eval
(
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):
...
@@ -129,7 +129,7 @@ def test_replication(cluster: Cluster):
for
instance
in
cluster
.
instances
:
for
instance
in
cluster
.
instances
:
with
instance
.
connect
(
1
)
as
conn
:
with
instance
.
connect
(
1
)
as
conn
:
raft_peer
=
conn
.
eval
(
raft_peer
=
conn
.
eval
(
"
return pico.space.
raft_group
:get(...):tomap()
"
,
"
return pico.space.
instance
:get(...):tomap()
"
,
instance
.
instance_id
,
instance
.
instance_id
,
)[
0
]
)[
0
]
space_cluster
=
conn
.
select
(
"
_cluster
"
)
space_cluster
=
conn
.
select
(
"
_cluster
"
)
...
@@ -189,7 +189,7 @@ def test_init_replication_factor(cluster: Cluster):
...
@@ -189,7 +189,7 @@ def test_init_replication_factor(cluster: Cluster):
replicaset_ids
=
i1
.
eval
(
replicaset_ids
=
i1
.
eval
(
"""
"""
return pico.space.
raft_group
:pairs()
return pico.space.
instance
:pairs()
:map(function(peer)
:map(function(peer)
return peer.replicaset_id
return peer.replicaset_id
end)
end)
...
@@ -345,7 +345,7 @@ def test_fail_to_join(cluster: Cluster):
...
@@ -345,7 +345,7 @@ def test_fail_to_join(cluster: Cluster):
joined_instances
=
i1
.
eval
(
joined_instances
=
i1
.
eval
(
"""
"""
return pico.space.
raft_group
:pairs()
return pico.space.
instance
:pairs()
:map(function(peer)
:map(function(peer)
return { peer.instance_id, peer.raft_id }
return { peer.instance_id, peer.raft_id }
end)
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