|
Project JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.impl.rendezvous.rpv.PeerView
public final class PeerView
This class models a Rendezvous Peer View (RPV): ordered collection of all other Rendezvous Peers visible to this Peer.
Presently this class implements a random "diffusion" algorithm where each Peer periodically selects a randomly selected peer advertisement from its view and sends it over to a randomly selected peer from its view. Over time, this causes every peer to learn about every other peer, resulting in a "consistent" peer view. This diffusion process is bootstrapped by every peer sending their own peer advertisements to some well-known, stable, "seed" peers on startup.
Field Summary | |
---|---|
protected AccessList |
acl
|
protected File |
aclFile
|
protected long |
aclFileLastModified
|
(package private) static MessageElement |
CACHED_RADV_ELEMENT
|
(package private) static String |
CACHED_RADV_ELEMENT_NAME
Element name that specifies by its presence whether the enclosed RdvAdvertisement is a hint (cached), or is known to be active. |
(package private) static MessageElement |
EDGE_ELEMENT
|
(package private) static String |
EDGE_ELEMENT_NAME
Element name that specifies by its presence whether the sender is configured as an edge peer. |
(package private) static MessageElement |
FAILURE_ELEMENT
|
(package private) static String |
FAILURE_ELEMENT_NAME
Element name that specifies by its presence whether the enclosed RdvAdvertisement is about a failure. |
(package private) static String |
MESSAGE_ELEMENT_NAME
Element name of outgoing messages. |
(package private) static String |
MESSAGE_NAMESPACE
Namespace used for rdv message elements. |
(package private) static String |
RESPONSE_ELEMENT_NAME
Element name of responses. |
(package private) static String |
SERVICE_NAME
Our service name |
(package private) static String |
SRCROUTEADV_ELEMENT_NAME
(optional) Element name that specifies the route advertisement of the source of the message. |
Constructor Summary | |
---|---|
PeerView(PeerGroup group,
PeerGroup advertisingGroup,
RendezVousServiceImpl rdvService,
String name)
Get an instance of PeerView for the specified PeerGroup and Service. |
Method Summary | |
---|---|
boolean |
addListener(PeerViewListener listener)
Add a listener for PeerViewEvent |
void |
addSeed(URI seed)
Adds the specified URI to the list of seeds. |
protected void |
addTask(TimerTask task,
long delay,
long interval)
|
PeerViewElement |
getDownPeer()
Get the down peer from the local peer. |
PeerViewElement |
getPeerViewElement(ID pid)
Get from the local view, the PeerViewElement for the given PeerID, if one exists. |
PeerViewElement |
getPeerViewElement(PeerViewDestination wanted)
Return from the local view, the PeerViewElement that is equal to the given PeerViewDestination, if one exists or null if it is
not present. |
PeerViewElement |
getSelf()
Get the local peer. |
PeerViewElement |
getUpPeer()
Get the up peer from the local peer. |
SortedSet |
getView()
Get a copy of the PeerView for this group. |
(package private) static URI[] |
loadSeeds(URI seedingURI)
|
void |
notifyFailure(PeerID pid,
boolean propagate)
Invoked by anyone in order to inform the PeerView of a failure of one of its rendezvous peer. |
(package private) void |
notifyFailure(PeerViewElement pve,
boolean propagateFailure)
Invoked by a PeerViewElement when a rendezvous peer becomes unreachable. |
boolean |
probeAddress(EndpointAddress address,
Object hint)
Probe the specified peer immediately. |
void |
processIncomingMessage(Message msg,
EndpointAddress srcAddr,
EndpointAddress dstAddr)
Listener for "PeerView"/ |
boolean |
removeListener(PeerViewListener listener)
Removes a PeerViewEvent Listener previously added with addListener. |
protected void |
removeTask(TimerTask task)
|
void |
rendezvousEvent(RendezvousEvent event)
|
void |
seed()
Send our own advertisement to all of the seed rendezvous. |
void |
start()
|
void |
stop()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final String SERVICE_NAME
static final String MESSAGE_NAMESPACE
static final String MESSAGE_ELEMENT_NAME
static final String RESPONSE_ELEMENT_NAME
static final String CACHED_RADV_ELEMENT_NAME
static final MessageElement CACHED_RADV_ELEMENT
static final String SRCROUTEADV_ELEMENT_NAME
static final String EDGE_ELEMENT_NAME
static final MessageElement EDGE_ELEMENT
static final String FAILURE_ELEMENT_NAME
static final MessageElement FAILURE_ELEMENT
protected final AccessList acl
protected File aclFile
protected long aclFileLastModified
Constructor Detail |
---|
public PeerView(PeerGroup group, PeerGroup advertisingGroup, RendezVousServiceImpl rdvService, String name)
group
- Peer Group in which this Peer View instance operates.advertisingGroup
- Peer Group in which this Peer View instance will
advertise and broadcast its existance.rdvService
- The rdvService we are to use.name
- The identifying name for this Peer View instance.Method Detail |
---|
public void processIncomingMessage(Message msg, EndpointAddress srcAddr, EndpointAddress dstAddr)
processIncomingMessage
in interface EndpointListener
public void rendezvousEvent(RendezvousEvent event)
rendezvousEvent
in interface RendezvousListener
public void start()
public void stop()
protected void addTask(TimerTask task, long delay, long interval)
protected void removeTask(TimerTask task)
public void addSeed(URI seed)
seed
- the URI of the seed rendezvous.public boolean probeAddress(EndpointAddress address, Object hint)
public void seed()
public void notifyFailure(PeerID pid, boolean propagate)
void notifyFailure(PeerViewElement pve, boolean propagateFailure)
public boolean addListener(PeerViewListener listener)
listener
- An PeerViewListener to process the event.public boolean removeListener(PeerViewListener listener)
listener
- the PeerViewListener listener remove
public SortedSet getView()
public PeerViewElement getPeerViewElement(PeerViewDestination wanted)
null
if it is
not present. Identity is defined by PeerViewDestination#equals()
which only looks at the destination address. Thus a PeerViewDestination
is enough. A full PeerViewElement may be passed as well. This method
does not require external synchronization.
wanted
- PeerViewDestination matching the desired one.
null
if it could not
be found.public PeerViewElement getPeerViewElement(ID pid)
pid
- the PeerID of the desired element.
public PeerViewElement getDownPeer()
public PeerViewElement getSelf()
public PeerViewElement getUpPeer()
static URI[] loadSeeds(URI seedingURI) throws IOException
IOException
|
JXTA J2SE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |