close Warning: Can't use blame annotator:
No changeset 10583 in the repository

source: source/services/ariba_dht/messages/DhtMessage.h@ 12749

Last change on this file since 12749 was 12060, checked in by hock@…, 11 years ago

Reintegrate branch: 20130111-hock-message_classes

improvements:

  • new message classes (reboost, zero-copy)
  • "fast path" for direct links (skip overlay layer)
  • link-properties accessible from the application
  • SystemQueue can call boost::bind functions
  • protlib compatibility removed (32bit overhead saved in every message)
  • addressing2
  • AddressDiscovery discoveres only addresses on which we're actually listening
  • ariba serialization usage reduced (sill used in OverlayMsg)
  • Node::connect, easier and cleaner interface to start-up ariba from the application
  • ariba configs via JSON, XML, etc (boost::property_tree)
  • keep-alive overhead greatly reduced
  • (relayed) overlay links can actually be closed now
  • lost messages are detected in most cases
  • notification to the application when link is transformed into direct-link
  • overlay routing: send message to second best hop if it would be dropped otherwise
  • SequenceNumbers (only mechanisms, so for: upward compatibility)
  • various small fixes


regressions:

  • bluetooth is not yet working again
  • bootstrap modules deactivated
  • liblog4xx is not working (use cout-logging)

This patch brings great performance and stability improvements at cost of backward compatibility.
Also bluetooth and the bootstrap modules have not been ported to the new interfaces, yet.

File size: 2.6 KB
RevLine 
1#ifndef DHTMESSAGE_H_
2#define DHTMESSAGE_H_
3
4#include "ariba/utility/messages.h"
5#include "ariba/utility/types/NodeID.h"
6#include "ariba/utility/serialization.h"
7#include "ariba/Name.h"
8
9namespace ariba_service {
10namespace dht {
11
12using ariba::utility::Message;
13using ariba::utility::NodeID;
14using_serialization;
15
16class DhtMessage : public Message { VSERIALIZEABLE
17public:
18 typedef enum {
19 DhtInvalid = 0,
20 DhtGet = 1,
21 DhtPut = 2,
22 DhtPutAndGet = 3,
23 DhtRemove = 4,
24 DhtRepublish = 5,
25 DhtAnswer = 8,
26 DhtReplica = 9
27 } DhtMessageType;
28
29 DhtMessage();
30 DhtMessage( DhtMessageType type, const std::string& key, const NodeID& sourceNodeID = NodeID::UNSPECIFIED);
31 DhtMessage( DhtMessageType type, const std::string& key,
32 const std::string& value, uint16_t ttl = 0, const NodeID& sourceNodeID = NodeID::UNSPECIFIED );
33
34 DhtMessage( DhtMessageType type, const std::string& key,
35 const vector<std::string>& values, uint16_t ttl = 0, const NodeID& sourceNodeID = NodeID::UNSPECIFIED );
36
37 virtual ~DhtMessage();
38
39 DhtMessageType getType() const {
40 return static_cast<DhtMessageType>(type);
41 }
42
43 NodeID getHashedKey() const {
44 return ariba::Name(key).toNodeId();
45 }
46
47 const std::string& getKey() const {
48 return key;
49 }
50
51 /// returns the first element of the key vector
52 const std::string& getValue() const {
53 return values.at(0);
54 }
55
56 /// return all values for the key
57 const vector<std::string>& getValues() const {
58 return values;
59 }
60
61 /// return all values for the key
62 vector<std::string>& getValues() {
63 return values;
64 }
65
66 bool hasValues() const {
67 return values.size() != 0;
68 }
69
70 uint16_t getTTL() const {
71 return ttl;
72 }
73
74 void setTTL( uint16_t ttl ) {
75 this->ttl = ttl;
76 }
77
78 void setReplace( bool replace ) {
79 this->replace = replace;
80 }
81
82 NodeID getSourceNode() const {
83 return sourceNode;
84 }
85
86 bool doReplace() const {
87 return replace;
88 }
89
90 static string DhtMessageTypeToString(DhtMessageType type);
91
92protected:
93 uint8_t type;
94 uint16_t ttl;
95 bool replace;
96 std::string key;
97 vector<std::string> values;
98 NodeID sourceNode;
99
100private:
101};
102
103}} // namespace ariba_service::dht
104
105sznBeginDefault( ariba_service::dht::DhtMessage, X ) {
106 X && type;
107
108 // serialize tll
109 X && ttl;
110
111 // key serialization
112 X && T(key);
113
114 X && &sourceNode;
115
116 // store number of values
117 uint16_t num_values = values.size();
118 X && num_values;
119
120 // value serialization
121 for (size_t i=0; i<num_values; i++) {
122 if (X.isSerializer()) {
123 X && T(values[i]);
124 }
125
126 if (X.isDeserializer()) {
127 std::string value;
128 X && T(value);
129 values.push_back(value);
130 }
131 }
132} sznEnd();
133
134#endif /* DHTMESSAGE_H_ */
Note: See TracBrowser for help on using the repository browser.