| 207 | } |
| 208 | |
| 209 | Monitor::MonitorTask::RepoKey |
| 210 | Monitor::MonitorTask::setRepoIor( const std::string& ior) |
| 211 | { |
| 212 | RepoKey key; |
| 213 | |
| 214 | if( this->options_.verbose()) { |
| 215 | ACE_DEBUG((LM_DEBUG, |
| 216 | ACE_TEXT("(%P|%t) MonitorTask::setRepoIor() - ") |
| 217 | ACE_TEXT("setting active repository to: %C.\n"), |
| 218 | ior.c_str() |
| 219 | )); |
| 220 | } |
| 221 | |
| 222 | { |
| 223 | ACE_GUARD_RETURN(ACE_SYNCH_MUTEX, guard, lock_, DEFAULT_REPO); |
| 224 | |
| 225 | IorKeyMap::iterator location = this->iorKeyMap_.find( ior); |
| 226 | if( location != this->iorKeyMap_.end()) { |
| 227 | // We already have this IOR mapped, use the existing key. |
| 228 | key = location->second; |
| 229 | // In case the same repo restart again, need resolve the |
| 230 | // repo object reference again. |
| 231 | TheServiceParticipant->set_repo_ior( ior.c_str(), key, false); |
| 232 | |
| 233 | } else { |
| 234 | // We need to find an open key to use. Check the actual |
| 235 | // Service_Participant mappings for a slot. |
| 236 | OpenDDS::DCPS::Service_Participant::RepoKeyDiscoveryMap::const_iterator |
| 237 | keyLocation; |
| 238 | do { |
| 239 | key = stringify(++this->lastKey_); |
| 240 | keyLocation = TheServiceParticipant->discoveryMap().find( key); |
| 241 | } while( keyLocation != TheServiceParticipant->discoveryMap().end()); |
| 242 | |
| 243 | // We have a new repository to install, go ahead. |
| 244 | TheServiceParticipant->set_repo_ior( ior.c_str(), key, false); |
| 245 | |
| 246 | // Check that we were able to resolve and attach to the repository. |
| 247 | keyLocation = TheServiceParticipant->discoveryMap().find( key); |
| 248 | if( keyLocation == TheServiceParticipant->discoveryMap().end()) { |
| 249 | // We failed to install this IOR, nothing left to do. |
| 250 | return DEFAULT_REPO; |
| 251 | } |
| 252 | |
| 253 | // Store the reverse mapping for our use. |
| 254 | this->iorKeyMap_[ ior] = key; |
| 255 | } |
| 256 | } // End of lock scope. |
| 257 | |
| 258 | // Shutdown current processing. This has the effect of removing the |
| 259 | // existing participant. |
| 260 | // N.B. The current participant needs to be removed before remapping |
| 261 | // the domain since it would be attached to the new repository, |
| 262 | // which does not work unless federated. This needs to work in |
| 263 | // the case of non-federated repositories. |
| 264 | this->stopInstrumentation(); |
| 265 | |
| 266 | return key; |
no test coverage detected