Project JXTA

net.jxta.impl.endpoint.router
Class RouteResolver

java.lang.Object
  extended bynet.jxta.impl.endpoint.router.RouteResolver
All Implemented Interfaces:
QueryHandler, Srdi.SrdiInterface, SrdiHandler

public class RouteResolver
extends Object
implements QueryHandler, SrdiHandler, Srdi.SrdiInterface


Field Summary
static String routerSName
          Router Service Name
 
Constructor Summary
(package private) RouteResolver()
          Default constructor
 
Method Summary
protected  Vector cleanupAnyEdges(String src, Vector results)
          cleanup any edge peers when trying to forward an SRDI query so we are guaranteed to the best of our knowledge that the peer is a rendezvous.
protected  void disableRouteResolver()
          disable routeResolver usage
protected  void enableRouteResolver()
          enable routeResolver usage
protected  void findRoute(EndpointAddress peer)
          issue a new route discovery resolver request
protected  void generateNACKRoute(PeerID src, PeerID dest, Vector origHops)
          Return a route error in case a route was found to be invalid as the current hop cannot find a way to forward the message to the destination or any other hops in the forward part of the route.
protected  Vector getGlobalPeerView()
          return the global peerview
 void init(PeerGroup group, ID assignedID, Advertisement impl, EndpointRouter router)
          initialize routeResolver
 void messageSendFailed(PeerID peerid, OutgoingMessageEvent e)
          
 int processQuery(ResolverQueryMsg query)
          Process the Query, and generate response
 void processResponse(ResolverResponseMsg response)
           This is called by the Generic ResolverServiceImpl when processing a response to a query.
 boolean processSrdi(ResolverSrdiMsg message)
          process an SRDI message request
 void pushEntries(boolean all)
          SrdiInterface
protected  void pushSrdi(ID peer, PeerID id)
           
protected  void pushSrdi(String peer, boolean all)
           
protected  void removeSrdi(String peer, PeerID id)
          remove a SRDI cache entry
protected  void removeSrdiIndex(PeerID pid)
          remove SRDI index
 int startApp(String[] arg)
          Make this transport as up and running.
 void stopApp()
          {@inheritDoc}

Carefull that stopApp() could in theory be called before startApp().

protected  boolean useRouteResolver()
          return routeResolver usage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

routerSName

public static final String routerSName
Router Service Name

See Also:
Constant Field Values
Constructor Detail

RouteResolver

RouteResolver()
Default constructor

Method Detail

useRouteResolver

protected boolean useRouteResolver()
return routeResolver usage


disableRouteResolver

protected void disableRouteResolver()
disable routeResolver usage


enableRouteResolver

protected void enableRouteResolver()
enable routeResolver usage


init

public void init(PeerGroup group,
                 ID assignedID,
                 Advertisement impl,
                 EndpointRouter router)
          throws PeerGroupException
initialize routeResolver

Throws:
PeerGroupException

startApp

public int startApp(String[] arg)
Make this transport as up and running.

When this method is called, all the services are already registered with the peergroup. So we do not need to delay binding any further. All the public methods, which could be called between init and startApp are defensive regarding the services possibly not being there.


stopApp

public void stopApp()
{@inheritDoc}

Carefull that stopApp() could in theory be called before startApp().


findRoute

protected void findRoute(EndpointAddress peer)
issue a new route discovery resolver request

Parameters:
peer - the destination as a logical enpoint address

processResponse

public void processResponse(ResolverResponseMsg response)
This is called by the Generic ResolverServiceImpl when processing a response to a query.

Specified by:
processResponse in interface QueryHandler

processQuery

public int processQuery(ResolverQueryMsg query)
Process the Query, and generate response

Specified by:
processQuery in interface QueryHandler
Parameters:
query - the query to process

generateNACKRoute

protected void generateNACKRoute(PeerID src,
                                 PeerID dest,
                                 Vector origHops)
Return a route error in case a route was found to be invalid as the current hop cannot find a way to forward the message to the destination or any other hops in the forward part of the route. In that case a negative route response is forwarded to the orginal source of the message. Now of course we do not have any way to guarantee that the NACK message will be received by the sender, but the best we can do is to try :-) we send a query ID to NACKROUTE_QUERYID to indicate this is a bad Route

Parameters:
src - original source of the message
dest - original destination of the message

processSrdi

public boolean processSrdi(ResolverSrdiMsg message)
process an SRDI message request

Specified by:
processSrdi in interface SrdiHandler
Parameters:
message - SRDI resolver message

pushEntries

public void pushEntries(boolean all)
SrdiInterface

Specified by:
pushEntries in interface Srdi.SrdiInterface
Parameters:
all - if true then push all entries otherwise just push those which have changed since the last push.

pushSrdi

protected void pushSrdi(String peer,
                        boolean all)

pushSrdi

protected void pushSrdi(ID peer,
                        PeerID id)

removeSrdi

protected void removeSrdi(String peer,
                          PeerID id)
remove a SRDI cache entry

Parameters:
peer - peer id we send the request, null for sending to all
id - peer id of the SRDI route that we want to remove from the cache

messageSendFailed

public void messageSendFailed(PeerID peerid,
                              OutgoingMessageEvent e)

Specified by:
messageSendFailed in interface SrdiHandler

cleanupAnyEdges

protected Vector cleanupAnyEdges(String src,
                                 Vector results)
cleanup any edge peers when trying to forward an SRDI query so we are guaranteed to the best of our knowledge that the peer is a rendezvous. This is not perfect, as it may take time for the peerview to converge but at least we can remove any peers that is not a rendezvous.


getGlobalPeerView

protected Vector getGlobalPeerView()
return the global peerview

Returns:
Vector of RDV member of the peerview

removeSrdiIndex

protected void removeSrdiIndex(PeerID pid)
remove SRDI index

Parameters:
pid - of the index to be removed

JXTA J2SE