planet.test.helloworld
Class DHTApplication

java.lang.Object
  extended byplanet.test.helloworld.DHTApplication
All Implemented Interfaces:
Application, java.io.Serializable

public class DHTApplication
extends java.lang.Object
implements Application

This application only make two tasks: send a "Hello World" message and receive it.

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

Field Summary
static java.lang.String applicationId
          Identification of the application.
 
Constructor Summary
DHTApplication()
          Constructor
DHTApplication(java.lang.String name)
          Builds a new application with the specified name as application id.
 
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 getId()
          Gets the identification of the Application
 Message makeTestMessage(java.lang.String data)
          Build a new DHTPeerTestMessage with the specified data.
 void send(java.lang.String textKey, DHTPeerTestMessage mess)
          This method permits to send a message with the specified key textKey
 void setEndPoint(EndPoint ep)
          Sets the underlying EndPoint for interact with the Node, for sending and receiving messages.
 void setId(java.lang.String appId)
          Sets the identification of the Application
 Application setValues(java.lang.String applicationName)
          Sets the name for this applicaton.
 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

applicationId

public static java.lang.String applicationId
Identification of the application.

Constructor Detail

DHTApplication

public DHTApplication()
Constructor


DHTApplication

public DHTApplication(java.lang.String name)
Builds a new application with the specified name as application id.

Parameters:
name - New name of the 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

makeTestMessage

public Message makeTestMessage(java.lang.String data)
Build a new DHTPeerTestMessage with the specified data.

Parameters:
data - Data to be sent with the new message.
Returns:
New generated Message with the data.

setEndPoint

public void setEndPoint(EndPoint ep)
Sets the underlying EndPoint for interact with the Node, for sending and receiving messages.

Specified by:
setEndPoint in interface Application
Parameters:
ep - EndPoint to interact.

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 - Application Message to test if is forwarding or not.
Returns:
Whether or not to forward the message further. Always true.

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

getId

public java.lang.String getId()
Gets the identification of the 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 the Application

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

send

public void send(java.lang.String textKey,
                 DHTPeerTestMessage mess)
This method permits to send a message with the specified key textKey

Parameters:
textKey - The String to use as key of the message.
mess - Message to be sent.

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)

setValues

public Application setValues(java.lang.String applicationName)
Sets the name for this applicaton.

Specified by:
setValues in interface Application
Parameters:
applicationName - Name for this application.
Returns:
The same instance, once it has been updated.