viceroy.net
Interface ViceroyPeerManager

All Known Implementing Classes:
DummyCommunicationManager

public interface ViceroyPeerManager

Handles the in and out communication for all local ViceroyPeers - all peers in a single machine Note: implementation of this interface will need to control all messages for all peers in a JVM, therefore it will probably be a Singleton class.

Author:
Anat Talmy
, Oren Dobzinski

Method Summary
 void addListener(Listener listener, AuthorizedViceroyPeer bounded)
          adds a new listener to the system.
 void discover(ViceroyPeer me)
          finds the successor of me in the Viceroy network.
 void leave(AuthorizedViceroyPeer peer)
          removes the given peer from the network.
 Address register(AuthorizedViceroyPeer peer)
          registers a new ViceroyPeer in the system.
 void send(ViceroyPeer destination, Message message)
          send a message
 

Method Detail

register

public Address register(AuthorizedViceroyPeer peer)
registers a new ViceroyPeer in the system. The return value of this method should be kept at the registerred peer, for messages which need a return address

Parameters:
peer - the peer to register
Returns:
an address that should be kept in case the registerred peer needs am answer for a certain message.

leave

public void leave(AuthorizedViceroyPeer peer)
removes the given peer from the network. All its listeners will be removed, and no messages will reach it

Parameters:
peer - the peer that leaves

addListener

public void addListener(Listener listener,
                        AuthorizedViceroyPeer bounded)
adds a new listener to the system. Several local peers can listen on the same message with different listeners. The listener is able to distinguish between the messages Note: if a bounded peer adds more than one listener from the same type, only one of them is activated, and not all of them

Parameters:
listener - the listener to add
bounded - the peer that the incoming messages specify as destination

send

public void send(ViceroyPeer destination,
                 Message message)
send a message

Parameters:
destination - the destination of the message
message - the message to be sent

discover

public void discover(ViceroyPeer me)
finds the successor of me in the Viceroy network. This step is called 'discovery'. The successor is the ViceroyPeer who is responsible to my HashValue before my takeover

Parameters:
me - The peer who wishes to find its successor - to initiate the discovery process.
Since:
version 1.1