source: sample/testdht/DHTTest.h@ 6760

Last change on this file since 6760 was 6760, checked in by mies, 14 years ago

added dht test case

File size: 1.9 KB
Line 
1#ifndef __PINGPONG_H_
2#define __PINGPONG_H_
3
4#include "ariba/ariba.h"
5#include "ariba/utility/system/StartupInterface.h"
6#include "ariba/utility/system/Timer.h"
7
8#include <vector>
9
10using namespace ariba;
11using ariba::utility::StartupInterface;
12using ariba::utility::Timer;
13
14namespace ariba {
15namespace application {
16namespace dhttest {
17
18using namespace std;
19
20/*
21 * DHTTest main class
22 */
23class DHTTest: public NodeListener,
24 public CommunicationListener,
25 public StartupInterface,
26 public Timer {
27
28 use_logging_h(DHTTest);
29
30public:
31 DHTTest();
32 virtual ~DHTTest();
33
34protected:
35 // communication listener interface
36 virtual bool onLinkRequest(const NodeID& remote, const DataMessage& msg =
37 DataMessage::UNSPECIFIED);
38 virtual void onLinkUp(const LinkID& lnk, const NodeID& remote);
39 virtual void onLinkDown(const LinkID& lnk, const NodeID& remote);
40 virtual void onLinkChanged(const LinkID& lnk, const NodeID& remote);
41 virtual void onLinkFail(const LinkID& lnk, const NodeID& remote);
42
43 // the dht message handler (for answers to get() requests)
44 virtual void onKeyValue( const Data& key, const vector<Data>& value );
45
46 // node listener interface
47 virtual void onJoinCompleted(const SpoVNetID& vid);
48 virtual void onJoinFailed(const SpoVNetID& vid);
49 virtual void onLeaveCompleted(const SpoVNetID& vid);
50 virtual void onLeaveFailed(const SpoVNetID& vid);
51
52 // startup wrapper interface
53 virtual void startup();
54 virtual void shutdown();
55
56 // timer events
57 virtual void eventFunction();
58
59 // helper functions to convert from string to Data and visa versa
60 Data stod(string s);
61 string dtos(Data d);
62
63private:
64 // the ariba module and a node
65 AribaModule* ariba;
66 Node* node;
67 string name;
68
69 // this is for the specific dht test
70 string key;
71 string data;
72 int counter;
73
74 // the dht test service id
75 static ServiceID DHTTEST_SERVICEID;
76
77};
78
79// needed for simulation support
80ARIBA_SIMULATION_SERVICE(DHTTest);
81
82}}} // namespace ariba, application, pingpong
83
84#endif // __DHTTEST_H_
Note: See TracBrowser for help on using the repository browser.