planet.test.symphonyDHT
Class SymphonyDHTApplication

java.lang.Object
  extended byplanet.test.symphonyDHT.SymphonyDHTApplication
All Implemented Interfaces:
Application, java.io.Serializable

public class SymphonyDHTApplication
extends java.lang.Object
implements Application

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

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

Field Summary
static java.lang.String APPLICATION_ID
           
 
Constructor Summary
SymphonyDHTApplication()
          Constructor
SymphonyDHTApplication(java.lang.String name)
          Simple constructor where is specified the application identification.
 
Method Summary
 void byStep()
          An upcall to inform this Application for a new step.
 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 insert(java.lang.String key, java.lang.String value)
          Owner SymphonyDHTApplication method which permits to send a Message with a key/value pair, for INSERT.
 void lookup(java.lang.String key)
          Owner SymphonyDHTApplication method which permits to send a Message with a key/value pair, for LOOKUP.
 void retrieve(SymphonyDHTMessage msg)
          This method retrieves value from a key from the dsitributed repository build on top of Symphony Lookup protocol.
 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 store(SymphonyDHTMessage msg)
          This method stores key/value pair on the distributed repository of DHT application.
 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

SymphonyDHTApplication

public SymphonyDHTApplication()
Constructor


SymphonyDHTApplication

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

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

byStep

public void byStep()
An upcall to inform this Application for a new step. This method is invoked at the end of each simulation step. Before this, may arrive any number of application Messages, depending on your own main application.

Specified by:
byStep in interface Application

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

store

public void store(SymphonyDHTMessage msg)
This method stores key/value pair on the distributed repository of DHT application.

Parameters:
msg - The message exchanged between applications.

retrieve

public void retrieve(SymphonyDHTMessage msg)
This method retrieves value from a key from the dsitributed repository build on top of Symphony Lookup protocol.

Parameters:
msg - The message exchanged between applications.

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)

insert

public void insert(java.lang.String key,
                   java.lang.String value)
Owner SymphonyDHTApplication 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.

lookup

public void lookup(java.lang.String key)
Owner SymphonyDHTApplication 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:
Application.update(planet.commonapi.NodeHandle, boolean)