${header}

meteor.dht.chord
Class MessageHandler

java.lang.Object
  extended bymeteor.dht.chord.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. At this time the types of Queries are:

find_successor To find the successor of a node id
predecessor To return the predecessor of this current node
notify TO notify the successor of this node that it should set its predecessor to this current node id
ping Checks to see if the peer is alive
set_predecessorWhen initializing finger tables and updating the ring, sets the predecessor
stabilize_othersStabilize peers as a result of detection of a predecessor failing in the ring
process_squid_messageSend the squid querry to the Squid layer for processing
update_finger_tableUpdate the finger table as part of the protocol for a new node joining

Author:
Vincent Matossian December 2003

Field Summary
static boolean QUEUEING
           
 
Constructor Summary
MessageHandler(ChordServiceImpl l)
           
 
Method Summary
 java.math.BigInteger getID()
          !!!ONLY FOR BLOCKING CALLS THe unique identifier exchanged by messages This is the response from a query returning the successor of a node ID.
 int getNextQID()
          Generates a query ID for the resolver service
 java.math.BigInteger getNodeID()
          This call sets the Responding Node ID, used for Predecessor
 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
 void setFingerTable(FingerTable f)
          Setting a pointer to the finger table instantiated in the DHTServiceImpl when it has received a Chord 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(ChordServiceImpl 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 that is therefore set here.


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


getID

public java.math.BigInteger getID()
!!!ONLY FOR BLOCKING CALLS THe unique identifier exchanged by messages This is the response from a query returning the successor of a node ID.


getNodeID

public java.math.BigInteger getNodeID()
This call sets the Responding Node ID, used for Predecessor


setFingerTable

public void setFingerTable(FingerTable f)
Setting a pointer to the finger table instantiated in the DHTServiceImpl when it has received a Chord 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.

${header}