source: source/services/ariba_dht/messages/DhtMessage.cpp@ 12756

Last change on this file since 12756 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: 1.8 KB
Line 
1#include "DhtMessage.h"
2
3#include<boost/foreach.hpp>
4
5namespace ariba_service {
6namespace dht {
7
8vsznDefault(DhtMessage);
9
10DhtMessage::DhtMessage() :
11 ttl( 0 ),
12 replace( false ),
13 sourceNode(NodeID::UNSPECIFIED)
14{}
15
16DhtMessage::DhtMessage( DhtMessageType type, const std::string& key, const NodeID& sourceNodeID ) :
17 type( static_cast<uint8_t>(type) ),
18 ttl( 0 ),
19 replace( false ),
20 key( key ),
21 sourceNode(sourceNodeID)
22
23{}
24
25DhtMessage::DhtMessage( DhtMessageType type, const std::string& key,
26 const std::string& value, uint16_t ttl, const NodeID& sourceNodeID ) :
27 type( static_cast<uint8_t>(type) ),
28 ttl( ttl ),
29 replace( false ),
30 key( key ),
31 values(1, value),
32 sourceNode(sourceNodeID)
33{}
34
35DhtMessage::DhtMessage( DhtMessageType type, const std::string& key,
36 const vector<string>& values, uint16_t ttl, const NodeID& sourceNodeID ) :
37 type( static_cast<uint8_t>(type) ),
38 ttl( ttl ),
39 replace( false ),
40 key( key ),
41 sourceNode(sourceNodeID)
42{
43 // preallocate enough room so we don't need to copy a lot
44 this->values.reserve(values.size());
45 BOOST_FOREACH(const std::string value, values )
46 this->values.push_back( value );
47}
48
49DhtMessage::~DhtMessage() {
50 // empty
51}
52
53string DhtMessage::DhtMessageTypeToString(DhtMessageType type) {
54 string temp;
55 switch (type)
56 {
57 case DhtMessage::DhtInvalid:
58 {
59 temp = "DhtInvalid";
60 break;
61 }
62
63 case DhtMessage::DhtGet:
64 {
65 temp = "DhtGet";
66 break;
67 }
68
69 case DhtMessage::DhtPut:
70 {
71 temp = "DhtPut";
72 break;
73 }
74
75 case DhtMessage::DhtPutAndGet:
76 {
77 temp = "DhtPutAndGet";
78 break;
79 }
80
81 case DhtMessage::DhtRemove:
82 {
83 temp = "DhtRemove";
84 break;
85 }
86
87 case DhtMessage::DhtRepublish:
88 {
89 temp = "DhtRepublish";
90 break;
91 }
92
93 case DhtMessage::DhtAnswer:
94 {
95 temp = "DhtAnswer";
96 break;
97 }
98
99 case DhtMessage::DhtReplica:
100 {
101 temp = "DhtReplica";
102 break;
103 }
104 }
105
106 return temp;
107}
108
109}}
Note: See TracBrowser for help on using the repository browser.