Class GroupMembership
java.lang.Object
ai.badmonkey.agentspaces.peering.membership.GroupMembership
- All Implemented Interfaces:
PeerSampler
Leased membership for one group (spec §5.2): the membership view is fed by
leased PeerAdvertisements arriving over gossip and by direct liveness contact,
and a member that neither gossips nor answers within its TTL is dropped without
ceremony (spec P2). A SWIM-style probe cycle runs on
tick(GroupMembership.Prober): ping a
random member, and on timeout ask indirectPeers others to probe the
target before dropping it.
Deterministic by construction: time comes from the injected clock, randomness
from the injected Random, and probing advances only on tick.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordMembership tuning.static final classOne member's view state.static interfaceCallback used by the probe cycle to send PING and PING_REQ frames. -
Constructor Summary
ConstructorsConstructorDescriptionGroupMembership(PeerId self, InstantSource clock, Random random, GroupMembership.Config config) Creates the membership view. -
Method Summary
Modifier and TypeMethodDescriptionReturns a snapshot of all current members.voidRemoves a peer from the view immediately (a revocation's enforcement, or any other authoritative eject).Looks up a member.voidHandles an ACK correlated to an outstanding probe.voidFeeds a verified PeerAdvertisement into the view, refreshing endpoints and liveness.randomMembers(int n) Returns up tonlive members chosen uniformly at random, excluding the local peer.voidrecordHeard(PeerId peer) Records direct contact from a peer (any verified frame counts as liveness).voidSets the peers this view must never admit, consulted on every advertisement: the group's revocations (ASF-047).voidtick(GroupMembership.Prober prober) Runs one membership round: expire silent members, escalate or drop timed-out probes, and probe one random member.Returns the members currently advertising a topology role.
-
Constructor Details
-
GroupMembership
public GroupMembership(PeerId self, InstantSource clock, Random random, GroupMembership.Config config) Creates the membership view.- Parameters:
self- the local peer (never a member of its own view)clock- the time sourcerandom- the randomness source (seed it in tests)config- membership tuning
-
-
Method Details
-
refuse
-
onPeerAdvertisement
Feeds a verified PeerAdvertisement into the view, refreshing endpoints and liveness.- Parameters:
ad- the advertisement (already signature-verified by the caller)
-
evict
Removes a peer from the view immediately (a revocation's enforcement, or any other authoritative eject). Idempotent.- Parameters:
peer- the peer to evict
-
recordHeard
Records direct contact from a peer (any verified frame counts as liveness).- Parameters:
peer- the peer heard from
-
onAck
Handles an ACK correlated to an outstanding probe. The liveness credit always goes to the probe's own recorded target — never to any identity the wire supplies — and the ACK counts only when its authenticated sender is that target (a direct probe) or a relay this node actually asked (an indirect probe). A sprayed or forged ACK neither cancels the probe nor marks anyone alive (ASF-011).- Parameters:
nonce- the echoed noncefrom- the frame's authenticated sender
-
tick
Runs one membership round: expire silent members, escalate or drop timed-out probes, and probe one random member.- Parameters:
prober- the frame sender
-
member
Looks up a member.- Parameters:
peer- the member id- Returns:
- the member, when present in the view
-
allMembers
Returns a snapshot of all current members. -
withRole
Returns the members currently advertising a topology role.- Parameters:
role- the role- Returns:
- members offering it
-
randomMembers
Description copied from interface:PeerSamplerReturns up tonlive members chosen uniformly at random, excluding the local peer.- Specified by:
randomMembersin interfacePeerSampler- Parameters:
n- the maximum number of members to return- Returns:
- the sampled members, possibly fewer than
n
-