This version of the module is deprecated: Superseded by refreshed release (documentation and provenance updated)

    lifeguard

    Lifeguard member failure detection (SWIM family) with paper-specified suspicion mechanisms.

    Download zip
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    14 days ago
    Downloads
    47

    #huanguan-Q/lifeguard-mbt

    MemberState

    pub(all) enum MemberState {
    Alive
    Suspect
    Failed
    } derive(Eq,
    Debug
    )

    MemberState::equal

    fn MemberState::equal(MemberState, MemberState) -> Bool

    MemberState::not_equal

    fn MemberState::not_equal(x : MemberState, y : MemberState) -> Bool

    MemberState::to_repr

    automatically derived

    Msg

    pub(all) enum Msg {
    Ping(String, Int)
    Ack(String, Int)
    PingReq(String, String, Int)
    Nack(String, Int)
    Suspect(String, UInt64, String)
    Alive(String, UInt64, String)
    Confirm(String, UInt64, String)
    } derive(Eq,
    Debug
    )

    Protocol messages (paper Sections III/IV).

    Msg::equal

    fn Msg::equal(Msg, Msg) -> Bool

    Msg::not_equal

    fn Msg::not_equal(x : Msg, y : Msg) -> Bool

    Msg::to_repr

    automatically derived

    SimResult

    pub struct SimResult {
    all_confirmed_dead : Bool
    no_false_positive : Bool
    dead_confirmed_by : Int
    awareness_max_seen : Int
    }

    SwimNode

    pub struct SwimNode {
    // private fields
    }

    SwimNode::awareness

    fn SwimNode::awareness(self : SwimNode) -> Int

    Local Health Awareness counter (paper: saturated 0..S, S=8).

    SwimNode::ever_failed_healthy

    fn SwimNode::ever_failed_healthy(self : SwimNode) -> Bool

    SwimNode::handle

    fn SwimNode::handle(self : SwimNode, msg : Msg) -> Array[Msg]

    Apply a membership message (Suspect/Alive/Confirm semantics); returns messages to relay onward.

    SwimNode::member_incarnation

    fn SwimNode::member_incarnation(self : SwimNode, id : String) -> UInt64?

    SwimNode::member_state

    fn SwimNode::member_state(self : SwimNode, id : String) -> MemberState?

    SwimNode::new

    fn SwimNode::new(id~ : String, peers~ : Array[String], base_probe_interval_ms~ : Int, base_probe_timeout_ms~ : Int, suspicion_alpha~ : Double, suspicion_beta~ : Double, suspicion_k~ : Int, max_awareness~ : Int) -> SwimNode

    Create a node; peers are the other members (cluster size = peers+1).

    SwimNode::probe_interval_ms

    fn SwimNode::probe_interval_ms(self : SwimNode) -> Int

    ProbeInterval = Base * (LHM+1); ProbeTimeout likewise.

    SwimNode::probe_timeout_ms

    fn SwimNode::probe_timeout_ms(self : SwimNode) -> Int

    SwimNode::record_ack

    fn SwimNode::record_ack(self : SwimNode) -> Unit

    SwimNode::record_missed_nack

    fn SwimNode::record_missed_nack(self : SwimNode) -> Unit

    SwimNode::record_probe_fail

    fn SwimNode::record_probe_fail(self : SwimNode) -> Unit

    SwimNode::record_refute

    fn SwimNode::record_refute(self : SwimNode) -> Unit

    SwimNode::self_incarnation

    fn SwimNode::self_incarnation(self : SwimNode) -> UInt64

    SwimNode::start_probe

    fn SwimNode::start_probe(self : SwimNode) -> Int

    Next probe sequence number for starting a new probe round.

    SwimNode::suspicion_min_ms

    fn SwimNode::suspicion_min_ms(self : SwimNode) -> Int

    Min = alpha * log10(n) * ProbeInterval, n = total member count.

    SwimNode::suspicion_timeout_ms

    fn SwimNode::suspicion_timeout_ms(self : SwimNode, independent_count : Int) -> Int

    SuspicionTimeout = max(Min, Max - (Max-Min) * ln(C+1)/ln(K+1)). C = independent suspect messages received since local suspicion began.

    simulate_cluster

    async fn simulate_cluster(node_ids~ : Array[String], dead_node~ : String, base_probe_interval_ms~ : Int, base_probe_timeout_ms~ : Int, alpha~ : Double, beta~ : Double, budget_ms~ : Int) -> Result[SimResult, String]

    Simulate a cluster where dead_node never responds.