Skip to content

Commit

Permalink
Eliminated most warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tailhook committed Mar 14, 2016
1 parent 5cb89ff commit 73698f6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
2 changes: 0 additions & 2 deletions src/elect/info.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::io::{Write, Read};
use std::str::FromStr;
use std::collections::HashMap;
use std::sync::Arc;
use std::time::Duration;

use cbor::{Encoder, EncodeResult, Decoder, DecodeResult};
use rotor::Time;
Expand Down
5 changes: 2 additions & 3 deletions src/elect/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ use std::cmp::Ordering::{Less as Older, Equal as Current, Greater as Newer};
use std::time::Duration;

use rotor::Time;
use rand::{thread_rng, Rng};

use super::{Id, Message, Info, Capsule};
use super::{Id, Info, Capsule};
use super::settings::{start_timeout, election_ivl, HEARTBEAT_INTERVAL};
use super::action::{Action, ActionList};

Expand Down Expand Up @@ -134,7 +133,7 @@ impl Machine {
(_, Older, me) => { // discard old messages
pass(me)
}
(Ping, Current, me @ Leader { .. }) => {
(Ping, Current, Leader { .. }) => {
// Another leader is here, restart the election
// This is valid when two partitions suddenly joined
start_election(msg_epoch+1, now, &info.id)
Expand Down
8 changes: 3 additions & 5 deletions src/elect/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use std::net::SocketAddr;
use std::sync::{Arc};
use std::time::Duration;
use std::collections::{HashSet, HashMap};
use std::collections::{HashMap};
use rustc_serialize::hex::ToHex;

use rotor::Time;
Expand Down Expand Up @@ -35,7 +33,7 @@ pub struct Election {
pub type Capsule = (Id, machine::Epoch, Message);

#[derive(Clone, Debug)]
enum Message {
pub enum Message {
/// Ping message from leader to followers, reassures that leadership
/// still holds
Ping,
Expand All @@ -52,7 +50,7 @@ struct PeerInfo {
}

#[derive(Debug)]
struct Info {
pub struct Info {
/// Unique identificator of the node, should be read from /etc/machine-id
id: Id,
/// This is used to find out whether hosts are actually valid
Expand Down
9 changes: 5 additions & 4 deletions src/elect/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use super::{machine, encode};
use super::settings::MAX_PACKET_SIZE;
use super::action::Action;
use super::machine::Epoch;
use super::{Election, Info, Id, PeerInfo, Capsule, Message};
use super::{Election, Info, Id, PeerInfo};


impl Election {
Expand All @@ -27,7 +27,7 @@ impl Election {
Err(e) => return Response::error(Box::new(e)),
};
scope.register(&sock, EventSet::readable() | EventSet::writable(),
PollOpt::edge());
PollOpt::edge()).expect("register socket");
Response::ok(Election {
info: Info::new(id),
schedule: schedule,
Expand Down Expand Up @@ -138,7 +138,7 @@ impl Machine for Election {
{
unreachable!();
}
fn timeout(mut self, scope: &mut Scope<Context>)
fn timeout(self, scope: &mut Scope<Context>)
-> Response<Self, Self::Seed>
{
let (me, wakeup) = {
Expand Down Expand Up @@ -167,7 +167,8 @@ impl Machine for Election {
peers.peers.iter()
.filter_map(|p| {
p.id.parse()
.map_err(|e| error!("Error parsing node id {:?}", p.id)).ok()
.map_err(|e| error!("Error parsing node id {:?}: {}",
p.id, e)).ok()
.map(|x| (x, p))
}).map(|(id, p)| (id, PeerInfo {
addr: p.primary_addr.as_ref()
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extern crate rotor_cantal;

use time::now_utc;
use std::net::ToSocketAddrs;
use std::sync::{Arc, RwLock};
use std::sync::{Arc};
use std::path::PathBuf;
use std::process::exit;

Expand Down

0 comments on commit 73698f6

Please sign in to comment.