From: caremoli Date: Thu, 30 Apr 2009 11:51:53 +0000 (+0000) Subject: CCAR: several changes in Container Manager and Resources Manager X-Git-Tag: CCAR_cm3_end X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=37af4eda88606505c841280582f86ca297f25a44;p=modules%2Fkernel.git CCAR: several changes in Container Manager and Resources Manager 1- remove unused members in MachineParameters, keep only members for requests the members removed are : alias, protocol, username, applipath, mpiImpl, batch 2- remove the enum policy which is replaced by a new member in MachineParameters (policy) 3- add a new member computerList in MachineParameters structure to specify a list of machines in a request to Container Manager 3- remove no more used parameters (policy, possibleComputers, componentList in FindOrStartContainer, FindOrStarParallelContainer, StartContainer, GiveContainer and GetFittingResources. These operations now take only one argument : a MachineParameters structure. 4- adapt LifeCycle to these changes --- diff --git a/idl/SALOME_ContainerManager.idl b/idl/SALOME_ContainerManager.idl index b7c4ace4a..184f341da 100644 --- a/idl/SALOME_ContainerManager.idl +++ b/idl/SALOME_ContainerManager.idl @@ -47,14 +47,6 @@ struct MachineParameters string container_name; //! host name if given else automatic string hostname; - //! if given alias name to use ?? - string alias; - //! protocol to use to start a remote container (ssh or rsh) - string protocol; - //! login name to use to start a remote container - string username; - //! salome application to use to start a remote container - string applipath; //! if given list of components that could be loaded on the container CompoList componentList; //! if given restricted list of machines to search in @@ -69,12 +61,8 @@ struct MachineParameters long nb_proc_per_node; //! required number of node long nb_node; - //! if true start a MPI container ?? + //! if true start a MPI container boolean isMPI; - //! required MPI implementation to use - string mpiImpl; - //! required batch system to use - string batch; //! container working directory string workingdir; //! creation mode for GiveContainer. @@ -96,6 +84,7 @@ struct MachineDefinition { //! host name string hostname; + //! alias name string alias; //! protocol to use to start a remote container (ssh or rsh) string protocol; @@ -124,17 +113,6 @@ struct MachineDefinition //! exception thrown if a computer is not found in the catalog exception NotFound {}; -//! enumeration to set a resource management policy - enum policy { - //! first machine in the list of admissible computers - P_FIRST, - //! next machine in the list of admissible computers - P_CYCL, - //! best machine in the list of admissible computers - P_BEST}; -//! resource management policy - typedef policy ResPolicy; - //! Structure used for Salome Batch Job parameters struct BatchParameters { @@ -180,35 +158,27 @@ struct BatchParameters interface ContainerManager { //! Find an existing container satisfying the constraints given by input parameters or start a new one. - Container FindOrStartContainer( in MachineParameters params, - in MachineList possibleComputers); + Container FindOrStartContainer( in MachineParameters params); //! This operation launches a PaCO++ container. /*! - \param Description of the container resquested. \param List of computers ressources. \return Container's CORBA reference. */ - Container FindOrStartParallelContainer( in MachineParameters params, - in MachineList possibleComputers); + Container FindOrStartParallelContainer( in MachineParameters params); //! Start a new container satisfying the constraints given by input parameters. - Container StartContainer( in MachineParameters params, - in ResPolicy policy, - in CompoList componentList ); + Container StartContainer( in MachineParameters params); //! Same as StartContainer except that in batch all containers have already been launched /*! - We are in batch if environment variable SALOME_BATCH is 1. In this case, containers have been launched at the beginning of the Salome session and the container manager picks one in the pool of existing containers. */ - Container GiveContainer( in MachineParameters params, - in ResPolicy policy, - in CompoList componentList ); + Container GiveContainer( in MachineParameters params); //! Shutdown all containers that have been launched by the container manager void ShutdownContainers(); @@ -231,9 +201,8 @@ struct BatchParameters /*! The constraints are resource constraints (params) and components constraints (componentList) */ - MachineList GetFittingResources( in MachineParameters params, - in CompoList componentList ) - raises (SALOME::SALOME_Exception); + MachineList GetFittingResources( in MachineParameters params) + raises (SALOME::SALOME_Exception); //! Get the current machine parameters of a computer MachineDefinition GetMachineParameters( in string hostname ); diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index e2acfc461..939f53bdb 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -96,8 +96,8 @@ SALOME_ContainerManager::~SALOME_ContainerManager() } //============================================================================= +//! shutdown all the containers, then the ContainerManager servant /*! CORBA method: - * shutdown all the containers, then the ContainerManager servant */ //============================================================================= @@ -111,8 +111,8 @@ void SALOME_ContainerManager::Shutdown() } //============================================================================= +//! Loop on all the containers listed in naming service, ask shutdown on each /*! CORBA Method: - * Loop on all the containers listed in naming service, ask shutdown on each */ //============================================================================= @@ -174,48 +174,56 @@ void SALOME_ContainerManager::ShutdownContainers() } //============================================================================= -//! Find a suitable Container in a list of machines, or start one +//! Give a suitable Container given constraints /*! CORBA Method: * \param params Machine Parameters required for the container - * \param possibleComputers list of machines usable for find or start + * \return the container or nil */ //============================================================================= Engines::Container_ptr -SALOME_ContainerManager:: -FindOrStartContainer(const Engines::MachineParameters& params, - const Engines::MachineList& possibleComputers) +SALOME_ContainerManager::GiveContainer(const Engines::MachineParameters& params) { - Engines::Container_ptr ret = FindContainer(params,possibleComputers); - if(!CORBA::is_nil(ret)) - return ret; - MESSAGE("Container doesn't exist try to launch it ..."); + char *valenv=getenv("SALOME_BATCH"); + if(valenv) + if (strcmp(valenv,"1")==0) + { + if(_batchLaunchedContainers.empty()) + fillBatchLaunchedContainers(); - return StartContainer(params,possibleComputers,Engines::P_FIRST); + if (_batchLaunchedContainersIter == _batchLaunchedContainers.end()) + _batchLaunchedContainersIter = _batchLaunchedContainers.begin(); + Engines::Container_ptr rtn = Engines::Container::_duplicate(*_batchLaunchedContainersIter); + _batchLaunchedContainersIter++; + return rtn; + } + return StartContainer(params); } //============================================================================= -//! Start a suitable Container in a list of machines with constraints and a policy +//! Start a suitable Container in a list of machines with constraints /*! C++ Method: * Constraints are given by a machine parameters struct * \param params Machine Parameters required for the container * \param possibleComputers list of machines usable for start - * \param policy policy to use (first,cycl or best) * \param container_exe specific container executable (default=SALOME_Container) */ //============================================================================= Engines::Container_ptr -SALOME_ContainerManager:: -StartContainer(const Engines::MachineParameters& params, +SALOME_ContainerManager::StartContainer(const Engines::MachineParameters& params, const Engines::MachineList& possibleComputers, - Engines::ResPolicy policy,const std::string& container_exe) + const std::string& container_exe) { #ifdef WITH_PACO_PARALLEL std::string parallelLib(params.parallelLib); if (parallelLib != "") - return FindOrStartParallelContainer(params, possibleComputers); + { + Engines::MachineParameters myparams(params); + myparams.computerList=possibleComputers; + return FindOrStartParallelContainer(myparams); + } #endif string containerNameInNS; Engines::Container_ptr ret = Engines::Container::_nil(); @@ -352,21 +360,16 @@ StartContainer(const Engines::MachineParameters& params, } //============================================================================= -//! Start a suitable Container for a list of components with constraints and a policy +//! Start a suitable Container given constraints /*! CORBA Method: * \param params Machine Parameters required for the container - * \param policy policy to use (first,cycl or best) - * \param componentList list of component to be loaded on this container */ //============================================================================= Engines::Container_ptr -SALOME_ContainerManager:: -StartContainer(const Engines::MachineParameters& params, - Engines::ResPolicy policy, - const Engines::CompoList& componentList) +SALOME_ContainerManager::StartContainer(const Engines::MachineParameters& params) { - Engines::MachineList_var possibleComputers = _ResManager->GetFittingResources(params,componentList); + Engines::MachineList_var possibleComputers = _ResManager->GetFittingResources(params); // Look into ModulCatalog if a specific container must be launched CORBA::String_var container_exe; @@ -378,9 +381,9 @@ StartContainer(const Engines::MachineParameters& params, if (CORBA::is_nil (Catalog)) return Engines::Container::_nil(); // Loop through component list - for(unsigned int i=0;iGetComponent(compoi); if (CORBA::is_nil (compoInfo)) { @@ -411,9 +414,77 @@ StartContainer(const Engines::MachineParameters& params, } if(found) - return StartContainer(params,possibleComputers,policy,container_exe.in()); + return StartContainer(params,possibleComputers,container_exe.in()); else - return StartContainer(params,possibleComputers,policy); + return StartContainer(params,possibleComputers); +} + +//============================================================================= +//! Find or start a suitable Container given some constraints +/*! CORBA Method: + * \param params Machine Parameters required for the container + * \return the container or nil + */ +//============================================================================= + +Engines::Container_ptr +SALOME_ContainerManager::FindOrStartContainer(const Engines::MachineParameters& params) +{ + Engines::Container_ptr ret = FindContainer(params,params.computerList); + if(!CORBA::is_nil(ret)) + return ret; + MESSAGE("Container doesn't exist try to launch it ..."); + + return StartContainer(params); +} + +//============================================================================= +//! Find a container given constraints (params) on a list of machines (possibleComputers) +/*! + * + */ +//============================================================================= + +Engines::Container_ptr +SALOME_ContainerManager::FindContainer(const Engines::MachineParameters& params, + const Engines::MachineList& possibleComputers) +{ + MESSAGE("FindContainer "<BuildContainerNameForNS(params,theMachine)); + CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str()); + try + { + if(obj->_non_existent()) + return Engines::Container::_nil(); + else + return Engines::Container::_narrow(obj); + } + catch(const CORBA::Exception& e) + { + return Engines::Container::_nil(); + } } #ifdef WITH_PACO_PARALLEL @@ -421,15 +492,11 @@ StartContainer(const Engines::MachineParameters& params, /*! CORBA Method: * Find or Start a suitable PaCO++ Parallel Container in a list of machines. * \param params Machine Parameters required for the container - * \param possibleComputers list of machines usable for find or start - * * \return CORBA container reference. */ //============================================================================= Engines::Container_ptr -SALOME_ContainerManager:: -FindOrStartParallelContainer(const Engines::MachineParameters& params_const, - const Engines::MachineList& possibleComputers) +SALOME_ContainerManager::FindOrStartParallelContainer(const Engines::MachineParameters& params_const) { CORBA::Object_var obj; PaCO::InterfaceManager_var proxy; @@ -440,14 +507,14 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params_const, // Currently not as good as could be since // we have to verified the number of nodes of the container // if a user tell that. - ret = FindContainer(params, possibleComputers); + ret = FindContainer(params, params.computerList); if(CORBA::is_nil(ret)) { // Step 2 : Starting a new parallel container INFOS("[FindOrStartParallelContainer] Starting a parallel container"); // Step 2.1 : Choose a computer - string theMachine = _ResManager->FindFirst(possibleComputers); + string theMachine = _ResManager->FindFirst(params.computerList); if(theMachine == "") { INFOS("[FindOrStartParallelContainer] !!!!!!!!!!!!!!!!!!!!!!!!!!"); INFOS("[FindOrStartParallelContainer] No possible computer found"); @@ -544,15 +611,11 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params_const, /*! CORBA Method: * Find or Start a suitable PaCO++ Parallel Container in a list of machines. * \param params Machine Parameters required for the container - * \param possibleComputers list of machines usable for find or start - * * \return CORBA container reference. */ //============================================================================= Engines::Container_ptr -SALOME_ContainerManager:: -FindOrStartParallelContainer(const Engines::MachineParameters& params, - const Engines::MachineList& possibleComputers) +SALOME_ContainerManager::FindOrStartParallelContainer(const Engines::MachineParameters& params) { Engines::Container_ptr ret = Engines::Container::_nil(); INFOS("[FindOrStartParallelContainer] is disabled !"); @@ -561,87 +624,6 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params, } #endif -//============================================================================= -//! Give a suitable Container for a list of components with constraints and a policy -/*! CORBA Method: - * \param params Machine Parameters required for the container - * \param policy policy to use (first,cycl or best) - * \param componentList list of component to be loaded on this container - */ -//============================================================================= - -Engines::Container_ptr -SALOME_ContainerManager:: -GiveContainer(const Engines::MachineParameters& params, - Engines::ResPolicy policy, - const Engines::CompoList& componentList) -{ - char *valenv=getenv("SALOME_BATCH"); - if(valenv) - if (strcmp(valenv,"1")==0) - { - if(_batchLaunchedContainers.empty()) - fillBatchLaunchedContainers(); - - if (_batchLaunchedContainersIter == _batchLaunchedContainers.end()) - _batchLaunchedContainersIter = _batchLaunchedContainers.begin(); - - Engines::Container_ptr rtn = Engines::Container::_duplicate(*_batchLaunchedContainersIter); - _batchLaunchedContainersIter++; - return rtn; - } - return StartContainer(params,policy,componentList); -} - -//============================================================================= -/*! - * - */ -//============================================================================= - -Engines::Container_ptr -SALOME_ContainerManager:: -FindContainer(const Engines::MachineParameters& params, - const char *theMachine) -{ - string containerNameInNS(_NS->BuildContainerNameForNS(params,theMachine)); - CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str()); - try - { - if(obj->_non_existent()) - return Engines::Container::_nil(); - else - return Engines::Container::_narrow(obj); - } - catch(const CORBA::Exception& e) - { - return Engines::Container::_nil(); - } -} - -//============================================================================= -/*! - * - */ -//============================================================================= - -Engines::Container_ptr -SALOME_ContainerManager:: -FindContainer(const Engines::MachineParameters& params, - const Engines::MachineList& possibleComputers) -{ - MESSAGE("FindContainer "< aCompoList ; try{ - aMachineList = _ResManager->GetFittingResources(params, aCompoList); + aMachineList = _ResManager->GetFittingResources(params); } catch(const ResourcesException &ex){ throw LauncherException(ex.msg.c_str()); @@ -207,9 +206,8 @@ long Launcher_cpp::submitSalomeJob( const string fileToExecute , throw LauncherException("Batch parameters are bad (see informations above)"); // find a cluster matching the structure params - vector aCompoList ; try{ - aMachineList = _ResManager->GetFittingResources(params, aCompoList); + aMachineList = _ResManager->GetFittingResources(params); } catch(const ResourcesException &ex){ throw LauncherException(ex.msg.c_str()); @@ -298,8 +296,7 @@ string Launcher_cpp::queryJob( long id, throw LauncherException("You must set Resources Manager to Launcher!!"); // find a cluster matching params structure - vector aCompoList ; - vector aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ; + vector aMachineList = _ResManager->GetFittingResources( params ) ; ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]); string clustername(p.Alias); @@ -346,8 +343,7 @@ void Launcher_cpp::deleteJob( const long id, throw LauncherException("You must set Resources Manager to Launcher!!"); // find a cluster matching params structure - vector aCompoList ; - vector aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ; + vector aMachineList = _ResManager->GetFittingResources( params ) ; ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]); string clustername(p.Alias); @@ -385,8 +381,7 @@ void Launcher_cpp::getResultsJob( const string directory, if(!_ResManager) throw LauncherException("You must set Resources Manager to Launcher!!"); - vector aCompoList ; - vector aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ; + vector aMachineList = _ResManager->GetFittingResources( params ) ; ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]); string clustername(p.Alias); diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index 817fa0f50..9ec5bf1f9 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -198,8 +198,7 @@ SALOME_Launcher::testBatch(const Engines::MachineParameters& params) try { // find a cluster matching the structure params - Engines::CompoList aCompoList ; - Engines::MachineList *aMachineList = _ResManager->GetFittingResources(params, aCompoList); + Engines::MachineList *aMachineList = _ResManager->GetFittingResources(params); if (aMachineList->length() == 0) throw SALOME_Exception("No resources have been found with your parameters"); diff --git a/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx b/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx index dee3b3109..26e08da56 100644 --- a/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx @@ -130,11 +130,7 @@ string SALOME_FileTransferCORBA::getLocalFile(string localFile) params.container_name = _containerName.c_str(); params.hostname = _refMachine.c_str(); - Engines::CompoList clist; - Engines::MachineList_var listOfMachines = - resManager->GetFittingResources(params, clist); - - container = contManager->FindOrStartContainer(params, listOfMachines); + container = contManager->FindOrStartContainer(params); if (CORBA::is_nil(container)) { INFOS("machine " << _refMachine << " unreachable"); diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index a96f9fac7..cdc04fde9 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -134,13 +134,12 @@ SALOME_LifeCycleCORBA::FindComponent(const Engines::MachineParameters& params, if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); - Engines::CompoList clist; - clist.length(1); - clist[0] = componentName; - Engines::MachineList_var listOfMachines = - _ResManager->GetFittingResources(params, clist); + Engines::MachineParameters parms(params); + parms.componentList.length(1); + parms.componentList[0] = componentName; + Engines::MachineList_var listOfMachines = _ResManager->GetFittingResources(parms); - Engines::Component_var compo = _FindComponent(params, + Engines::Component_var compo = _FindComponent(parms, componentName, studyId, listOfMachines); @@ -168,16 +167,13 @@ SALOME_LifeCycleCORBA::LoadComponent(const Engines::MachineParameters& params, if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); - Engines::CompoList clist; - clist.length(1); - clist[0] = componentName; - Engines::MachineList_var listOfMachines = - _ResManager->GetFittingResources(params, clist); + Engines::MachineParameters parms(params); + parms.componentList.length(1); + parms.componentList[0] = componentName; - Engines::Component_var compo = _LoadComponent(params, + Engines::Component_var compo = _LoadComponent(parms, componentName, - studyId, - listOfMachines); + studyId); return compo._retn(); } @@ -204,22 +200,20 @@ FindOrLoad_Component(const Engines::MachineParameters& params, if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); - Engines::CompoList clist; - clist.length(1); - clist[0] = componentName; - Engines::MachineList_var listOfMachines = - _ResManager->GetFittingResources(params,clist); + Engines::MachineParameters parms(params); + parms.componentList.length(1); + parms.componentList[0] = componentName; + Engines::MachineList_var listOfMachines = _ResManager->GetFittingResources(parms); - Engines::Component_var compo = _FindComponent(params, + Engines::Component_var compo = _FindComponent(parms, componentName, studyId, listOfMachines); if(CORBA::is_nil(compo)) - compo = _LoadComponent(params, + compo = _LoadComponent(parms, componentName, - studyId, - listOfMachines); + studyId); return compo._retn(); } @@ -369,10 +363,6 @@ void SALOME_LifeCycleCORBA::preSet( Engines::MachineParameters& params) { params.container_name = ""; params.hostname = ""; - params.alias = ""; - params.protocol = ""; - params.username = ""; - params.applipath = ""; //param.componentList = 0; //param.computerList = 0; params.OS = ""; @@ -381,8 +371,6 @@ void SALOME_LifeCycleCORBA::preSet( Engines::MachineParameters& params) params.nb_proc_per_node = 0; params.nb_node = 0; params.isMPI = false; - params.mpiImpl=""; - params.batch=""; params.workingdir = ""; params.mode = ""; params.policy = ""; @@ -634,7 +622,6 @@ _FindComponent(const Engines::MachineParameters& params, * \param params machine parameters like type or name... * \param componentName the name of component class * \param studyId default = 0 : multistudy instance - * \param listOfMachines list of machine address * \return a CORBA reference of the component instance, or _nil if problem */ //============================================================================= @@ -643,15 +630,12 @@ Engines::Component_ptr SALOME_LifeCycleCORBA:: _LoadComponent(const Engines::MachineParameters& params, const char *componentName, - int studyId, - const Engines::MachineList& listOfMachines) + int studyId) { MESSAGE("_LoadComponent, required " << params.container_name << " " << componentName << " " << NbProc(params)); - Engines::Container_var cont = - _ContManager->FindOrStartContainer(params, - listOfMachines); + Engines::Container_var cont = _ContManager->FindOrStartContainer(params); if (CORBA::is_nil(cont)) return Engines::Component::_nil(); bool isLoadable = cont->load_component_Library(componentName); @@ -683,19 +667,12 @@ SALOME_LifeCycleCORBA::Load_ParallelComponent(const Engines::MachineParameters& MESSAGE("Number of component nodes : " << params.nb_component_nodes); MESSAGE("Component Name : " << componentName);*/ - Engines::CompoList clist; - clist.length(1); - clist[0] = componentName; - MESSAGE("Building a list of machines"); - Engines::MachineList_var listOfMachines = _ResManager->GetFittingResources(params, clist); - if (listOfMachines->length() == 0) - { - INFOS("No matching machines founded !"); - return Engines::Component::_nil(); - } + Engines::MachineParameters parms(params); + parms.componentList.length(1); + parms.componentList[0] = componentName; MESSAGE("Starting Parallel Container"); - Engines::Container_var cont = _ContManager->FindOrStartParallelContainer(params, listOfMachines); + Engines::Container_var cont = _ContManager->FindOrStartParallelContainer(parms); if (CORBA::is_nil(cont)) { INFOS("FindOrStartParallelContainer() returns a NULL container !"); return Engines::Component::_nil(); @@ -739,16 +716,11 @@ void SALOME_LifeCycleCORBA::copyFile(const char* hostSrc, const char* fileSrc, c Engines::MachineParameters params; preSet(params); - Engines::MachineList listOfMachines; - listOfMachines.length(1); - params.hostname = hostDest; - listOfMachines[0] = hostDest; - Engines::Container_var containerDest = contManager->FindOrStartContainer(params, listOfMachines); + Engines::Container_var containerDest = contManager->FindOrStartContainer(params); params.hostname = hostSrc; - listOfMachines[0] = hostSrc; - Engines::Container_var containerSrc = contManager->FindOrStartContainer(params, listOfMachines); + Engines::Container_var containerSrc = contManager->FindOrStartContainer(params); containerDest->copyFile(containerSrc,fileSrc,fileDest); } diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx index d7ba91303..4083c428b 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx @@ -123,8 +123,7 @@ protected: Engines::Component_ptr _LoadComponent(const Engines::MachineParameters& params, const char *componentName, - int studyId, - const Engines::MachineList& listOfMachines); + int studyId); SALOME_NamingService *_NS; Engines::ContainerManager_var _ContManager; diff --git a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx index 9629055e6..fa4fc4777 100644 --- a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx +++ b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx @@ -681,12 +681,10 @@ string LifeCycleCORBATest::GetRemoteHost() Engines::MachineParameters params; _LCC.preSet(params); // empty params to get all the machines + params.componentList.length(1); + params.componentList[0]="SalomeTestComponent"; - Engines::CompoList clist; - clist.length(1); - clist[0] = "SalomeTestComponent"; - Engines::MachineList_var hostList = - resourcesManager->GetFittingResources(params,clist); + Engines::MachineList_var hostList = resourcesManager->GetFittingResources(params); CPPUNIT_ASSERT(hostList->length() > 1); string localHost = Kernel_Utils::GetHostname(); diff --git a/src/LifeCycleCORBA/TestContainerManager.cxx b/src/LifeCycleCORBA/TestContainerManager.cxx index c5fc4ef06..aaa52b195 100644 --- a/src/LifeCycleCORBA/TestContainerManager.cxx +++ b/src/LifeCycleCORBA/TestContainerManager.cxx @@ -66,10 +66,9 @@ int main (int argc, char * argv[]) Engines::ResourcesManager_var _ResManager=Engines::ResourcesManager::_narrow(obj); Engines::MachineParameters p; - Engines::CompoList clist; - clist.length(2); - clist[0] = "MED"; - clist[1] = "GEOM"; + p.componentList.length(2); + p.componentList[0] = "MED"; + p.componentList[1] = "GEOM"; p.hostname = ""; p.OS = "LINUX"; @@ -83,19 +82,22 @@ int main (int argc, char * argv[]) for(int i=0;i<10;i++){ sprintf(st,"cycl_%d",i); p.container_name = CORBA::string_dup(st); - cont = _ContManager->GiveContainer(p,Engines::P_CYCL,clist); + p.policy="cycl"; + cont = _ContManager->GiveContainer(p); if(CORBA::is_nil(cont)) error = true; } for(int i=0;i<10;i++){ sprintf(st,"first_%d",i); p.container_name = CORBA::string_dup(st); - cont = _ContManager->GiveContainer(p,Engines::P_FIRST,clist); + p.policy="best"; + cont = _ContManager->GiveContainer(p); if(CORBA::is_nil(cont)) error = true; } p.container_name = CORBA::string_dup("best"); - cont = _ContManager->GiveContainer(p,Engines::P_BEST,clist); + p.policy="best"; + cont = _ContManager->GiveContainer(p); if(CORBA::is_nil(cont)) bestImplemented = false; else bestImplemented = true; diff --git a/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py b/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py index a2422f8b5..7946e1d54 100644 --- a/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py +++ b/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py @@ -39,12 +39,10 @@ class LifeCycleCORBA (SALOME_LifeCycleCORBA): componentName) class MachineParameters (Engines.MachineParameters): - def __init__(self, container_name='', hostname='', alias='', protocol='', username='', - applipath='', componentList=[], computerList=[], OS='', mem_mb=0, cpu_clock=0, - nb_proc_per_node=0, nb_node=0, isMPI=False, mpiImpl='', batch='', workingdir='', + def __init__(self, container_name='', hostname='', componentList=[], computerList=[], OS='', + mem_mb=0, cpu_clock=0, nb_proc_per_node=0, nb_node=0, isMPI=False, workingdir='', mode='start', policy='altcycl', parallelLib='', nb_component_nodes=0): - Engines.MachineParameters.__init__(self,container_name, hostname, alias, protocol, username, - applipath, componentList, computerList, OS, mem_mb, cpu_clock, - nb_proc_per_node, nb_node, isMPI, mpiImpl, batch, workingdir, + Engines.MachineParameters.__init__(self,container_name, hostname, componentList, computerList, OS, + mem_mb, cpu_clock, nb_proc_per_node, nb_node, isMPI, workingdir, mode, policy, parallelLib, nb_component_nodes) diff --git a/src/LifeCycleCORBA_SWIG/Test/LifeCycleCORBA_SWIGTest.py b/src/LifeCycleCORBA_SWIG/Test/LifeCycleCORBA_SWIGTest.py index d74b61537..ba9331b2f 100644 --- a/src/LifeCycleCORBA_SWIG/Test/LifeCycleCORBA_SWIGTest.py +++ b/src/LifeCycleCORBA_SWIG/Test/LifeCycleCORBA_SWIGTest.py @@ -178,7 +178,7 @@ class LifeCycleCORBA_SWIGTest(unittest.TestCase): try: cp1=self.lcc.FindOrLoad_Component(containerName,"SalomeTestComponent") except RuntimeError,ex : - self.assertEqual(ex.args[0],'Salome Exception : unknown host') + self.assertEqual(ex.args[0],'unknown host') pass diff --git a/src/LifeCycleCORBA_SWIG/Test/Makefile.am b/src/LifeCycleCORBA_SWIG/Test/Makefile.am index cd322e39d..4191c3d5e 100644 --- a/src/LifeCycleCORBA_SWIG/Test/Makefile.am +++ b/src/LifeCycleCORBA_SWIG/Test/Makefile.am @@ -38,6 +38,8 @@ salomeinclude_HEADERS= # Scripts to be installed dist_salomescript_PYTHON = \ LifeCycleCORBA_SWIGTest.py \ + testresourcemanager.py \ + testcontainermanager.py \ TestLifeCycleCORBA_SWIG.py # diff --git a/src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py b/src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py new file mode 100644 index 000000000..256d3373a --- /dev/null +++ b/src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py @@ -0,0 +1,56 @@ +import unittest +import salome +import Engines +import LifeCycleCORBA +salome.salome_init() +cm= salome.lcc.getContainerManager() +rm= salome.lcc.getResourcesManager() + +class TestContainerManager(unittest.TestCase): + """ +Test with catalog : + + + + + + + +""" + def setUp(self): + pass + + def test0(self): + """""" + p=LifeCycleCORBA.MachineParameters(container_name="MyContainer",mode="start", + policy="best",componentList=["PYHELLO"]) + co=cm.StartContainer( p ) + print "Container:",co,co.getHostName(), co.getPID(),co._get_name() + self.assertEqual(co._get_name(), "/Containers/claui2c6/MyContainer") + co=cm.StartContainer( p ) + self.assertEqual(co._get_name(), "/Containers/clt10br/MyContainer") + + def test1(self): + """""" + p=LifeCycleCORBA.MachineParameters(container_name="MyContainer",mode="get", + policy="best",componentList=["PYHELLO"]) + co=cm.StartContainer( p ) + print "Container:",co,co.getHostName(), co.getPID(),co._get_name() + self.assertEqual(co._get_name(), "/Containers/claui2c6/MyContainer") + co=cm.StartContainer( p ) + self.assertEqual(co._get_name(), "/Containers/clt10br/MyContainer") + + def test2(self): + """""" + p=LifeCycleCORBA.MachineParameters(container_name="MyContainer",mode="getorstart", + policy="best",componentList=["PYHELLO"]) + co=cm.StartContainer( p ) + print "Container:",co,co.getHostName(), co.getPID(),co._get_name() + self.assertEqual(co._get_name(), "/Containers/claui2c6/MyContainer") + co=cm.StartContainer( p ) + self.assertEqual(co._get_name(), "/Containers/clt10br/MyContainer") + + +if __name__ == '__main__': + unittest.main() + diff --git a/src/LifeCycleCORBA_SWIG/Test/testresourcemanager.py b/src/LifeCycleCORBA_SWIG/Test/testresourcemanager.py new file mode 100644 index 000000000..aba62953f --- /dev/null +++ b/src/LifeCycleCORBA_SWIG/Test/testresourcemanager.py @@ -0,0 +1,116 @@ +import unittest +import salome +import LifeCycleCORBA +salome.salome_init() +cm= salome.lcc.getContainerManager() +rm= salome.lcc.getResourcesManager() + +class TestResourceManager(unittest.TestCase): + """ +Test with CatalogResources.xml: + + + + + + + + + + + + + + + +""" + def setUp(self): + pass + + def test0(self): + """host required""" + params=LifeCycleCORBA.MachineParameters(hostname="m3") + machineList=rm.GetFittingResources(params) + self.assertEqual(machineList, ["m3"]) + + def test1(self): + """OS required""" + params=LifeCycleCORBA.MachineParameters(OS="Linux") + machineList=rm.GetFittingResources(params) + self.assertEqual(machineList, []) + + def test2(self): + """component add required""" + params=LifeCycleCORBA.MachineParameters(componentList=["add"]) + machineList=rm.GetFittingResources(params) + self.assertEqual(machineList, ['claui2c6', 'm1', 'm2']) + + def test3(self): + """component tutu required""" + machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["tutu"])) + self.assertEqual(machineList, ['m1', 'm2', 'm3']) + + def test4(self): + """component tata required""" + machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["tata"])) + self.assertEqual(machineList, ['m1', 'm2']) + + def test5(self): + """component titi required""" + machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["titi"])) + self.assertEqual(machineList, ['m1', 'm2']) + + def test6(self): + """component toto required""" + machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["toto"])) + self.assertEqual(machineList, ['claui2c6', 'm1', 'm2']) + + def test7(self): + """components add and toto required""" + machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + self.assertEqual(machineList, ['claui2c6', 'm1', 'm2']) + + def test8(self): + """components add and toto required""" + machineDef=rm.GetMachineParameters('claui2c6') + self.assertEqual(machineDef.componentList, ['toto', 'add']) + + def test10(self): + """policy altcycl""" + machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + self.assertEqual(rm.Find('altcycl',machineList), "claui2c6") + self.assertEqual(rm.Find('altcycl',machineList), "m1") + self.assertEqual(rm.Find('altcycl',machineList), "m2") + self.assertEqual(rm.Find('altcycl',machineList), "claui2c6") + self.assertEqual(rm.Find('altcycl',machineList), "m1") + self.assertEqual(rm.Find('altcycl',machineList), "m2") + + def test11(self): + """policy cycl""" + machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + self.assertEqual(rm.Find('cycl',machineList), "claui2c6") + self.assertEqual(rm.Find('cycl',machineList), "m1") + self.assertEqual(rm.Find('cycl',machineList), "m2") + self.assertEqual(rm.Find('cycl',machineList), "claui2c6") + self.assertEqual(rm.Find('cycl',machineList), "m1") + self.assertEqual(rm.Find('cycl',machineList), "m2") + + def test12(self): + """policy first""" + machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + self.assertEqual(rm.Find('first',machineList), "claui2c6") + self.assertEqual(rm.Find('first',machineList), "claui2c6") + + def test13(self): + """policy best""" + machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + self.assertEqual(rm.Find('best',machineList), "claui2c6") + self.assertEqual(rm.Find('best',machineList), "m1") + self.assertEqual(rm.Find('best',machineList), "m2") + self.assertEqual(rm.Find('best',machineList), "claui2c6") + self.assertEqual(rm.Find('best',machineList), "m1") + self.assertEqual(rm.Find('best',machineList), "m2") + +if __name__ == '__main__': + unittest.main() + diff --git a/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i b/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i index 3da83ad0d..22da974ba 100644 --- a/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i +++ b/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i @@ -149,14 +149,6 @@ using namespace std; { param->hostname = CORBA::string_dup(PyString_AsString(value)); } - else if (strcmp(keystr,"alias")==0) - param->alias = CORBA::string_dup(PyString_AsString(value)); - else if (strcmp(keystr,"protocol")==0) - param->protocol = CORBA::string_dup(PyString_AsString(value)); - else if (strcmp(keystr,"username")==0) - param->username = CORBA::string_dup(PyString_AsString(value)); - else if (strcmp(keystr,"applipath")==0) - param->applipath = CORBA::string_dup(PyString_AsString(value)); else if (strcmp(keystr,"OS")==0) { param->OS = CORBA::string_dup(PyString_AsString(value)); @@ -181,10 +173,6 @@ using namespace std; { param->isMPI = PyLong_AsLong(value); } - else if (strcmp(keystr,"mpiImpl")==0) - param->mpiImpl = CORBA::string_dup(PyString_AsString(value)); - else if (strcmp(keystr,"batch")==0) - param->batch = CORBA::string_dup(PyString_AsString(value)); else if (strcmp(keystr,"workingdir")==0) param->workingdir = CORBA::string_dup(PyString_AsString(value)); else if (strcmp(keystr,"mode")==0) diff --git a/src/ResourcesManager/ResourcesManager.cxx b/src/ResourcesManager/ResourcesManager.cxx index e09908f76..381be2fd2 100644 --- a/src/ResourcesManager/ResourcesManager.cxx +++ b/src/ResourcesManager/ResourcesManager.cxx @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -82,6 +83,7 @@ ResourcesManager_cpp::ResourcesManager_cpp() throw(ResourcesException) _resourceManagerMap["altcycl"]=&altcycl; _resourceManagerMap["best"]=&altcycl; _resourceManagerMap[""]=&altcycl; + _isAppliSalomeDefined = (getenv("APPLI") != 0); if(!getenv("KERNEL_ROOT_DIR")) throw ResourcesException("you must define KERNEL_ROOT_DIR environment variable!!"); @@ -120,22 +122,21 @@ ResourcesManager_cpp::~ResourcesManager_cpp() } //============================================================================= +//! get the list of resource names fitting constraints given by params /*! - * get the list of name of ressources fitting for the specified component. - * If hostname specified, check it is local or known in resources catalog. + * If hostname is specified, check if it is local or known in resources catalog. * * Else * - select first machines with corresponding OS (all machines if * parameter OS empty), - * - then select the sublist of machines on witch the component is known + * - then select the sublist of machines on which the component is known * (if the result is empty, that probably means that the inventory of * components is probably not done, so give complete list from previous step) */ //============================================================================= std::vector -ResourcesManager_cpp::GetFittingResources(const machineParams& params, - const std::vector& componentList) throw(ResourcesException) +ResourcesManager_cpp::GetFittingResources(const machineParams& params) throw(ResourcesException) { vector vec; @@ -196,10 +197,13 @@ ResourcesManager_cpp::GetFittingResources(const machineParams& params, else{ // --- Search for available resources sorted by priority + vec=params.computerList; + SelectOnlyResourcesWithOS(vec, params.OS.c_str()); - KeepOnlyResourcesWithComponent(vec, componentList); - + KeepOnlyResourcesWithComponent(vec, params.componentList); + + //if hosts list (vec) is empty, ignore componentList constraint and use only OS constraint if (vec.size() == 0) SelectOnlyResourcesWithOS(vec, params.OS.c_str()); @@ -343,6 +347,15 @@ void ResourcesManager_cpp::WriteInXmlFile() const MapOfParserResourcesType& ResourcesManager_cpp::ParseXmlFile() { + //Parse file only if its modification time is greater than lasttime (last registered modification time) + static time_t lasttime=0; + struct stat statinfo; + int result = stat(_path_resources.c_str(), &statinfo); + if (result < 0) return _resourcesList; + if(statinfo.st_mtime <= lasttime) + return _resourcesList; + lasttime=statinfo.st_mtime; + SALOME_ResourcesCatalog_Handler* handler = new SALOME_ResourcesCatalog_Handler(_resourcesList, _resourcesBatchList); @@ -406,13 +419,29 @@ throw(ResourcesException) { string base(OS); - for (map::const_iterator iter = - _resourcesList.begin(); - iter != _resourcesList.end(); - iter++) + if(hosts.size()==0) + { + //No constraint on computer list : take all known resources with OS + map::const_iterator iter; + for (iter = _resourcesList.begin(); iter != _resourcesList.end(); iter++) + { + if ( (*iter).second.OS == base || base.size() == 0) + hosts.push_back((*iter).first); + } + } + else { - if ( (*iter).second.OS == base || base.size() == 0) - hosts.push_back((*iter).first); + //a computer list is given : take only resources with OS on those computers + vector vec=hosts; + hosts.clear(); + vector::iterator iter; + for (iter = vec.begin(); iter != vec.end(); iter++) + { + MapOfParserResourcesType::const_iterator it = _resourcesList.find(*iter); + if(it != _resourcesList.end()) + if ( (*it).second.OS == base || base.size() == 0 ) + hosts.push_back(*iter); + } } } @@ -439,7 +468,6 @@ throw(ResourcesException) vector::const_iterator itt = find(mapOfComponentsOfCurrentHost.begin(), mapOfComponentsOfCurrentHost.end(), compoi); -// componentList[i]); if (itt == mapOfComponentsOfCurrentHost.end()){ erasedHost = true; break; diff --git a/src/ResourcesManager/ResourcesManager.hxx b/src/ResourcesManager/ResourcesManager.hxx index 608ce750b..c343a73e0 100644 --- a/src/ResourcesManager/ResourcesManager.hxx +++ b/src/ResourcesManager/ResourcesManager.hxx @@ -44,6 +44,8 @@ struct machineParams{ unsigned int nb_proc_per_node; unsigned int cpu_clock; unsigned int mem_mb; + std::vector componentList; + std::vector computerList; }; class RESOURCESMANAGER_EXPORT ResourcesException @@ -65,8 +67,7 @@ class RESOURCESMANAGER_EXPORT ResourcesManager_cpp ~ResourcesManager_cpp(); std::vector - GetFittingResources(const machineParams& params, - const std::vector& componentList) throw(ResourcesException); + GetFittingResources(const machineParams& params) throw(ResourcesException); std::string Find(const std::string& policy, const std::vector& listOfMachines); diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index 874b79ab6..3531bc30b 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -125,22 +125,21 @@ void SALOME_ResourcesManager::Shutdown() } //============================================================================= +//! get the name of resources fitting the specified constraints (params) /*! - * get the list of name of ressources fitting for the specified component. * If hostname specified, check it is local or known in resources catalog. * * Else * - select first machines with corresponding OS (all machines if * parameter OS empty), - * - then select the sublist of machines on witch the component is known + * - then select the sublist of machines on which the component is known * (if the result is empty, that probably means that the inventory of * components is probably not done, so give complete list from previous step) */ //============================================================================= Engines::MachineList * -SALOME_ResourcesManager::GetFittingResources(const Engines::MachineParameters& params, - const Engines::CompoList& componentList) +SALOME_ResourcesManager::GetFittingResources(const Engines::MachineParameters& params) { // MESSAGE("ResourcesManager::GetFittingResources"); machineParams p; @@ -151,13 +150,15 @@ SALOME_ResourcesManager::GetFittingResources(const Engines::MachineParameters& p p.cpu_clock = params.cpu_clock; p.mem_mb = params.mem_mb; - vector cl; - for(unsigned int i=0;i vec = _rm.GetFittingResources(p,cl); + vector vec = _rm.GetFittingResources(p); ret->length(vec.size()); for(unsigned int i=0;i