Skip to content

Join group sequence

ndlewis edited this page Sep 18, 2012 · 4 revisions

This describes what happens when a peer joins an established group.

ControlCenter.setUpConnections()

  1. The application makes a call to ControlCenter.setUpConnections(). This creates an ObjectManagerImpl. It creates a PeerManagerImpl and calls activate(). It then calls its own checkPeersConnected().
  2. checkPeersConnected waits while ControlCenter.flag is less than PeerManagerImpl.getNoOfPeers().

ObjectManagerImpl.startObjectManager()

  1. Creates the singleton instance. That is all.

PeerManagerImpl.startPeerManager()

  1. Creates the singleton instance. That is all.

PeerManagerImpl.activate()

  1. Sets up a JChannel and makes itself a listener.
  2. Creates a PullPushAdapter.
  3. Waits while peerListReceived is false (updated to true by viewAccepted, after the initial current list of peers has been received).
  4. Waits while allPeersHaveFinishedSetup is false (skip this if there are no peers - if we are the first).
  5. Starts a new PeerFosteringThread.

PeerManagerImpl.viewAccepted()

  1. Called by JGroups when the list of members changes.
  2. Updates members to contain the current list. Updates noOfPeers to the number of peers (don't count self).
  3. Set peerListReceived to true and notify (received by PeerManagerImpl.activate()).
  4. Call memberJoined() and memberLeft() for each new or missing member.

PeerManagerImpl.memberLeft()

  1. If the member is still joining then their JoinThread will still be running. Tell the thread to stop.
  2. Fix fostering.

PeerManagerImpl.memberJoined()

  1. Set ControlCenter.allPeersHaveFinishedSetup to false and signal, so that anyone listening knows that there are peers that have not been set up.
  2. Start a new JoinThread to set up the connection to the new peer. We keep a track of this thread so that it can be killed if the peer is reported to have left the group before setup has been completed.

JoinThread.run()

  1. A JoinThread is created each time a new peer is detected (informed from JGroups via viewAccepted)
  2. Send PEER_NAME to this peer.
  3. Allocate space in the Object Manager for this peer.
  4. Send SPACE_ALLOCATED_FOR_NEW_PEER to this peer.
  5. Wait until spaceForMeHasBeenAllocated is signaled and contains this peer. This will end when SPACE_HAS_BEEN_ALLOCATED has been received from this peer.
  6. Wait until peerAddressToNameTable is signaled and contain this peer. This will end when PEER_NAME has been received from this peer.
  7. Tell the Object Manager to send all our objects to this peer.
  8. Send OBJECTS_HAVE_BEEN_SENT to this peer. This indicates to the peer that we have sent them all of our objects. This is necessary in the case where we have no objects for the peer to receive.
  9. Remove this thread from the joinThreads list, since it is complete and we want it to be automatically cleaned by the garbage collector.
  10. If there are no more threads registered in joinThreads then we update ControlCenter.allPeersHaveFinishedSetup to true and notify anyone who is waiting.

JoinThread.stopJoin()

  1. Called when JGroups says that a peer has left before it has completed setup (according to viewAccepted).
  2. Remove this thread from the joinThreads list, since it is complete and we want it to be automatically cleaned by the garbage collector.
  3. Set isRunning to false and signal spaceAllocated and peerAddressToNameTable so that the run() method will finish (bypassing whatever has yet to be completed) and the thread can be garbage collected.
  4. If there are no more threads registered in joinThreads then we update ControlCenter.allPeersHaveFinishedSetup to true and notify anyone who is waiting.

Clone this wiki locally