Changeset 5838 for source/ariba/overlay/OverlayBootstrap.cpp
- Timestamp:
- Aug 11, 2009, 8:39:47 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/OverlayBootstrap.cpp
r5412 r5838 50 50 spovnetid( SpoVNetID::UNSPECIFIED ), 51 51 nodeid( NodeID::UNSPECIFIED ), 52 overlay( NULL ){ 52 overlay( NULL ), 53 watchtimer(this) { 54 55 srand(time(NULL)); 53 56 } 54 57 … … 66 69 manager.registerModule( BootstrapManager::BootstrapTypePeriodicBroadcast ); 67 70 manager.registerModule( BootstrapManager::BootstrapTypeBluetoothSdp ); 71 72 watchtimer.startWatchdog(); 68 73 } 69 74 … … 78 83 manager.unregisterModule( BootstrapManager::BootstrapTypePeriodicBroadcast ); 79 84 manager.unregisterModule( BootstrapManager::BootstrapTypeBluetoothSdp ); 85 86 watchtimer.stopWatchdog(); 80 87 } 81 88 … … 144 151 } 145 152 153 void OverlayBootstrap::recordJoin(const EndpointDescriptor& _ep){ 154 boost::mutex::scoped_lock lock(lastJoinesMutex); 155 156 EventData data; 157 data.spovnetid = spovnetid; 158 data.nodeid = nodeid; 159 data.endpoint = _ep; 160 161 lastJoines.push_front(JoinData(data)); 162 } 163 164 void OverlayBootstrap::checkOverlayStatus(){ 165 166 // if we have no overlay neighbors, try to bootstrap using 167 // bootstrap information that we already used 168 169 { //limit history to 10 endpoints 170 boost::mutex::scoped_lock lock(lastJoinesMutex); 171 while(lastJoines.size() > 10) 172 lastJoines.pop_back(); 173 } 174 175 // we have overlay neighbors -> ok 176 if(overlay->getOverlayNeighbors().size() > 0) return; 177 178 // no overlay neighbors -> try out already 179 // successfully used bootstrap nodes 180 JoinData data; 181 { 182 boost::mutex::scoped_lock lock(lastJoinesMutex); 183 JoinStack::iterator i = lastJoines.begin(); 184 if(i == lastJoines.end()) return; 185 186 // use last used element and then put it into back 187 JoinData data = *i; 188 lastJoines.pop_front(); 189 lastJoines.push_back(data); 190 } 191 192 logging_info("no overlay connections detected, " << 193 "trying to join using old bootstrap information"); 194 195 // try to join using this node, if the join is successfull 196 // the endpoint will again be inserted using recordJoin 197 overlay->joinSpoVNet( spovnetid, data.data.endpoint ); 198 } 199 200 OverlayBootstrap::WatchdogTimer::WatchdogTimer(OverlayBootstrap* _obj) : obj(_obj) { 201 } 202 203 void OverlayBootstrap::WatchdogTimer::startWatchdog(){ 204 Timer::setInterval(2000); 205 Timer::start(); 206 } 207 208 void OverlayBootstrap::WatchdogTimer::stopWatchdog(){ 209 Timer::stop(); 210 } 211 212 void OverlayBootstrap::WatchdogTimer::eventFunction(){ 213 if(obj == NULL) return; 214 obj->checkOverlayStatus(); 215 } 216 146 217 }} // namespace ariba, overlay
Note:
See TracChangeset
for help on using the changeset viewer.