1
0

3 Коміти 2901e7a443 ... eb3ed5fd01

Автор SHA1 Опис Дата
  Jing Yang eb3ed5fd01 Update README. 2 роки тому
  Jing Yang c6d3ce06f3 Mark LogArray and VerifyAuthorityResult as crate-private types. 2 роки тому
  Jing Yang f67a450783 Move all remote-related structs into their own mod. 2 роки тому

+ 2 - 1
README.md

@@ -20,7 +20,7 @@ consistently across replicas.
 
 I have a 3-replica durio service running on Raspberry Pis. See the [README][durio] for more details.
 
-## Application Interafce
+## Application Interface
 
 Each application replica has a Raft instance that runs side by side with it. To add a log entry to the Raft log, the
 application calls `start()` with the data it wants to store (commonly referred to as a "command"). The log entry is not
@@ -119,6 +119,7 @@ assuming there is no thread starvation.
 - [x] Add public documentation
 - [x] Add a proper RPC interface to all public methods
 - [x] Allow storing arbitrary information
+- [x] Build a better storage interface
 - [x] Add more logging
 - [ ] Benchmarks
 - [x] Support the `Prevote` state

+ 1 - 1
src/election.rs

@@ -5,7 +5,7 @@ use std::time::{Duration, Instant};
 use parking_lot::{Condvar, Mutex};
 use rand::{thread_rng, Rng};
 
-use crate::remote_context::RemoteContext;
+use crate::remote::RemoteContext;
 use crate::storage::SharedLogPersister;
 use crate::sync_log_entries::SyncLogEntriesComms;
 use crate::utils::{retry_rpc, RPC_DEADLINE};

+ 1 - 1
src/heartbeats.rs

@@ -5,7 +5,7 @@ use std::time::{Duration, Instant};
 
 use parking_lot::Mutex;
 
-use crate::remote_context::RemoteContext;
+use crate::remote::RemoteContext;
 use crate::utils::{retry_rpc, RPC_DEADLINE};
 use crate::{AppendEntriesArgs, Peer, Raft, RaftState, ReplicableCommand};
 

+ 2 - 5
src/lib.rs

@@ -6,7 +6,7 @@ pub use crate::index_term::IndexTerm;
 pub use crate::log_array::Index;
 pub use crate::messages::*;
 pub use crate::raft::{Raft, Term};
-pub use crate::remote_raft::RemoteRaft;
+pub use crate::remote::RemoteRaft;
 pub use crate::replicable_command::ReplicableCommand;
 pub use crate::snapshot::Snapshot;
 pub use crate::verify_authority::VerifyAuthorityResult;
@@ -30,13 +30,10 @@ mod process_install_snapshot;
 mod process_request_vote;
 mod raft;
 mod raft_state;
-mod remote_context;
-mod remote_peer;
-mod remote_raft;
+mod remote;
 mod replicable_command;
 mod snapshot;
 pub mod storage;
 mod sync_log_entries;
-mod term_marker;
 pub mod utils;
 mod verify_authority;

+ 1 - 1
src/log_array.rs

@@ -36,7 +36,7 @@ enum LogEntryEnum<Command> {
 }
 
 #[derive(Clone, Debug, Serialize, Deserialize)]
-pub struct LogEntry<Command> {
+pub(crate) struct LogEntry<Command> {
     pub index: Index,
     pub term: Term,
     command: LogEntryEnum<Command>,

+ 3 - 3
src/raft.rs

@@ -11,12 +11,12 @@ use crate::daemon_env::{DaemonEnv, ThreadEnv};
 use crate::daemon_watch::{Daemon, DaemonWatch};
 use crate::election::ElectionState;
 use crate::heartbeats::{HeartbeatsDaemon, HEARTBEAT_INTERVAL};
-use crate::remote_context::RemoteContext;
-use crate::remote_peer::RemotePeer;
+use crate::remote::RemoteContext;
+use crate::remote::RemotePeer;
+use crate::remote::TermMarker;
 use crate::snapshot::{RequestSnapshotFnMut, SnapshotDaemon};
 use crate::storage::{RaftStorageTrait, SharedLogPersister};
 use crate::sync_log_entries::SyncLogEntriesComms;
-use crate::term_marker::TermMarker;
 use crate::verify_authority::VerifyAuthorityDaemon;
 use crate::{IndexTerm, RaftState, RemoteRaft, ReplicableCommand};
 

+ 9 - 0
src/remote/mod.rs

@@ -0,0 +1,9 @@
+pub(crate) use remote_context::RemoteContext;
+pub(crate) use remote_peer::RemotePeer;
+pub use remote_raft::RemoteRaft;
+pub(crate) use term_marker::TermMarker;
+
+pub mod remote_context;
+pub mod remote_peer;
+pub mod remote_raft;
+pub mod term_marker;

+ 4 - 4
src/remote_context.rs → src/remote/remote_context.rs

@@ -1,8 +1,8 @@
 use std::any::Any;
 use std::cell::RefCell;
 
-use crate::remote_peer::RemotePeer;
-use crate::term_marker::TermMarker;
+use crate::remote::RemotePeer;
+use crate::remote::TermMarker;
 use crate::verify_authority::DaemonBeatTicker;
 use crate::{Peer, RemoteRaft};
 
@@ -104,8 +104,8 @@ mod tests {
     use parking_lot::Mutex;
 
     use crate::election::ElectionState;
-    use crate::remote_peer::RemotePeer;
-    use crate::term_marker::TermMarker;
+    use crate::remote::RemotePeer;
+    use crate::remote::TermMarker;
     use crate::utils::do_nothing::{
         DoNothingRaftStoragePersister, DoNothingRemoteRaft,
     };

+ 0 - 0
src/remote_peer.rs → src/remote/remote_peer.rs


+ 0 - 0
src/remote_raft.rs → src/remote/remote_raft.rs


+ 0 - 0
src/term_marker.rs → src/remote/term_marker.rs


+ 1 - 1
src/sync_log_entries.rs

@@ -6,7 +6,7 @@ use parking_lot::{Condvar, Mutex};
 use crate::daemon_env::ErrorKind;
 use crate::heartbeats::HEARTBEAT_INTERVAL;
 use crate::peer_progress::PeerProgress;
-use crate::remote_context::RemoteContext;
+use crate::remote::RemoteContext;
 use crate::utils::{retry_rpc, SharedSender, RPC_DEADLINE};
 use crate::{
     check_or_record, AppendEntriesArgs, Index, IndexTerm, InstallSnapshotArgs,

+ 1 - 1
src/verify_authority.rs

@@ -14,7 +14,7 @@ use crate::{Index, Raft, Term};
 /// This request is not directly exposed to end users. Instead it is used
 /// internally to implement no-commit read-only requests.
 #[derive(Debug, Eq, PartialEq)]
-pub enum VerifyAuthorityResult {
+pub(crate) enum VerifyAuthorityResult {
     Success(Index),
     TermElapsed,
     TimedOut,