From: secher Date: Tue, 24 May 2005 11:59:53 +0000 (+0000) Subject: manage MPI containers in resources manager X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b0a7fae3bf2f049acd1db0e16b220dc2ba88d80d;p=modules%2Fkernel.git manage MPI containers in resources manager --- diff --git a/Makefile.in b/Makefile.in index 5c92e402e..84ed33f36 100644 --- a/Makefile.in +++ b/Makefile.in @@ -22,7 +22,6 @@ cascade.png \ CatalogDataType.xml \ KERNELCatalog.xml \ CatalogResources.xml \ -CatalogRessources.xml \ close.png \ config \ default.png \ diff --git a/idl/SALOME_ContainerManager.idl b/idl/SALOME_ContainerManager.idl index d8a57247e..cba348c18 100644 --- a/idl/SALOME_ContainerManager.idl +++ b/idl/SALOME_ContainerManager.idl @@ -17,6 +17,7 @@ struct MachineParameters { long cpu_clock; long nb_proc_per_node; long nb_node; + boolean isMPI; }; /*! @@ -29,7 +30,7 @@ struct MachineParameters { */ interface ContainerManager { - Container FindOrStartContainer( in string containerName, in MachineList possibleComputers); + Container FindOrStartContainer( in MachineParameters params, in MachineList possibleComputers); string FindBest(in MachineList possibleComputers); MachineList GetFittingResources( in MachineParameters params, in string componentName ); void Shutdown(); diff --git a/idl/SALOME_MPIContainer.idl b/idl/SALOME_MPIContainer.idl index c23e1c061..8265c7380 100644 --- a/idl/SALOME_MPIContainer.idl +++ b/idl/SALOME_MPIContainer.idl @@ -34,9 +34,6 @@ module Engines // start MPI container executable MPIContainer start_MPIimpl( in string ContainerName, in short nbproc ); - // shutdown corba server - void MPIShutdown() ; - // asynchronous version to load and remove parallel component in parallel oneway void SPload_impl(in string nameToRegister, in string componentName); oneway void SPremove_impl(in Component component_i); diff --git a/resources/CatalogResources.xml b/resources/CatalogResources.xml index 99939a378..985ea9858 100644 --- a/resources/CatalogResources.xml +++ b/resources/CatalogResources.xml @@ -1,8 +1,18 @@ - - - - - - + + + + + + + + + + + + + + + + diff --git a/resources/CatalogRessources.xml b/resources/CatalogRessources.xml deleted file mode 100644 index 2200b4171..000000000 --- a/resources/CatalogRessources.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - eri - Linux - 2.2.14-6.1.1smp - - - 0 - Pentium III (Coppermine) - 860.946775 - 256 - - - 1 - Pentium III (Coppermine) - 860.946775 - 256 - - - - C++ - python - NP - - - - omote - Linux - 2.4.3-12smp - - - 0 - Pentium II (Deschutes) - 398.780 - 512 - - - - C++ - python - - - diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index ff343a2cc..7bde5d8fc 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -407,11 +407,3 @@ string Engines_Component_i::GetDynLibraryName(const char *componentName) return ret; } -string Engines_Component_i::BuildComponentNameForNS(const char *ComponentName, const char *ContainerName, const char *hostname) -{ - string ret=Engines_Container_i::BuildContainerNameForNS(ContainerName,hostname); - ret+="/"; - ret+=ComponentName; - return ret; -} - diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index 2a4257217..919bbf03b 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -53,8 +53,6 @@ char ** _ArgV ; extern "C" {void ActSigIntHandler() ; } extern "C" {void SigIntHandler(int, siginfo_t *, void *) ; } -const char *Engines_Container_i::_defaultContainerName="FactoryServer"; - Engines_Container_i::Engines_Container_i () : _numInstance(0) { @@ -102,8 +100,6 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, SCRUTE(hostname); - _containerName = BuildContainerNameForNS(containerName,hostname.c_str()); - _orb = CORBA::ORB::_duplicate(orb) ; _poa = PortableServer::POA::_duplicate(poa) ; @@ -116,6 +112,8 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, CORBA::Object_var obj=_poa->id_to_reference(*_id); Engines::Container_var pCont = Engines::Container::_narrow(obj); + + _containerName = _NS->BuildContainerNameForNS(containerName,hostname.c_str()); SCRUTE(_containerName); _NS->Register(pCont, _containerName.c_str()); } @@ -353,19 +351,6 @@ bool Engines_Container_i::isPythonContainer(const char* ContainerName) return ret; } -string Engines_Container_i::BuildContainerNameForNS(const char *ContainerName, const char *hostname) -{ - string ret="/Containers/"; - ret += hostname; - ret+="/"; - if (strlen(ContainerName)== 0) - ret+=_defaultContainerName; - else - ret += ContainerName; - return ret; -} - - /* * Create one instance of componentName component and register it * as nameToRegister in naming service diff --git a/src/Container/SALOME_Component_i.hxx b/src/Container/SALOME_Component_i.hxx index 620ca1499..65e0ae77d 100644 --- a/src/Container/SALOME_Component_i.hxx +++ b/src/Container/SALOME_Component_i.hxx @@ -93,7 +93,6 @@ public: CORBA::Long CpuUsed_impl() ; static std::string GetDynLibraryName(const char *componentName); - static std::string BuildComponentNameForNS(const char *ComponentName, const char *ContainerName, const char *hostname); protected: std::string _instanceName ; std::string _interfaceName ; diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 77cebf354..d3b5f53ff 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -14,6 +14,7 @@ const char *SALOME_ContainerManager::_ContainerManagerNameInNS="/ContainerManage SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb) { _NS=new SALOME_NamingService(orb); + _ResManager=new SALOME_ResourcesManager(orb); PortableServer::POA_var root_poa=PortableServer::POA::_the_root_poa(); PortableServer::POAManager_var pman = root_poa->the_POAManager(); PortableServer::POA_var my_poa; @@ -32,6 +33,7 @@ SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb) SALOME_ContainerManager::~SALOME_ContainerManager() { delete _NS; + delete _ResManager; } void SALOME_ContainerManager::Shutdown() @@ -49,6 +51,7 @@ void SALOME_ContainerManager::ShutdownContainers() vector vec=_NS->list_directory_recurs(); for(vector::iterator iter=vec.begin();iter!=vec.end();iter++) { + cerr << "SALOME_ContainerManager::ShutdownContainers : " << (*iter).c_str() << endl; SCRUTE((*iter)); CORBA::Object_var obj=_NS->Resolve((*iter).c_str()); Engines::Container_var cont=Engines::Container::_narrow(obj); @@ -57,21 +60,23 @@ void SALOME_ContainerManager::ShutdownContainers() } } -Engines::Container_ptr SALOME_ContainerManager::FindOrStartContainer(const char *containerName, const Engines::MachineList& possibleComputers) +Engines::Container_ptr SALOME_ContainerManager::FindOrStartContainer(const Engines::MachineParameters& params, const Engines::MachineList& possibleComputers) { - Engines::Container_ptr ret=FindContainer(containerName,possibleComputers); + Engines::Container_ptr ret=FindContainer(params,possibleComputers); if(!CORBA::is_nil(ret)) return ret; // Container doesn't exist try to launch it ... + MESSAGE("Container doesn't exist try to launch it ..."); vector vector; string theMachine=_LoadManager.FindBest(possibleComputers); string command; if(theMachine==GetHostname()) - command=_ResManager.BuildCommandToLaunchLocalContainer(containerName); + command=_ResManager->BuildCommandToLaunchLocalContainer(params); else - command=_ResManager.BuildTempFileToLaunchRemoteContainer(theMachine,containerName); - _ResManager.RmTmpFile(); + command=_ResManager->BuildTempFileToLaunchRemoteContainer(theMachine,params); + _ResManager->RmTmpFile(); int status=system(command.c_str()); + cerr << status << endl; if (status == -1) { MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status -1)"); return Engines::Container::_nil(); @@ -87,7 +92,7 @@ Engines::Container_ptr SALOME_ContainerManager::FindOrStartContainer(const char count-- ; if ( count != 10 ) MESSAGE( count << ". Waiting for FactoryServer on " << theMachine); - string containerNameInNS=BuildContainerNameInNS(containerName,theMachine.c_str()); + string containerNameInNS=_NS->BuildContainerNameForNS(params,theMachine.c_str()); SCRUTE(containerNameInNS); CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str()); ret=Engines::Container::_narrow(obj); @@ -101,7 +106,7 @@ Engines::Container_ptr SALOME_ContainerManager::FindOrStartContainer(const char Engines::MachineList *SALOME_ContainerManager::GetFittingResources(const Engines::MachineParameters& params, const char *componentName) { - vector vec=_ResManager.GetFittingResources(params,componentName); + vector vec=_ResManager->GetFittingResources(params,componentName); Engines::MachineList *ret=new Engines::MachineList; ret->length(vec.size()); for(unsigned int i=0;iBuildContainerNameForNS(params,theMachine)); CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str()); if( !CORBA::is_nil(obj) ) return Engines::Container::_narrow(obj); @@ -128,22 +132,13 @@ Engines::Container_ptr SALOME_ContainerManager::FindContainer(const char *contai return Engines::Container::_nil(); } -Engines::Container_ptr SALOME_ContainerManager::FindContainer(const char *containerName,const Engines::MachineList& possibleComputers) +Engines::Container_ptr SALOME_ContainerManager::FindContainer(const Engines::MachineParameters& params,const Engines::MachineList& possibleComputers) { for(unsigned int i=0;iResolve("/Kernel/ModulCatalog"); - SALOME_ModuleCatalog::ModuleCatalog_var Catalog = - SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ; - try { - path = Catalog->GetPathPrefix( theComputer ); - } - catch (SALOME_ModuleCatalog::NotFound&) { - INFOS("GetPathPrefix(" << theComputer << ") not found!"); - path = "" ; - } - SCRUTE( path ) ; - return CORBA::string_dup( path ) ; -} - -Engines::Container_ptr SALOME_LifeCycleCORBA::FindContainer(const char *containerName) +bool SALOME_LifeCycleCORBA::isMpiContainer(const Engines::MachineParameters& params) throw(IncompatibleComponent) { - ASSERT(_NS != NULL); - string cont ; - if ( strncmp( containerName , "/Containers/" , 12 ) ) { // Compatibility ... - string theComputer ; - string theContainer ; - cont = ContainerName( containerName , &theComputer , &theContainer ) ; - } - else { - cont = containerName ; - } - try { +// MESSAGE(params.container_name) +// if( strstr(params.container_name,"MPI") ){ +// if( !params.isMPI ){ +// cerr << "IncompatibleComponent" << endl; +// throw IncompatibleComponent(); +// } +// return true; +// } +// else{ +// if( params.isMPI ){ +// cerr << "IncompatibleComponent" << endl; +// throw IncompatibleComponent(); +// } +// return false; +// } + if( params.isMPI ) + return true; + else + return false; - SCRUTE( cont ); +} - CORBA::Object_var obj = _NS->Resolve( cont.c_str() ); - if( !CORBA::is_nil( obj ) ) { - return Engines::Container::_narrow( obj ) ; - } - } - catch (ServiceUnreachable&) { - INFOS("Caught exception: Naming Service Unreachable"); - } - catch (...) { - INFOS("Caught unknown exception."); - } - return Engines::Container::_nil(); +int SALOME_LifeCycleCORBA::NbProc(const Engines::MachineParameters& params) +{ + if( !isMpiContainer(params) ) + return 0; + else if( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) ) + return 1; + else if( params.nb_node == 0 ) + return params.nb_proc_per_node; + else if( params.nb_proc_per_node == 0 ) + return params.nb_node; + else + return params.nb_node * params.nb_proc_per_node; } Engines::Component_ptr SALOME_LifeCycleCORBA::FindOrLoad_Component (const char *containerName, const char *componentName) { + // Check if Component Name is known if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); + + // Chack if containerName contains machine name (if yes: rg>0) char *stContainer=strdup(containerName); string st2Container(stContainer); int rg=st2Container.find("/"); - if(rg>=0) - { - stContainer[rg]='\0'; - if(strcmp(stContainer,"localhost")==0) - { - Engines::Component_ptr ret=FindOrLoad_Component(stContainer+rg+1,componentName); - free(stContainer); - return ret; - } - } + + Engines::MachineParameters_var params=new Engines::MachineParameters; if(rg<0) { - //containerName doesn't contain "/" => Local container - free(stContainer); - Engines::MachineList_var listOfMachine=new Engines::MachineList; - listOfMachine->length(1); - listOfMachine[0]=CORBA::string_dup(GetHostname().c_str()); - Engines::Component_ptr ret=FindComponent(containerName,componentName,listOfMachine.in()); - if(CORBA::is_nil(ret)) - return LoadComponent(containerName,componentName,listOfMachine); - else - return ret; + params->container_name=CORBA::string_dup(stContainer); + params->hostname=CORBA::string_dup(GetHostname().c_str()); } else { - //containerName contains "/" => Remote container stContainer[rg]='\0'; - Engines::MachineParameters_var params=new Engines::MachineParameters; params->container_name=CORBA::string_dup(stContainer+rg+1); params->hostname=CORBA::string_dup(stContainer); - params->OS=CORBA::string_dup("LINUX"); - free(stContainer); - return FindOrLoad_Component(params,componentName); } + free(stContainer); + return FindOrLoad_Component(params,componentName); + } -Engines::Component_ptr SALOME_LifeCycleCORBA::FindOrLoad_Component(const Engines::MachineParameters& params, - const char *componentName) +Engines::Component_ptr SALOME_LifeCycleCORBA::FindOrLoad_Component(const Engines::MachineParameters& params, const char *componentName) { if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); + Engines::MachineList_var listOfMachine=_ContManager->GetFittingResources(params,componentName); - Engines::Component_ptr ret=FindComponent(params.container_name,componentName,listOfMachine); + Engines::Component_ptr ret=FindComponent(params,componentName,listOfMachine); if(CORBA::is_nil(ret)) - return LoadComponent(params.container_name,componentName,listOfMachine); + return LoadComponent(params,componentName,listOfMachine); else return ret; } -Engines::Component_ptr SALOME_LifeCycleCORBA::FindComponent(const char *containerName, - const char *componentName, - const Engines::MachineList& listOfMachines) +Engines::Component_ptr SALOME_LifeCycleCORBA::FindComponent(const Engines::MachineParameters& params, const char *componentName, const Engines::MachineList& listOfMachines) { + const char *containerName = params.container_name; + int nbproc = NbProc(params); + cerr << nbproc << endl;; + if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); - if(containerName[0]!='\0') - { - Engines::MachineList_var machinesOK=new Engines::MachineList; - unsigned int lghtOfmachinesOK=0; - machinesOK->length(listOfMachines.length()); - for(unsigned int i=0;iResolve(componentNameForNS.c_str()); - if(!CORBA::is_nil(obj)) - { - machinesOK[lghtOfmachinesOK++]=CORBA::string_dup(currentMachine); - } - } - if(lghtOfmachinesOK!=0) - { - machinesOK->length(lghtOfmachinesOK); - CORBA::String_var bestMachine=_ContManager->FindBest(machinesOK); - string componentNameForNS=Engines_Component_i::BuildComponentNameForNS(componentName,containerName,bestMachine); - CORBA::Object_var obj=_NS->Resolve(componentNameForNS.c_str()); - return Engines::Component::_narrow(obj); - } - else - return Engines::Component::_nil(); - } + + // find list of machines which have component + Engines::MachineList_var machinesOK=new Engines::MachineList; + unsigned int lghtOfmachinesOK=0; + machinesOK->length(listOfMachines.length()); + for(unsigned int i=0;iResolveComponent(currentMachine,containerName,componentName,nbproc); + if(!CORBA::is_nil(obj)) + machinesOK[lghtOfmachinesOK++]=CORBA::string_dup(currentMachine); + } + + // find the best machine among the list which have component + if(lghtOfmachinesOK!=0) { + machinesOK->length(lghtOfmachinesOK); + CORBA::String_var bestMachine=_ContManager->FindBest(machinesOK); + CORBA::Object_var obj = _NS->ResolveComponent(bestMachine,containerName,componentName,nbproc); + return Engines::Component::_narrow(obj); + } else - { - //user specified no container name so trying to find a component in the best machine among listOfMachines - CORBA::String_var bestMachine=_ContManager->FindBest(listOfMachines); - //Normally look at all containers launched on bestMachine to see if componentName is already launched on one of them. To do.. - string componentNameForNS=Engines_Component_i::BuildComponentNameForNS(componentName,containerName,bestMachine); - CORBA::Object_var obj = _NS->Resolve(componentNameForNS.c_str()); - return Engines::Component::_narrow(obj); - } + return Engines::Component::_nil(); } -Engines::Component_ptr SALOME_LifeCycleCORBA::LoadComponent(const char *containerName, const char *componentName, const Engines::MachineList& listOfMachines) +Engines::Component_ptr SALOME_LifeCycleCORBA::LoadComponent(const Engines::MachineParameters& params, const char *componentName, const Engines::MachineList& listOfMachines) { - Engines::Container_var cont=_ContManager->FindOrStartContainer(containerName,listOfMachines); + Engines::Container_var cont=_ContManager->FindOrStartContainer(params,listOfMachines); string implementation=Engines_Component_i::GetDynLibraryName(componentName); return cont->load_impl(componentName, implementation.c_str()); } - - -Engines::Container_ptr SALOME_LifeCycleCORBA::FindOrStartContainer( - const string aComputerContainer , - const string theComputer , - const string theContainer ) { - SCRUTE( aComputerContainer ) ; - SCRUTE( theComputer ) ; - SCRUTE( theContainer ) ; - - Engines::Container_var aContainer = FindContainer( aComputerContainer.c_str() ) ; - - if ( !CORBA::is_nil( aContainer ) ) { - return aContainer ; - } - - Engines::Container_var aFactoryServer ; - - bool pyCont = false ; - int len = theContainer.length() ; - if ( !strcmp( &theContainer.c_str()[len-2] , "Py" ) ) { - pyCont = true ; - } - - string addr=_NS->getIORaddr(); - string CMD="SALOME_Container"; - if ( pyCont ) { - CMD="SALOME_ContainerPy.py"; - } - CMD=CMD + " " + theContainer; - CMD=CMD + " -ORBInitRef NameService="+addr; - - /* - * Get the appropriate launcher and ask to launch - */ - PyObject * launcher=getLauncher((char *)theComputer.c_str()); - Launcher_Slaunch(launcher,(char *)theComputer.c_str(),(char *)CMD.c_str()); - /* - * Wait until the container is registered in Naming Service - */ - int count = 5 ; - while ( CORBA::is_nil( aFactoryServer ) && count ) { - sleep( 1 ) ; - count-- ; - if ( count != 10 ) - MESSAGE( count << ". Waiting for FactoryServer on " << theComputer) - aFactoryServer = FindContainer( aComputerContainer.c_str() ) ; - } - if ( !CORBA::is_nil( aFactoryServer ) ) { - return aFactoryServer; - } - MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed") ; - return Engines::Container::_nil(); -} diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx index ca91a238f..146ca4419 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx @@ -39,37 +39,35 @@ class SALOME_NamingService; +class IncompatibleComponent : public SALOME_Exception +{ +public : + IncompatibleComponent( void ); + IncompatibleComponent( const IncompatibleComponent &ex ); +} ; + class SALOME_LifeCycleCORBA { public: SALOME_LifeCycleCORBA(SALOME_NamingService *ns); virtual ~SALOME_LifeCycleCORBA(); - Engines::Container_ptr FindContainer(const char *containerName); // for supervision Engines::Component_ptr FindOrLoad_Component(const Engines::MachineParameters& params, const char *componentName); Engines::Component_ptr FindOrLoad_Component(const char *containerName, const char *componentName); - bool isKnownComponentClass(const char *componentName); protected: + bool isKnownComponentClass(const char *componentName); + bool isMpiContainer(const Engines::MachineParameters& params) throw(IncompatibleComponent); + int NbProc(const Engines::MachineParameters& params); //! Establish if a component called "componentName" in a container called "containerName" exists among the list of resources //! in "listOfMachines". This method uses Naming Service to find the component. - Engines::Component_ptr FindComponent(const char *containerName, - const char *componentName, - const Engines::MachineList& listOfMachines); + Engines::Component_ptr FindComponent(const Engines::MachineParameters& params, const char *componentName, const Engines::MachineList& listOfMachines); - Engines::Component_ptr LoadComponent(const char *containerName, const char *componentName, const Engines::MachineList& listOfMachines); + Engines::Component_ptr LoadComponent(const Engines::MachineParameters& params, const char *componentName, const Engines::MachineList& listOfMachines); SALOME_NamingService *_NS; Engines::ContainerManager_var _ContManager; - //private: - std::string ContainerName( const char * aComputerContainer , - std::string * theComputer , - std::string * theContainer ) ; - std::string ComputerPath( const char * theComputer ) ; - Engines::Container_ptr FindOrStartContainer(const std::string aComputerContainer , - const std::string theComputer , - const std::string theContainer ) ; } ; #endif diff --git a/src/MPIContainer/MPIContainer_i.cxx b/src/MPIContainer/MPIContainer_i.cxx index c190fa2bb..f95236226 100644 --- a/src/MPIContainer/MPIContainer_i.cxx +++ b/src/MPIContainer/MPIContainer_i.cxx @@ -44,18 +44,21 @@ Engines_MPIContainer_i::Engines_MPIContainer_i(int nbproc, int numproc, { MESSAGE("[" << numproc << "] activate object"); _id = _poa->activate_object(this); - this->_add_ref(); +// this->_add_ref(); if(numproc==0){ - // _NS = new SALOME_NamingService(_orb); - _NS = SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - _NS->init_orb( orb ) ; + _NS = new SALOME_NamingService(); +// _NS = SINGLETON_::Instance() ; +// ASSERT(SINGLETON_::IsAlreadyExisting()) ; + _NS->init_orb( CORBA::ORB::_duplicate(_orb) ) ; // Engines::Container_ptr pCont // = Engines::Container::_narrow(POA_Engines::MPIContainer::_this()); - Engines::Container_ptr pCont = Engines::Container::_narrow(_poa->id_to_reference(*_id)); + CORBA::Object_var obj=_poa->id_to_reference(*_id); + Engines::Container_var pCont = Engines::Container::_narrow(obj); + string hostname = GetHostname(); + _containerName = _NS->BuildContainerNameForNS(containerName,hostname.c_str()); SCRUTE(_containerName); _NS->Register(pCont, _containerName.c_str()); } @@ -388,16 +391,17 @@ void Engines_MPIContainer_i::Lfinalize_removal() } // Load component -void Engines_MPIContainer_i::MPIShutdown() +void Engines_MPIContainer_i::Shutdown() { int ip; - MESSAGE("[" << _numproc << "] shutdown of Corba Server"); + MESSAGE("[" << _numproc << "] shutdown of MPI Corba Server"); if( _numproc == 0 ){ + MESSAGE("[" << _numproc << "] destroy from Naming Service of " << _containerName); + _NS->Destroy_Name(_containerName.c_str()); for(ip= 1;ip<_nbproc;ip++) (Engines::MPIContainer::_narrow((*_tior)[ip]))->Shutdown(); } - - Shutdown(); + _orb->shutdown(0); } diff --git a/src/MPIContainer/MPIContainer_i.hxx b/src/MPIContainer/MPIContainer_i.hxx index a971b7f20..d58aef574 100644 --- a/src/MPIContainer/MPIContainer_i.hxx +++ b/src/MPIContainer/MPIContainer_i.hxx @@ -57,7 +57,7 @@ class Engines_MPIContainer_i : public POA_Engines::MPIContainer, Engines::Component_ptr load_impl(const char* nameToRegister, const char* componentName); // shutdown corba server - void MPIShutdown(); + void Shutdown(); // asynchronous version for other process void SPload_impl(const char* nameToRegister, const char* componentName); diff --git a/src/MPIContainer/SALOME_MPIContainer.cxx b/src/MPIContainer/SALOME_MPIContainer.cxx index 52152364e..1d74a218b 100644 --- a/src/MPIContainer/SALOME_MPIContainer.cxx +++ b/src/MPIContainer/SALOME_MPIContainer.cxx @@ -4,13 +4,12 @@ #include "Utils_SINGLETON.hxx" #include "utilities.h" #include -#include "LocalTraceCollector.hxx" +#include "SALOMETraceCollector.hxx" using namespace std; int main(int argc, char* argv[]) { int nbproc, numproc; - int flag; Engines_MPIContainer_i * myContainer=NULL; MPI_Init(&argc,&argv); @@ -20,7 +19,7 @@ int main(int argc, char* argv[]) // Initialise the ORB. ORB_INIT &init = *SINGLETON_::Instance() ; CORBA::ORB_var &orb = init( argc , argv ) ; - LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb); + SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); BEGIN_OF("[" << numproc << "] " << argv[0]) try { @@ -69,7 +68,6 @@ int main(int argc, char* argv[]) pman->activate(); orb->run(); - orb->destroy(); } catch(CORBA::SystemException&){ @@ -90,12 +88,11 @@ int main(int argc, char* argv[]) if(myContainer) delete myContainer; - MPI_Initialized(&flag); - if(flag) - MPI_Finalize(); END_OF("[" << numproc << "] " << argv[0]); delete myThreadTrace; - return 0 ; + + MPI_Finalize(); + } diff --git a/src/MPILifeCycleCORBA/MPILifeCycleCORBA.py b/src/MPILifeCycleCORBA/MPILifeCycleCORBA.py deleted file mode 100644 index 0b26acfb0..000000000 --- a/src/MPILifeCycleCORBA/MPILifeCycleCORBA.py +++ /dev/null @@ -1,143 +0,0 @@ -#============================================================================== -# File : MPILifeCycleCORBA.py -# Created : ven may 30 08:42:01 CEST 2003 -# Author : Bernard SECHER, CEA -# Project : SALOME -# Copyright : CEA 2003 -# $Header$ -#============================================================================== - -from LifeCycleCORBA import * -from Utils_Identity import getShortHostName - -class MPILifeCycleCORBA(LifeCycleCORBA): - #------------------------------------------------------------------------- - - def __init__(self, orb): - MESSAGE( "MPILifeCycleCORBA::__init__" ) - LifeCycleCORBA.__init__(self, orb) - - #------------------------------------------------------------------------- - - def FindOrStartMPIContainer(self, theComputer , theMPIContainerRoot, nbproc ): - theMPIContainer = theMPIContainerRoot + "_" + str(nbproc) - MESSAGE( "FindOrStartMPIContainer" + theComputer + theMPIContainer ) - aMPIContainer = self.FindContainer( theComputer + "/" + theMPIContainer ) - if aMPIContainer is None : - if (theMPIContainerRoot == "MPIFactoryServer") | (theMPIContainerRoot == "MPIFactoryServerPy") : - if theComputer == getShortHostName() : - rshstr = "" - else : - rshstr = "rsh -n " + theComputer + " " - path = self.ComputerPath( theComputer ) -## if path != "" : -## rshstr = rshstr + path + "/../bin/salome/" -## else : -## rshstr = rshstr + os.getenv( "KERNEL_ROOT_DIR" ) + "/bin/" -# rshstr = rshstr + os.getenv( "PWD" ) + "/" - if theMPIContainerRoot == "MPIFactoryServer" : - rshstr = rshstr + "mpirun -np " + str(nbproc) + " " + path + "SALOME_MPIContainer " - else : - rshstr = rshstr + path + "SALOME_MPIContainerPy.py '" - rshstr = rshstr + theMPIContainer + " -" - omniORBcfg = os.getenv( "OMNIORB_CONFIG" ) -# omniORBcfg = os.getenv( "HOME" ) + "/.omniORB.cfg" - file = os.open( omniORBcfg , os.O_RDONLY ) - ORBInitRef = os.read(file,132) - if ORBInitRef[len(ORBInitRef)-1] == '\n' : - ORBInitRef,bsn = ORBInitRef.split('\n') - os.close( file ) - rshstr = rshstr + ORBInitRef - if theMPIContainerRoot == "MPIFactoryServerPy" : - rshstr = rshstr + "'" - rshstr = rshstr + " > /tmp/" + theMPIContainer + "_" - rshstr = rshstr + theComputer - rshstr = rshstr + ".log 2>&1 &" - os.system( rshstr ) - MESSAGE( "FindOrStartMPIContainer" + rshstr + " done" ) - else : - if theMPIContainer.find('Py') == -1 : - aMPIContainer = self.FindContainer( theComputer + "/" + "MPIFactoryServer_" + str(nbproc) ) - else : - aMPIContainer = self.FindContainer( theComputer + "/" + "MPIFactoryServerPy_" + str(nbproc) ) - aMPIContainer = aMPIContainer.start_impl( theMPIContainer ) - - count = 21 - while aMPIContainer is None : - time.sleep(1) - count = count - 1 - MESSAGE( str(count) + ". Waiting for " + theComputer + "/" + theMPIContainer ) - aMPIContainer = self.FindContainer( theComputer + "/" + theMPIContainer ) - if count == 0 : - return aMPIContainer - - return aMPIContainer - #os.system("rsh -n dm2s0017 /export/home/SALOME_ROOT/bin/runSession SALOME_Container -ORBInitRef NameService=corbaname::dm2s0017:1515") - - #------------------------------------------------------------------------- - - def FindOrLoadMPIComponent(self, MPIcontainerName, MPIcomponentName, nbproc): - - theComputer,theMPIContainerRoot = self.ContainerName( MPIcontainerName ) - theMPIContainer = theMPIContainerRoot + "_" + str(nbproc) - name = [CosNaming.NameComponent(theComputer,"dir"), - CosNaming.NameComponent(theMPIContainer,"dir"), - CosNaming.NameComponent(MPIcomponentName,"object")] - try: - obj = self._containerRootContext.resolve(name) - except CosNaming.NamingContext.NotFound, ex: - MESSAGE( "component " + MPIcomponentName + " not found, trying to load" ) - MPIcontainer = self.FindContainer(theComputer + "/" + theMPIContainer) - if MPIcontainer is None: - MESSAGE( "MPIcontainer " + theComputer + "/" + theMPIContainer + " not found in Naming Service, trying to start" ) - if (theMPIContainerRoot != "MPIFactoryServer") & (theMPIContainerRoot != "MPIFactoryServerPy") : - if theMPIContainer.find('Py') == -1 : - theMPIFactorycontainerRoot = "MPIFactoryServer" - theMPIFactorycontainer = theMPIFactorycontainerRoot + "_" + str(nbproc) - else : - theMPIFactorycontainerRoot = "MPIFactoryServerPy" - theMPIFactorycontainer = theMPIFactorycontainerRoot + "_" + str(nbproc) - MPIFactorycontainer = self.FindContainer(theComputer + "/" + theMPIFactorycontainer) - if MPIFactorycontainer is None: - MESSAGE( "MPIcontainer " + theComputer + "/" + theMPIFactorycontainer + " not found in Naming Service, trying to start" ) - MPIFactorycontainer = self.FindOrStartMPIContainer(theComputer,theMPIFactorycontainerRoot,nbproc) - else: - MPIFactorycontainer = self.FindOrStartMPIContainer(theComputer,theMPIContainerRoot,nbproc) - if MPIFactorycontainer != None : - MPIcontainer = self.FindOrStartMPIContainer(theComputer,theMPIContainerRoot,nbproc) - - if MPIcontainer != None: - compoinfo = self._catalog.GetComponent(MPIcomponentName) - if compoinfo is None: - MESSAGE( "MPIcomponent " + MPIcomponentName + " not found in Module Catalog" ) - else: - try: - machineName = theComputer - path = compoinfo.GetPathPrefix(machineName) + "/" - except SALOME_ModuleCatalog.NotFound, ex: - MESSAGE( "machine " + machineName + " not found in Module Catalog" ) - MESSAGE( "trying localhost" ) - try: - path = compoinfo.GetPathPrefix("localhost") + "/" - except SALOME_ModuleCatalog.NotFound, ex: - path = "" - implementation = path + "lib" + MPIcomponentName + "Engine.so" - MESSAGE( "Trying to load " + implementation ) - try: - MPIcomponent = MPIcontainer.load_impl(MPIcomponentName, implementation) - MESSAGE( "component " + MPIcomponent._get_instanceName() + " launched !" ) - return MPIcomponent - except: - MESSAGE( "component " + MPIcomponentName + " NOT launched !" ) - - else: - try: - MPIcomponent = obj._narrow(Engines.Component) - if MPIcomponent is None: - MESSAGE( MPIcomponentName + " is not a component !" ) - else: - MESSAGE( "MPIcomponent " + MPIcomponent._get_instanceName() + " found !" ) - return MPIcomponent - except: - MESSAGE( MPIcomponentName + " failure" ) - return None diff --git a/src/MPILifeCycleCORBA/MPIsalome.py b/src/MPILifeCycleCORBA/MPIsalome.py deleted file mode 100644 index 789641fd1..000000000 --- a/src/MPILifeCycleCORBA/MPIsalome.py +++ /dev/null @@ -1,5 +0,0 @@ -import salome -from MPILifeCycleCORBA import * - -# create an LifeCycleCORBA instance -lcc = MPILifeCycleCORBA(salome.orb) diff --git a/src/MPILifeCycleCORBA/Makefile.in b/src/MPILifeCycleCORBA/Makefile.in deleted file mode 100644 index ab76b0360..000000000 --- a/src/MPILifeCycleCORBA/Makefile.in +++ /dev/null @@ -1,38 +0,0 @@ -#============================================================================== -# File : Makefile.in -# Created : lun jui 2 20:32:24 CEST 2001 -# Author : Paul RASCLE, EDF - Marc Tajchman, CEA -# Project : SALOME -# Copyright : EDF 2001 -# $Header$ -#============================================================================== - -# source path -top_srcdir=@top_srcdir@ -top_builddir=../.. -srcdir=@srcdir@ -VPATH=.:@srcdir@:@top_srcdir@/idl - - -@COMMENCE@ - -EXPORT_HEADERS = SALOME_MPILifeCycleCORBA.hxx - -EXPORT_PYSCRIPTS = MPIsalome.py MPILifeCycleCORBA.py - -# Libraries targets - -LIB = libSalomeMPILifeCycleCORBA.la -LIB_SRC = SALOME_MPILifeCycleCORBA.cxx -LIB_CLIENT_IDL = SALOME_MPIObject.idl SALOME_MPIContainer.idl \ - SALOME_Component.idl SALOME_ModuleCatalog.idl - -# Executables targets -BIN = TestMPILifeCycleCORBA -BIN_SRC = -BIN_CLIENT_IDL = Logger.idl SALOME_MPIObject.idl SALOME_MPIContainer.idl SALOME_TestMPIComponent.idl - -LDFLAGS += -lSalomeNS -lSalomeLifeCycleCORBA -lOpUtil -lSALOMELocalTrace - -@CONCLUDE@ - diff --git a/src/MPILifeCycleCORBA/SALOME_MPILifeCycleCORBA.cxx b/src/MPILifeCycleCORBA/SALOME_MPILifeCycleCORBA.cxx deleted file mode 100644 index 5dfe13fcb..000000000 --- a/src/MPILifeCycleCORBA/SALOME_MPILifeCycleCORBA.cxx +++ /dev/null @@ -1,357 +0,0 @@ -//============================================================================= -// File : SALOME_MPILifeCycleCORBA.cxx -// Created : mar jui 03 14:55:50 CEST 2003 -// Author : Bernard SECHER CEA -// Project : SALOME -// Copyright : CEA 2003 -// $Header$ -//============================================================================= - -#include -#include -#include -#include -#include -#include - -#include "OpUtil.hxx" -#include "utilities.h" - -#include - -#include "SALOME_MPILifeCycleCORBA.hxx" -#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog) -#include "SALOME_NamingService.hxx" -using namespace std; - -SALOME_MPILifeCycleCORBA::SALOME_MPILifeCycleCORBA() : - SALOME_LifeCycleCORBA() -{ - _MPIFactoryServer = NULL; -} - -SALOME_MPILifeCycleCORBA::SALOME_MPILifeCycleCORBA(SALOME_NamingService *ns) : - SALOME_LifeCycleCORBA(ns) -{ - _MPIFactoryServer = NULL; -} - -SALOME_MPILifeCycleCORBA::~SALOME_MPILifeCycleCORBA() -{ -} - -Engines::MPIContainer_var SALOME_MPILifeCycleCORBA::FindOrStartMPIContainer( - const std::string theComputer , - const std::string theMPIContainerRoot, - const int nbproc) -{ - char nbp[1024]; - - sprintf(nbp,"_%d",nbproc); - std::string theMPIContainer = theMPIContainerRoot + nbp; - std::string aComputerContainer = theComputer + "/" + theMPIContainer; - - SCRUTE( aComputerContainer ) ; - SCRUTE( theComputer ) ; - SCRUTE( theMPIContainer ) ; - - // On recherche si le containe rest deja lance - Engines::MPIContainer_var aMPIContainer = Engines::MPIContainer::_narrow(FindContainer(aComputerContainer.c_str())); - - //On a trouve le container: on renvoie une poigne dessus - if ( !CORBA::is_nil( aMPIContainer ) ) { - MESSAGE("MPIContainer " << aComputerContainer << " found!!!"); - return aMPIContainer ; - } - // On a pas trouve le container - else { - MESSAGE("MPIContainer " << aComputerContainer << " not found!!!"); - // On recherche un container generique - bool pyCont = false ; - int len = theMPIContainer.length() ; - if ( !strcmp( &theMPIContainerRoot.c_str()[len-2] , "Py" ) ) { - pyCont = true ; - } - std::string MPIFactoryServer = theComputer ; - if ( pyCont ) { - MPIFactoryServer += "/MPIFactoryServerPy" ; - } - else { - MPIFactoryServer += "/MPIFactoryServer" ; - } - MPIFactoryServer += nbp; - Engines::MPIContainer_var aMPIFactoryServer = Engines::MPIContainer::_narrow(FindContainer( MPIFactoryServer.c_str())); - - // On n'a pas trouve le container generique: on lance le container demande - if ( CORBA::is_nil( aMPIFactoryServer ) ) { -// rsh -n ikkyo /export/home/rahuel/SALOME_ROOT/bin/runSession SALOME_Container -ORBInitRef NameService=corbaname::dm2s0017:1515 & - std::string rsh( "" ) ; - if ( theComputer!= GetHostname() ) { - rsh += "rsh -n " ; - rsh += theComputer ; - rsh += " " ; - } - std::string path = ComputerPath( theComputer.c_str() ) ; - SCRUTE( path ) ; - // rsh += "runSession " ; - if ( pyCont ) { - MESSAGE("MPI python container not implemented"); - return Engines::MPIContainer::_nil(); -// rsh += "SALOME_MPIContainerPy.py " ; -// rsh += "MPIFactoryServerPy -" ; - } - else { - sprintf(nbp,"mpirun -np %d %sSALOME_MPIContainer ",nbproc,path.c_str()); - rsh += nbp; - rsh += theMPIContainer +" -" ; - } - std::string omniORBcfg( getenv( "OMNIORB_CONFIG" ) ) ; - ifstream omniORBfile( omniORBcfg.c_str() ) ; - char ORBInitRef[12] ; - char nameservice[132] ; - omniORBfile >> ORBInitRef ; - rsh += ORBInitRef ; - rsh += " " ; - omniORBfile >> nameservice ; - omniORBfile.close() ; - char * bsn = strchr( nameservice , '\n' ) ; - if ( bsn ) { - bsn[ 0 ] = '\0' ; - } - rsh += nameservice ; - if ( pyCont ) { - rsh += " > /tmp/MPIFactoryServerPy_" ; - } - else { - rsh += " > /tmp/MPIFactoryServer_" ; - } - sprintf(nbp,"%d_",nbproc); - rsh += nbp; - rsh += theComputer ; - rsh += ".log 2>&1 &" ; - SCRUTE( rsh ); - int status = system( rsh.c_str() ) ; - if (status == -1) { - INFOS("SALOME_MPILifeCycleCORBA::FindOrStartMPIContainer rsh failed (system command status -1)") ; - } - else if (status == 217) { - INFOS("SALOME_MPILifeCycleCORBA::FindOrStartContainer rsh failed (system command status 217)") ; - } - else { - int count = 21 ; - while ( CORBA::is_nil( aMPIFactoryServer ) && count ) { - sleep( 1 ) ; - count-- ; - if ( count != 10 ) - MESSAGE( count << ". Waiting for FactoryServer on " << theComputer) - aMPIFactoryServer = Engines::MPIContainer::_narrow(FindContainer( MPIFactoryServer.c_str())); - } - if ( CORBA::is_nil( aMPIFactoryServer ) ) { - INFOS("SALOME_MPILifeCycleCORBA::FindOrStartMPIContainer rsh failed") ; - } - else if ( strcmp( theComputer.c_str() , GetHostname().c_str() ) ) { - _MPIFactoryServer = aMPIFactoryServer ; - } - } - } - // On a trouve le container generique distant: on se sert de lui - // pour lancer un nouveau container MPI - // a revoir... - if ( !CORBA::is_nil( aMPIFactoryServer ) ) { - if ( strcmp( theMPIContainer.c_str() , "MPIFactoryServer" ) || - strcmp( theMPIContainer.c_str() , "MPIFactoryServerPy" ) ) { - MESSAGE("MPI Container not found ! trying to start " << aComputerContainer); - Engines::MPIContainer_var myMPIContainer = aMPIFactoryServer->start_MPIimpl( theMPIContainer.c_str(), nbproc ) ; - if ( !CORBA::is_nil( myMPIContainer ) ) { - MESSAGE("MPIContainer " << aComputerContainer << " started"); - return myMPIContainer ; - } - else { - MESSAGE("MPIContainer " << aComputerContainer << " NOT started"); - } - } - else { - MESSAGE("MPIContainer " << aComputerContainer << " started"); - return aMPIFactoryServer ; - } - } - } - return Engines::MPIContainer::_nil(); -} - -// Engines::Component_var SALOME_MPILifeCycleCORBA::FindOrLoad_MPIComponent -// (const char *MPIcontainerName, -// const char *MPIcomponentName, -// const char *implementation, -// const int nbproc) -// { -// BEGIN_OF("FindOrLoad_MPIComponent(1)"); -// ASSERT(_NS != NULL); -// string theComputer ; -// string theMPIContainer ; -// string theComputerContainer = ContainerName( MPIcontainerName , -// &theComputer , -// &theMPIContainer ) ; -// Engines::MPIContainer_var cont = FindOrStartMPIContainer( theComputerContainer , -// theComputer , -// theMPIContainer, -// nbproc) ; -// // ASSERT(!CORBA::is_nil(cont)); - -// string path( theComputerContainer ); -// path = path + "/"; -// path = path + MPIcomponentName; -// SCRUTE(path); -// try -// { -// CORBA::Object_var obj = _NS->Resolve(path.c_str()); -// if (CORBA::is_nil(obj)) -// { -// MESSAGE("MPIComponent not found ! trying to load " << path); -// Engines::Component_var compo -// = cont->load_impl(MPIcomponentName, implementation); -// // ASSERT(!CORBA::is_nil(compo)); -// MESSAGE("MPIComponent launched !" << path); -// return compo; -// } -// else -// { -// MESSAGE("MPIComponent found !" << path); -// Engines::Component_var compo = Engines::Component::_narrow(obj); -// // ASSERT(!CORBA::is_nil(compo)); -// try -// { -// compo->ping(); -// } -// catch (CORBA::COMM_FAILURE&) -// { -// INFOS("Caught CORBA::SystemException CommFailure. Engine " -// << path << "does not respond" ); -// } -// return compo; -// } -// } -// catch (ServiceUnreachable&) -// { -// INFOS("Caught exception: Naming Service Unreachable"); -// } -// catch (...) -// { -// INFOS("Caught unknown exception."); -// } -// return Engines::Component::_nil(); -// } - -Engines::Component_var SALOME_MPILifeCycleCORBA::FindOrLoad_MPIComponent - (const char *MPIcontainerName, - const char *MPIcomponentName, - const int nbproc) -{ - - char nbp[1024]; - - sprintf(nbp,"_%d",nbproc); -// BEGIN_OF("FindOrLoad_Component(2)"); - ASSERT(_NS != NULL); - string theComputer ; - string theMPIContainerRoot ; - string theMPIContainer; - string theComputerContainer = ContainerName( MPIcontainerName , - &theComputer , - &theMPIContainerRoot ) ; - theMPIContainer = theMPIContainerRoot + nbp; - Engines::MPIContainer_var cont = FindOrStartMPIContainer( theComputer , - theMPIContainerRoot, - nbproc ) ; - - if ( CORBA::is_nil( cont ) ) { - MESSAGE("MPIContainer not found ! " << theComputerContainer ); - return Engines::Component::_nil(); - } - -// char * machine = cont->machineName() ; - const char * machine = theComputer.c_str() ; - - string path( theComputerContainer ); - path += nbp; - path += "/"; - path += MPIcomponentName; - SCRUTE(path); - - try { - CORBA::Object_var obj = _NS->Resolve(path.c_str()); - if ( CORBA::is_nil( obj ) ) { - MESSAGE("MPIComponent not found ! trying to load " << path); - CORBA::Object_var obj2 = _NS->Resolve("/Kernel/ModulCatalog"); - SALOME_ModuleCatalog::ModuleCatalog_var Catalog = - SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj2); - - SALOME_ModuleCatalog::Acomponent_ptr compoInfo = - Catalog->GetComponent(MPIcomponentName); - if (CORBA::is_nil (compoInfo)) - { - INFOS("Catalog Error : Component not found in the catalog") - return Engines::Component::_nil(); -// exit (-1); - } - - string path; - try - { - path = compoInfo->GetPathPrefix( machine ) ; - path += "/" ; - } - catch (SALOME_ModuleCatalog::NotFound&) - { - MESSAGE("GetPathPrefix(" << machine << ") not found!" - << "trying localhost"); - try { - path = compoInfo->GetPathPrefix("localhost") ; - path += "/" ; - } - catch (SALOME_ModuleCatalog::NotFound&) { - MESSAGE("GetPathPrefix(localhost) not found!") ; - path = "" ; - } - } - - SCRUTE(path); - string implementation(path); - implementation += "lib"; - implementation += MPIcomponentName; - implementation += "Engine.so"; - - Engines::Component_var compo - = cont->load_impl(MPIcomponentName, implementation.c_str()); - -// ASSERT(!CORBA::is_nil(compo)); -// MESSAGE("Component launched !" << path); - return compo; - } - else - { - MESSAGE("MPIComponent found !" << path); - Engines::Component_var compo = Engines::Component::_narrow(obj); - // ASSERT(!CORBA::is_nil(compo)); - try - { - string instanceName = compo->instanceName(); - } - catch (CORBA::SystemException&) - { - INFOS("Caught CORBA::SystemException CommFailure. Engine " - << path << "does not respond" ); - } - return compo; - } - } - catch (ServiceUnreachable&) - { - INFOS("Caught exception: Naming Service Unreachable"); - } - catch (...) - { - INFOS("Caught unknown exception."); - } - return Engines::Component::_nil(); -} diff --git a/src/MPILifeCycleCORBA/SALOME_MPILifeCycleCORBA.hxx b/src/MPILifeCycleCORBA/SALOME_MPILifeCycleCORBA.hxx deleted file mode 100644 index e560a072e..000000000 --- a/src/MPILifeCycleCORBA/SALOME_MPILifeCycleCORBA.hxx +++ /dev/null @@ -1,45 +0,0 @@ -//============================================================================= -// File : SALOME_MPILifeCycleCORBA.hxx -// Created : mar jui 03 14:55:45 CEST 2003 -// Author : Bernard SECHER, CEA -// Project : SALOME -// Copyright : CEA 2003 -// $Header$ -//============================================================================= - -#ifndef _SALOME_MPILIFECYCLECORBA_HXX_ -#define _SALOME_MPILIFECYCLECORBA_HXX_ - -#include -#include -#include - -#include -#include CORBA_CLIENT_HEADER(SALOME_MPIContainer) -#include "SALOME_LifeCycleCORBA.hxx" - -class SALOME_MPILifeCycleCORBA : public SALOME_LifeCycleCORBA -{ -public: - SALOME_MPILifeCycleCORBA(); - SALOME_MPILifeCycleCORBA(SALOME_NamingService *ns); - virtual ~SALOME_MPILifeCycleCORBA(); - -// Engines::Component_var FindOrLoad_MPIComponent(const char *MPIcontainerName, -// const char *MPIcomponentName, -// const char *implementationPath, -// const int nbproc); - Engines::Component_var FindOrLoad_MPIComponent(const char *MPIcontainerName, - const char *MPIcomponentName, - const int nbproc); -protected: - Engines::MPIContainer_var _MPIFactoryServer ; - -private: - Engines::MPIContainer_var FindOrStartMPIContainer(const std::string theComputer , - const std::string theMPIContainerRoot, - const int nbproc) ; - -} ; - -#endif diff --git a/src/MPILifeCycleCORBA/TestMPILifeCycleCORBA.cxx b/src/MPILifeCycleCORBA/TestMPILifeCycleCORBA.cxx deleted file mode 100644 index 680ba3766..000000000 --- a/src/MPILifeCycleCORBA/TestMPILifeCycleCORBA.cxx +++ /dev/null @@ -1,70 +0,0 @@ -// using namespace std; -//============================================================================= -// File : TestMPILifeCycleCORBA.cxx -// Created : mer jui 4 13:11:27 CEST 2003 -// Author : Bernard SECHER, 2003 -// Project : SALOME -// Copyright : CEA 2003 -// $Header$ -//============================================================================= - -#include "utilities.h" -#include -#include -#include -#include -#include CORBA_CLIENT_HEADER(SALOME_MPIContainer) -#include CORBA_CLIENT_HEADER(SALOME_TestMPIComponent) - -# include "Utils_ORB_INIT.hxx" -# include "Utils_SINGLETON.hxx" -#include "SALOME_NamingService.hxx" -#include "SALOME_MPILifeCycleCORBA.hxx" -#include "OpUtil.hxx" -using namespace std; - -int main (int argc, char * argv[]) -{ - - try{ - // Initializing omniORB - CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); - - // Obtain a reference to the root POA - CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ; - PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ; - - // Use Name Service to find container - SALOME_NamingService NS(orb); - - SALOME_MPILifeCycleCORBA LCC(&NS); - - Engines::Component_var comp = LCC.FindOrLoad_MPIComponent("MPIFactoryServer","TestMPIComponent",2); - - Engines::TestMPIComponent_var m1 = Engines::TestMPIComponent::_narrow(comp); - if(CORBA::is_nil(m1)){ - INFOS("echec recuperation poignee composant"); - } - else{ - - INFOS("Lancement de coucou"); - m1->Coucou(1L); - } - - orb->destroy(); - } - catch(CORBA::COMM_FAILURE& ex) { - INFOS("Caught system exception COMM_FAILURE -- unable to contact the object."); - } - catch(CORBA::SystemException&) { - INFOS("Caught a CORBA::SystemException."); - } - catch(CORBA::Exception&) { - INFOS("Caught CORBA::Exception."); - } - catch(...) { - INFOS("Caught unknown exception."); - } - - return 0; -} diff --git a/src/Makefile.in b/src/Makefile.in index d0daa6ea2..f8bc74369 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -57,7 +57,7 @@ SUBDIRS = MSG2QM SALOMELocalTrace SALOMETraceCollector Logger Utils CASCatch \ endif ifeq (@mpi_ok@,yes) - SUBDIRS+= MPIContainer MPILifeCycleCORBA TestMPIContainer + SUBDIRS+= MPIContainer TestMPIContainer endif ifeq (@WITH_BATCH@,yes) diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index 4beb6d4e3..70ea6e56a 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -33,6 +33,7 @@ #include #include +#include using namespace std; @@ -368,6 +369,109 @@ CORBA::Object_ptr SALOME_NamingService::Resolve(const char* Path) return _obj; } +//---------------------------------------------------------------------- +/*! Function : Resolve Component from hostname, containername, componentName and number of prcoessors + * Purpose : method to get the ObjRef of a component + * If the NamingService is out, the exception ServiceUnreachable is thrown + * \param hostname const char* argument + * \param containername const char* argument + * \param componentname const char* argument + * \param nbproc const int argument + * \return the object reference + */ +//---------------------------------------------------------------------- + +CORBA::Object_ptr SALOME_NamingService::ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc) +{ + + string name="/Containers/"; + name += hostname; + if( strlen(containerName) != 0 ){ + name += "/"; + if( nbproc >=1 ){ + char *newContainerName = new char[strlen(containerName)+8]; + sprintf(newContainerName,"%s_%d",containerName,nbproc); + name += newContainerName; + } + else + name += containerName; + name += "/"; + name += componentName; + return Resolve(name.c_str()); + } + else { + Change_Directory(name.c_str()); + vector contList = list_directory(); + for(unsigned int ind = 0; ind < contList.size(); ind++){ + name = contList[ind].c_str(); + name += "/"; + name += componentName; + CORBA::Object_ptr obj = Resolve(name.c_str()); + if( !CORBA::is_nil(obj) ) + return obj; + } + return CORBA::Object::_nil(); + } + +} + +string SALOME_NamingService::ContainerName(const char *containerName) +{ + string ret; + + if (strlen(containerName)== 0) + ret = "FactoryServer"; + else + ret = containerName; + + return ret; +} + +string SALOME_NamingService::ContainerName(const Engines::MachineParameters& params) +{ + int nbproc; + if( !params.isMPI ) + nbproc = 0; + else if( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) ) + nbproc = 1; + else if( params.nb_node == 0 ) + nbproc = params.nb_proc_per_node; + else if( params.nb_proc_per_node == 0 ) + nbproc = params.nb_node; + else + nbproc = params.nb_node * params.nb_proc_per_node; + + string ret=ContainerName(params.container_name); + + if( nbproc >=1 ){ + char *suffix = new char[8]; + sprintf(suffix,"_%d",nbproc); + ret += suffix; + } + + return ret; +} + +string SALOME_NamingService::BuildContainerNameForNS(const char *containerName, const char *hostname) +{ + string ret="/Containers/"; + ret += hostname; + ret+="/"; + ret+=ContainerName(containerName); + + return ret; +} + +string SALOME_NamingService::BuildContainerNameForNS(const Engines::MachineParameters& params, const char *hostname) +{ + string ret="/Containers/"; + ret += hostname; + ret+="/"; + ret+=ContainerName(params); + + return ret; +} + //---------------------------------------------------------------------- /*! Function : Find * Purpose : method to research a name from the current directory diff --git a/src/NamingService/SALOME_NamingService.hxx b/src/NamingService/SALOME_NamingService.hxx index db9c39e17..31866d4c8 100644 --- a/src/NamingService/SALOME_NamingService.hxx +++ b/src/NamingService/SALOME_NamingService.hxx @@ -34,6 +34,9 @@ #include #include +#include +#include CORBA_CLIENT_HEADER(SALOME_ContainerManager) +#include CORBA_CLIENT_HEADER(SALOME_Component) //class ServiceUnreachable; #include "ServiceUnreachable.hxx" @@ -60,6 +63,15 @@ public: CORBA::Object_ptr Resolve(const char* Path) throw( ServiceUnreachable); + //! method to get the ObjRef of a component + CORBA::Object_ptr ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc=0); + + std::string ContainerName(const char *ContainerName); + std::string ContainerName(const Engines::MachineParameters& params); + + std::string BuildContainerNameForNS(const char *ContainerName, const char *hostname); + std::string BuildContainerNameForNS(const Engines::MachineParameters& params, const char *hostname); + //! method to research a name from the naming service's current directory int Find(const char* name) throw(ServiceUnreachable); diff --git a/src/RegistryDisplay/RegWidget.hxx b/src/RegistryDisplay/RegWidget.hxx index 556d26727..02ad9ab9c 100644 --- a/src/RegistryDisplay/RegWidget.hxx +++ b/src/RegistryDisplay/RegWidget.hxx @@ -33,6 +33,8 @@ #include #include CORBA_CLIENT_HEADER(SALOME_Registry) +#include CORBA_CLIENT_HEADER(SALOME_Component) +#include CORBA_CLIENT_HEADER(SALOME_ContainerManager) #include diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index da3c89977..89c34e8d0 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -21,12 +22,14 @@ using namespace std; //just for test -SALOME_ResourcesManager::SALOME_ResourcesManager(const char *xmlFilePath):_path_resources(xmlFilePath) +SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb,const char *xmlFilePath):_path_resources(xmlFilePath) { + _NS=new SALOME_NamingService(orb); } -SALOME_ResourcesManager::SALOME_ResourcesManager() +SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb) { + _NS=new SALOME_NamingService(orb); _path_resources=getenv("KERNEL_ROOT_DIR"); _path_resources+="/share/salome/resources/CatalogResources.xml"; ParseXmlFile(); @@ -34,17 +37,21 @@ SALOME_ResourcesManager::SALOME_ResourcesManager() SALOME_ResourcesManager::~SALOME_ResourcesManager() { + delete _NS; } vector SALOME_ResourcesManager::GetFittingResources(const Engines::MachineParameters& params,const char *moduleName) throw(SALOME_Exception) { + MESSAGE("ResourcesManager::GetFittingResources"); vector ret; //To be sure that we search in a correct list. ParseXmlFile(); const char *hostname=(const char *)params.hostname; if(hostname[0]!='\0') { - if(_resourcesList.find(hostname)!=_resourcesList.end()) + if( strcmp(hostname,"localhost") == 0 || strcmp(hostname,GetHostname().c_str()) == 0 ) + ret.push_back(GetHostname().c_str()); + else if(_resourcesList.find(hostname)!=_resourcesList.end()) // params.hostame is in the list of resources so return it. ret.push_back(hostname); else @@ -176,7 +183,7 @@ string SALOME_ResourcesManager::FindBest(const Engines::MachineList& listOfMachi return _dynamicResourcesSelecter.FindBest(listOfMachines); } -string SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer(const string& machine,const char *containerName) +string SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer(const string& machine,const Engines::MachineParameters& params) { _TmpFileName=BuildTemporaryFileName(); ofstream tempOutputFile; @@ -197,12 +204,34 @@ string SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer(const strin tempOutputFile << "export PYTHONPATH" << endl; tempOutputFile << "source " << resInfo.PreReqFilePath << endl; // ! env vars + if(params.isMPI){ + tempOutputFile << "mpirun -np "; + int nbproc; + if( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) ) + nbproc = 1; + else if( params.nb_node == 0 ) + nbproc = params.nb_proc_per_node; + else if( params.nb_proc_per_node == 0 ) + nbproc = params.nb_node; + else + nbproc = params.nb_node * params.nb_proc_per_node; + std::ostringstream o; + tempOutputFile << nbproc << " "; + } tempOutputFile << (*(resInfo.ModulesPath.find("KERNEL"))).second << "/bin/salome/"; - if(Engines_Container_i::isPythonContainer(containerName)) - tempOutputFile << "SALOME_ContainerPy.py "; - else - tempOutputFile << "SALOME_Container "; - tempOutputFile << containerName << " -"; + if(params.isMPI){ + if(Engines_Container_i::isPythonContainer(params.container_name)) + tempOutputFile << "pyMPI SALOME_ContainerPy.py "; + else + tempOutputFile << "SALOME_MPIContainer "; + } + else{ + if(Engines_Container_i::isPythonContainer(params.container_name)) + tempOutputFile << "SALOME_ContainerPy.py "; + else + tempOutputFile << "SALOME_Container "; + } + tempOutputFile << _NS->ContainerName(params) << " -"; AddOmninamesParams(tempOutputFile); tempOutputFile << " &" << endl; tempOutputFile.flush(); @@ -231,27 +260,48 @@ string SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer(const strin command+=_TmpFileName; command += " > "; command += "/tmp/"; - command += containerName; + command += _NS->ContainerName(params); command += "_"; command += machine; - command += ".log &"; + command += ".log 2>&1 &"; cout << "Command is ... " << command << endl; return command; } -string SALOME_ResourcesManager::BuildCommandToLaunchLocalContainer(const char *containerName) +string SALOME_ResourcesManager::BuildCommandToLaunchLocalContainer(const Engines::MachineParameters& params) { _TmpFileName=""; string command; - if(Engines_Container_i::isPythonContainer(containerName)) - command="SALOME_ContainerPy.py "; - else - command="SALOME_Container "; - command+=containerName; + int nbproc=0; + if(params.isMPI){ + command="mpirun -np "; + if( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) ) + nbproc = 1; + else if( params.nb_node == 0 ) + nbproc = params.nb_proc_per_node; + else if( params.nb_proc_per_node == 0 ) + nbproc = params.nb_node; + else + nbproc = params.nb_node * params.nb_proc_per_node; + std::ostringstream o; + o << nbproc << " "; + command += o.str(); + if(Engines_Container_i::isPythonContainer(params.container_name)) + command+="pyMPI SALOME_ContainerPy.py "; + else + command+="SALOME_MPIContainer "; + } + else{ + if(Engines_Container_i::isPythonContainer(params.container_name)) + command="SALOME_ContainerPy.py "; + else + command="SALOME_Container "; + } + command+=_NS->ContainerName(params); command+=" -"; AddOmninamesParams(command); command+=" > /tmp/"; - command+=containerName; + command+=_NS->ContainerName(params); command += "_"; command += GetHostname(); command += ".log 2>&1 &" ; diff --git a/src/ResourcesManager/SALOME_ResourcesManager.hxx b/src/ResourcesManager/SALOME_ResourcesManager.hxx index c0b6ef385..9bfe9a075 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.hxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.hxx @@ -6,6 +6,7 @@ #include #include "SALOME_ResourcesCatalog_Handler.hxx" #include "SALOME_LoadRateManager.hxx" +#include "SALOME_NamingService.hxx" #include CORBA_CLIENT_HEADER(SALOME_ContainerManager) #include #include @@ -18,10 +19,10 @@ class SALOME_ResourcesManager { public: //! standard constructor - SALOME_ResourcesManager(); + SALOME_ResourcesManager(CORBA::ORB_ptr orb); //!just for test - SALOME_ResourcesManager(const char *xmlFilePath); + SALOME_ResourcesManager(CORBA::ORB_ptr orb,const char *xmlFilePath); //! standard destructor ~SALOME_ResourcesManager(); @@ -33,10 +34,10 @@ public: std::string FindBest(const Engines::MachineList& listOfMachines); //! method that builds in a temporary file the script to be launched - std::string BuildTempFileToLaunchRemoteContainer(const std::string& machine,const char *containerName); + std::string BuildTempFileToLaunchRemoteContainer(const std::string& machine,const Engines::MachineParameters& params); //! method that builds the command to be launched. - std::string BuildCommandToLaunchLocalContainer(const char *containerName); + std::string BuildCommandToLaunchLocalContainer(const Engines::MachineParameters& params); //! method that remove the generated temporary file in case of a remote launch. void RmTmpFile(); @@ -62,6 +63,7 @@ public: const MapOfParserResourcesType& GetList() const; private: + SALOME_NamingService *_NS; //! method to verify ressources catalog content - return true if verfication is OK bool _verify_resources(MapOfParserResourcesType resourceslist); diff --git a/src/TestMPIContainer/Makefile.in b/src/TestMPIContainer/Makefile.in index b268fd20e..451d9d20f 100644 --- a/src/TestMPIContainer/Makefile.in +++ b/src/TestMPIContainer/Makefile.in @@ -31,7 +31,7 @@ BIN_SRC = BIN_CLIENT_IDL = Logger.idl SALOME_MPIObject.idl SALOME_MPIContainer.idl SALOME_TestMPIComponent.idl BIN_SERVER_IDL = -LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeMPILifeCycleCORBA -lSalomeLifeCycleCORBA -lSalomeMPIContainer -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace ${MPI_LIBS} +LDFLAGSFORBIN+= -lSalomeNotification -lSalomeNS -lSalomeLifeCycleCORBA -lSalomeMPIContainer -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace -lSalomeResourcesManager ${MPI_LIBS} CXXFLAGS+=${MPI_INCLUDES} CXX_DEPEND_FLAG+=${MPI_INCLUDES} diff --git a/src/TestMPIContainer/TestMPIContainer.cxx b/src/TestMPIContainer/TestMPIContainer.cxx index 898007487..f17d5a630 100644 --- a/src/TestMPIContainer/TestMPIContainer.cxx +++ b/src/TestMPIContainer/TestMPIContainer.cxx @@ -20,7 +20,7 @@ # include "Utils_SINGLETON.hxx" #include "SALOME_NamingService.hxx" #include "OpUtil.hxx" -#include "LocalTraceCollector.hxx" +#include "SALOMETraceCollector.hxx" using namespace std; int main (int argc, char * argv[]) @@ -29,7 +29,7 @@ int main (int argc, char * argv[]) // Initializing omniORB ORB_INIT &init = *SINGLETON_::Instance() ; CORBA::ORB_var &orb = init( argc , argv ) ; - LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb); + SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); BEGIN_OF(argv[0]) try{ @@ -115,7 +115,7 @@ int main (int argc, char * argv[]) // // Clean-up. // // iGenFact->finalize_removal() ; // // sleep(5); - iGenFact->MPIShutdown(); + iGenFact->Shutdown(); // INFOS("shut down corba server for Test MPI Container"); // orb->destroy(); }