Project JXTA

net.jxta.impl.rendezvous
Class StdRendezVousService

java.lang.Object
  extended by net.jxta.impl.rendezvous.RendezVousServiceProvider
      extended by net.jxta.impl.rendezvous.StdRendezVousService
All Implemented Interfaces:
EndpointListener
Direct Known Subclasses:
EdgePeerRdvService, RdvPeerRdvService

public abstract class StdRendezVousService
extends RendezVousServiceProvider

Base class for providers which implement the JXTA Standard Rendezvous Protocol.

See Also:
JXTA Protocols Specification : Rendezvous Protocol

Nested Class Summary
protected static interface StdRendezVousService.StdRdvProtocolListener
          Interface for listeners to : /
 
Field Summary
static String ConnectedLeaseReply
           
static String ConnectedPeerReply
           
static String ConnectedRdvAdvReply
           
static String ConnectRequest
           
protected static int DEFAULT_MAX_TTL
          Default Maximum TTL.
static String DisconnectRequest
           
protected  String pName
           
protected  String pParam
           
static String RdvAdvReply
           
protected  Timer 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
protected StdRendezVousService(PeerGroup group, RendezVousServiceImpl rdvService)
          Constructor
 
Method Summary
abstract  PeerConnection getPeerConnection(ID id)
          Returns the peer connection or null if not present.
protected abstract  PeerConnection[] getPeerConnections()
          Returns a list of the current peer connections.
protected  void processRdvAdvReply(Message msg)
          Receive and publish a Rendezvous Peer Advertisement.
 void processReceivedMessage(Message message, RendezVousPropagateMessage propHdr, EndpointAddress srcAddr, EndpointAddress dstAddr)
          Process a propagated message.
 void propagate(Enumeration destPeerIDs, Message msg, String serviceName, String serviceParam, int ttl)
          Propagates a message onto as many peers on the local network as possible.
 void propagateToNeighbors(Message msg, String serviceName, String serviceParam, int ttl)
          Propagates a message onto as many peers on the local network as possible.
protected  void sendDisconnect(PeerConnection pConn)
          Sends a disconnect message to the specified peer.
protected  void sendDisconnect(PeerID peerid, PeerAdvertisement padv)
          Sends a disconnect message to the specified peer.
protected  int sendToEachConnection(Message msg, RendezVousPropagateMessage propHdr)
          Sends to all connected peers.
protected  int startApp(String[] argv, StdRendezVousService.StdRdvProtocolListener handler)
           
protected  void stopApp()
          Ask this service to stop.
 
Methods inherited from class net.jxta.impl.rendezvous.RendezVousServiceProvider
challengeRendezVous, checkPropHeader, disconnectFromRendezVous, getConnectedPeerIDs, getConnectedPeers, getConnectedRendezVous, getDisconnectedRendezVous, getPeerAdvertisementDoc, getPropHeader, isConnectedToRendezVous, mkAddress, mkAddress, processIncomingMessage, propagate, propagateInGroup, repropagate, sendToNetwork, setChoiceDelay, setRendezvousServiceMonitor, startApp, updatePropHeader, walk, walk
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ConnectRequest

public static final String ConnectRequest
See Also:
Constant Field Values

DisconnectRequest

public static final String DisconnectRequest
See Also:
Constant Field Values

ConnectedPeerReply

public static final String ConnectedPeerReply
See Also:
Constant Field Values

ConnectedLeaseReply

public static final String ConnectedLeaseReply
See Also:
Constant Field Values

ConnectedRdvAdvReply

public static final String ConnectedRdvAdvReply
See Also:
Constant Field Values

RdvAdvReply

public static final String RdvAdvReply
See Also:
Constant Field Values

DEFAULT_MAX_TTL

protected static final int DEFAULT_MAX_TTL
Default Maximum TTL.

See Also:
Constant Field Values

pName

protected final String pName

pParam

protected final String pParam

timer

protected final Timer timer
Constructor Detail

StdRendezVousService

protected StdRendezVousService(PeerGroup group,
                               RendezVousServiceImpl rdvService)
Constructor

Method Detail

startApp

protected int startApp(String[] argv,
                       StdRendezVousService.StdRdvProtocolListener handler)

stopApp

protected void stopApp()
Description copied from class: RendezVousServiceProvider
Ask this service to stop.

Overrides:
stopApp in class RendezVousServiceProvider

processRdvAdvReply

protected void processRdvAdvReply(Message msg)
Receive and publish a Rendezvous Peer Advertisement.

Parameters:
msg - Message containing the Rendezvous Peer Advertisement

processReceivedMessage

public void processReceivedMessage(Message message,
                                   RendezVousPropagateMessage propHdr,
                                   EndpointAddress srcAddr,
                                   EndpointAddress dstAddr)
Process a propagated message.

Overrides:
processReceivedMessage in class RendezVousServiceProvider

propagate

public void propagate(Enumeration destPeerIDs,
                      Message msg,
                      String serviceName,
                      String serviceParam,
                      int ttl)
Description copied from class: RendezVousServiceProvider
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
msg - is the message to propagate.
serviceName - is the name of the service
serviceParam - is the parameter of the service

propagateToNeighbors

public void propagateToNeighbors(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. 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:
propagateToNeighbors 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

getPeerConnection

public abstract PeerConnection getPeerConnection(ID id)
Returns the peer connection or null if not present.

Returns:
PeerConnection the peer connection or null if not present.

getPeerConnections

protected abstract PeerConnection[] getPeerConnections()
Returns a list of the current peer connections.

Returns:
PeerConnection the peer connection or null if not present.

sendToEachConnection

protected int sendToEachConnection(Message msg,
                                   RendezVousPropagateMessage propHdr)
Sends to all connected peers.

Note: The original msg is not modified and may be reused upon return.

Parameters:
msg - is the message to propagate.
serviceName - is the name of the service
serviceParam - is the parameter of the service

sendDisconnect

protected void sendDisconnect(PeerID peerid,
                              PeerAdvertisement padv)
Sends a disconnect message to the specified peer.

Parameters:
id - the peer which we will disconnect from.
Messenger - the messenger to use in sending the disconnect.

sendDisconnect

protected void sendDisconnect(PeerConnection pConn)
Sends a disconnect message to the specified peer.

Parameters:
id - the peer which we will disconnect from.
Messenger - the messenger to use in sending the disconnect.

JXTA J2SE