planet.test.trivialp2ptest
Class TrivialApplication

java.lang.Object
  extended byplanet.test.trivialp2ptest.TrivialApplication
All Implemented Interfaces:
Application, java.io.Serializable

public class TrivialApplication
extends java.lang.Object
implements Application

This simple application makes only a one way sending message.

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
TrivialApplication()
          Constructor
TrivialApplication(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.
 void find(Id key)
          This method permits to send a message with the specified key key
 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(Id data)
          Build a new TrivialMessage with the specified data.
 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

TrivialApplication

public TrivialApplication()
Constructor


TrivialApplication

public TrivialApplication(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(Id data)
Build a new TrivialMessage with the specified data.

Parameters:
data - The key to be found.
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)

find

public void find(Id key)
This method permits to send a message with the specified key key

Parameters:
key - The key to be found.

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.