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.CurrentCredential
          Encapsulates current Membership Service credential.
(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.
(package private)  PipeResolver.CurrentCredential currentCredential
          The current Membership service default credential.
(package private)  net.jxta.impl.pipe.PipeResolver.CredentialListener membershipCredListener
           
 
Constructor Summary
PipeResolver(PeerGroup peerGroup)
          Constructor for the PipeResolver object
 
Method Summary
(package private)  boolean addListener(ID pipeID, PipeResolver.Listener listener, int queryID)
          Add a pipe resolver listener
(package private)  void callListener(int qid, ID 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)
          Resolver calls this method when a failure to send a message to specified peer occurs
 int processQuery(ResolverQueryMsg query)
          Process the resolver query, and generate response it is the responsibility of the handler to send the response

result = processIncomingQuery(query); if (result !

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

result = processIncommingQuery(query); if (result !

 void processResponse(ResolverResponseMsg response)
          Called when messages are received by the ResolverService it calls back this method to deal with received responses
 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)
          Process the SrdiMessage message, returns true if the message was processed properly
 void pushEntries(boolean all)
          Pushe SRDI entries.
 boolean register(InputPipe ip)
          Register that this peer is an InputPipe for the specified Pipe ID.
(package private)  PipeResolver.Listener removeListener(ID pipeID, int queryID)
          Remove a pipe resolver listener
(package private)  int sendPipeQuery(PipeAdvertisement adv, Set<? extends ID> 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

currentCredential

PipeResolver.CurrentCredential currentCredential
The current Membership service default credential.


membershipCredListener

final net.jxta.impl.pipe.PipeResolver.CredentialListener membershipCredListener
Constructor Detail

PipeResolver

PipeResolver(PeerGroup peerGroup)
Constructor for the PipeResolver object

Parameters:
peerGroup - 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)
Process the resolver query, and generate response it is the responsibility of the handler to send the response

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

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

processQuery

public int processQuery(ResolverQueryMsg query,
                        EndpointAddress srcAddr)
Process the resolver query, and generate response it is the responsibility 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
srcAddr - source address
Returns:
int status, OK success, Repropagate to indicate a re-propagation is needed

processResponse

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

Specified by:
processResponse in interface QueryHandler
Parameters:
response - ResolverQueryMsg response

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 response
srcAddr - source address

processSrdi

public boolean processSrdi(ResolverSrdiMsg message)
Process the SrdiMessage message, returns true if the message was processed properly

Specified by:
processSrdi in interface SrdiHandler
Parameters:
message - Description of the Parameter
Returns:
true if the message was processed properly

messageSendFailed

public void messageSendFailed(PeerID peerid,
                              OutgoingMessageEvent e)
Resolver calls this method when a failure to send a message to specified peer occurs

Specified by:
messageSendFailed in interface SrdiHandler
Parameters:
peerid - peerid failure occured on

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 InputPipe to be registered.
Returns:
If true then the pipe was registered, otherwise false.

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
Parameters:
pipe - The InputPipe to be forgotten.
Returns:
true if the pipe was removed otherwise false.

addListener

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

Parameters:
listener - listener
queryID - The query this callback is being made in response to.
pipeID - The pipe which is the subject of the event.
Returns:
true if sucessfully added

callListener

void callListener(int qid,
                  ID 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.
NAK - indicate whether the event is a nack

removeListener

PipeResolver.Listener removeListener(ID 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<? extends ID> 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()


JXSE