Class MembershipSampleMessage

java.lang.Object
pt.unl.fct.di.novasys.babel.generic.ProtoMessage
protocols.membership.full.messages.MembershipSampleMessage

public class MembershipSampleMessage extends pt.unl.fct.di.novasys.babel.generic.ProtoMessage
The one message the membership protocol exchanges: a periodic "here are some peers I know" sample. A node sends it to a random current neighbour; the receiver opens connections to any peers in the sample it doesn't already know. Repeated over time, this gossip lets every node eventually learn about (and connect to) every other node — a full membership.

What a Babel message is

A ProtoMessage is something a protocol sends over a channel to a peer (via sendMessage). It is identified by a numeric id (MSG_ID) that the protocol registers a serializer and a handler for. When a peer's bytes arrive, Babel uses the id to pick the serializer (to rebuild the object) and the handler (to process it).

Serialization

Every Babel message needs an ISerializer: the framework calls it to turn the object into bytes on the wire and back. The rule is simply to write each field and read it back in the same order. Here we write the number of hosts, then each Host using Babel's built-in Host.serializer (so we never hand-encode an address/port ourselves).
  • Field Details

  • Constructor Details

    • MembershipSampleMessage

      public MembershipSampleMessage(Set<pt.unl.fct.di.novasys.network.data.Host> sample)
  • Method Details

    • getSample

      public Set<pt.unl.fct.di.novasys.network.data.Host> getSample()
    • toString

      public String toString()
      Overrides:
      toString in class Object