void LiveEntry::add_listener (LiveListener *ll) { ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_); LiveListener_ptr llp(ll->_add_ref()); this->listeners_.insert (llp); }
void LiveEntry::remove_listener (LiveListener *ll) { ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_); LiveListener_ptr llp(ll->_add_ref()); int result = this->listeners_.remove (llp); if (ImR_Locator_i::debug() > 4) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) LiveEntry::remove_listener, result = %d\n"), result)); } }
bool ImR_Locator_i::server_is_alive (UpdateableServerInfo& info) { this->connect_server (info); SyncListener *listener = 0; ACE_NEW_RETURN (listener, SyncListener (info->ping_id(), this->orb_.in(), this->pinger_), false); LiveListener_ptr llp(listener); return listener->is_alive(); }
void AsyncAccessManager::server_is_running (const char *partial_ior, ImplementationRepository::ServerObject_ptr ref) { if (ImR_Locator_i::debug () > 4) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) AsyncAccessManager(%@)::server_is_running\n"), this)); } this->update_status (ImplementationRepository::AAM_WAIT_FOR_ALIVE); this->info_.edit ()->partial_ior = partial_ior; this->info_.edit ()->server = ImplementationRepository::ServerObject::_duplicate (ref); if (this->locator_.pinger().is_alive (this->info_->ping_id()) == LS_ALIVE) { this->status (ImplementationRepository::AAM_SERVER_READY); this->final_state (); } AccessLiveListener *l = 0; if (this->info_->is_mode (ImplementationRepository::PER_CLIENT)) { ACE_NEW (l, AccessLiveListener (this->info_->ping_id(), this, this->locator_.pinger(), this->info_->active_info()->server.in())); } else { ACE_NEW (l, AccessLiveListener (this->info_->ping_id(), this, this->locator_.pinger())); } LiveListener_ptr llp(l); if (!l->start()) { this->status (ImplementationRepository::AAM_SERVER_DEAD); this->final_state (); } }
void QgsGrassNewMapset::loadRegions() { QgsDebugMsg( "entered." ); QString path = QgsApplication::pkgDataPath() + "/grass/locations.gml"; QgsDebugMsg( QString( "load:%1" ).arg( path.toLocal8Bit().constData() ) ); QFile file( path ); if ( !file.exists() ) { QMessageBox::warning( 0, tr( "Warning" ), tr( "Regions file (%1) not found." ).arg( path ) ); return; } if ( ! file.open( QIODevice::ReadOnly ) ) { QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot open locations file (%1)" ).arg( path ) ); return; } QDomDocument doc( "gml:FeatureCollection" ); QString err; int line, column; if ( !doc.setContent( &file, &err, &line, &column ) ) { QString errmsg = tr( "Cannot read locations file (%1):" ).arg( path ) + tr( "\n%1\nat line %2 column %3" ).arg( err ).arg( line ).arg( column ); QgsDebugMsg( errmsg ); QMessageBox::warning( 0, tr( "Warning" ), errmsg ); file.close(); return; } QDomElement docElem = doc.documentElement(); QDomNodeList nodes = docElem.elementsByTagName( "gml:featureMember" ); for ( int i = 0; i < nodes.count(); i++ ) { QDomNode node = nodes.item( i ); if ( node.isNull() ) { continue; } QDomElement elem = node.toElement(); QDomNodeList nameNodes = elem.elementsByTagName( "gml:name" ); if ( nameNodes.count() == 0 ) continue; if ( nameNodes.item( 0 ).isNull() ) continue; QDomElement nameElem = nameNodes.item( 0 ).toElement(); if ( nameElem.text().isNull() ) continue; QDomNodeList envNodes = elem.elementsByTagName( "gml:Envelope" ); if ( envNodes.count() == 0 ) continue; if ( envNodes.item( 0 ).isNull() ) continue; QDomElement envElem = envNodes.item( 0 ).toElement(); QDomNodeList coorNodes = envElem.elementsByTagName( "gml:coordinates" ); if ( coorNodes.count() == 0 ) continue; if ( coorNodes.item( 0 ).isNull() ) continue; QDomElement coorElem = coorNodes.item( 0 ).toElement(); if ( coorElem.text().isNull() ) continue; QStringList coor = coorElem.text().split( " ", QString::SkipEmptyParts ); if ( coor.size() != 2 ) { QgsDebugMsg( QString( "Cannot parse coordinates: %1" ).arg( coorElem.text() ) ); continue; } QStringList ll = coor[0].split( ",", QString::SkipEmptyParts ); QStringList ur = coor[1].split( ",", QString::SkipEmptyParts ); if ( ll.size() != 2 || ur.size() != 2 ) { QgsDebugMsg( QString( "Cannot parse coordinates: %1" ).arg( coorElem.text() ) ); continue; } // Add region mRegionsComboBox->addItem( nameElem.text() ); QgsPoint llp( ll[0].toDouble(), ll[1].toDouble() ); mRegionsPoints.push_back( llp ); QgsPoint urp( ur[0].toDouble(), ur[1].toDouble() ); mRegionsPoints.push_back( urp ); } file.close(); }
void AsyncAccessManager::add_interest (ImR_ResponseHandler *rh, bool manual) { { ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_); this->rh_list_.push_back (rh); } if (manual) { this->manual_start_ = true; } else if (this->is_terminating()) { this->notify_waiters (); return; } if (ImR_Locator_i::debug () > 4) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) AsyncAccessManager(%@)::add_interest status = %s\n"), this, status_name (this->status_))); } this->info_.notify_remote_access (this->status_); if (this->info_->is_mode (ImplementationRepository::PER_CLIENT)) { if (!this->send_start_request()) { this->final_state(); } return; } if (this->status_ == ImplementationRepository::AAM_SERVER_READY || this->status_ == ImplementationRepository::AAM_SERVER_STARTED_RUNNING) { if (this->locator_.pinger().is_alive (this->info_->ping_id()) == LS_ALIVE) { this->status (ImplementationRepository::AAM_SERVER_READY); this->final_state(); return; } } if (this->status_ == ImplementationRepository::AAM_INIT || this->status_ == ImplementationRepository::AAM_SERVER_READY || this->status_ == ImplementationRepository::AAM_SERVER_STARTED_RUNNING) { // This is not a leak. The listener registers with // the pinger and will delete itself when done. AccessLiveListener *l = 0; ACE_NEW (l, AccessLiveListener (this->info_->ping_id(), this, this->locator_.pinger())); LiveListener_ptr llp(l); if (!l->start()) { if (!this->send_start_request()) { this->final_state(); } } else { if (this->status_ == ImplementationRepository::AAM_SERVER_STARTED_RUNNING) { this->update_status (ImplementationRepository::AAM_WAIT_FOR_ALIVE); } else { this->update_status (ImplementationRepository::AAM_WAIT_FOR_PING); } } } }
void AsyncListManager::list_i (CORBA::ULong start, CORBA::ULong how_many) { this->first_ = start; CORBA::ULong len = this->repo_->servers ().current_size () - start; if (how_many > 0 && len > how_many) { len = how_many; } Locator_Repository::SIMap::ENTRY* entry = 0; Locator_Repository::SIMap::CONST_ITERATOR it (this->repo_->servers ()); for (;start > 0; start--) { it.advance (); } this->server_list_.length (len); this->waiters_ = 0; for (CORBA::ULong i = 0; i < len; i++) { it.next (entry); it.advance (); Server_Info_Ptr info = entry->int_id_; if (info->jacorb_server) { ACE_CString jacorb_name (ACE_TEXT ("JACORB:") + info->name); this->server_list_[i].server = jacorb_name.c_str (); } else { this->server_list_[i].server = info->name.c_str (); } this->server_list_[i].startup.command_line = info->cmdline.c_str (); this->server_list_[i].startup.environment = info->env_vars; this->server_list_[i].startup.working_directory = info->dir.c_str (); this->server_list_[i].startup.activation = info->activation_mode; this->server_list_[i].startup.activator = info->activator.c_str (); this->server_list_[i].startup.start_limit = info->start_limit; this->server_list_[i].partial_ior = info->partial_ior.c_str (); this->server_list_[i].activeStatus = ImplementationRepository::ACTIVE_MAYBE; if (this->pinger_ != 0) { ListLiveListener *l = 0; ACE_NEW (l, ListLiveListener (info->name.c_str (), i, this, *this->pinger_)); LiveListener_ptr llp(l); if (!l->start()) { this->server_list_[i].activeStatus = ImplementationRepository::ACTIVE_NO; } else { if (!evaluate_status (i,l->status())) { this->waiters_++; } } } } if (ImR_Locator_i::debug() > 4) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) AsyncListManager::list_i, %d waiters") ACE_TEXT (" out of %d regsitered servers\n"), this->waiters_, len)); } if (this->waiters_ == 0) { this->final_state (); } }