${header}

meteor.dht.can
Class MessageHandler

java.lang.Object
  extended bymeteor.dht.can.MessageHandler
All Implemented Interfaces:
net.jxta.resolver.QueryHandler

public class MessageHandler
extends java.lang.Object
implements net.jxta.resolver.QueryHandler

This class is responsible of handling messages between peers It implements the QueryHandler class for processQuery and processResponse methods.

Author:
Vincent Matossian December 2004

Field Summary
static boolean QUEUEING
           
 
Constructor Summary
MessageHandler(CANServiceImpl l)
           
 
Method Summary
 Zone deserialize(java.lang.String sz)
          Deserialize a Zone object
 int getNextQID()
          Generates a query ID for the resolver service
 int processQuery(net.jxta.protocol.ResolverQueryMsg query)
          Implementing QueryHandler Resolves the queries between peers to find successor or predecessor nodes, or simply notifying a node through the Notification protocol
 void processResponse(net.jxta.protocol.ResolverResponseMsg response)
          Process a Resolver response message.
 int sendQuery(java.lang.String destination, QueryMessage queryMsg)
          Send a query to a specific peer, by building a QueryMessage and using the resolver service to actually send the message
 java.lang.String serialize(Zone z)
          Serialize a Zone object
 void setNeighbourTable(NeighbourTable n)
          Setting a pointer to the neighbour table instantiated in the DHTServiceImpl when it has received an overlay ID
 void setResolver(net.jxta.resolver.ResolverService r)
          DHTservice implementation registers a handler for the resolver being this MessageHandler, it then points MessageHandler to that new resolver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QUEUEING

public static boolean QUEUEING
Constructor Detail

MessageHandler

public MessageHandler(CANServiceImpl l)
Parameters:
l - is the DHTServiceImplementation associated to this MessageHandler
Method Detail

setResolver

public void setResolver(net.jxta.resolver.ResolverService r)
DHTservice implementation registers a handler for the resolver being this MessageHandler, it then points MessageHandler to that new resolver. The reason why the resolver is not loaded from the peergroup is because 1) the Shell command registers interest with the MeteorPeer. 2) For compact design, the MeteorPeer only has a handle to DHTService 3) Only DHTService knows of MessageHandler and registers Listeners. Since we want the shell commands to be notified of events happening in MessageHandler, it has to register with a unique resolver


sendQuery

public int sendQuery(java.lang.String destination,
                     QueryMessage queryMsg)
Send a query to a specific peer, by building a QueryMessage and using the resolver service to actually send the message


getNextQID

public int getNextQID()
Generates a query ID for the resolver service


setNeighbourTable

public void setNeighbourTable(NeighbourTable n)
Setting a pointer to the neighbour table instantiated in the DHTServiceImpl when it has received an overlay ID


processQuery

public int processQuery(net.jxta.protocol.ResolverQueryMsg query)
Implementing QueryHandler Resolves the queries between peers to find successor or predecessor nodes, or simply notifying a node through the Notification protocol

Specified by:
processQuery in interface net.jxta.resolver.QueryHandler

processResponse

public void processResponse(net.jxta.protocol.ResolverResponseMsg response)
Process a Resolver response message. Handling the 3 possible types of queries find_successor raises a receivedSuccessor predecessor raises a receivedPredecessor

Specified by:
processResponse in interface net.jxta.resolver.QueryHandler
Parameters:
response - a response message to be processed.

serialize

public java.lang.String serialize(Zone z)
Serialize a Zone object


deserialize

public Zone deserialize(java.lang.String sz)
Deserialize a Zone object


${header}