From: caremoli Date: Tue, 8 Sep 2009 17:29:16 +0000 (+0000) Subject: CCAR: add a message in case of error when loading a component. X-Git-Tag: V5_1_3rc1~67 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6870ab4b643d9987d294e6f9d508ee81378e00a8;p=modules%2Fkernel.git CCAR: add a message in case of error when loading a component. The dlerror output for dlopen plus the traceback for the import of the python module The import_component python function now returns a string instead of a boolean. If the string is empty, the import is OK. The C++ code in container MPIContainer and ParallelContainer has been adapted. --- diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index eca25186b..83ed0d557 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -88,10 +88,10 @@ Engines_Component_i::Engines_Component_i():_myConnexionToRegistry(0), _notifSupp //============================================================================= Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - PortableServer::ObjectId * contId, - const char *instanceName, - const char *interfaceName, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName, bool notif, bool regist ) : _instanceName(instanceName), @@ -448,17 +448,17 @@ bool Engines_Component_i::Suspend_impl() #endif { if ( _Sleeping ) - { - return false ; - } + { + return false ; + } else { #ifndef WIN32 - RetVal = Killer( _ThreadId ,SIGINT ) ; + RetVal = Killer( _ThreadId ,SIGINT ) ; #else - RetVal = Killer( *_ThreadId ,SIGINT ) ; + RetVal = Killer( *_ThreadId ,SIGINT ) ; #endif - //if ( RetVal ) _Sleeping = true; + //if ( RetVal ) _Sleeping = true; } } @@ -495,12 +495,12 @@ bool Engines_Component_i::Resume_impl() { if ( _Sleeping ) { - _Sleeping = false ; - RetVal = true ; + _Sleeping = false ; + RetVal = true ; } else { - RetVal = false ; + RetVal = false ; } } return RetVal ; @@ -524,35 +524,35 @@ CORBA::Long Engines_Component_i::CpuUsed_impl() #else if ( pthread_self().p != _ThreadId->p ) #endif - { + { if ( _Sleeping ) - { - } + { + } else - { - // Get Cpu in the appropriate thread with that object !... - theEngines_Component = this ; + { + // Get Cpu in the appropriate thread with that object !... + theEngines_Component = this ; #ifndef WIN32 - Killer( _ThreadId ,SIGUSR1 ) ; + Killer( _ThreadId ,SIGUSR1 ) ; #else - Killer( *_ThreadId ,SIGUSR11 ) ; + Killer( *_ThreadId ,SIGUSR11 ) ; #endif - } + } cpu = _ThreadCpuUsed ; - } + } else - { - _ThreadCpuUsed = CpuUsed() ; - cpu = _ThreadCpuUsed ; - // cout << pthread_self() << " Engines_Component_i::CpuUsed_impl " - // << _serviceName << " " << cpu << endl ; + { + _ThreadCpuUsed = CpuUsed() ; + cpu = _ThreadCpuUsed ; + // cout << pthread_self() << " Engines_Component_i::CpuUsed_impl " + // << _serviceName << " " << cpu << endl ; } } else { - cpu = _ThreadCpuUsed ; - // cout << pthread_self() << " Engines_Component_i::CpuUsed_impl " - // << _serviceName << " " << cpu<< endl ; + cpu = _ThreadCpuUsed ; + // cout << pthread_self() << " Engines_Component_i::CpuUsed_impl " + // << _serviceName << " " << cpu<< endl ; } } else @@ -623,10 +623,10 @@ void Engines_Component_i::beginService(const char *serviceName) { #ifndef WIN32 MESSAGE(pthread_self() << "Send BeginService notification for " <kind() == CORBA::tk_string) - { - const char* value; - (*it).second >>= value; - // ---todo: replace __GNUC__ test by an autoconf macro AC_CHECK_FUNC. + { + const char* value; + (*it).second >>= value; + // ---todo: replace __GNUC__ test by an autoconf macro AC_CHECK_FUNC. #if defined __GNUC__ -// int ret = setenv(cle.c_str(), value, overwrite); - setenv(cle.c_str(), value, overwrite); +// int ret = setenv(cle.c_str(), value, overwrite); + setenv(cle.c_str(), value, overwrite); #else - //CCRT porting : setenv not defined in stdlib.h - std::string s(cle); - s+='='; - s+=value; - // char* cast because 1st arg of linux putenv function - // is not a const char* ! -// int ret=putenv((char *)s.c_str()); - putenv((char *)s.c_str()); - //End of CCRT porting + //CCRT porting : setenv not defined in stdlib.h + std::string s(cle); + s+='='; + s+=value; + // char* cast because 1st arg of linux putenv function + // is not a const char* ! +// int ret=putenv((char *)s.c_str()); + putenv((char *)s.c_str()); + //End of CCRT porting #endif - MESSAGE("--- setenv: "<Send(_graphName.c_str(), _nodeName.c_str(), event_type, message); } @@ -897,8 +897,8 @@ string Engines_Component_i::GetDynLibraryName(const char *componentName) //============================================================================= Engines::TMPFile* Engines_Component_i::DumpPython(CORBA::Object_ptr theStudy, - CORBA::Boolean isPublished, - CORBA::Boolean& isValidScript) + CORBA::Boolean isPublished, + CORBA::Boolean& isValidScript) { const char* aScript = "def RebuildData(theStudy): pass"; char* aBuffer = new char[strlen(aScript)+1]; @@ -912,7 +912,7 @@ Engines::TMPFile* Engines_Component_i::DumpPython(CORBA::Object_ptr theStudy, Engines::Salome_file_ptr Engines_Component_i::getInputFileToService(const char* service_name, - const char* Salome_file_name) + const char* Salome_file_name) { // Try to find the service, if it doesn't exist, we throw an exception. _Service_file_map_it = _Input_Service_file_map.find(service_name); @@ -939,7 +939,7 @@ Engines_Component_i::getInputFileToService(const char* service_name, Engines::Salome_file_ptr Engines_Component_i::setInputFileToService(const char* service_name, - const char* Salome_file_name) + const char* Salome_file_name) { // Try to find the service, if it doesn't exist, we add it. _Service_file_map_it = _Input_Service_file_map.find(service_name); @@ -983,7 +983,7 @@ Engines_Component_i::checkInputFilesToService(const char* service_name) Engines::Salome_file_ptr Engines_Component_i::getOutputFileToService(const char* service_name, - const char* Salome_file_name) + const char* Salome_file_name) { // Try to find the service, if it doesn't exist, we throw an exception. _Service_file_map_it = _Output_Service_file_map.find(service_name); @@ -1010,7 +1010,7 @@ Engines_Component_i::getOutputFileToService(const char* service_name, Engines::Salome_file_ptr Engines_Component_i::setOutputFileToService(const char* service_name, - const char* Salome_file_name) + const char* Salome_file_name) { // Try to find the service, if it doesn't exist, we add it. _Service_file_map_it = _Output_Service_file_map.find(service_name); @@ -1063,8 +1063,8 @@ Engines_Component_i::checkOutputFilesToService(const char* service_name) //============================================================================= void Engines_Component_i::configureSalome_file(std::string service_name, - std::string file_port_name, - Salome_file_i * file) + std::string file_port_name, + Salome_file_i * file) { // By default this method does nothing } diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index 065c5b4b5..6db3ab07a 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -83,6 +83,9 @@ map Engines_Container_i::_library_map; map Engines_Container_i::_toRemove_map; omni_mutex Engines_Container_i::_numInstanceMutex ; +int checkifexecutable(const std::string&); +int findpathof(std::string&, const std::string&); + /*! \class Engines_Container_i * \brief C++ implementation of Engines::Container interface * @@ -404,8 +407,8 @@ int findpathof(string& pth, const string& exe) { string path( getenv("PATH") ); if ( path.size() == 0 ) - return 0; - + return 0; + char path_spr = #ifdef WIN32 ';'; @@ -519,9 +522,11 @@ Engines_Container_i::load_component_Library(const char* componentName) return true; } + std::string retso=""; #ifndef WIN32 void* handle; handle = dlopen( impl_name.c_str() , RTLD_LAZY ) ; + if ( !handle )retso=dlerror(); #else HINSTANCE handle; handle = LoadLibrary( impl_name.c_str() ); @@ -538,6 +543,7 @@ Engines_Container_i::load_component_Library(const char* componentName) // --- try import Python component INFOS("try import Python component "<deleteInstance(bp1); return 0 ; } diff --git a/src/Container/SALOME_Container.py b/src/Container/SALOME_Container.py index 1a92f6b54..73ba33123 100644 --- a/src/Container/SALOME_Container.py +++ b/src/Container/SALOME_Container.py @@ -46,7 +46,7 @@ from launchConfigureParser import verbose #============================================================================= -#define an implementation of the container interface +#define an implementation of the container interface for embedding in Container implemented in C++ class SALOME_Container_i: _orb = None @@ -67,20 +67,17 @@ class SALOME_Container_i: #------------------------------------------------------------------------- - #def __del__(self ): - # self._orb.destroy() - def import_component(self, componentName): MESSAGE( "SALOME_Container_i::import_component" ) - ret=0 + ret="" try: if verbose(): print "try import ",componentName __import__(componentName) if verbose(): print "import ",componentName," successful" - ret=1 except: + import traceback + ret=traceback.format_exc(10) if verbose(): - import traceback traceback.print_exc() print "import ",componentName," not possible" return ret diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index f0a5a04a9..d1e401c85 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -168,28 +168,28 @@ void SALOME_ContainerManager::ShutdownContainers() { try { - SCRUTE((*iter)); - CORBA::Object_var obj=_NS->Resolve((*iter).c_str()); - Engines::Container_var cont=Engines::Container::_narrow(obj); - if(!CORBA::is_nil(cont)) - { - MESSAGE("ShutdownContainers: " << (*iter)); - cont->Shutdown(); - } - else - MESSAGE("ShutdownContainers: no container ref for " << (*iter)); + SCRUTE((*iter)); + CORBA::Object_var obj=_NS->Resolve((*iter).c_str()); + Engines::Container_var cont=Engines::Container::_narrow(obj); + if(!CORBA::is_nil(cont)) + { + MESSAGE("ShutdownContainers: " << (*iter)); + cont->Shutdown(); + } + else + MESSAGE("ShutdownContainers: no container ref for " << (*iter)); } catch(CORBA::SystemException& e) { - INFOS("CORBA::SystemException ignored : " << e); + INFOS("CORBA::SystemException ignored : " << e); } catch(CORBA::Exception&) { - INFOS("CORBA::Exception ignored."); + INFOS("CORBA::Exception ignored."); } catch(...) { - INFOS("Unknown exception ignored."); + INFOS("Unknown exception ignored."); } } } @@ -648,12 +648,12 @@ SALOME_ContainerManager::StartParallelContainer(const Engines::MachineParameters // Il faut tuer le proxy try { - Engines::Container_var proxy = Engines::Container::_narrow(container_proxy); - proxy->Shutdown(); + Engines::Container_var proxy = Engines::Container::_narrow(container_proxy); + proxy->Shutdown(); } catch (...) { - INFOS("[StartParallelContainer] Exception catched from proxy Shutdown..."); + INFOS("[StartParallelContainer] Exception catched from proxy Shutdown..."); } return ret; } @@ -671,34 +671,34 @@ SALOME_ContainerManager::StartParallelContainer(const Engines::MachineParameters obj = _NS->Resolve(containerNameInNS.c_str()); if (CORBA::is_nil(obj)) { - INFOS("[StartParallelContainer] CONNECTION FAILED From Naming Service !"); - INFOS("[StartParallelContainer] Container name is " << containerNameInNS); - return ret; + INFOS("[StartParallelContainer] CONNECTION FAILED From Naming Service !"); + INFOS("[StartParallelContainer] Container name is " << containerNameInNS); + return ret; } try { - MESSAGE("[StartParallelContainer] Deploying node : " << container_node_name); - PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(obj); - node->deploy(); - MESSAGE("[StartParallelContainer] node " << container_node_name << " is deployed"); + MESSAGE("[StartParallelContainer] Deploying node : " << container_node_name); + PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(obj); + node->deploy(); + MESSAGE("[StartParallelContainer] node " << container_node_name << " is deployed"); } catch(CORBA::SystemException& e) { - INFOS("[StartParallelContainer] Exception in deploying node : " << containerNameInNS); - INFOS("CORBA::SystemException : " << e); - return ret; + INFOS("[StartParallelContainer] Exception in deploying node : " << containerNameInNS); + INFOS("CORBA::SystemException : " << e); + return ret; } catch(CORBA::Exception& e) { - INFOS("[StartParallelContainer] Exception in deploying node : " << containerNameInNS); - INFOS("CORBA::Exception" << e); - return ret; + INFOS("[StartParallelContainer] Exception in deploying node : " << containerNameInNS); + INFOS("CORBA::Exception" << e); + return ret; } catch(...) { - INFOS("[StartParallelContainer] Exception in deploying node : " << containerNameInNS); - INFOS("Unknown exception !"); - return ret; + INFOS("[StartParallelContainer] Exception in deploying node : " << containerNameInNS); + INFOS("Unknown exception !"); + return ret; } } @@ -764,9 +764,9 @@ SALOME_ContainerManager::StartParallelContainer(const Engines::MachineParameters //============================================================================= CORBA::Object_ptr SALOME_ContainerManager::LaunchParallelContainer(const std::string& command, - const Engines::MachineParameters& params, - const std::string& name, - SALOME_ContainerManager::actual_launch_machine_t & vect_machine) + const Engines::MachineParameters& params, + const std::string& name, + SALOME_ContainerManager::actual_launch_machine_t & vect_machine) { CORBA::Object_ptr obj = CORBA::Object::_nil(); std::string containerNameInNS; @@ -817,17 +817,17 @@ SALOME_ContainerManager::LaunchParallelContainer(const std::string& command, INFOS("[LaunchParallelContainer] Waiting for Parallel Container node " << containerNameInNS << " on " << theMachine); while (CORBA::is_nil(obj) && count) { #ifndef WIN32 - sleep(1) ; + sleep(1) ; #else - Sleep(1000); + Sleep(1000); #endif - count-- ; - obj = _NS->Resolve(containerNameInNS.c_str()); + count-- ; + obj = _NS->Resolve(containerNameInNS.c_str()); } if (CORBA::is_nil(obj)) { - INFOS("[LaunchParallelContainer] Launch of node failed (or not found) !"); - return obj; + INFOS("[LaunchParallelContainer] Launch of node failed (or not found) !"); + return obj; } } } @@ -900,7 +900,7 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer { string command; int nbproc; - + if ( ! _isAppliSalomeDefined ) command = BuildTempFileToLaunchRemoteContainer(machine, params); @@ -931,21 +931,21 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer throw SALOME_Exception("Unknown protocol"); if (resInfo.UserName != "") - { - command += resInfo.UserName; - command += "@"; - } + { + command += resInfo.UserName; + command += "@"; + } command += machine; command += " "; if (resInfo.AppliPath != "") - command += resInfo.AppliPath; // path relative to user@machine $HOME + command += resInfo.AppliPath; // path relative to user@machine $HOME else - { - ASSERT(getenv("APPLI")); - command += getenv("APPLI"); // path relative to user@machine $HOME - } + { + ASSERT(getenv("APPLI")); + command += getenv("APPLI"); // path relative to user@machine $HOME + } command += "/runRemote.sh "; @@ -968,23 +968,23 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer } if(params.isMPI) - { - command += " mpirun -np "; - std::ostringstream o; - o << nbproc << " "; - command += o.str(); + { + command += " mpirun -np "; + std::ostringstream o; + o << nbproc << " "; + command += o.str(); #ifdef WITHLAM - command += "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace "; + command += "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace "; #elif defined(WITHOPENMPI) - if( getenv("OMPI_URI_FILE") == NULL ) - command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace"; - else{ - command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:"; - command += getenv("OMPI_URI_FILE"); - } -#endif - command += " SALOME_MPIContainer "; - } + if( getenv("OMPI_URI_FILE") == NULL ) + command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace"; + else{ + command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:"; + command += getenv("OMPI_URI_FILE"); + } +#endif + command += " SALOME_MPIContainer "; + } else command += " " +container_exe+ " "; @@ -1040,7 +1040,7 @@ SALOME_ContainerManager::BuildCommandToLaunchLocalContainer #elif defined(WITHOPENMPI) //command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace "; if( getenv("OMPI_URI_FILE") == NULL ) - command_file << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace"; + command_file << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace"; else { command_file << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:"; @@ -1246,10 +1246,10 @@ SALOME_ContainerManager::BuildTempFileToLaunchRemoteContainer tempOutputFile << "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace "; #elif defined(WITHOPENMPI) if( getenv("OMPI_URI_FILE") == NULL ) - tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace"; + tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace"; else{ - tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:"; - tempOutputFile << getenv("OMPI_URI_FILE"); + tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:"; + tempOutputFile << getenv("OMPI_URI_FILE"); } #endif } @@ -1332,9 +1332,9 @@ SALOME_ContainerManager::BuildTempFileToLaunchRemoteContainer //============================================================================= string SALOME_ContainerManager::BuildCommandToLaunchParallelContainer(const std::string& exe_name, - const Engines::MachineParameters& params, - SALOME_ContainerManager::actual_launch_machine_t & vect_machine, - const std::string proxy_hostname) + const Engines::MachineParameters& params, + SALOME_ContainerManager::actual_launch_machine_t & vect_machine, + const std::string proxy_hostname) { // This method knows the differences between the proxy and the nodes. // nb_component_nodes is not used in the same way if it is a proxy or @@ -1387,14 +1387,14 @@ SALOME_ContainerManager::BuildCommandToLaunchParallelContainer(const std::string if (is_a_proxy) { machine_file_name = _ResManager->getMachineFile(hostname, - 1, - parallelLib); + 1, + parallelLib); } else { machine_file_name = _ResManager->getMachineFile(hostname, - params.nb_component_nodes, - parallelLib); + params.nb_component_nodes, + parallelLib); } if (machine_file_name == "") { @@ -1442,32 +1442,32 @@ SALOME_ContainerManager::BuildCommandToLaunchParallelContainer(const std::string std::string command_remote(""); if (remote) { - std::string machine_name; - std::ifstream machine_file(machine_file_name.c_str()); - std::getline(machine_file, machine_name); - MESSAGE("[BuildCommandToLaunchParallelContainer] machine file name extracted is " << machine_name) - - // We want to launch a command like : - // ssh user@machine distantPath/runRemote.sh hostNS portNS - const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(machine_name); - if (resInfo.Protocol == rsh) - command_remote = "rsh "; - else - command_remote = "ssh "; - command_remote += resInfo.UserName; - command_remote += "@"; - command_remote += machine_name; - command_remote += " "; - command_remote += resInfo.AppliPath; // path relative to user@machine $HOME - command_remote += "/runRemote.sh "; - ASSERT(getenv("NSHOST")); - command_remote += getenv("NSHOST"); // hostname of CORBA name server - command_remote += " "; - ASSERT(getenv("NSPORT")); - command_remote += getenv("NSPORT"); // port of CORBA name server - command_remote += " "; - - hostname = machine_name; + std::string machine_name; + std::ifstream machine_file(machine_file_name.c_str()); + std::getline(machine_file, machine_name); + MESSAGE("[BuildCommandToLaunchParallelContainer] machine file name extracted is " << machine_name) + + // We want to launch a command like : + // ssh user@machine distantPath/runRemote.sh hostNS portNS + const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(machine_name); + if (resInfo.Protocol == rsh) + command_remote = "rsh "; + else + command_remote = "ssh "; + command_remote += resInfo.UserName; + command_remote += "@"; + command_remote += machine_name; + command_remote += " "; + command_remote += resInfo.AppliPath; // path relative to user@machine $HOME + command_remote += "/runRemote.sh "; + ASSERT(getenv("NSHOST")); + command_remote += getenv("NSHOST"); // hostname of CORBA name server + command_remote += " "; + ASSERT(getenv("NSPORT")); + command_remote += getenv("NSPORT"); // port of CORBA name server + command_remote += " "; + + hostname = machine_name; } command = real_exe_name; @@ -1485,63 +1485,63 @@ SALOME_ContainerManager::BuildCommandToLaunchParallelContainer(const std::string { std::ifstream * machine_file = NULL; if (remote) - machine_file = new std::ifstream(machine_file_name.c_str()); + machine_file = new std::ifstream(machine_file_name.c_str()); for (int i= 0; i < nb_nodes; i++) { - std::string command_remote(""); - if (remote) - { - std::string machine_name; - std::getline(*machine_file, machine_name); - MESSAGE("[BuildCommandToLaunchParallelContainer] machine file name extracted is " << machine_name) - - // We want to launch a command like : - // ssh user@machine distantPath/runRemote.sh hostNS portNS - const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(machine_name); - if (resInfo.Protocol == rsh) - command_remote = "rsh "; - else - command_remote = "ssh "; - command_remote += resInfo.UserName; - command_remote += "@"; - command_remote += machine_name; - command_remote += " "; - command_remote += resInfo.AppliPath; // path relative to user@machine $HOME - command_remote += "/runRemote.sh "; - ASSERT(getenv("NSHOST")); - command_remote += getenv("NSHOST"); // hostname of CORBA name server - command_remote += " "; - ASSERT(getenv("NSPORT")); - command_remote += getenv("NSPORT"); // port of CORBA name server - command_remote += " "; - - hostname = machine_name; - } - - std::ostringstream tmp; - tmp << i; - std::string proc_number = tmp.str(); - - std::string command_tmp(""); - command_tmp += real_exe_name; - command_tmp += " " + _NS->ContainerName(rtn); - command_tmp += " " + parallelLib; - command_tmp += " " + proxy_hostname; - command_tmp += " " + proc_number; - command_tmp += " -"; - AddOmninamesParams(command_tmp); - - // On change _Node_ par _Nodex_ pour avoir chaque noeud - // sur un fichier - std::string command_end_tmp = command_end; - std::string::size_type loc_node = command_end_tmp.find("_Node_"); - if (loc_node != std::string::npos) - command_end_tmp.insert(loc_node+5, proc_number); - command += command_begin + command_remote + command_tmp + command_end_tmp; - vect_machine.push_back(hostname); + std::string command_remote(""); + if (remote) + { + std::string machine_name; + std::getline(*machine_file, machine_name); + MESSAGE("[BuildCommandToLaunchParallelContainer] machine file name extracted is " << machine_name) + + // We want to launch a command like : + // ssh user@machine distantPath/runRemote.sh hostNS portNS + const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(machine_name); + if (resInfo.Protocol == rsh) + command_remote = "rsh "; + else + command_remote = "ssh "; + command_remote += resInfo.UserName; + command_remote += "@"; + command_remote += machine_name; + command_remote += " "; + command_remote += resInfo.AppliPath; // path relative to user@machine $HOME + command_remote += "/runRemote.sh "; + ASSERT(getenv("NSHOST")); + command_remote += getenv("NSHOST"); // hostname of CORBA name server + command_remote += " "; + ASSERT(getenv("NSPORT")); + command_remote += getenv("NSPORT"); // port of CORBA name server + command_remote += " "; + + hostname = machine_name; + } + + std::ostringstream tmp; + tmp << i; + std::string proc_number = tmp.str(); + + std::string command_tmp(""); + command_tmp += real_exe_name; + command_tmp += " " + _NS->ContainerName(rtn); + command_tmp += " " + parallelLib; + command_tmp += " " + proxy_hostname; + command_tmp += " " + proc_number; + command_tmp += " -"; + AddOmninamesParams(command_tmp); + + // On change _Node_ par _Nodex_ pour avoir chaque noeud + // sur un fichier + std::string command_end_tmp = command_end; + std::string::size_type loc_node = command_end_tmp.find("_Node_"); + if (loc_node != std::string::npos) + command_end_tmp.insert(loc_node+5, proc_number); + command += command_begin + command_remote + command_tmp + command_end_tmp; + vect_machine.push_back(hostname); } if (machine_file) - delete machine_file; + delete machine_file; } } else if (parallelLib == "Mpi") @@ -1565,9 +1565,9 @@ SALOME_ContainerManager::BuildCommandToLaunchParallelContainer(const std::string std::string command_remote(""); const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(remote_machine); if (resInfo.Protocol == rsh) - command_remote = "rcp "; + command_remote = "rcp "; else - command_remote = "scp "; + command_remote = "scp "; command_remote += machine_file_name; command_remote += " "; @@ -1580,8 +1580,8 @@ SALOME_ContainerManager::BuildCommandToLaunchParallelContainer(const std::string int status = system(command_remote.c_str()); if (status == -1) { - INFOS("copy of the mpi machine file failed !"); - return ""; + INFOS("copy of the mpi machine file failed !"); + return ""; } } @@ -1590,27 +1590,27 @@ SALOME_ContainerManager::BuildCommandToLaunchParallelContainer(const std::string std::string command_remote(""); if (remote) { - // We want to launch a command like : - // ssh user@machine distantPath/runRemote.sh hostNS portNS - const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(remote_machine); - if (resInfo.Protocol == rsh) - command_remote = "rsh "; - else - command_remote = "ssh "; - command_remote += resInfo.UserName; - command_remote += "@"; - command_remote += remote_machine; - command_remote += " "; - command_remote += resInfo.AppliPath; // path relative to user@machine $HOME - command_remote += "/runRemote.sh "; - ASSERT(getenv("NSHOST")); - command_remote += getenv("NSHOST"); // hostname of CORBA name server - command_remote += " "; - ASSERT(getenv("NSPORT")); - command_remote += getenv("NSPORT"); // port of CORBA name server - command_remote += " "; - - hostname = remote_machine; + // We want to launch a command like : + // ssh user@machine distantPath/runRemote.sh hostNS portNS + const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(remote_machine); + if (resInfo.Protocol == rsh) + command_remote = "rsh "; + else + command_remote = "ssh "; + command_remote += resInfo.UserName; + command_remote += "@"; + command_remote += remote_machine; + command_remote += " "; + command_remote += resInfo.AppliPath; // path relative to user@machine $HOME + command_remote += "/runRemote.sh "; + ASSERT(getenv("NSHOST")); + command_remote += getenv("NSHOST"); // hostname of CORBA name server + command_remote += " "; + ASSERT(getenv("NSPORT")); + command_remote += getenv("NSPORT"); // port of CORBA name server + command_remote += " "; + + hostname = remote_machine; } // We use Dummy proxy for MPI parallel containers @@ -1631,61 +1631,61 @@ SALOME_ContainerManager::BuildCommandToLaunchParallelContainer(const std::string std::string command_remote(""); if (remote) { - const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(remote_machine); - if (resInfo.Protocol == rsh) - command_remote = "rsh "; - else - command_remote = "ssh "; - command_remote += resInfo.UserName; - command_remote += "@"; - command_remote += remote_machine; - command_remote += " "; - - std::string new_real_exe_name(""); - new_real_exe_name += resInfo.AppliPath; // path relative to user@machine $HOME - new_real_exe_name += "/runRemote.sh "; - ASSERT(getenv("NSHOST")); - new_real_exe_name += getenv("NSHOST"); // hostname of CORBA name server - new_real_exe_name += " "; - ASSERT(getenv("NSPORT")); - new_real_exe_name += getenv("NSPORT"); // port of CORBA name server - new_real_exe_name += " "; - - real_exe_name = new_real_exe_name + real_exe_name; - hostname = remote_machine; + const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(remote_machine); + if (resInfo.Protocol == rsh) + command_remote = "rsh "; + else + command_remote = "ssh "; + command_remote += resInfo.UserName; + command_remote += "@"; + command_remote += remote_machine; + command_remote += " "; + + std::string new_real_exe_name(""); + new_real_exe_name += resInfo.AppliPath; // path relative to user@machine $HOME + new_real_exe_name += "/runRemote.sh "; + ASSERT(getenv("NSHOST")); + new_real_exe_name += getenv("NSHOST"); // hostname of CORBA name server + new_real_exe_name += " "; + ASSERT(getenv("NSPORT")); + new_real_exe_name += getenv("NSPORT"); // port of CORBA name server + new_real_exe_name += " "; + + real_exe_name = new_real_exe_name + real_exe_name; + hostname = remote_machine; } const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(hostname); if (resInfo.mpi == lam) { - command = "mpiexec -ssi boot "; - if (resInfo.Protocol == rsh) - command += "rsh "; - else - command += "ssh "; - command += "-machinefile " + machine_file_name + " "; - command += "-n " + nbproc + " "; - command += real_exe_name; - command += " " + _NS->ContainerName(rtn); - command += " " + parallelLib; - command += " " + proxy_hostname; - command += " -"; - AddOmninamesParams(command); + command = "mpiexec -ssi boot "; + if (resInfo.Protocol == rsh) + command += "rsh "; + else + command += "ssh "; + command += "-machinefile " + machine_file_name + " "; + command += "-n " + nbproc + " "; + command += real_exe_name; + command += " " + _NS->ContainerName(rtn); + command += " " + parallelLib; + command += " " + proxy_hostname; + command += " -"; + AddOmninamesParams(command); } else { - command = "mpirun -np " + nbproc + " "; - command += real_exe_name; - command += " " + _NS->ContainerName(rtn); - command += " " + parallelLib; - command += " " + proxy_hostname; - command += " -"; - AddOmninamesParams(command); + command = "mpirun -np " + nbproc + " "; + command += real_exe_name; + command += " " + _NS->ContainerName(rtn); + command += " " + parallelLib; + command += " " + proxy_hostname; + command += " -"; + AddOmninamesParams(command); } command = command_begin + command_remote + command + command_end; for (int i= 0; i < nb_nodes; i++) - vect_machine.push_back(proxy_hostname); + vect_machine.push_back(proxy_hostname); } } else diff --git a/src/Container/SALOME_ContainerManager.hxx b/src/Container/SALOME_ContainerManager.hxx index d5f4b2b2d..e401de3be 100644 --- a/src/Container/SALOME_ContainerManager.hxx +++ b/src/Container/SALOME_ContainerManager.hxx @@ -77,14 +77,14 @@ protected: void fillBatchLaunchedContainers(); std::string BuildCommandToLaunchRemoteContainer(const std::string& machine, - const Engines::MachineParameters& params, - const std::string& container_exe="SALOME_Container"); + const Engines::MachineParameters& params, + const std::string& container_exe="SALOME_Container"); std::string BuildCommandToLaunchLocalContainer(const Engines::MachineParameters& params, const std::string& container_exe="SALOME_Container"); std::string BuildTempFileToLaunchRemoteContainer(const std::string& machine, - const Engines::MachineParameters& params) throw(SALOME_Exception); + const Engines::MachineParameters& params) throw(SALOME_Exception); void RmTmpFile(std::string& tmpFile); @@ -99,14 +99,14 @@ protected: // For PacO++ Parallel extension typedef std::vector actual_launch_machine_t; std::string BuildCommandToLaunchParallelContainer(const std::string& exe_name, - const Engines::MachineParameters& params, - SALOME_ContainerManager::actual_launch_machine_t & vect_machine, - const std::string proxy_hostname = ""); + const Engines::MachineParameters& params, + SALOME_ContainerManager::actual_launch_machine_t & vect_machine, + const std::string proxy_hostname = ""); CORBA::Object_ptr LaunchParallelContainer(const std::string& command, - const Engines::MachineParameters& params, - const std::string& name, - SALOME_ContainerManager::actual_launch_machine_t & vect_machine); + const Engines::MachineParameters& params, + const std::string& name, + SALOME_ContainerManager::actual_launch_machine_t & vect_machine); CORBA::ORB_var _orb; PortableServer::POA_var _poa; diff --git a/src/Container/SALOME_ContainerPy.py b/src/Container/SALOME_ContainerPy.py index 955a1d8d9..2e3d893eb 100755 --- a/src/Container/SALOME_ContainerPy.py +++ b/src/Container/SALOME_ContainerPy.py @@ -42,7 +42,7 @@ from launchConfigureParser import verbose #============================================================================= -#define an implementation of the container interface +#define an implementation of the container interface for the container implemented in Python class SALOME_ContainerPy_i (Engines__POA.Container): _orb = None @@ -58,7 +58,6 @@ class SALOME_ContainerPy_i (Engines__POA.Container): self._poa = poa myMachine=getShortHostName() Container_path = "/Containers/" + myMachine + "/" + containerName - #self._containerName = containerName self._containerName = Container_path if verbose(): print "container name ",self._containerName @@ -174,10 +173,9 @@ class SALOME_ContainerPy_i (Engines__POA.Container): if verbose(): print "import ",componentName," successful" ret=1 except: - if verbose(): - import traceback - traceback.print_exc() - print "import ",componentName," not possible" + import traceback + traceback.print_exc() + print "import ",componentName," not possible" return ret #------------------------------------------------------------------------- @@ -187,24 +185,6 @@ class SALOME_ContainerPy_i (Engines__POA.Container): ret = 0 instanceName = componentName + "_inst_" + `self._numInstance` interfaceName = componentName - #the_command = "import " + componentName + "\n" - #the_command = the_command + "comp_i = " + componentName + "." + componentName - #the_command = the_command + "(self._orb, self._poa, self._this(), self._containerName, instanceName, interfaceName)\n" - #MESSAGE( "SALOME_ContainerPy_i::load_component_Library :" + str (the_command) ) - #exec the_command - #comp_o = comp_i._this() - #if comp_o is not None: - # ret = 1 - #else: - # --- try to import Python component - # retImpl = self.import_component(componentName) - # if retImpl == 1: - #import is possible - # ret = 1 - # else: - #import isn't possible - # ret = 0 - #return ret return self.import_component(componentName) #------------------------------------------------------------------------- diff --git a/src/Container/SALOME_Container_i.hxx b/src/Container/SALOME_Container_i.hxx index 9dae83fb6..e45b939e6 100644 --- a/src/Container/SALOME_Container_i.hxx +++ b/src/Container/SALOME_Container_i.hxx @@ -53,11 +53,11 @@ class CONTAINER_EXPORT Engines_Container_i: public: Engines_Container_i(); Engines_Container_i(CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - char * containerName , + PortableServer::POA_ptr poa, + char * containerName , int argc, char* argv[], - bool activAndRegist = true, - bool isServantAloneInProcess = true); + bool activAndRegist = true, + bool isServantAloneInProcess = true); virtual ~Engines_Container_i(); // --- CORBA methods @@ -66,15 +66,15 @@ public: virtual Engines::Component_ptr create_component_instance( const char* componentName, - CORBA::Long studyId); // 0 for multiStudy + CORBA::Long studyId); // 0 for multiStudy Engines::Component_ptr find_component_instance( const char* registeredName, - CORBA::Long studyId); // 0 for multiStudy + CORBA::Long studyId); // 0 for multiStudy Engines::Component_ptr load_impl(const char* nameToRegister, - const char* componentName); + const char* componentName); void remove_impl(Engines::Component_ptr component_i); @@ -101,12 +101,12 @@ public: Engines::Component_ptr find_or_create_instance( std::string genericRegisterName, - std::string componentLibraryName); + std::string componentLibraryName); Engines::Component_ptr createInstance(std::string genericRegisterName, - void *handle, - int studyId); + void *handle, + int studyId); static bool isPythonContainer(const char* ContainerName); static void decInstanceCnt(std::string genericRegisterName); diff --git a/src/Container/SALOME_FileRef_i.cxx b/src/Container/SALOME_FileRef_i.cxx index 62c06dbcb..f4b670be7 100644 --- a/src/Container/SALOME_FileRef_i.cxx +++ b/src/Container/SALOME_FileRef_i.cxx @@ -48,7 +48,7 @@ fileRef_i::fileRef_i() //============================================================================= fileRef_i::fileRef_i(Engines::Container_ptr container, - const char* origFileName) + const char* origFileName) { MESSAGE("fileRef_i::fileRef_i "<< origFileName); _container = Engines::Container::_duplicate(container); @@ -126,7 +126,7 @@ Engines::Container_ptr fileRef_i::getContainer() //============================================================================= CORBA::Boolean fileRef_i::addRef(const char* machine, - const char* fileName) + const char* fileName) { MESSAGE("fileRef_i::addRef " << machine << " " << fileName); string theMachine = machine; @@ -147,7 +147,7 @@ CORBA::Boolean fileRef_i::addRef(const char* machine, if (! _copies[theMachine].empty()) { INFOS("there is already a copy on " << theMachine << " under the path " - << _copies[theMachine] << " new ref not added! "); + << _copies[theMachine] << " new ref not added! "); return 0; } @@ -173,12 +173,12 @@ char* fileRef_i::getRef(const char* machine) if (_copies[theMachine].empty()) { MESSAGE("no copy of " << _machine << _origFileName << " available on " - << theMachine); + << theMachine); } else { MESSAGE("a copy of " << _machine << _origFileName << "is available on " - << theMachine << _copies[theMachine]); + << theMachine << _copies[theMachine]); } return CORBA::string_dup(_copies[theMachine].c_str()); } diff --git a/src/Container/SALOME_FileRef_i.hxx b/src/Container/SALOME_FileRef_i.hxx index 357473bf6..53266d217 100644 --- a/src/Container/SALOME_FileRef_i.hxx +++ b/src/Container/SALOME_FileRef_i.hxx @@ -42,7 +42,7 @@ class CONTAINER_EXPORT fileRef_i: public: fileRef_i(); fileRef_i(Engines::Container_ptr container, - const char* origFileName); + const char* origFileName); virtual ~fileRef_i(); char* origFileName(); @@ -52,7 +52,7 @@ public: Engines::Container_ptr getContainer(); CORBA::Boolean addRef(const char* machine, - const char* fileName); + const char* fileName); char* getRef(const char* machine); diff --git a/src/Container/Salome_file_i.cxx b/src/Container/Salome_file_i.cxx index 567fd1dc5..25949f9fc 100644 --- a/src/Container/Salome_file_i.cxx +++ b/src/Container/Salome_file_i.cxx @@ -175,66 +175,66 @@ Salome_file_i::load(const char* hdf5_file) { if (mode == "all") { - // Changing path, is now current directory - path = getcwd(NULL, _path_max); + // Changing path, is now current directory + path = getcwd(NULL, _path_max); - std::string group_name("GROUP"); - group_name += file_name; - hdf_group = new HDFgroup(group_name.c_str(),hdf_file); - hdf_group->OpenOnDisk(); - hdf_dataset = new HDFdataset("FILE DATASET",hdf_group); - hdf_dataset->OpenOnDisk(); - size = hdf_dataset->GetSize(); - buffer = new char[size]; + std::string group_name("GROUP"); + group_name += file_name; + hdf_group = new HDFgroup(group_name.c_str(),hdf_file); + hdf_group->OpenOnDisk(); + hdf_dataset = new HDFdataset("FILE DATASET",hdf_group); + hdf_dataset->OpenOnDisk(); + size = hdf_dataset->GetSize(); + buffer = new char[size]; - if ( (fd = ::open(file_name.c_str(),O_RDWR|O_CREAT,00666)) <0) { - SALOME::ExceptionStruct es; - es.type = SALOME::INTERNAL_ERROR; - std::string text = "open failed"; - es.text = CORBA::string_dup(text.c_str()); - throw SALOME::SALOME_Exception(es); - }; - hdf_dataset->ReadFromDisk(buffer); - if ( write(fd,buffer,size) <0) { - SALOME::ExceptionStruct es; - es.type = SALOME::INTERNAL_ERROR; - std::string text = "write failed"; - es.text = CORBA::string_dup(text.c_str()); - throw SALOME::SALOME_Exception(es); - }; - // Close the target file - ::close(fd); - - Engines::file infos; - infos.file_name = CORBA::string_dup(file_name.c_str()); - infos.path = CORBA::string_dup(path.c_str()); - infos.type = CORBA::string_dup(type.c_str()); - infos.source_file_name = CORBA::string_dup(source_file_name.c_str()); - infos.status = CORBA::string_dup(status.c_str()); - - _fileManaged[file_name] = infos; - - // Update Salome_file state - _state.number_of_files++; - _state.files_ok = true; + if ( (fd = ::open(file_name.c_str(),O_RDWR|O_CREAT,00666)) <0) { + SALOME::ExceptionStruct es; + es.type = SALOME::INTERNAL_ERROR; + std::string text = "open failed"; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + }; + hdf_dataset->ReadFromDisk(buffer); + if ( write(fd,buffer,size) <0) { + SALOME::ExceptionStruct es; + es.type = SALOME::INTERNAL_ERROR; + std::string text = "write failed"; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + }; + // Close the target file + ::close(fd); + + Engines::file infos; + infos.file_name = CORBA::string_dup(file_name.c_str()); + infos.path = CORBA::string_dup(path.c_str()); + infos.type = CORBA::string_dup(type.c_str()); + infos.source_file_name = CORBA::string_dup(source_file_name.c_str()); + infos.status = CORBA::string_dup(status.c_str()); + + _fileManaged[file_name] = infos; + + // Update Salome_file state + _state.number_of_files++; + _state.files_ok = true; } else { - Engines::file infos; - infos.file_name = CORBA::string_dup(file_name.c_str()); - infos.path = CORBA::string_dup(path.c_str()); - infos.type = CORBA::string_dup(type.c_str()); - infos.source_file_name = CORBA::string_dup(source_file_name.c_str()); - infos.status = CORBA::string_dup(status.c_str()); - // Infos for parallel extensions... - infos.node = 0; - infos.container = Engines::Container::_duplicate(_container); - - _fileManaged[file_name] = infos; - - // Update Salome_file state - _state.number_of_files++; - if (status != "ok") - _state.files_ok = false; + Engines::file infos; + infos.file_name = CORBA::string_dup(file_name.c_str()); + infos.path = CORBA::string_dup(path.c_str()); + infos.type = CORBA::string_dup(type.c_str()); + infos.source_file_name = CORBA::string_dup(source_file_name.c_str()); + infos.status = CORBA::string_dup(status.c_str()); + // Infos for parallel extensions... + infos.node = 0; + infos.container = Engines::Container::_duplicate(_container); + + _fileManaged[file_name] = infos; + + // Update Salome_file state + _state.number_of_files++; + if (status != "ok") + _state.files_ok = false; } } } @@ -631,7 +631,7 @@ Salome_file_i::connect(Engines::Salome_file_ptr source_Salome_file) _t_fileDistributedSource::iterator it = _fileDistributedSource.find(file_name); if (it == _fileDistributedSource.end()) { - _fileDistributedSource[file_name] = Engines::Salome_file::_duplicate(source_Salome_file); + _fileDistributedSource[file_name] = Engines::Salome_file::_duplicate(source_Salome_file); } } } @@ -671,7 +671,7 @@ Salome_file_i::connect(Engines::Salome_file_ptr source_Salome_file) //============================================================================= void Salome_file_i::connectDistributedFile(const char * file_name, - Engines::Salome_file_ptr source_Salome_file) + Engines::Salome_file_ptr source_Salome_file) { // Test if this file is added _t_fileManaged::iterator it = _fileManaged.find(file_name); @@ -697,7 +697,7 @@ Salome_file_i::connectDistributedFile(const char * file_name, //============================================================================= void Salome_file_i::setDistributedSourceFile(const char* file_name, - const char * source_file_name) + const char * source_file_name) { std::string fname(file_name); @@ -738,12 +738,12 @@ Salome_file_i::recvFiles() { if (std::string(file_infos.type.in()) == "local") { if (std::string(file_infos.status.in()) == "not_ok") - result = checkLocalFile(file_infos.file_name.in()); + result = checkLocalFile(file_infos.file_name.in()); } else { if (std::string(file_infos.status.in()) == "not_ok") - result = getDistributedFile(file_infos.file_name.in()); + result = getDistributedFile(file_infos.file_name.in()); } // if the result is false // we add this file to files_not_ok diff --git a/src/Container/Salome_file_i.hxx b/src/Container/Salome_file_i.hxx index d92ab4f4c..d493dc089 100644 --- a/src/Container/Salome_file_i.hxx +++ b/src/Container/Salome_file_i.hxx @@ -58,9 +58,9 @@ class CONTAINER_EXPORT Salome_file_i: // Configure DistributedFile virtual void connect(Engines::Salome_file_ptr source_Salome_file); virtual void connectDistributedFile(const char * file_name, - Engines::Salome_file_ptr source_Salome_file); + Engines::Salome_file_ptr source_Salome_file); virtual void setDistributedSourceFile(const char* file_name, - const char * source_file_name); + const char * source_file_name); // Recv and check files virtual void recvFiles(); diff --git a/src/MPIContainer/MPIContainer_i.cxx b/src/MPIContainer/MPIContainer_i.cxx index b486c65c5..b127d2a32 100644 --- a/src/MPIContainer/MPIContainer_i.cxx +++ b/src/MPIContainer/MPIContainer_i.cxx @@ -193,11 +193,11 @@ bool Engines_MPIContainer_i::Lload_component_Library(const char* componentName) PyObject *result = PyObject_CallMethod(pyCont, (char*)"import_component", (char*)"s",componentName); - int ret= PyInt_AsLong(result); + std::string ret= PyString_AsString(result); SCRUTE(ret); Py_RELEASE_NEW_THREAD; - if (ret) // import possible: Python component + if (ret=="") // import possible: Python component { _library_map[aCompName] = (void *)pyCont; // any non O value OK MESSAGE("[" << _numproc << "] import Python: "<