viceroy
Interface AuthorizedLookupPeer

All Superinterfaces:
LookupPeer
All Known Subinterfaces:
AuthorizedViceroyPeer
All Known Implementing Classes:
LocalViceroyPeer

public interface AuthorizedLookupPeer
extends LookupPeer

Represents a peer in some Lookup network. The network's topology can be of any type. the autorization stands for some additional permissions: join the network and leave it. Authorized peer can initiate these actions, unlike the non-authorized peer - LookupPeer

Since:
1.2
Author:
Anat Talmy
, Oren Dobzinski

Method Summary
 void addResource(Resource newResource)
          Adds new Resource to this peer, and to the viceroy network
 boolean containsResource(Resource resource)
          Checks if this peer actually holds the given resource.
 void deleteResource(Resource resource)
          Deletes a resource from this peer- if it is present
 boolean isResponsibleFor(HashValue value)
          True if this peer is responsible for the given value - if the value is in the range of values that this peer is responsible for (predecessor,id]
 void join()
          Joins this peer to the network
 void leave()
          Removes this peer from the network
 
Methods inherited from interface viceroy.LookupPeer
getAddress, lookup, lookup
 

Method Detail

join

public void join()
Joins this peer to the network


leave

public void leave()
Removes this peer from the network


isResponsibleFor

public boolean isResponsibleFor(HashValue value)
True if this peer is responsible for the given value - if the value is in the range of values that this peer is responsible for (predecessor,id]

Parameters:
value - the value to check
Returns:
true if this peer is responsible for the given value - if the value is in the range of values that this peer is responsible for (predecessor,id]. false otherwise

addResource

public void addResource(Resource newResource)
                 throws IllegalResourceInsertionException
Adds new Resource to this peer, and to the viceroy network

Parameters:
newResource - The new resource to be added
Throws:
IllegalResourceInsertionException - if !this.isResponsibleFor(newResource.hashValue())

deleteResource

public void deleteResource(Resource resource)
                    throws IllegalResourceInsertionException
Deletes a resource from this peer- if it is present

Parameters:
resource - The resource to be deleted
Throws:
IllegalResourceInsertionException - if !this.isResponsibleFor(newResource.hashValue())

containsResource

public boolean containsResource(Resource resource)
Checks if this peer actually holds the given resource. note, this method differ from isResponsibleFor(): it is possible that some peer is responsible for a specific resource, but it does not neccessarily hold it.

Parameters:
resource - the resource to be checked
Returns:
True if this peer holds the given resource False otherwise