|
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 "converged" 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 | |
---|---|
(package private) static MessageElement |
CACHED_RADV_ELEMENT
Optional message element that specifies by its presence in a peerview message that the referenced peer is not the provider of the RdvAdvertisement and the advertisement is a "hint" or referral from the responding peer. |
(package private) static String |
CACHED_RADV_ELEMENT_NAME
Message element name for PeerView "Cached" Message Element |
(package private) static MessageElement |
EDGE_ELEMENT
Optional message element that specifies by its presence in a peerview message that the referenced peer is an edge peer and not a member of the peerview. |
(package private) static String |
EDGE_ELEMENT_NAME
Message element name for PeerView "Edge" Message Element |
(package private) static MessageElement |
FAILURE_ELEMENT
Optional message element that specifies by its presence in a peerview message that the referenced peer has either failed or is quitting. |
(package private) static String |
FAILURE_ELEMENT_NAME
Message element name for PeerView "Failure" Message Element |
(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
Message 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)
|
(package private) static RdvAdvertisement |
createRdvAdvertisement(PeerAdvertisement padv,
String serviceName)
|
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<PeerViewElement> |
getView()
Get a copy of the PeerView for this group. |
(package private) static PipeAdvertisement |
makeWirePipeAdvertisement(PeerGroup destGroup,
PeerGroup group,
String name)
|
void |
notifyFailure(PeerID pid,
boolean propagateFailure)
Invoked by anyone in order to inform the PeerView of a failure of one of the member peers. |
(package private) void |
notifyFailure(PeerViewElement pve,
boolean propagateFailure)
Invoked when a peerview member peer becomes unreachable. |
boolean |
probeAddress(EndpointAddress address,
RouteAdvertisement hint)
Probe the specified peer immediately. |
void |
processIncomingMessage(Message msg,
EndpointAddress srcAddr,
EndpointAddress dstAddr)
This method is invoked by the EndpointService for each incoming message which is addressed to this listener. |
boolean |
removeListener(PeerViewListener listener)
Removes a PeerViewEvent Listener previously added with addListener. |
protected void |
removeTask(TimerTask task)
|
void |
rendezvousEvent(RendezvousEvent event)
Called when an event occurs for the Rendezvous service |
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
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 existence.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
msg
- Incoming messagesrcAddr
- Endpoint Address of the source of the message.dstAddr
- Endpoint Address of the destination of the message.public void rendezvousEvent(RendezvousEvent event)
rendezvousEvent
in interface RendezvousListener
event
- the rendezvous eventpublic 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, RouteAdvertisement hint)
public void seed()
public void notifyFailure(PeerID pid, boolean propagateFailure)
pid
- ID of the peer which failed.propagateFailure
- If truethen broadcast the failure to
other peers otherwise only update the local peerview.void notifyFailure(PeerViewElement pve, boolean propagateFailure)
pve
- The peer which failed.propagateFailure
- If true
then broadcast the failure to
other peers otherwise only update the local peerview.static RdvAdvertisement createRdvAdvertisement(PeerAdvertisement padv, String serviceName)
public boolean addListener(PeerViewListener listener)
listener
- An PeerViewListener to process the event.
public boolean removeListener(PeerViewListener listener)
listener
- the PeerViewListener listener remove
static PipeAdvertisement makeWirePipeAdvertisement(PeerGroup destGroup, PeerGroup group, String name)
public SortedSet<PeerViewElement> getView()
public PeerViewElement getPeerViewElement(PeerViewDestination wanted)
null
if it is
not present. Identity is defined by PeerViewDestination.equals(java.lang.Object)
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()
|
JXSE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |