edu.vub.at.actors.net
Class MembershipNotifier

java.lang.Object
  extended byorg.jgroups.ExtendedReceiverAdapter
      extended byedu.vub.at.actors.net.MembershipNotifier
All Implemented Interfaces:
org.jgroups.ExtendedMembershipListener, org.jgroups.ExtendedMessageListener, org.jgroups.ExtendedReceiver, org.jgroups.MembershipListener, org.jgroups.MessageListener, org.jgroups.Receiver

public class MembershipNotifier
extends org.jgroups.ExtendedReceiverAdapter
implements org.jgroups.MembershipListener

An instance of the class MembershipNotifier is registered with an instance of the JGroups MessageDispatcher class as its MembershipListener. Whenever virtual machines connect or disconnect from the multicast group, this object is notified. Its role is to propagate these notifications to: A) The AT/2 DiscoveryManager which is interested in contacting newly joined virtual machines to see whether they provide some services that this VM requires. B) All connected ConnectionListeners, which will usually be remote references pointing to objects hosted by the connecting/disconnecting VM. TODO: change Address keys of ConnectionListeners to GUIDs to support changing addresses.

Author:
tvcutsem

Field Summary
private  MultiMap connectionListeners_
          A collection of ConnectionListeners which are interested in the (dis)appearance of a single node in the JGroups overlay network.
private  DiscoveryListener discoveryManager_
          The general manager for service discovery for the entire virtual machine.
private  java.util.Vector knownMembers_
          Members of the previously accepted view are stored to evaluate the difference with any new view that may be signalled to this class.
 
Constructor Summary
MembershipNotifier(DiscoveryListener discoveryManager)
          Creates a new MembershipNotifier on which ConnectionListeners monitoring the (dis)appearance of a single address can register to.
 
Method Summary
 void addConnectionListener(GUID virtualMachine, ConnectionListener listener)
          Registers listener to be notified whenever a virtual machine becomes (un)reachable.
 void channelDisconnected()
           
 void notifyConnected(GUID vmId)
           
 void notifyDisconnected(GUID vmId)
           
 void removeConnectionListener(GUID virtualMachine, ConnectionListener listener)
          Unregisters listener such that it will no longer be notified whenever a particular virtual machine becomes (un)reachable.
 void viewAccepted(org.jgroups.View newView)
          This method is a callback from the JGroups framework that is invoked whenever the set of connected group members has changed.
 
Methods inherited from class org.jgroups.ExtendedReceiverAdapter
block, getState, getState, getState, getState, receive, setState, setState, setState, setState, suspect, unblock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jgroups.MembershipListener
block, suspect
 

Field Detail

knownMembers_

private final java.util.Vector knownMembers_
Members of the previously accepted view are stored to evaluate the difference with any new view that may be signalled to this class.


connectionListeners_

private final MultiMap connectionListeners_
A collection of ConnectionListeners which are interested in the (dis)appearance of a single node in the JGroups overlay network.


discoveryManager_

private final DiscoveryListener discoveryManager_
The general manager for service discovery for the entire virtual machine. Whenever a new VM is encountered, this manager needs to be notified such that it can exchange the necessary service descriptions. Likewise, VM disconnections should be delegated to this listener.

Constructor Detail

MembershipNotifier

public MembershipNotifier(DiscoveryListener discoveryManager)
Creates a new MembershipNotifier on which ConnectionListeners monitoring the (dis)appearance of a single address can register to.

Parameters:
discoveryManager - - the service discovery manager for the current address.
Method Detail

addConnectionListener

public void addConnectionListener(GUID virtualMachine,
                                  ConnectionListener listener)
Registers listener to be notified whenever a virtual machine becomes (un)reachable.

Parameters:
virtualMachine - - an address of the virtual machine hosting the object the listener is interested in
listener - - a listener which will be notified whenever the said address connects or disconnects

removeConnectionListener

public void removeConnectionListener(GUID virtualMachine,
                                     ConnectionListener listener)
Unregisters listener such that it will no longer be notified whenever a particular virtual machine becomes (un)reachable.


viewAccepted

public void viewAccepted(org.jgroups.View newView)
This method is a callback from the JGroups framework that is invoked whenever the set of connected group members has changed. The callback responds to such an event by comparing the new set of members with the previously known set of members to calculate which members joined and left. For each of these joined and left members, the corresponding connection listeners are notified. Also, the discovery manager is always notified when a member has joined.

Specified by:
viewAccepted in interface org.jgroups.MembershipListener

notifyConnected

public void notifyConnected(GUID vmId)

notifyDisconnected

public void notifyDisconnected(GUID vmId)

channelDisconnected

public void channelDisconnected()