PlantUML |
---|
title This diagram shows a member (N) using a locator (L) discovering the Coordinator (C) and joining entity N entity L entity C N -> L : FindCoordinator(myId) note right : via tcp/ip L -> N : FindCoordinatorResponse(c) N -> C : JoinRequest note right : this and subsequent communications via UDP note right of C : ViewCreator thread processes request C -> N : PrepareView(c,l,n) note right of C : ViewCreator thread processes request N -> C : ack C -> L : PrepareView(c,l,n) L -> C : ack C -> N : InstallView(c,l,n) N -> C : ack note right of N continue startup after sending ack end note C -> L : InstallView(c,l,n) L -> C : ack |
Once the coordinator's ID is known the new member sends a JoinRequest to it. The new member will know that it has been accepted when it receives a membership view containing its ID. At this point it sets the view-ID of its identifiers. The view-ID, in combination with its IP address and membership port (the UDP port used by JGroups) uniquely identifies this member.
PlantUML |
---|
title This shows a member (M) leaving and another member (P) joining in the same view entity M entity C entity P M -> C : LeaveRequest C -> M : LeaveResponse note right of C : LeaveRequest is queued M -> M : done P -> C : JoinRequest note right of C JoinRequest is queued. View Creator wakes up and creates view {C,P} removing M end note C -> P : Prepare {C,P} P -> C : ack C -> P : Install {C,P} P -> C : ack note right of P: P processes view and completes Join |
PlantUML |
---|
title This diagram shows two Locators starting up at the same time with no other members present. entity L1 entity L2 L1 -> L2 : FindCoordinator note right : via tcp/ip L2 -> L1 : FindCoordinatorResponse(registrants={L2,L1}) note right of L2 both members get {L1,L2} registrants and choose L1 as coordinator due to ID sort order end note L2 -> L1 : FindCoordinator L1 -> L2 : FindCoordinatorResponse(registrants={L1,L2}) note right of L2 : subsequent messaging is via UDP L2 -> L1 : JoinRequest L1 -> L1 : becomeCoordinator note right of L1 : L1 ViewCreator thread processes request L1 -> L2 : PrepareView(L1,L2) L2 -> L1 : ack L1 -> L2 : InstallView(L1,L2) L2 -> L1 : ack note right of L1 : L1 and L2 continue startup |
In the above diagram we see L1 make the decision to become coordinator and create an initial membership view. Since it has received a JoinRequest from L2 it includes it in this initial view.