planet.test.broadcast
Class DHTApplication

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

public class DHTApplication
extends java.lang.Object
implements Application

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)
          Sets a new 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)
          Makes a new instance of a Message to be sent with the specified data.
 void send(java.lang.String textKey, DHTPeerTestMessage mess)
          Owner DHTApplication method which permits to send a broadcast Message.
 void setEndPoint(EndPoint ep)
          Sets the underlying EndPoint of this application.
 void setId(java.lang.String appId)
          Sets the String identification of this application.
 Application setValues(java.lang.String applicationName)
          Sets the name for this applicaton.
 java.lang.String toString()
          Shows a String representation of the actual 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, 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)
Sets a new application id.

Parameters:
name - New application id.
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)
Makes a new instance of a Message to be sent with the specified data.

Parameters:
data - Data to be sent.
Returns:
A new Message to be sent.

setEndPoint

public void setEndPoint(EndPoint ep)
Sets the underlying EndPoint of this application.

Specified by:
setEndPoint in interface Application
Parameters:
ep - Underlying EndPoint to be used in Message comunication.

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

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 String identification of this application.

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

send

public void send(java.lang.String textKey,
                 DHTPeerTestMessage mess)
Owner DHTApplication method which permits to send a broadcast Message.

Parameters:
textKey - Text to be used as material for construct Message Id.
mess - Message to be send with broadcast.

toString

public java.lang.String toString()
Shows a String representation of the actual Application.

Returns:
String representation of this Application with its ApplicationId and its EndPoint reference.
See Also:
Object.toString()

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.