Changeset 6797 for source/ariba/overlay
- Timestamp:
- Nov 2, 2009, 11:06:46 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/BaseOverlay.cpp
r6796 r6797 125 125 return vect; 126 126 } 127 128 void erase_expired_entries() { 129 for (vector<ValueEntry>::iterator i = values.begin(); 130 i != values.end(); i++ ) 131 if (i->is_ttl_elapsed()) i = values.erase(i); 132 } 127 133 }; 128 134 … … 132 138 typedef vector<ValueEntry> Values; 133 139 Entries entries; 140 static const bool verbose = true; 134 141 135 142 static bool equals( const Data& lhs, const Data& rhs ) { … … 154 161 if ( equals(entry.values[j].get_value(), value) ) { 155 162 entry.values[j].refresh(); 156 std::cout << "DHT: Republished value. Refreshing TTL." 163 if (verbose) 164 std::cout << "DHT: Republished value. Refreshing value timestamp." 157 165 << std::endl; 158 166 return; … … 161 169 162 170 // new value-> add to entry 163 std::cout << "DHT: Added value to " 171 if (verbose) 172 std::cout << "DHT: Added value to " 164 173 << " key=" << key << " with value=" << value << std::endl; 165 174 entry.values.push_back( ValueEntry( value ) ); … … 170 179 171 180 // key is unknown-> add key value pair 172 std::cout << "DHT: New key value pair " 181 if (verbose) 182 std::cout << "DHT: New key value pair " 173 183 << " key=" << key << " with value=" << value << std::endl; 174 184 … … 1907 1917 /// stabilize DHT state 1908 1918 void BaseOverlay::stabilizeDHT() { 1909 1919 // remove old values from DHT 1920 BOOST_FOREACH( DHTEntry& entry, dht->entries ) { 1921 // erase old entries 1922 entry.erase_expired_entries(); 1923 } 1924 1925 // re-publish values 1926 BOOST_FOREACH( DHTEntry& entry, localDHT->entries ) { 1927 // erase old entries 1928 entry.erase_expired_entries(); 1929 1930 // re-publish values 1931 BOOST_FOREACH( ValueEntry& value, entry.values ) 1932 dhtPut(entry.key, value.get_value(), 0 ); 1933 } 1910 1934 } 1911 1935
Note:
See TracChangeset
for help on using the changeset viewer.