Project JXTA

net.jxta.impl.rendezvous.rdv
Class RdvPeerRdvService

java.lang.Object
  extended by net.jxta.impl.rendezvous.RendezVousServiceProvider
      extended by net.jxta.impl.rendezvous.StdRendezVousService
          extended by net.jxta.impl.rendezvous.rdv.RdvPeerRdvService
All Implemented Interfaces:
EndpointListener

public class RdvPeerRdvService
extends StdRendezVousService

A JXTA RendezvousService implementation which implements the rendezvous server portion of the standard JXTA Rendezvous Protocol (RVP).

See Also:
RendezvousService, JXTA Protocols Specification : Rendezvous Protocol

Nested Class Summary
 
Nested classes/interfaces inherited from class net.jxta.impl.rendezvous.StdRendezVousService
StdRendezVousService.StdRdvProtocolListener
 
Field Summary
static long GC_INTERVAL
           
static String RDV_SVC_NAME
           
static String RDV_SVC_PARAM
           
 
Fields inherited from class net.jxta.impl.rendezvous.StdRendezVousService
ConnectedLeaseReply, ConnectedPeerReply, ConnectedRdvAdvReply, ConnectRequest, DEFAULT_MAX_TTL, DisconnectRequest, pName, pParam, RdvAdvReply, timer
 
Fields inherited from class net.jxta.impl.rendezvous.RendezVousServiceProvider
closed, group, HEADER_NAME, MAX_TTL, MESSAGE_NAMESPACE_NAME, PropPName, PropSName, rdvService, rendezvousMeter, rendezvousServiceMonitor
 
Constructor Summary
RdvPeerRdvService(PeerGroup g, RendezVousServiceImpl rdvService)
          Constructor for the RdvPeerRdvService object
 
Method Summary
 void challengeRendezVous(ID peer, long delay)
          Resets the local idea of the lease to the specified value.
 void disconnectFromRendezVous(ID peerId)
          Remove a RendezVousService point.
 Vector getConnectedPeerIDs()
          
 Enumeration getConnectedPeers()
          
 Enumeration getConnectedRendezVous()
          Returns an Enumeration of the PeerID all the RendezVous on which this Peer is currentely connected.
 Enumeration getDisconnectedRendezVous()
          Returns an Enumeration of the PeerID all the RendezVous on which this Peer failed to connect to.
 PeerConnection getPeerConnection(ID peer)
          Returns the peer connection or null if not present.
protected  PeerConnection[] getPeerConnections()
          Returns a list of the current peer connections.
 boolean isConnectedToRendezVous()
          Return true if connected to a rendezvous.
 void propagate(Message msg, String serviceName, String serviceParam, int ttl)
          Propagates a message onto as many peers on the local network as possible.
 void propagateInGroup(Message msg, String serviceName, String serviceParam, int ttl)
          
protected  void repropagate(Message msg, RendezVousPropagateMessage propHdr, String serviceName, String serviceParam)
          
 void setChoiceDelay(long delay)
          
protected  int startApp(String[] argv)
          Supply arguments and starts this service if it hadn't started by itself.
protected  void stopApp()
          Ask this service to stop.
 void walk(Message msg, String serviceName, String serviceParam, int ttl)
          Walk a message through the rendezvous peers of the network: only rendezvous peers will receive the message.
 void walk(Vector destPeerIDs, Message msg, String serviceName, String serviceParam, int defaultTTL)
          Walk a message through the rendezvous peers of the network: only rendezvous peers will receive the message.
 
Methods inherited from class net.jxta.impl.rendezvous.StdRendezVousService
processRdvAdvReply, processReceivedMessage, propagate, propagateToNeighbors, sendDisconnect, sendDisconnect, sendToEachConnection, startApp
 
Methods inherited from class net.jxta.impl.rendezvous.RendezVousServiceProvider
checkPropHeader, getPeerAdvertisementDoc, getPropHeader, mkAddress, mkAddress, processIncomingMessage, sendToNetwork, setRendezvousServiceMonitor, updatePropHeader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RDV_SVC_NAME

public static final String RDV_SVC_NAME
See Also:
Constant Field Values

RDV_SVC_PARAM

public static final String RDV_SVC_PARAM
See Also:
Constant Field Values

GC_INTERVAL

public static final long GC_INTERVAL
See Also:
Constant Field Values
Constructor Detail

RdvPeerRdvService

public RdvPeerRdvService(PeerGroup g,
                         RendezVousServiceImpl rdvService)
Constructor for the RdvPeerRdvService object

Method Detail

startApp

protected int startApp(String[] argv)
Supply arguments and starts this service if it hadn't started by itself.

Currently this service starts by itself and does not expect arguments.

Overrides:
startApp in class RendezVousServiceProvider

stopApp

protected void stopApp()
Ask this service to stop.

Overrides:
stopApp in class StdRendezVousService

challengeRendezVous

public void challengeRendezVous(ID peer,
                                long delay)
Resets the local idea of the lease to the specified value. As a result a lease reponse must be sought and obtained within the new specified delay or the rdv is considered disconnected.

Specified by:
challengeRendezVous in class RendezVousServiceProvider
Parameters:
peer - The peer to be chanllenged
delay - The delay

disconnectFromRendezVous

public void disconnectFromRendezVous(ID peerId)
Remove a RendezVousService point.

Specified by:
disconnectFromRendezVous in class RendezVousServiceProvider
Parameters:
peerId - the PeerId of the RendezVous to disconnect from.

isConnectedToRendezVous

public boolean isConnectedToRendezVous()
Return true if connected to a rendezvous.

Specified by:
isConnectedToRendezVous in class RendezVousServiceProvider
Returns:
true if connected to a rendezvous, false otherwise

setChoiceDelay

public void setChoiceDelay(long delay)

Specified by:
setChoiceDelay in class RendezVousServiceProvider

getConnectedPeerIDs

public Vector getConnectedPeerIDs()

Specified by:
getConnectedPeerIDs in class RendezVousServiceProvider

getConnectedPeers

public Enumeration getConnectedPeers()

Specified by:
getConnectedPeers in class RendezVousServiceProvider

getConnectedRendezVous

public Enumeration getConnectedRendezVous()
Returns an Enumeration of the PeerID all the RendezVous on which this Peer is currentely connected.

Specified by:
getConnectedRendezVous in class RendezVousServiceProvider
Returns:
Enumeration enumeration of RendezVous

getDisconnectedRendezVous

public Enumeration getDisconnectedRendezVous()
Returns an Enumeration of the PeerID all the RendezVous on which this Peer failed to connect to.

Specified by:
getDisconnectedRendezVous in class RendezVousServiceProvider
Returns:
Enumeration enumeration of RendezVous

propagate

public void propagate(Message msg,
                      String serviceName,
                      String serviceParam,
                      int ttl)
               throws IOException
Propagates a message onto as many peers on the local network as possible. Typically the message will go to all the peers to which at least one endpoint transport can address without using the router. This method sends the message to all peers, rendezvous peers and edge peer. This method of propation is very expensive and should not be frequentely used. When rendezvous peers are used in order to cache index of data, it is more efficient to use the walk() method. Only a single HOP at a time is performed. Messages are always delivered to the destination handler on arrival. This handler is responsible for repropagating further, if deemed appropropriate. Loop and TTL control are performed automatically. Messages can be propagated via this method for the first time or can be re-propagated by re-using a message that came in via propagation. In the later case, the TTL and loop detection parameters CANNOT be re-initialized. If one wants to "re-propagate" a message with a new TTL and blank gateways list one must generate a completely new message. This limits the risk of accidental propagation storms, although they can always be engineered deliberately. Note: The original msg is not modified and may be reused upon return.

Specified by:
propagate in class RendezVousServiceProvider
Parameters:
msg - is the message to propagate.
serviceName - is the name of the service
serviceParam - is the parameter of the service
Throws:
IOException

propagateInGroup

public void propagateInGroup(Message msg,
                             String serviceName,
                             String serviceParam,
                             int ttl)
                      throws IOException

Specified by:
propagateInGroup in class RendezVousServiceProvider
Throws:
IOException

repropagate

protected void repropagate(Message msg,
                           RendezVousPropagateMessage propHdr,
                           String serviceName,
                           String serviceParam)

Specified by:
repropagate in class RendezVousServiceProvider

getPeerConnection

public PeerConnection getPeerConnection(ID peer)
Description copied from class: StdRendezVousService
Returns the peer connection or null if not present.

Specified by:
getPeerConnection in class StdRendezVousService
Returns:
PeerConnection the peer connection or null if not present.

getPeerConnections

protected PeerConnection[] getPeerConnections()
Description copied from class: StdRendezVousService
Returns a list of the current peer connections.

Specified by:
getPeerConnections in class StdRendezVousService
Returns:
PeerConnection the peer connection or null if not present.

walk

public void walk(Message msg,
                 String serviceName,
                 String serviceParam,
                 int ttl)
          throws IOException
Walk a message through the rendezvous peers of the network: only rendezvous peers will receive the message. Only a single HOP at a time is performed. Messages are always delivered to the destination handler on arrival. This handler is responsible for repropagating further, if deemed appropropriate. Loop and TTL control are performed automatically. Messages can be propagated via this method for the first time or can be re-propagated by re-using a message that came in via propagation. In the later case, the TTL and loop detection parameters CANNOT be re-initialized. If one wants to "re-propagate" a message with a new TTL and blank gateways list one must generate a completely new message. This limits the risk of accidental propagation storms, although they can always be engineered deliberately. Note: The original msg is not modified and may be reused upon return.

Specified by:
walk in class RendezVousServiceProvider
Parameters:
msg - is the message to walk.
serviceName - is the name of the service
serviceParam - is the parameter of the service
ttl - is the maximum TTL of the message (note that the Rendezvous Service implementation is free to decrease that value.
Throws:
IOException - when walking the message is impossible (network failure)

walk

public void walk(Vector destPeerIDs,
                 Message msg,
                 String serviceName,
                 String serviceParam,
                 int defaultTTL)
          throws IOException
Walk a message through the rendezvous peers of the network: only rendezvous peers will receive the message. Only a single HOP at a time is performed. Messages are always delivered to the destination handler on arrival. This handler is responsible for repropagating further, if deemed appropropriate. Loop and TTL control are performed automatically. Messages can be propagated via this method for the first time or can be re-propagated by re-using a message that came in via propagation. In the later case, the TTL and loop detection parameters CANNOT be re-initialized. If one wants to "re-propagate" a message with a new TTL and blank gateways list one must generate a completely new message. This limits the risk of accidental propagation storms, although they can always be engineered deliberately. Note: The original msg is not modified and may be reused upon return.

Specified by:
walk in class RendezVousServiceProvider
Parameters:
destPeerIDs - is a Vector of PeerID of the peers which are receiving first the walker. Note that each entry in the Vector will create its own walker.
msg - is the message to walk.
serviceName - is the name of the service
serviceParam - is the parameter of the service
defaultTTL - is the maximum TTL of the message (note that the Rendezvous Service implementation is free to decrease that value.
Throws:
IOException - when walking the message is impossible (network failure)

JXTA J2SE