Skip to content

Commit

Permalink
Restore stapshot and docs fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Hobden committed Jul 30, 2015
1 parent 40cb6ea commit dc5f017
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
15 changes: 8 additions & 7 deletions examples/hashmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@ use Message::*;

// Using docopt we define the overall usage of the application.
static USAGE: &'static str = "
A replicated mutable value. Operations on the register have serializable
A replicated mutable hashmap. Operations on the register have serializable
consistency, but no durability (once all register servers are terminated the
value is lost).
map is lost).
Each register server holds a replica of the register, and coordinates with its
peers to update the register's value according to client commands. The register
Each register server holds a replica of the map, and coordinates with its
peers to update the maps values according to client commands. The register
is available for reading and writing only if a majority of register servers are
available.
Commands:
get Returns the current value of the key.
Expand Down Expand Up @@ -137,7 +138,7 @@ fn server(args: &Args) {
// A persistent log implementation, which manages the persistent, replicated log...
let persistent_log = persistent_log::MemLog::new();

// A state machine which replicated state. This state should be the same on all nodes.
// A state machine which replicates state. This state should be the same on all nodes.
let state_machine = HashmapStateMachine::new();

// As well as a unique server id.
Expand All @@ -150,7 +151,7 @@ fn server(args: &Args) {
.map(|(&id, addr)| (ServerId::from(id), parse_addr(&addr)))
.collect::<HashMap<_,_>>();

// The Raft Server will panic if it's ID is inside of it's peer set. Don't do that.
// The Raft Server will return an error if it's ID is inside of it's peer set. Don't do that.
// Instead, take it out and use it!
let addr = peers.remove(&id).unwrap();

Expand Down Expand Up @@ -306,7 +307,7 @@ impl state_machine::StateMachine for HashmapStateMachine {
.into_bytes()
}

fn restore_snapshot(&mut self, snapshot_value: Vec<u8>) -> () {
fn restore_snapshot(&mut self, snapshot_value: Vec<u8>) {
self.map = json::from_str(&String::from_utf8_lossy(&snapshot_value)).unwrap();
()
}
Expand Down
12 changes: 6 additions & 6 deletions examples/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ enum Message {

// Using docopt we define the overall usage of the application.
static USAGE: &'static str = "
A replicated mutable hashmap. Operations on the register have serializable
A replicated mutable value. Operations on the register have serializable
consistency, but no durability (once all register servers are terminated the
map is lost).
value is lost).
Each register server holds a replica of the map, and coordinates with its
peers to update the maps values according to client commands. The register
Each register server holds a replica of the register, and coordinates with its
peers to update the register's value according to client commands. The register
is available for reading and writing only if a majority of register servers are
available.
Expand Down Expand Up @@ -141,7 +141,7 @@ fn server(args: &Args) {
.map(|(&id, addr)| (ServerId::from(id), parse_addr(&addr)))
.collect::<HashMap<_,_>>();

// The Raft Server will panic if it's ID is inside of it's peer set. Don't do that.
// The Raft Server will error if it's ID is inside of it's peer set. Don't do that.
// Instead, take it out and use it!
let addr = peers.remove(&id).unwrap();

Expand Down Expand Up @@ -292,7 +292,7 @@ impl state_machine::StateMachine for RegisterStateMachine {
self.value.clone()
}

fn restore_snapshot(&mut self, snapshot_value: Vec<u8>) -> () {
fn restore_snapshot(&mut self, snapshot_value: Vec<u8>) {
self.value = snapshot_value;
()
}
Expand Down
2 changes: 1 addition & 1 deletion src/state_machine/null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl StateMachine for NullStateMachine {
Vec::new()
}

fn restore_snapshot(&mut self, _snapshot: Vec<u8>) -> () {
fn restore_snapshot(&mut self, _snapshot: Vec<u8>) {
()
}
}

0 comments on commit dc5f017

Please sign in to comment.