viceroy
Interface AuthorizedViceroyPeer

All Superinterfaces:
AuthorizedLookupPeer, LookupPeer, Resource, ViceroyPeer
All Known Implementing Classes:
LocalViceroyPeer

public interface AuthorizedViceroyPeer
extends ViceroyPeer, AuthorizedLookupPeer

Represents an authorized lookup peer in the viceroy network. Such a peer can initiate lookups, joins and leaves. The non-authorized version (ViceroyPeer) can not initiate those actions. Note that the lookup operation of a non-authorized ViceroyPeer actually deals with lookup requests, performed by other peers.

Since:
1.2
Author:
Anat Talmy
, Oren Dobzinski

Method Summary
 void addJoinDataListener(JoinDataListener listener)
          Adds a new listener.
 void addLookupAnswerListener(LookupAnswerListener listener)
          Adds a new listener.
 ViceroyPeerManager getCommunicationManager()
          Gets the communication manager of the peer
 java.util.List getConnections()
          Gets a set holding both outgoing and ingoing connections of this peer.
 java.util.Set getInboundRelatives()
          Gets a view of the inbound conections to this peer: children and parents.
 ViceroyPeer getLeftChild()
          Gets the peer's left child
 ViceroyPeer getPredecessor()
          Gets the peer's predecessor
 ViceroyPeer getRightChild()
          Gets the peer's right child
 PeerState getState()
          Gets the peer's state
 ViceroyPeer getSuccessor()
          Gets the peer's successor
 ViceroyPeer parent()
          Gets the peer's parent
 boolean removeJoinDataListener(JoinDataListener listener)
          Removes the given listener.
 boolean removeLookupAnswerListener(LookupAnswerListener listener)
          Removes the given listener.
 
Methods inherited from interface viceroy.ViceroyPeer
changingLevelReceived, discoverReceived, findRelative, getLevel, joinDataReceived, leaveDataReceived, leavingPeerReceived, lookupAnswerReceived, newInboundRelativeReceived, newLeftChildReceived, newParentReceived, newPredecessorReceived, newRightChildReceived, newSuccessorReceived
 
Methods inherited from interface viceroy.LookupPeer
getAddress, lookup, lookup
 
Methods inherited from interface viceroy.Resource
hashValue
 
Methods inherited from interface viceroy.AuthorizedLookupPeer
addResource, containsResource, deleteResource, isResponsibleFor, join, leave
 

Method Detail

getCommunicationManager

public ViceroyPeerManager getCommunicationManager()
Gets the communication manager of the peer

Returns:
the communication manager of the peer

parent

public ViceroyPeer parent()
Gets the peer's parent

Returns:
the peer's parent

getLeftChild

public ViceroyPeer getLeftChild()
Gets the peer's left child

Returns:
the peer's left child

getRightChild

public ViceroyPeer getRightChild()
Gets the peer's right child

Returns:
the peer's right child

getSuccessor

public ViceroyPeer getSuccessor()
Gets the peer's successor

Returns:
the peer's successor

getPredecessor

public ViceroyPeer getPredecessor()
Gets the peer's predecessor

Returns:
the peer's predecessor

getState

public PeerState getState()
Gets the peer's state

Returns:
the peer's state

getInboundRelatives

public java.util.Set getInboundRelatives()
Gets a view of the inbound conections to this peer: children and parents. Note: this peer can have several inbound connections from the same kind. Also note that successor-predecessor links are not inbound connections. Last note: even if some peer has this peer both as left and right child, this method will get only one copy of it in the Set, of course. Holds ViceroyPeer elements

Returns:
a view of the inbound conections to this peer: children and parents. Note: this peer can have several inbound connections from the same kind. Also note that successor-predecessor links are not inbound connections.

getConnections

public java.util.List getConnections()
Gets a set holding both outgoing and ingoing connections of this peer. Holds ViceroyPeer objects. imp note: it is a list becuase it someone is my suc and my left I want to notify both

Returns:
a set holding all outgoing connections of this peer. Holds ViceroyPeer objects.

addLookupAnswerListener

public void addLookupAnswerListener(LookupAnswerListener listener)
Adds a new listener. Will be activated when a lookup answer will be received. when someone activates the method lookup(), he/she wants to get the answer after it is found. Since the Viceroy network works in an asynchronous model, the user will be notified by this listener once the answer is received.

Parameters:
listener - the listener to add
See Also:
viceroy.net.LookupAnswerListener.onLookupAnswerMessage, viceroy.ViceroyPeer.lookup

addJoinDataListener

public void addJoinDataListener(JoinDataListener listener)
Adds a new listener. Will be activated when a join approval will be received. when someone activates the method join(), he/she wants to get the final approval after the peer has joined. Since the Viceroy network works in an asynchronous model, the user will be notified by this listener once the answer is received.

Parameters:
listener - the listener to add
See Also:
viceroy.net.JoinDataListener.onJoinDataMessage, viceroy.AuthorizedLookupPeer.join

removeLookupAnswerListener

public boolean removeLookupAnswerListener(LookupAnswerListener listener)
Removes the given listener.

Parameters:
listener - the listener to be removed
Returns:
True if the set of listeners has changed as a result of this call

removeJoinDataListener

public boolean removeJoinDataListener(JoinDataListener listener)
Removes the given listener.

Parameters:
listener - the listener to be removed
Returns:
True if the set of listeners has changed as a result of this call