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
AProtoMessage 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 anISerializer: 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 Summary
FieldsModifier and TypeFieldDescriptionstatic final shortstatic final pt.unl.fct.di.novasys.network.ISerializer<MembershipSampleMessage> -
Constructor Summary
ConstructorsConstructorDescriptionMembershipSampleMessage(Set<pt.unl.fct.di.novasys.network.data.Host> sample) -
Method Summary
Methods inherited from class pt.unl.fct.di.novasys.babel.generic.ProtoMessage
getId
-
Field Details
-
MSG_ID
public static final short MSG_ID- See Also:
-
serializer
-
-
Constructor Details
-
MembershipSampleMessage
-
-
Method Details