From 18bf7ad3e59d5456830d299cc05cf9b65350b2db Mon Sep 17 00:00:00 2001 From: secher Date: Thu, 12 Jul 2007 13:59:40 +0000 Subject: [PATCH] debugging of simultaneous registry of containers in naming service --- src/Container/Container_i.cxx | 3 +- src/Container/SALOME_ContainerManager.cxx | 3 +- .../SALOME_ModuleCatalog_impl.hxx | 2 +- src/NamingService/SALOME_NamingService.cxx | 286 ++++++++---------- .../SALOME_ResourcesCatalog_Handler.cxx | 6 +- .../SALOME_ResourcesManager.cxx | 4 +- src/SALOMEDS/SALOMEDS_StudyManager_i.hxx | 2 +- 7 files changed, 143 insertions(+), 163 deletions(-) diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index 21091ea25..ffb9a5c07 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -284,7 +284,8 @@ void Engines_Container_i::Shutdown() MESSAGE("Effective Shutdown of container Begins..."); LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance(); bp1->deleteInstance(bp1); - _orb->shutdown(0); + if(!CORBA::is_nil(_orb)) + _orb->shutdown(0); } } diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 70cc2b70f..858ad1add 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -104,7 +104,8 @@ void SALOME_ContainerManager::Shutdown() PortableServer::ObjectId_var oid = _default_POA()->servant_to_id(this); _default_POA()->deactivate_object(oid); _remove_ref(); - _orb->shutdown(0); + if(!CORBA::is_nil(_orb)) + _orb->shutdown(0); } //============================================================================= diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx index 96e1a91a9..e8516ea46 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx @@ -119,7 +119,7 @@ public: void ping(){}; - void shutdown() { if (_orb) _orb->shutdown(0); }; + void shutdown() { if(!CORBA::is_nil(_orb)) _orb->shutdown(0); }; private: //! method to parse one module catalog diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index 15984d058..fed012728 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -132,10 +132,9 @@ void SALOME_NamingService::Register(CORBA::Object_ptr ObjRef, // --- _current_context is replaced to the _root_context // if the Path begins whith '/' - if (Path[0] == '/') - { - _current_context = _root_context; - } + if (Path[0] == '/'){ + _current_context = _root_context; + } // --- the resolution of the directory path has to be done // to place the current_context to the correct node @@ -149,179 +148,158 @@ void SALOME_NamingService::Register(CORBA::Object_ptr ObjRef, CORBA::Boolean not_exist = false; - if (dimension_resultat > 0) - { - // A directory is treated (not only an object name) - // test if the directory where ObjRef should be recorded already exists - // If not, create the new context - - try - { - CORBA::Object_var obj = _current_context->resolve(context_name); - _current_context = CosNaming::NamingContext::_narrow(obj); - } - - catch (CosNaming::NamingContext::NotFound &) - { - // --- failed to resolve, therefore assume cold start - not_exist = true; - } - - catch (CosNaming::NamingContext::InvalidName &) - { - INFOS("Register() : CosNaming::NamingContext::InvalidName"); - } - - catch (CosNaming::NamingContext::CannotProceed &) - { - INFOS("Register() : CosNaming::NamingContext::CannotProceed"); - } - - catch (CORBA::SystemException&) - { - INFOS("Register() : CORBA::SystemException: " - << "unable to contact the naming service"); - throw ServiceUnreachable(); - } - - if (not_exist) - { - try - { - context_name.length(1); - for (int i = 0 ; i < dimension_resultat ;i++) - { - context_name[0].id = - CORBA::string_dup(splitPath[i].c_str()); - context_name[0].kind = CORBA::string_dup("dir"); - // SCRUTE(_context_name[0].id); - // --- check if the path is created - try - { - // --- if the context is already created, nothing to do - CORBA::Object_var obj = - _current_context->resolve(context_name); - _current_context = - CosNaming::NamingContext::_narrow(obj); - } - - catch (CosNaming::NamingContext::NotFound &) - { - // --- the context must be created - CosNaming::NamingContext_var temp_context = - _current_context->bind_new_context(context_name); - _current_context = temp_context; - } - } - } - - catch (CosNaming::NamingContext::AlreadyBound&) - { - INFOS("Register() : CosNaming::NamingContext::AlreadyBound"); - } - - catch (CosNaming::NamingContext::NotFound& ex) - { - CosNaming::Name n = ex.rest_of_name; - - if (ex.why == CosNaming::NamingContext::missing_node) - INFOS("Register() : " << (char *) n[0].id - << " (" << (char *) n[0].kind << ") not found"); + if (dimension_resultat > 0){ + // A directory is treated (not only an object name) + // test if the directory where ObjRef should be recorded already exists + // If not, create the new context + + try{ + CORBA::Object_var obj = _current_context->resolve(context_name); + _current_context = CosNaming::NamingContext::_narrow(obj); + } - if (ex.why == CosNaming::NamingContext::not_context) - INFOS("Register() : " << (char *) n[0].id - << " (" << (char *) n[0].kind - << ") is not a context"); + catch (CosNaming::NamingContext::NotFound &){ + // --- failed to resolve, therefore assume cold start + not_exist = true; + } - if (ex.why == CosNaming::NamingContext::not_object) - INFOS("Register() : " << (char *) n[0].id - << " (" << (char *) n[0].kind - << ") is not an object"); - } + catch (CosNaming::NamingContext::InvalidName &){ + INFOS("Register() : CosNaming::NamingContext::InvalidName"); + } - catch (CosNaming::NamingContext::CannotProceed&) - { - INFOS("Register(): CosNaming::NamingContext::CannotProceed"); - } + catch (CosNaming::NamingContext::CannotProceed &){ + INFOS("Register() : CosNaming::NamingContext::CannotProceed"); + } - catch (CosNaming::NamingContext::InvalidName&) - { - INFOS("Register(): CosNaming::NamingContext::InvalidName"); - } + catch (CORBA::SystemException&){ + INFOS("Register() : CORBA::SystemException: " + << "unable to contact the naming service"); + throw ServiceUnreachable(); + } - catch (CORBA::SystemException&) - { - INFOS("Register():CORBA::SystemException: " - << "unable to contact the naming service"); - throw ServiceUnreachable(); - } - } + if (not_exist){ + try{ + context_name.length(1); + for (int i = 0 ; i < dimension_resultat ;i++){ + context_name[0].id = CORBA::string_dup(splitPath[i].c_str()); + context_name[0].kind = CORBA::string_dup("dir"); + // SCRUTE(_context_name[0].id); + // --- check if the path is created + try{ + // --- if the context is already created, nothing to do + CORBA::Object_var obj = _current_context->resolve(context_name); + _current_context = CosNaming::NamingContext::_narrow(obj); + } + + catch (CosNaming::NamingContext::NotFound &){ + try{ + // --- the context must be created + CosNaming::NamingContext_var temp_context = + _current_context->bind_new_context(context_name); + _current_context = temp_context; + } + catch (CosNaming::NamingContext::AlreadyBound&){ + CORBA::Object_var obj = _current_context->resolve(context_name); + _current_context = CosNaming::NamingContext::_narrow(obj); + } + } + } + } + + catch (CosNaming::NamingContext::AlreadyBound&){ + INFOS("Register() : CosNaming::NamingContext::AlreadyBound"); + } + + catch (CosNaming::NamingContext::NotFound& ex){ + CosNaming::Name n = ex.rest_of_name; + + if (ex.why == CosNaming::NamingContext::missing_node) + INFOS("Register() : " << (char *) n[0].id + << " (" << (char *) n[0].kind << ") not found"); + + if (ex.why == CosNaming::NamingContext::not_context) + INFOS("Register() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not a context"); + + if (ex.why == CosNaming::NamingContext::not_object) + INFOS("Register() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not an object"); + } + + catch (CosNaming::NamingContext::CannotProceed&){ + INFOS("Register(): CosNaming::NamingContext::CannotProceed"); + } + + catch (CosNaming::NamingContext::InvalidName&){ + INFOS("Register(): CosNaming::NamingContext::InvalidName"); + } + + catch (CORBA::SystemException&){ + INFOS("Register():CORBA::SystemException: " + << "unable to contact the naming service"); + throw ServiceUnreachable(); + } } + } // --- The current directory is now the directory where the object should // be recorded int sizePath = splitPath.size(); - if (sizePath > dimension_resultat) - { - ASSERT(sizePath == dimension_resultat+1); - context_name.length(1); + if (sizePath > dimension_resultat){ + ASSERT(sizePath == dimension_resultat+1); + context_name.length(1); - try - { - // --- the last element is an object and not a directory + try{ + // --- the last element is an object and not a directory - context_name[0].id = - CORBA::string_dup(splitPath[dimension_resultat].c_str()); - context_name[0].kind = CORBA::string_dup("object"); - //SCRUTE(context_name[0].id); + context_name[0].id = CORBA::string_dup(splitPath[dimension_resultat].c_str()); + context_name[0].kind = CORBA::string_dup("object"); + //SCRUTE(context_name[0].id); - _current_context->bind(context_name, ObjRef); - } + _current_context->bind(context_name, ObjRef); + } - catch (CosNaming::NamingContext::NotFound& ex) - { - CosNaming::Name n = ex.rest_of_name; + catch (CosNaming::NamingContext::NotFound& ex){ + CosNaming::Name n = ex.rest_of_name; - if (ex.why == CosNaming::NamingContext::missing_node) - INFOS("Register() : " << (char *) n[0].id - << " (" << (char *) n[0].kind << ") not found"); + if (ex.why == CosNaming::NamingContext::missing_node) + INFOS("Register() : " << (char *) n[0].id + << " (" << (char *) n[0].kind << ") not found"); - if (ex.why == CosNaming::NamingContext::not_context) - INFOS("Register() : " << (char *) n[0].id - << " (" << (char *) n[0].kind - << ") is not a context"); + if (ex.why == CosNaming::NamingContext::not_context) + INFOS("Register() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not a context"); - if (ex.why == CosNaming::NamingContext::not_object) - INFOS("Register() : " << (char *) n[0].id - << " (" << (char *) n[0].kind - << ") is not an object"); - } + if (ex.why == CosNaming::NamingContext::not_object) + INFOS("Register() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not an object"); + } - catch (CosNaming::NamingContext::CannotProceed&) - { - INFOS("Register(): CosNaming::NamingContext::CannotProceed"); - } + catch (CosNaming::NamingContext::CannotProceed&){ + INFOS("Register(): CosNaming::NamingContext::CannotProceed"); + } - catch (CosNaming::NamingContext::InvalidName&) - { - INFOS("Register(): CosNaming::NamingContext::InvalidName"); - } + catch (CosNaming::NamingContext::InvalidName&){ + INFOS("Register(): CosNaming::NamingContext::InvalidName"); + } - catch (CosNaming::NamingContext::AlreadyBound&) - { - INFOS("Register(): CosNaming::NamingContext::AlreadyBound, " - << "object will be rebind"); - _current_context->rebind(context_name, ObjRef); - } + catch (CosNaming::NamingContext::AlreadyBound&){ + INFOS("Register(): CosNaming::NamingContext::AlreadyBound, " + << "object will be rebind"); + _current_context->rebind(context_name, ObjRef); + } - catch (CORBA::SystemException&) - { - INFOS("!!!Register(): CORBA::SystemException: " - << "unable to contact the naming service"); - throw ServiceUnreachable(); - } + catch (CORBA::SystemException&){ + INFOS("!!!Register(): CORBA::SystemException: " + << "unable to contact the naming service"); + throw ServiceUnreachable(); } + } } // ============================================================================ diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx index 8263ca440..79fd376eb 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx @@ -269,9 +269,9 @@ bool SALOME_ResourcesCatalog_Handler::characters(const QString& chars) bool SALOME_ResourcesCatalog_Handler::endDocument() { - map::const_iterator it; - for(it=_resources_list.begin();it!=_resources_list.end();it++) - (*it).second.Print(); +// map::const_iterator it; +// for(it=_resources_list.begin();it!=_resources_list.end();it++) +// (*it).second.Print(); MESSAGE("This is the end of document"); return true; diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index bec7fff69..0b774d3fe 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -644,12 +644,12 @@ std::string SALOME_ResourcesManager::BuildCmdrunSalomeBatch( tempOutputFile << " do" << endl ; tempOutputFile << " arglist=\"$arglist YACS_Server_\"$ip" << endl ; tempOutputFile << " done" << endl ; - tempOutputFile << " sleep 1" << endl ; + tempOutputFile << " sleep 5" << endl ; tempOutputFile << " ./runSession waitContainers.py $arglist" << endl ; tempOutputFile << " ./runSession python ~/" << DirForTmpFiles << "/" << FileNameToExecute << ".py" << endl; tempOutputFile << " ./runSession killCurrentPort" << endl; tempOutputFile << "else" << endl ; - tempOutputFile << " sleep 1" << endl ; + tempOutputFile << " sleep 5" << endl ; tempOutputFile << " ./runSession waitNS.py" << endl ; tempOutputFile << " ./runSession SALOME_Container 'YACS_Server_'${SLURM_PROCID}" << endl ; tempOutputFile << "fi" << endl ; diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx index ec1db4708..bdfa88d54 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx @@ -146,7 +146,7 @@ public: static PortableServer::POA_ptr GetPOA(const SALOMEDS::Study_ptr theStudy); - void Shutdown() { _orb->shutdown(0); return; } + void Shutdown() { if(!CORBA::is_nil(_orb)) _orb->shutdown(0); } }; #endif -- 2.39.2