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
8056973b
Commit
8056973b
authored
2 years ago
by
Georgy Moshkin
Browse files
Options
Downloads
Patches
Plain Diff
refactor: use DMLOp for replication_factor
parent
3b3e8179
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!239
Feat/cluster wide dml op
Pipeline
#11992
passed
2 years ago
Stage: build
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main.rs
+10
-3
10 additions, 3 deletions
src/main.rs
src/traft/mod.rs
+0
-12
0 additions, 12 deletions
src/traft/mod.rs
src/traft/storage.rs
+28
-5
28 additions, 5 deletions
src/traft/storage.rs
with
38 additions
and
20 deletions
src/main.rs
+
10
−
3
View file @
8056973b
...
...
@@ -11,6 +11,7 @@ use ::tarantool::tlua;
use
::
tarantool
::
transaction
::
start_transaction
;
use
std
::
convert
::
TryFrom
;
use
std
::
time
::{
Duration
,
Instant
};
use
traft
::
storage
::{
RaftSpace
,
RaftStateKey
};
use
traft
::
ExpelRequest
;
use
clap
::
StructOpt
as
_
;
...
...
@@ -610,9 +611,15 @@ fn start_boot(args: &args::Run) {
lc
.inc
();
init_entries
.push
({
let
ctx
=
traft
::
EntryContextNormal
{
op
:
traft
::
Op
::
PersistReplicationFactor
{
replication_factor
:
args
.init_replication_factor
,
},
op
:
traft
::
OpDML
::
insert
(
RaftSpace
::
State
,
&
(
RaftStateKey
::
ReplicationFactor
,
args
.init_replication_factor
,
),
)
.expect
(
"cannot fail"
)
.into
(),
lc
,
};
let
e
=
traft
::
Entry
{
...
...
This diff is collapsed.
Click to expand it.
src/traft/mod.rs
+
0
−
12
View file @
8056973b
...
...
@@ -87,11 +87,6 @@ pub enum Op {
PersistPeer
{
peer
:
Peer
,
},
#[serde(alias
=
"persist_replication_factor"
)]
PersistReplicationFactor
{
replication_factor
:
u8
,
},
/// Cluster-wide data modification operation.
/// Should be used to manipulate the cluster-wide configuration.
Dml
(
OpDML
),
...
...
@@ -107,9 +102,6 @@ impl std::fmt::Display for Op {
Self
::
PersistPeer
{
peer
}
=>
{
write!
(
f
,
"PersistPeer{}"
,
peer
)
}
Self
::
PersistReplicationFactor
{
replication_factor
}
=>
{
write!
(
f
,
"PersistReplicationFactor({replication_factor})"
)
}
Self
::
Dml
(
OpDML
::
Insert
{
space
,
tuple
})
=>
{
write!
(
f
,
"Insert({space}, {})"
,
DisplayAsJson
(
tuple
))
}
...
...
@@ -170,10 +162,6 @@ impl Op {
Storage
::
persist_peer
(
peer
)
.unwrap
();
Box
::
new
(
peer
.clone
())
}
Self
::
PersistReplicationFactor
{
replication_factor
}
=>
{
Storage
::
persist_replication_factor
(
*
replication_factor
)
.unwrap
();
Box
::
new
(())
}
Self
::
Dml
(
op
)
=>
Box
::
new
(
op
.result
()),
}
}
...
...
This diff is collapsed.
Click to expand it.
src/traft/storage.rs
+
28
−
5
View file @
8056973b
...
...
@@ -45,6 +45,33 @@ const RAFT_GROUP: &str = RaftSpace::Group.as_str();
const
RAFT_STATE
:
&
str
=
RaftSpace
::
State
.as_str
();
const
RAFT_LOG
:
&
str
=
RaftSpace
::
Log
.as_str
();
////////////////////////////////////////////////////////////////////////////////
// RaftStateKey
////////////////////////////////////////////////////////////////////////////////
define_str_enum!
{
/// An enumeration of builtin raft spaces
pub
enum
RaftStateKey
{
ReplicationFactor
=
"replication_factor"
,
Commit
=
"commit"
,
Applied
=
"applied"
,
Term
=
"term"
,
Vote
=
"vote"
,
Gen
=
"gen"
,
Voters
=
"voters"
,
Learners
=
"learners"
,
VotersOutgoing
=
"voters_outgoing"
,
LearnersNext
=
"learners_next"
,
AutoLeave
=
"auto_leave"
,
}
FromStr
::
Err
=
UnknownRaftStateKey
;
}
#[derive(Error,
Debug)]
#[error(
"unknown raft state key {0}"
)]
pub
struct
UnknownRaftStateKey
(
pub
String
);
////////////////////////////////////////////////////////////////////////////////
// Error
////////////////////////////////////////////////////////////////////////////////
...
...
@@ -271,11 +298,7 @@ impl Storage {
}
pub
fn
replication_factor
()
->
Result
<
Option
<
u8
>
,
StorageError
>
{
Storage
::
raft_state
(
"replication_factor"
)
}
pub
fn
persist_replication_factor
(
replication_factor
:
u8
)
->
Result
<
(),
StorageError
>
{
Storage
::
persist_raft_state
(
"replication_factor"
,
replication_factor
)
Storage
::
raft_state
(
RaftStateKey
::
ReplicationFactor
.as_str
())
}
pub
fn
persist_commit
(
commit
:
RaftIndex
)
->
Result
<
(),
StorageError
>
{
...
...
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