planet.test.dht
Class ChordDHTApplication

java.lang.Object
  extended byplanet.test.dht.ChordDHTApplication
All Implemented Interfaces:
Application, java.io.Serializable

public class ChordDHTApplication
extends java.lang.Object
implements Application

Application that contains all key/values pairs, required for owner Node Id.

Author:
Carles Pairot , Jordi Pujol
See Also:
Serialized Form

Field Summary
static java.lang.String APPLICATION_ID
           
 
Constructor Summary
ChordDHTApplication()
          Constructor
ChordDHTApplication(java.lang.String name)
          Simple constructor where is specified the application identification.
 
Method Summary
 void deliver(Id id, Message message)
          This method is called on the application at the destination node for the given id.
 boolean forward(Message message)
          This method is invoked on applications when the underlying node is about to forward the given message with the provided target to the specified next hop.
 java.lang.String gatherStatistics()
          Generate a string with a representation of keys and values existing at this application.
 java.lang.String getId()
          Gets the identification of this instance of Application.
 void send(java.lang.String key)
          Owner ChordDHTApplication method which permits to send a Message with a key/value pair, for LOOKUP.
 void send(java.lang.String key, java.lang.String value)
          Owner ChordDHTApplication method which permits to send a Message with a key/value pair, for INSERT.
 void setEndPoint(EndPoint endPoint)
          Sets the actual EndPoint to use to communication with underlying network.
 void setId(java.lang.String appId)
          Sets the identification of this instance of Application.
 void setNode(java.lang.String node)
          Sets the identification of the node over which this instance of application is running.
 void update(NodeHandle node, boolean joined)
          Shows that the node has been joinded or not to the network.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

APPLICATION_ID

public static final java.lang.String APPLICATION_ID
See Also:
Constant Field Values
Constructor Detail

ChordDHTApplication

public ChordDHTApplication()
Constructor


ChordDHTApplication

public ChordDHTApplication(java.lang.String name)
Simple constructor where is specified the application identification.

Parameters:
name - New name to set to this application.
Method Detail

setNode

public void setNode(java.lang.String node)
Sets the identification of the node over which this instance of application is running.

Parameters:
node - Identification of the local node.

forward

public boolean forward(Message message)
This method is invoked on applications when the underlying node is about to forward the given message with the provided target to the specified next hop. Applications can change the contents of the message, specify a different nextHop (through re-routing), or completely terminate the message.

Specified by:
forward in interface Application
Parameters:
message - The message being sent, containing an internal message along with a destination key and nodeHandle next hop.
Returns:
Whether or not to forward the message further

deliver

public void deliver(Id id,
                    Message message)
This method is called on the application at the destination node for the given id.

Specified by:
deliver in interface Application
Parameters:
id - The destination id of the message
message - The message being sent

gatherStatistics

public java.lang.String gatherStatistics()
Generate a string with a representation of keys and values existing at this application.

Returns:
A string representation of keys and values existing at this application.

getId

public java.lang.String getId()
Gets the identification of this instance of Application.

Specified by:
getId in interface Application
Returns:
Identification of this application.
See Also:
Application.getId()

setId

public void setId(java.lang.String appId)
Sets the identification of this instance of Application.

Specified by:
setId in interface Application
Parameters:
appId - New identification of this instance of Application.
See Also:
Application.setId(java.lang.String)

setEndPoint

public void setEndPoint(EndPoint endPoint)
Sets the actual EndPoint to use to communication with underlying network.

Specified by:
setEndPoint in interface Application
Parameters:
endPoint - EndPoint to contact that knows how talk with underlying node.
See Also:
Application.setEndPoint(planet.commonapi.EndPoint)

send

public void send(java.lang.String key,
                 java.lang.String value)
Owner ChordDHTApplication method which permits to send a Message with a key/value pair, for INSERT. IMPORTANT: the key is in hexadecimal format.

Parameters:
key - Text to be used as material for construct Message Id, in hexadecimal format.
value - Related value to that key.

send

public void send(java.lang.String key)
Owner ChordDHTApplication method which permits to send a Message with a key/value pair, for LOOKUP. IMPORTANT: the key is in hexadecimal format.

Parameters:
key - Text to be used as material for construct Message Id, in hexadecimal format.

update

public void update(NodeHandle node,
                   boolean joined)
Shows that the node has been joinded or not to the network.

Specified by:
update in interface Application
Parameters:
node - Node that has been joined or leaved.
joined - If true, the node has been joinded. If false, the node has been leaved to the network.
See Also:
planet.commonapi.Application#update(planet.commonapi.Id, boolean)