Skip to content

Log repair #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
all: server

clean:
rm -f *lib server log log_entry append_entries_request serror
rm -f server

server:
rustc server.rs
Expand Down
8 changes: 2 additions & 6 deletions src/schooner/append_entries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@ use schooner::log_entry::LogEntry;
#[deriving(Decodable, Encodable, Clone, Show)]
pub struct AppendEntriesRequest {
pub term: u64, // current term of leader
pub prev_log_idx: u64, // last log idx in leader's log
pub prev_log_term: u64, // last log term in leader's log
pub prev_log_idx: u64, // idx of leader's log entry immediately before first entry in this AER
pub prev_log_term: u64, // term of leader's log entry immediately before first entry in this AER
pub commit_idx: u64, // last idx of log committed to leader's state machine
pub leader_id: uint, // id for leader (based on config file)
pub entries: Vec<LogEntry>, // entries to log; may be empty (hearbeat msg)
}


// how goraft creates it
// return newAppendEntriesResponse(s.currentTerm, false, s.log.currentIndex(), s.log.CommitIndex()), false

// TODO: this needs to have the server id in it (just AEReq has the leader id)
#[deriving(Decodable, Encodable, Clone, Show)]
pub struct AppendEntriesResponse {
// required by Raft protocol
Expand Down
3 changes: 1 addition & 2 deletions src/schooner/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ mod test {
use schooner::log_entry::LogEntry;
use schooner::append_entries::AppendEntriesRequest;

static testlog: &'static str = "datalog/log.test"; //'
static testlog: &'static str = "datalog/log.test";

fn cleanup() {
let p = Path::new(testlog);
Expand All @@ -208,7 +208,6 @@ mod test {
#[test]
fn test_truncate() {
cleanup();
// TODO: remove command from the logentry !!!!!
// need to write some logs first
let logent1 = LogEntry{idx: 1, term: 1, data: ~"a", uuid: ~"u01"};
let logent2 = LogEntry{idx: 2, term: 1, data: ~"b", uuid: ~"u02"};
Expand Down
9 changes: 3 additions & 6 deletions src/schooner/peer.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use std::io::{BufferedReader, File, InvalidInput, IoError, IoResult};
use std::vec::Vec;

// #[deriving(Clone,ToStr,Rand)]
#[deriving(Clone, Show)]
pub struct Peer {
pub id: uint,
pub ip: ~str,
pub tcpport: uint,

// only used by leader
pub next_idx: u64,
pub match_idx: u64,
pub next_idx: u64, // idx of next log entry to send to peer
pub match_idx: u64, // idx of highest log entry replicated on peer
}

///
Expand Down Expand Up @@ -41,9 +40,7 @@ pub fn parse_config(cfgpath: Path) -> IoResult<Vec<Peer>> {
peers.push( try!(create_peer(v)) );
}
},
Err(e) => {
return Err(e);
}
Err(e) => return Err(e)
}
}

Expand Down
Loading