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
02250914
Commit
02250914
authored
2 years ago
by
Georgy Moshkin
Committed by
Yaroslav Dynnikov
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor(storage): storage::ClusterSpace -> storage::ClusterwideSpace
parent
9e2edd9c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!393
179/clusterwide storage
Pipeline
#13921
passed
2 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main.rs
+18
-9
18 additions, 9 deletions
src/main.rs
src/traft/mod.rs
+11
-11
11 additions, 11 deletions
src/traft/mod.rs
src/traft/node.rs
+12
-7
12 additions, 7 deletions
src/traft/node.rs
with
41 additions
and
27 deletions
src/main.rs
+
18
−
9
View file @
02250914
...
@@ -12,7 +12,7 @@ use ::tarantool::transaction::start_transaction;
...
@@ -12,7 +12,7 @@ use ::tarantool::transaction::start_transaction;
use
std
::
convert
::
TryFrom
;
use
std
::
convert
::
TryFrom
;
use
std
::
time
::{
Duration
,
Instant
};
use
std
::
time
::{
Duration
,
Instant
};
use
storage
::
Clusterwide
;
use
storage
::
Clusterwide
;
use
storage
::{
ClusterSpace
,
StateKey
};
use
storage
::{
Cluster
wide
Space
,
StateKey
};
use
traft
::
rpc
;
use
traft
::
rpc
;
use
traft
::
RaftSpaceAccess
;
use
traft
::
RaftSpaceAccess
;
...
@@ -396,7 +396,7 @@ fn picolib_setup(args: &args::Run) {
...
@@ -396,7 +396,7 @@ fn picolib_setup(args: &args::Run) {
"add_migration"
,
"add_migration"
,
tlua
::
function2
(|
id
:
u64
,
body
:
String
|
->
traft
::
Result
<
()
>
{
tlua
::
function2
(|
id
:
u64
,
body
:
String
|
->
traft
::
Result
<
()
>
{
let
migration
=
Migration
{
id
,
body
};
let
migration
=
Migration
{
id
,
body
};
let
op
=
OpDML
::
insert
(
ClusterSpace
::
Migrations
,
&
migration
)
?
;
let
op
=
OpDML
::
insert
(
Cluster
wide
Space
::
Migrations
,
&
migration
)
?
;
node
::
global
()
?
.propose_and_wait
(
op
,
Duration
::
MAX
)
??
;
node
::
global
()
?
.propose_and_wait
(
op
,
Duration
::
MAX
)
??
;
Ok
(())
Ok
(())
}),
}),
...
@@ -405,7 +405,10 @@ fn picolib_setup(args: &args::Run) {
...
@@ -405,7 +405,10 @@ fn picolib_setup(args: &args::Run) {
luamod
.set
(
luamod
.set
(
"push_schema_version"
,
"push_schema_version"
,
tlua
::
function1
(|
id
:
u64
|
->
traft
::
Result
<
()
>
{
tlua
::
function1
(|
id
:
u64
|
->
traft
::
Result
<
()
>
{
let
op
=
OpDML
::
replace
(
ClusterSpace
::
State
,
&
(
StateKey
::
DesiredSchemaVersion
,
id
))
?
;
let
op
=
OpDML
::
replace
(
ClusterwideSpace
::
State
,
&
(
StateKey
::
DesiredSchemaVersion
,
id
),
)
?
;
node
::
global
()
?
.propose_and_wait
(
op
,
Duration
::
MAX
)
??
;
node
::
global
()
?
.propose_and_wait
(
op
,
Duration
::
MAX
)
??
;
Ok
(())
Ok
(())
}),
}),
...
@@ -419,7 +422,10 @@ fn picolib_setup(args: &args::Run) {
...
@@ -419,7 +422,10 @@ fn picolib_setup(args: &args::Run) {
Some
(
m
)
=>
m
.id
,
Some
(
m
)
=>
m
.id
,
None
=>
return
Ok
(()),
None
=>
return
Ok
(()),
};
};
let
op
=
OpDML
::
replace
(
ClusterSpace
::
State
,
&
(
StateKey
::
DesiredSchemaVersion
,
id
))
?
;
let
op
=
OpDML
::
replace
(
ClusterwideSpace
::
State
,
&
(
StateKey
::
DesiredSchemaVersion
,
id
),
)
?
;
node
.propose_and_wait
(
op
,
Duration
::
MAX
)
??
;
node
.propose_and_wait
(
op
,
Duration
::
MAX
)
??
;
event
::
wait
(
Event
::
MigrateDone
)
event
::
wait
(
Event
::
MigrateDone
)
}),
}),
...
@@ -816,7 +822,7 @@ fn start_boot(args: &args::Run) {
...
@@ -816,7 +822,7 @@ fn start_boot(args: &args::Run) {
init_entries_push_op
(
init_entries_push_op
(
traft
::
OpDML
::
insert
(
traft
::
OpDML
::
insert
(
ClusterSpace
::
Addresses
,
Cluster
wide
Space
::
Addresses
,
&
traft
::
PeerAddress
{
raft_id
,
address
},
&
traft
::
PeerAddress
{
raft_id
,
address
},
)
)
.expect
(
"cannot fail"
)
.expect
(
"cannot fail"
)
...
@@ -825,16 +831,19 @@ fn start_boot(args: &args::Run) {
...
@@ -825,16 +831,19 @@ fn start_boot(args: &args::Run) {
init_entries_push_op
(
traft
::
Op
::
persist_peer
(
peer
));
init_entries_push_op
(
traft
::
Op
::
persist_peer
(
peer
));
init_entries_push_op
(
init_entries_push_op
(
OpDML
::
insert
(
OpDML
::
insert
(
ClusterSpace
::
State
,
Cluster
wide
Space
::
State
,
&
(
StateKey
::
ReplicationFactor
,
args
.init_replication_factor
),
&
(
StateKey
::
ReplicationFactor
,
args
.init_replication_factor
),
)
)
.expect
(
"cannot fail"
)
.expect
(
"cannot fail"
)
.into
(),
.into
(),
);
);
init_entries_push_op
(
init_entries_push_op
(
OpDML
::
insert
(
ClusterSpace
::
State
,
&
(
StateKey
::
DesiredSchemaVersion
,
0
))
OpDML
::
insert
(
.expect
(
"cannot fail"
)
ClusterwideSpace
::
State
,
.into
(),
&
(
StateKey
::
DesiredSchemaVersion
,
0
),
)
.expect
(
"cannot fail"
)
.into
(),
);
);
init_entries
.push
({
init_entries
.push
({
...
...
This diff is collapsed.
Click to expand it.
src/traft/mod.rs
+
11
−
11
View file @
02250914
...
@@ -10,7 +10,7 @@ pub mod rpc;
...
@@ -10,7 +10,7 @@ pub mod rpc;
pub
mod
topology
;
pub
mod
topology
;
use
crate
::
storage
;
use
crate
::
storage
;
use
crate
::
storage
::
ClusterSpace
;
use
crate
::
storage
::
Cluster
wide
Space
;
use
crate
::
stringify_debug
;
use
crate
::
stringify_debug
;
use
crate
::
util
::{
AnyWithTypeName
,
Uppercase
};
use
crate
::
util
::{
AnyWithTypeName
,
Uppercase
};
use
::
raft
::
prelude
as
raft
;
use
::
raft
::
prelude
as
raft
;
...
@@ -190,7 +190,7 @@ impl Op {
...
@@ -190,7 +190,7 @@ impl Op {
}
}
Self
::
Dml
(
op
)
=>
{
Self
::
Dml
(
op
)
=>
{
let
res
=
Box
::
new
(
op
.result
());
let
res
=
Box
::
new
(
op
.result
());
if
op
.space
()
==
&
ClusterSpace
::
State
{
if
op
.space
()
==
&
Cluster
wide
Space
::
State
{
event
::
broadcast
(
Event
::
ClusterStateChanged
);
event
::
broadcast
(
Event
::
ClusterStateChanged
);
}
}
res
res
...
@@ -256,24 +256,24 @@ pub trait OpResult {
...
@@ -256,24 +256,24 @@ pub trait OpResult {
#[derive(Clone,
Debug,
Serialize,
Deserialize,
PartialEq,
Eq)]
#[derive(Clone,
Debug,
Serialize,
Deserialize,
PartialEq,
Eq)]
pub
enum
OpDML
{
pub
enum
OpDML
{
Insert
{
Insert
{
space
:
ClusterSpace
,
space
:
Cluster
wide
Space
,
#[serde(with
=
"serde_bytes"
)]
#[serde(with
=
"serde_bytes"
)]
tuple
:
TupleBuffer
,
tuple
:
TupleBuffer
,
},
},
Replace
{
Replace
{
space
:
ClusterSpace
,
space
:
Cluster
wide
Space
,
#[serde(with
=
"serde_bytes"
)]
#[serde(with
=
"serde_bytes"
)]
tuple
:
TupleBuffer
,
tuple
:
TupleBuffer
,
},
},
Update
{
Update
{
space
:
ClusterSpace
,
space
:
Cluster
wide
Space
,
#[serde(with
=
"serde_bytes"
)]
#[serde(with
=
"serde_bytes"
)]
key
:
TupleBuffer
,
key
:
TupleBuffer
,
#[serde(with
=
"vec_of_raw_byte_buf"
)]
#[serde(with
=
"vec_of_raw_byte_buf"
)]
ops
:
Vec
<
TupleBuffer
>
,
ops
:
Vec
<
TupleBuffer
>
,
},
},
Delete
{
Delete
{
space
:
ClusterSpace
,
space
:
Cluster
wide
Space
,
#[serde(with
=
"serde_bytes"
)]
#[serde(with
=
"serde_bytes"
)]
key
:
TupleBuffer
,
key
:
TupleBuffer
,
},
},
...
@@ -299,7 +299,7 @@ impl From<OpDML> for Op {
...
@@ -299,7 +299,7 @@ impl From<OpDML> for Op {
impl
OpDML
{
impl
OpDML
{
/// Serializes `tuple` and returns an [`OpDML::Insert`] in case of success.
/// Serializes `tuple` and returns an [`OpDML::Insert`] in case of success.
pub
fn
insert
(
space
:
ClusterSpace
,
tuple
:
&
impl
ToTupleBuffer
)
->
tarantool
::
Result
<
Self
>
{
pub
fn
insert
(
space
:
Cluster
wide
Space
,
tuple
:
&
impl
ToTupleBuffer
)
->
tarantool
::
Result
<
Self
>
{
let
res
=
Self
::
Insert
{
let
res
=
Self
::
Insert
{
space
,
space
,
tuple
:
tuple
.to_tuple_buffer
()
?
,
tuple
:
tuple
.to_tuple_buffer
()
?
,
...
@@ -308,7 +308,7 @@ impl OpDML {
...
@@ -308,7 +308,7 @@ impl OpDML {
}
}
/// Serializes `tuple` and returns an [`OpDML::Replace`] in case of success.
/// Serializes `tuple` and returns an [`OpDML::Replace`] in case of success.
pub
fn
replace
(
space
:
ClusterSpace
,
tuple
:
&
impl
ToTupleBuffer
)
->
tarantool
::
Result
<
Self
>
{
pub
fn
replace
(
space
:
Cluster
wide
Space
,
tuple
:
&
impl
ToTupleBuffer
)
->
tarantool
::
Result
<
Self
>
{
let
res
=
Self
::
Replace
{
let
res
=
Self
::
Replace
{
space
,
space
,
tuple
:
tuple
.to_tuple_buffer
()
?
,
tuple
:
tuple
.to_tuple_buffer
()
?
,
...
@@ -318,7 +318,7 @@ impl OpDML {
...
@@ -318,7 +318,7 @@ impl OpDML {
/// Serializes `key` and returns an [`OpDML::Update`] in case of success.
/// Serializes `key` and returns an [`OpDML::Update`] in case of success.
pub
fn
update
(
pub
fn
update
(
space
:
ClusterSpace
,
space
:
Cluster
wide
Space
,
key
:
&
impl
ToTupleBuffer
,
key
:
&
impl
ToTupleBuffer
,
ops
:
impl
Into
<
Vec
<
TupleBuffer
>>
,
ops
:
impl
Into
<
Vec
<
TupleBuffer
>>
,
)
->
tarantool
::
Result
<
Self
>
{
)
->
tarantool
::
Result
<
Self
>
{
...
@@ -331,7 +331,7 @@ impl OpDML {
...
@@ -331,7 +331,7 @@ impl OpDML {
}
}
/// Serializes `key` and returns an [`OpDML::Delete`] in case of success.
/// Serializes `key` and returns an [`OpDML::Delete`] in case of success.
pub
fn
delete
(
space
:
ClusterSpace
,
key
:
&
impl
ToTupleBuffer
)
->
tarantool
::
Result
<
Self
>
{
pub
fn
delete
(
space
:
Cluster
wide
Space
,
key
:
&
impl
ToTupleBuffer
)
->
tarantool
::
Result
<
Self
>
{
let
res
=
Self
::
Delete
{
let
res
=
Self
::
Delete
{
space
,
space
,
key
:
key
.to_tuple_buffer
()
?
,
key
:
key
.to_tuple_buffer
()
?
,
...
@@ -340,7 +340,7 @@ impl OpDML {
...
@@ -340,7 +340,7 @@ impl OpDML {
}
}
#[rustfmt::skip]
#[rustfmt::skip]
pub
fn
space
(
&
self
)
->
&
ClusterSpace
{
pub
fn
space
(
&
self
)
->
&
Cluster
wide
Space
{
match
&
self
{
match
&
self
{
Self
::
Insert
{
space
,
..
}
=>
space
,
Self
::
Insert
{
space
,
..
}
=>
space
,
Self
::
Replace
{
space
,
..
}
=>
space
,
Self
::
Replace
{
space
,
..
}
=>
space
,
...
...
This diff is collapsed.
Click to expand it.
src/traft/node.rs
+
12
−
7
View file @
02250914
...
@@ -31,7 +31,7 @@ use crate::governor::raft_conf_change;
...
@@ -31,7 +31,7 @@ use crate::governor::raft_conf_change;
use
crate
::
governor
::
waiting_migrations
;
use
crate
::
governor
::
waiting_migrations
;
use
crate
::
kvcell
::
KVCell
;
use
crate
::
kvcell
::
KVCell
;
use
crate
::
r
#
loop
::{
FlowControl
,
Loop
};
use
crate
::
r
#
loop
::{
FlowControl
,
Loop
};
use
crate
::
storage
::{
Cluster
Spac
e
,
Clusterwide
,
StateKey
};
use
crate
::
storage
::{
Cluster
wid
e
,
Clusterwide
Space
,
StateKey
};
use
crate
::
stringify_cfunc
;
use
crate
::
stringify_cfunc
;
use
crate
::
traft
::
rpc
;
use
crate
::
traft
::
rpc
;
use
crate
::
traft
::
ContextCoercion
as
_
;
use
crate
::
traft
::
ContextCoercion
as
_
;
...
@@ -489,7 +489,7 @@ impl NodeImpl {
...
@@ -489,7 +489,7 @@ impl NodeImpl {
address
,
address
,
};
};
let
op
=
let
op
=
OpDML
::
replace
(
ClusterSpace
::
Addresses
,
&
peer_address
)
.expect
(
"can't fail"
);
OpDML
::
replace
(
Cluster
wide
Space
::
Addresses
,
&
peer_address
)
.expect
(
"can't fail"
);
let
(
lc
,
notify
)
=
self
.schedule_notification
();
let
(
lc
,
notify
)
=
self
.schedule_notification
();
notify_for_address
=
Some
(
notify
);
notify_for_address
=
Some
(
notify
);
let
ctx
=
traft
::
EntryContextNormal
::
new
(
lc
,
op
);
let
ctx
=
traft
::
EntryContextNormal
::
new
(
lc
,
op
);
...
@@ -1048,7 +1048,8 @@ fn raft_conf_change_loop(
...
@@ -1048,7 +1048,8 @@ fn raft_conf_change_loop(
let
mut
ops
=
UpdateOps
::
new
();
let
mut
ops
=
UpdateOps
::
new
();
ops
.assign
(
"master_id"
,
&
peer
.instance_id
)
?
;
ops
.assign
(
"master_id"
,
&
peer
.instance_id
)
?
;
let
op
=
OpDML
::
update
(
ClusterSpace
::
Replicasets
,
&
[
replicaset_id
],
ops
)
?
;
let
op
=
OpDML
::
update
(
ClusterwideSpace
::
Replicasets
,
&
[
replicaset_id
],
ops
)
?
;
tlog!
(
Info
,
"proposing replicaset master change"
;
"op"
=>
?
op
);
tlog!
(
Info
,
"proposing replicaset master change"
;
"op"
=>
?
op
);
// TODO: don't hard code the timeout
// TODO: don't hard code the timeout
node
.propose_and_wait
(
op
,
Duration
::
from_secs
(
3
))
??
;
node
.propose_and_wait
(
op
,
Duration
::
from_secs
(
3
))
??
;
...
@@ -1282,7 +1283,7 @@ fn raft_conf_change_loop(
...
@@ -1282,7 +1283,7 @@ fn raft_conf_change_loop(
}
else
{
}
else
{
let
vshard_bootstrapped
=
storage
.state
.vshard_bootstrapped
()
?
;
let
vshard_bootstrapped
=
storage
.state
.vshard_bootstrapped
()
?
;
let
req
=
traft
::
OpDML
::
insert
(
let
req
=
traft
::
OpDML
::
insert
(
ClusterSpace
::
Replicasets
,
Cluster
wide
Space
::
Replicasets
,
&
traft
::
Replicaset
{
&
traft
::
Replicaset
{
replicaset_id
:
peer
.replicaset_id
.clone
(),
replicaset_id
:
peer
.replicaset_id
.clone
(),
replicaset_uuid
:
peer
.replicaset_uuid
.clone
(),
replicaset_uuid
:
peer
.replicaset_uuid
.clone
(),
...
@@ -1367,7 +1368,7 @@ fn raft_conf_change_loop(
...
@@ -1367,7 +1368,7 @@ fn raft_conf_change_loop(
// gets reconfigured
// gets reconfigured
node
.propose_and_wait
(
node
.propose_and_wait
(
traft
::
OpDML
::
replace
(
traft
::
OpDML
::
replace
(
ClusterSpace
::
State
,
Cluster
wide
Space
::
State
,
&
(
StateKey
::
VshardBootstrapped
,
true
),
&
(
StateKey
::
VshardBootstrapped
,
true
),
)
?
,
)
?
,
// TODO: don't hard code the timeout
// TODO: don't hard code the timeout
...
@@ -1432,7 +1433,11 @@ fn raft_conf_change_loop(
...
@@ -1432,7 +1433,11 @@ fn raft_conf_change_loop(
let
mut
ops
=
UpdateOps
::
new
();
let
mut
ops
=
UpdateOps
::
new
();
ops
.assign
(
"weight"
,
weight
)
?
;
ops
.assign
(
"weight"
,
weight
)
?
;
node
.propose_and_wait
(
node
.propose_and_wait
(
traft
::
OpDML
::
update
(
ClusterSpace
::
Replicasets
,
&
[
replicaset_id
],
ops
)
?
,
traft
::
OpDML
::
update
(
ClusterwideSpace
::
Replicasets
,
&
[
replicaset_id
],
ops
,
)
?
,
// TODO: don't hard code the timeout
// TODO: don't hard code the timeout
Duration
::
from_secs
(
3
),
Duration
::
from_secs
(
3
),
)
??
;
)
??
;
...
@@ -1525,7 +1530,7 @@ fn raft_conf_change_loop(
...
@@ -1525,7 +1530,7 @@ fn raft_conf_change_loop(
let
mut
ops
=
UpdateOps
::
new
();
let
mut
ops
=
UpdateOps
::
new
();
ops
.assign
(
"current_schema_version"
,
migration
.id
)
.unwrap
();
ops
.assign
(
"current_schema_version"
,
migration
.id
)
.unwrap
();
let
op
=
OpDML
::
update
(
let
op
=
OpDML
::
update
(
ClusterSpace
::
Replicasets
,
Cluster
wide
Space
::
Replicasets
,
&
[
replicaset
.replicaset_id
.clone
()],
&
[
replicaset
.replicaset_id
.clone
()],
ops
,
ops
,
)
)
...
...
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