Class Topology

All Implemented Interfaces:
WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, MembershipListener

public class Topology extends Frame implements WindowListener, MembershipListener
Demonstrates the membership service. Each member is represented by a rectangle that contains the addresses of all the members. The coordinator (= oldest member in the group) is painted in blue. New members can be started; all existing members will update their graphical appearance to reflect the new membership. When the coordinator itself is killed, another one will take over (the next in rank).

A nice demo is to start a number of Topology instances at the same time. All of them will be blue (all are coordinators since they don't find each other). Then the MERGE2 protocol sets in and only one will retain its coordinator role.

Author:
Bela Ban
See Also:
To do:
Needs to be ported to Swing.
  • Constructor Details

    • Topology

      public Topology()
  • Method Details

    • addNode

      public void addNode(Object member)
    • removeNode

      public void removeNode(Object member)
    • drawNode

      public void drawNode(Graphics g, int x, int y, String label, int style)
    • drawTopology

      public void drawTopology(Graphics g)
    • paint

      public void paint(Graphics g)
      Overrides:
      paint in class Window
    • viewAccepted

      public void viewAccepted(View view)
      Description copied from interface: MembershipListener
      Called when a change in membership has occurred. No long running actions or sending of messages should be done in this callback. If some long running action needs to be performed, it should be done in a separate thread.

      Note that on reception of the first view (a new member just joined), the channel will not yet be in the connected state. This only happens when Channel.connect(String) returns.

      Specified by:
      viewAccepted in interface MembershipListener
    • suspect

      public void suspect(Address suspected_mbr)
      Description copied from interface: MembershipListener
      Called whenever a member is suspected of having crashed, but has not yet been excluded.
      Specified by:
      suspect in interface MembershipListener
    • block

      public void block()
      Description copied from interface: MembershipListener
      Called (usually by the FLUSH protocol), as an indication that the member should stop sending messages. Any messages sent after returning from this callback might get blocked by the FLUSH protocol. When the FLUSH protocol is done, and messages can be sent again, the FLUSH protocol will simply unblock all pending messages. If a callback for unblocking is desired, implement ExtendedMembershipListener.unblock(). Note that block() is the equivalent of reception of a BlockEvent in the pull mode.
      Specified by:
      block in interface MembershipListener
    • setState

      public void setState(Vector mbrs)
    • coordinatorChosen

      public void coordinatorChosen()
    • windowActivated

      public void windowActivated(WindowEvent e)
      Specified by:
      windowActivated in interface WindowListener
    • windowClosed

      public void windowClosed(WindowEvent e)
      Specified by:
      windowClosed in interface WindowListener
    • windowClosing

      public void windowClosing(WindowEvent e)
      Specified by:
      windowClosing in interface WindowListener
    • windowDeactivated

      public void windowDeactivated(WindowEvent e)
      Specified by:
      windowDeactivated in interface WindowListener
    • windowDeiconified

      public void windowDeiconified(WindowEvent e)
      Specified by:
      windowDeiconified in interface WindowListener
    • windowIconified

      public void windowIconified(WindowEvent e)
      Specified by:
      windowIconified in interface WindowListener
    • windowOpened

      public void windowOpened(WindowEvent e)
      Specified by:
      windowOpened in interface WindowListener
    • start

      public void start() throws Exception
      Throws:
      Exception
    • main

      public static void main(String[] args)