Project JXTA

net.jxta.impl.pipe
Class PipeResolver

java.lang.Object
  extended by net.jxta.impl.pipe.PipeResolver
All Implemented Interfaces:
Srdi.SrdiInterface, PipeRegistrar, InternalQueryHandler, QueryHandler, SrdiHandler

 class PipeResolver
extends Object
implements Srdi.SrdiInterface, InternalQueryHandler, SrdiHandler, PipeRegistrar

This class implements the Resolver interfaces for a PipeServiceImpl.


Nested Class Summary
(package private) static class PipeResolver.Event
          A pipe resolver event.
(package private) static interface PipeResolver.Listener
          Pipe Resolver Event Listener.
 
Field Summary
(package private) static int ANYQUERY
          Constant for pipe event listeners to signify any query id.
 
Constructor Summary
PipeResolver(PeerGroup g)
          Constructor for the PipeResolver object
 
Method Summary
(package private)  boolean addListener(PipeID pipeID, PipeResolver.Listener listener, int queryID)
          Add a pipe resolver listener
(package private)  void callListener(int qid, PipeID pipeID, String type, PeerID peer, boolean NAK)
          Call the listener for the specified pipe id informing it about the specified peer.
 InputPipe findLocal(PipeID pipeID)
          Return the local InputPipe, if any, for the specified PipeID.
 boolean forget(InputPipe pipe)
          This peer is no longer listening on the specified pipe.
(package private) static int getNextQueryID()
          return the next query id.
(package private)  SrdiIndex getSrdiIndex()
          
 void messageSendFailed(PeerID peerid, OutgoingMessageEvent e)
          
 int processQuery(ResolverQueryMsg query)
          
 int processQuery(ResolverQueryMsg query, EndpointAddress srcAddr)
          Process the resolver query, and generate response it is the responsibilty of the handler to send the response

 result = processIncommingQuery(query);
 if (result !
 void processResponse(ResolverResponseMsg response)
          
 void processResponse(ResolverResponseMsg response, EndpointAddress srcAddr)
          Called when messages are received by the ResolverService it calls back this method to deal with received responses
 boolean processSrdi(ResolverSrdiMsg message)
          
 void pushEntries(boolean all)
          Pushe SRDI entries.
(package private)  void pushSrdi(InputPipe ip, boolean adding)
          Push SRDI entry for the specified pipe
 boolean register(InputPipe ip)
          Register that this peer is an InputPipe for the specified Pipe ID.
(package private)  PipeResolver.Listener removeListener(PipeID pipeID, int queryID)
          Remove a pipe resolver listener
(package private)  int sendPipeQuery(PipeAdvertisement adv, Set acceptablePeers, int queryID)
          Send a request to find an input pipe
(package private)  void stop()
          unregisters the resolver handler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANYQUERY

static final int ANYQUERY
Constant for pipe event listeners to signify any query id.

See Also:
Constant Field Values
Constructor Detail

PipeResolver

PipeResolver(PeerGroup g)
Constructor for the PipeResolver object

Parameters:
g - group for which this PipeResolver operates in
Method Detail

getNextQueryID

static int getNextQueryID()
return the next query id.

Returns:
the next eligible query id.

processQuery

public int processQuery(ResolverQueryMsg query)

Specified by:
processQuery in interface QueryHandler

processQuery

public int processQuery(ResolverQueryMsg query,
                        EndpointAddress srcAddr)
Process the resolver query, and generate response it is the responsibilty of the handler to send the response

 result = processIncommingQuery(query);
 if (result != null) {
   resolver.sendResponse(query.getSrc(), response);
   return resolver.OK;
  } else return resolver.Repropagate;
 

Specified by:
processQuery in interface InternalQueryHandler
Parameters:
query - ResolverQueryMsg query
Returns:
int status, OK success, Repropagate to indicate a re-propagation is needed

processResponse

public void processResponse(ResolverResponseMsg response)

Specified by:
processResponse in interface QueryHandler

processResponse

public void processResponse(ResolverResponseMsg response,
                            EndpointAddress srcAddr)
Called when messages are received by the ResolverService it calls back this method to deal with received responses

Specified by:
processResponse in interface InternalQueryHandler
Parameters:
response - ResolverQueryMsg reponse

processSrdi

public boolean processSrdi(ResolverSrdiMsg message)

Specified by:
processSrdi in interface SrdiHandler

messageSendFailed

public void messageSendFailed(PeerID peerid,
                              OutgoingMessageEvent e)

Specified by:
messageSendFailed in interface SrdiHandler

pushEntries

public void pushEntries(boolean all)
Pushe SRDI entries.

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.

stop

void stop()
unregisters the resolver handler


register

public boolean register(InputPipe ip)
Register that this peer is an InputPipe for the specified Pipe ID.

Specified by:
register in interface PipeRegistrar
Parameters:
ip - the pipe object

findLocal

public InputPipe findLocal(PipeID pipeID)
Return the local InputPipe, if any, for the specified PipeID.

Parameters:
pipeID - the PipeID who's InputPipe is desired.
Returns:
The InputPipe object.

forget

public boolean forget(InputPipe pipe)
This peer is no longer listening on the specified pipe.

Specified by:
forget in interface PipeRegistrar
Returns:
true if the pipe was removed otherwise false.

addListener

boolean addListener(PipeID pipeID,
                    PipeResolver.Listener listener,
                    int queryID)
Add a pipe resolver listener

Parameters:
listener - listener

callListener

void callListener(int qid,
                  PipeID pipeID,
                  String type,
                  PeerID peer,
                  boolean NAK)
Call the listener for the specified pipe id informing it about the specified peer.

Parameters:
qid - The query this callback is being made in response to.
pipeID - The pipe which is the subject of the event.
type - The type of the pipe which is the subject of the event.
peer - The peer on which the remote input pipe was found.

removeListener

PipeResolver.Listener removeListener(PipeID pipeID,
                                     int queryID)
Remove a pipe resolver listener

Parameters:
pipeid - listener to remove
queryid - matching queryid.
Returns:
listener object removed

sendPipeQuery

int sendPipeQuery(PipeAdvertisement adv,
                  Set acceptablePeers,
                  int queryID)
Send a request to find an input pipe

Parameters:
adv - the advertisement for the pipe we are seeking.
acceptablePeers - the set of peers at which we wish the pipe to be resolved. We will not accept responses from peers other than those in this set. Empty set means all peers are acceptable.
queryID - the query ID to use for the query. if zero then a query ID will be generated
Returns:
the query id under which the request was sent

getSrdiIndex

SrdiIndex getSrdiIndex()


pushSrdi

void pushSrdi(InputPipe ip,
              boolean adding)
Push SRDI entry for the specified pipe

Parameters:
ip - the pipe who's entry we are pushing
adding - adding an entry for the pipe or expiring the entry?

JXTA J2SE