Package org.catnets.p2pagent.apiSamples.Echoes

Echoes Sample Application

See:
          Description

Class Summary
EchoClient This class implements a simple requestor that executes a serie of request to a EchoServer and registers the time to completation of each request, computing an average at the end of this serie.
EchoesMainApp Main application that initiates the EchoServer and EchoServer agents passing the appropiate parameters.
EchoServer Receives a message and replies to the originator with the same message, after waiting for a random time, wich simulates the server's response time.
 

Package org.catnets.p2pagent.apiSamples.Echoes Description

Echoes Sample Application

Author: Pablo Chacin

Version. 1.0

Created: Feb 23, 2006

(c) Technical University of Catalonya 2006

Overview

This sample application presents a simple, yet very complete example of the main functionalities provided by the P2pAgents API, a fundamental part of the Grid Market Middleware.

The application shows two agents, EchoesServer and EchoesClient, which engage in a multiple communications of the type send/reply to implement a sort of "ping" command, as provided for TCPIP in most platforms. Along this process, the EchoesClient determines the average response time of the sever.

Throught this example we can show how the following functionalities are implemented:

Components

Executing the application

The Echoes application components are contained in the EchoesSample project. This project contains the following directories:
Also in the project's root directory there is a configuration file HostingConfig.properties.

In Eclipse

  1. Import the Echoes project
  2. run the class EchoesMainApp, passing the following command line parameters:
    config.node EchoClient config.port 8051 config.workdirectory ./Echoes

Execution Results

After executing the application a trace should be shown in the console. This trace can also be seen in the file log.txt in the project's root directory. The trace should look as follows:

Timestamp: 1140713385943
Severity: INFO
AgentName: EchoServer
ClassName: Server
Method: handleEvent
Message: Event expired

Timestamp: 1140713385944
Severity: INFO
AgentName: EchoClient
ClassName: EchoRequestor
Method: Request completation
Message: Request execution time 1875

Timestamp: 1140713385944
Severity: INFO
AgentName: EchoClient
ClassName: EchoRequestor
Method: makeRequest
Message: Making request number: 3

Also, in the project's root directory there should be a file named ResponseTime.txt with a series of rows, each with the response time of each echo request sent by the client to the server. This file should look as follows:

1140714229886,EchoClient,ResponseTime,1565
1140714231382,EchoClient,ResponseTime,1495
1140714233083,EchoClient,ResponseTime,1701
1140714234642,EchoClient,ResponseTime,1559