org.planx.xmlstore.routing.operation
Class NodeLookupOperation

java.lang.Object
  extended by org.planx.xmlstore.routing.operation.Operation
      extended by org.planx.xmlstore.routing.operation.NodeLookupOperation
All Implemented Interfaces:
Receiver
Direct Known Subclasses:
DataLookupOperation

public class NodeLookupOperation
extends Operation
implements Receiver

Finds the K closest nodes to a specified identifier. The algorithm terminates when the operation has gotten responses from the K closest nodes it has seen. Nodes that fail to respond are removed from consideration.

Author:
Thomas Ambus

Field Summary
protected  Configuration conf
           
protected  boolean error
           
protected  Identifier id
           
protected  Node local
           
protected  LookupMessage lookupMessage
          Message sent to each peer.
protected  MessageServer server
           
protected  Space space
           
 
Constructor Summary
NodeLookupOperation(Configuration conf, MessageServer server, Space space, Node local, Identifier id)
          Create a NodeLookupOperation for the specified id.
 
Method Summary
 Object execute()
          Starts the operation and returns when the operation is finished.
 void receive(Message incoming, int comm)
          Receives an incoming NodeReplyMessage.
 void timeout(int comm)
          A node does not respond or a packet was lost.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

conf

protected Configuration conf

server

protected MessageServer server

space

protected Space space

local

protected Node local

id

protected Identifier id

error

protected boolean error

lookupMessage

protected LookupMessage lookupMessage
Message sent to each peer. Subclasses could change this field to send other kinds of lookup messages.

Constructor Detail

NodeLookupOperation

public NodeLookupOperation(Configuration conf,
                           MessageServer server,
                           Space space,
                           Node local,
                           Identifier id)
Create a NodeLookupOperation for the specified id.

Method Detail

execute

public Object execute()
               throws IOException,
                      RoutingException
Description copied from class: Operation
Starts the operation and returns when the operation is finished.

Specified by:
execute in class Operation
Returns:
A List containing the K closest nodes to the id provided in the constructor.
Throws:
RoutingException - If the lookup operation timed out
IOException - If a network error occurred

receive

public void receive(Message incoming,
                    int comm)
             throws IOException
Receives an incoming NodeReplyMessage.

Specified by:
receive in interface Receiver
Throws:
IOException - if an I/O error occurs

timeout

public void timeout(int comm)
             throws IOException
A node does not respond or a packet was lost.

Specified by:
timeout in interface Receiver
Throws:
IOException - if an I/O error occurs


Copyright © 2010. All Rights Reserved.