Comments (6)
Close #73
from xline.
What‘s the meaning of the relevant context?
from xline.
What‘s the meaning of the relevant context?
Just miscellanea that will be used in RawCurp
:
/// Relevant context for Curp
struct Context<C: Command> {
/// Id of the server
id: ServerId,
/// Other server ids and addresses
others: HashSet<ServerId>,
/// Timeout
timeout: Arc<ServerTimeout>,
/// Cmd board for tracking the cmd sync results
cb: CmdBoardRef<C>,
/// Speculative pool
sp: SpecPoolRef<C>,
/// Tx to send leader changes
leader_tx: broadcast::Sender<Option<ServerId>>,
/// Election tick
election_tick: AtomicU8,
/// Heartbeat opt out flag
hb_opt: AtomicBool,
/// Tx to send cmds to execute and do after sync
cmd_tx: Box<dyn CmdExeSenderInterface<C>>,
}
from xline.
What's the difference between LeaderState
and CandidateState
? How come the CandidateState
is wrapped in a Mutex while the other is in a RwLock?
from xline.
What's the difference between
LeaderState
andCandidateState
? How come theCandidateState
is wrapped in a Mutex while the other is in a RwLock?
pub(super) struct State {
/* persisted state */
/// Current term
pub(super) term: u64,
/// Candidate id that received vote in current term
pub(super) voted_for: Option<ServerId>,
/* volatile state */
/// Role of the server
pub(super) role: Role,
/// Cached id of the leader.
pub(super) leader_id: Option<ServerId>,
}
pub(super) struct CandidateState<C> {
/// Collected speculative pools, used for recovery
pub(super) sps: HashMap<ServerId, Vec<Arc<C>>>,
/// Votes received in the election
pub(super) votes_received: u64,
}
pub(super) struct LeaderState {
/// For each server, index of the next log entry to send to that server
pub(super) next_index: HashMap<ServerId, usize>,
/// For each server, index of highest log entry known to be replicated on server
pub(super) match_index: HashMap<ServerId, usize>,
}
Why Mutex for candidate state?
CandidateState
is only used in election, so it's idle most of the times. WhileLeaderState
andState
is used all the times, useRwLock
can increase performance.- When accessing
CandidateState
, we always need to modify its value.
from xline.
FYI: the Log
struct
pub(super) struct Log<C: Command> {
/// Log entries
pub(super) entries: Vec<LogEntry<C>>,
/// Index of highest log entry known to be committed
pub(super) commit_index: usize,
/// Index of highest log entry applied to state machine
pub(super) last_applied: usize,
}
from xline.
Related Issues (20)
- [Bug]: Xline will loss event when using watch feature
- [Bug]: Test frozen
- [Refactor]: Add a session structure to renew lock lease automatically HOT 5
- [Feature]: Refine interval tree implementation
- [Bug]: publish failed at startup HOT 1
- [Improvement] Check if the parameters client-listen-urls and peer-listen-urls are provided when starting Xline. HOT 4
- [Feature]: Better testing framework HOT 3
- [Bug]: Quick Start README Change HOT 3
- [Feature]: Create a reusable gh workflow for build xline image HOT 5
- [Feature]: A new release 0.6.2. HOT 6
- [Refactor]: Remove KeyRange HOT 1
- [Feature]: e2e test with kubernetes for xline cluster of 3 node. HOT 2
- [Bug]: The test case curp::it server::shutdown_rpc_should_shutdown_the_cluster failed HOT 2
- [Test]: Add test for kube-apiserver storage-media-type HOT 1
- [Bug]: The test case curp::it read_state::read_state sometimes failed HOT 1
- Refactor the `LogEntryVecDeque` in the log.rs HOT 1
- [Refactor]: Remove request wrappers in xline-client HOT 5
- [Refactor] refactor Xline ci process HOT 6
- [Feature]: Add exec command args for xlinectl lock command HOT 6
- [Feature]: Add exec command args for xlinectl watch command HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xline.