- Timestamp:
- Nov 5, 2009, 10:18:18 AM (15 years ago)
- Location:
- source/ariba/overlay
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/BaseOverlay.cpp
r6832 r6835 2108 2108 switch (msg->getType()) { 2109 2109 case OverlayMsg::typeDHTPut: { 2110 if (dhtMsg->doReplace()) dht->remove(dhtMsg->getKey()); 2110 2111 BOOST_FOREACH( Data value, dhtMsg->getValues() ) 2111 2112 dht->put(dhtMsg->getKey(), value, dhtMsg->getTTL() ); … … 2145 2146 2146 2147 /// put a value to the DHT with a ttl given in seconds 2147 void BaseOverlay::dhtPut( const Data& key, const Data& value, int ttl ) {2148 void BaseOverlay::dhtPut( const Data& key, const Data& value, int ttl, bool replace ) { 2148 2149 2149 2150 logging_info("DHT: putting key=" << key 2150 2151 << " value=" << value 2151 2152 << " ttl=" << ttl 2153 << " replace=" << replace 2152 2154 ); 2153 2155 2156 2154 2157 // put into local data store (for refreshes) 2155 localDHT->put(key,value,ttl); 2158 if (replace) localDHT->remove(key); 2159 localDHT->put(key, value, ttl); 2156 2160 2157 2161 // calculate hash 2158 2162 NodeID dest = NodeID::sha1(key.getBuffer(), key.getLength() / 8); 2159 2163 DHTMessage dhtmsg(key,value); 2164 dhtmsg.setReplace(replace); 2160 2165 dhtmsg.setTTL(ttl); 2161 2166 -
source/ariba/overlay/BaseOverlay.h
r6822 r6835 279 279 280 280 /// put a value to the DHT with a ttl given in seconds 281 void dhtPut( const Data& key, const Data& value, int ttl = 0 );281 void dhtPut( const Data& key, const Data& value, int ttl = 0, bool replace = false); 282 282 283 283 /// removes a key value pair from the DHT -
source/ariba/overlay/messages/DHTMessage.cpp
r6796 r6835 11 11 this->key.setLength(0); 12 12 this->ttl =0 ; 13 this->replace = false; 13 14 } 14 15 … … 18 19 this->key = key.clone(); 19 20 this->ttl =0 ; 21 this->replace = false; 20 22 } 21 23 … … 26 28 this->values.push_back( value.clone() ); 27 29 this->ttl =0 ; 30 this->replace = false; 28 31 } 29 32 … … 32 35 BOOST_FOREACH(const Data value, values ) 33 36 this->values.push_back( value.clone() ); 37 this->replace = false; 34 38 } 35 39 -
source/ariba/overlay/messages/DHTMessage.h
r6796 r6835 44 44 } 45 45 46 void setReplace( bool replace ) { 47 this->replace = replace; 48 } 49 50 bool doReplace() const { 51 return replace; 52 } 53 46 54 /// return alles values for the key 47 55 const vector<Data>& getValues() const { … … 52 60 NodeID hash; 53 61 uint16_t ttl; 62 bool replace; 54 63 Data key; 55 64 vector<Data> values; … … 60 69 sznBeginDefault( ariba::overlay::DHTMessage, X ) { 61 70 71 // serialize flags 72 X && replace && cI(0,7); 73 74 // serialize tll 62 75 X && ttl; 63 76
Note:
See TracChangeset
for help on using the changeset viewer.