|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--viceroy.RemoteViceroyPeer
Represents a remote viceroy peer. this is a stub class that actually sends messages to a real LocalViceroyPeer on remote peer. this class is immutable
| Field Summary | |
private Address |
address
The address of this peer in the communication world. |
private ViceroyPeerManager |
communicationManager
A communication manager. |
private HashValue |
id
This peer's identifier in the viceroy network |
private int |
level
The peer's level |
| Constructor Summary | |
RemoteViceroyPeer(Address add,
HashValue idd,
int _level,
ViceroyPeerManager manager)
constructs a new RemoteViceroyPeer. |
|
| Method Summary | |
void |
changingLevelReceived(ViceroyPeer changing)
Is activated when a changing level message was received. |
void |
discoverReceived(ViceroyPeer sender)
Is activated when some peer wants to join in. |
void |
findRelative(ViceroyPeer searcher,
Relative type)
Finds the relative of this peer Impl note: The algorithm for the left child is as follows: find a successor with this.level+1 . |
Address |
getAddress()
Returns a real-world address for sending messages |
int |
getLevel()
Gets the level of this peer. |
int |
hashCode()
Return the peer's id |
HashValue |
hashValue()
Calculates the hash value. |
void |
joinDataReceived(ViceroyPeer yourSuccessor,
ViceroyPeer yourPredecessor,
java.util.SortedMap yourValues)
Is activated when a JoinData message arrives |
void |
leaveDataReceived(ViceroyPeer _successor,
ViceroyPeer _predecessor,
java.util.SortedMap _values)
Is activated when a LeaveData message arrives from the predecessor of this peer |
void |
leavingPeerReceived(ViceroyPeer leaving,
ViceroyPeer leavingPre,
ViceroyPeer leavingSuc,
java.util.SortedMap leavingValues)
Is activated once a LeavingPeerMessage arrives. |
void |
lookup(Resource valueToLook,
LookupAlgorithm method)
Performs a lookup operation on this peer Note: this method is used when this peer initiate a lookup request. |
void |
lookup(Resource valueToLook,
LookupPeer returnAddress,
LookupAlgorithm method)
Performs a lookup operation on this peer Note: this method is used when this peer recieves a lookup a lookup message that was initiated by another peer. |
void |
lookupAnswerReceived(Resource lookedUp,
ViceroyPeer answer,
MessagePath path)
Is activated when a lookup answer was received. |
void |
newInboundRelativeReceived(ViceroyPeer inbound,
Relative type)
Activated when a new inbound relative is received: when someone informs this peer that this peer is its parent, left child or right child. |
void |
newLeftChildReceived(ViceroyPeer _leftChild)
Activated when an answer is received after this peer has initiated findLeftChild method. |
void |
newParentReceived(ViceroyPeer _parent)
Activated when an answer is received after this peer has initiated findParent method. |
void |
newPredecessorReceived(ViceroyPeer pre)
Sets the predecessor to the given value |
void |
newRightChildReceived(ViceroyPeer _rightChild)
Activated when an answer is received after this peer has initiated findRightChild method. |
void |
newSuccessorReceived(ViceroyPeer succ)
Sets the successor to the given value |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private Address address
private HashValue id
private ViceroyPeerManager communicationManager
private int level
| Constructor Detail |
public RemoteViceroyPeer(Address add,
HashValue idd,
int _level,
ViceroyPeerManager manager)
add - The address of the remote peeridd - The id of the remote peer_level - The level of the remote peermanager - a communication manager. Sends and receives messages, deals with listeners that this peer
will register to.| Method Detail |
public void joinDataReceived(ViceroyPeer yourSuccessor,
ViceroyPeer yourPredecessor,
java.util.SortedMap yourValues)
throws java.lang.IllegalStateException
joinDataReceived in interface ViceroyPeeryourSuccessor - the new successor that I should haveyourPredecessor - the new predeccessor that I should haveyourValues - the values that I should be in charge of
java.lang.IllegalStateException - when this peer's state is not PeerState.JOININGPeerState.JOININGpublic int hashCode()
hashCode in class java.lang.Objectpublic void newPredecessorReceived(ViceroyPeer pre)
newPredecessorReceived in interface ViceroyPeerpre - the new value of predeccesorpublic void newSuccessorReceived(ViceroyPeer succ)
newSuccessorReceived in interface ViceroyPeersucc - the new value of successor
public void lookup(Resource valueToLook,
LookupPeer returnAddress,
LookupAlgorithm method)
lookup in interface LookupPeervalueToLook - the value to lookupreturnAddress - the peer who initiated this searchmethod - the lookup algorithm to use
java.lang.IllegalStateException - if the peer is not in a legal state for looking up.LookupState
public void lookup(Resource valueToLook,
LookupAlgorithm method)
throws ResourceNotFoundException
lookup in interface LookupPeervalueToLook - the value to lookupmethod - the lookup algorithm to use
java.lang.IllegalStateException - if the peer is not in a legal state for looking up.
ResourceNotFoundExceptionpublic Address getAddress()
getAddress in interface LookupPeerpublic HashValue hashValue()
hashValue in interface Resource
public void leavingPeerReceived(ViceroyPeer leaving,
ViceroyPeer leavingPre,
ViceroyPeer leavingSuc,
java.util.SortedMap leavingValues)
leavingPeerReceived in interface ViceroyPeerleaving - the leaving peer
public void leaveDataReceived(ViceroyPeer _successor,
ViceroyPeer _predecessor,
java.util.SortedMap _values)
throws java.lang.IllegalStateException
leaveDataReceived in interface ViceroyPeer_successor - the successor of the leaving peer_predecessor - the predecessor of the leaving peer_values - the values of the leaving peer
java.lang.IllegalStateExceptionpublic int getLevel()
getLevel in interface ViceroyPeer
public void newLeftChildReceived(ViceroyPeer _leftChild)
throws java.lang.IllegalStateException
newLeftChildReceived in interface ViceroyPeer_leftChild - the received answer
java.lang.IllegalStateException
public void newRightChildReceived(ViceroyPeer _rightChild)
throws java.lang.IllegalStateException
newRightChildReceived in interface ViceroyPeer_rightChild - the received answer
java.lang.IllegalStateException
public void lookupAnswerReceived(Resource lookedUp,
ViceroyPeer answer,
MessagePath path)
lookupAnswerReceived in interface ViceroyPeerlookedUp - the resource that was looked upanswer - the peer that holds this resourcepath - the path that the message went through
java.lang.IllegalStateException - if the peer is not in the correct state - if it didn't
initiated this lookup
public void newParentReceived(ViceroyPeer _parent)
throws java.lang.IllegalStateException
newParentReceived in interface ViceroyPeer_parent - the received answer
java.lang.IllegalStateException
public void findRelative(ViceroyPeer searcher,
Relative type)
findRelative in interface ViceroyPeersearcher - the peer which initiated this search.type - The type of the relative
public void discoverReceived(ViceroyPeer sender)
throws java.lang.IllegalStateException,
ResourceNotFoundException
discoverReceived in interface ViceroyPeersender - the peer who sent this message
java.lang.IllegalStateException
ResourceNotFoundException
public void newInboundRelativeReceived(ViceroyPeer inbound,
Relative type)
newInboundRelativeReceived in interface ViceroyPeerinbound - the peer that is the inbound connectiontype - the type of relativepublic void changingLevelReceived(ViceroyPeer changing)
changingLevelReceived in interface ViceroyPeerchanging - the peer whose level has changed
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||