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
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.
{
//! host name
string hostname;
+ //! alias name
string alias;
//! protocol to use to start a remote container (ssh or rsh)
string protocol;
//! 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
{
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();
/*!
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 );
}
//=============================================================================
+//! shutdown all the containers, then the ContainerManager servant
/*! CORBA method:
- * shutdown all the containers, then the ContainerManager servant
*/
//=============================================================================
}
//=============================================================================
+//! 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
*/
//=============================================================================
}
//=============================================================================
-//! 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();
}
//=============================================================================
-//! 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;
if (CORBA::is_nil (Catalog))
return Engines::Container::_nil();
// Loop through component list
- for(unsigned int i=0;i<componentList.length();i++)
+ for(unsigned int i=0;i<params.componentList.length();i++)
{
- const char* compoi = componentList[i];
+ const char* compoi = params.componentList[i];
SALOME_ModuleCatalog::Acomponent_var compoInfo = Catalog->GetComponent(compoi);
if (CORBA::is_nil (compoInfo))
{
}
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 "<<possibleComputers.length());
+ for(unsigned int i=0;i<possibleComputers.length();i++)
+ {
+ MESSAGE("FindContainer possible " << possibleComputers[i]);
+ Engines::Container_ptr cont = FindContainer(params,possibleComputers[i]);
+ if( !CORBA::is_nil(cont) )
+ return cont;
+ }
+ MESSAGE("FindContainer: not found");
+ return Engines::Container::_nil();
+}
+
+//=============================================================================
+//! Find a container given constraints (params) on a machine (theMachine)
+/*!
+ *
+ */
+//=============================================================================
+
+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();
+ }
}
#ifdef WITH_PACO_PARALLEL
/*! 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;
// 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");
/*! 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 !");
}
#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 "<<possibleComputers.length());
- for(unsigned int i=0;i<possibleComputers.length();i++)
- {
- MESSAGE("FindContainer possible " << possibleComputers[i]);
- Engines::Container_ptr cont = FindContainer(params,possibleComputers[i]);
- if( !CORBA::is_nil(cont) )
- return cont;
- }
- MESSAGE("FindContainer: not found");
- return Engines::Container::_nil();
-}
-
//=============================================================================
/*! This method launches the parallel container.
* It will may be placed on the ressources manager.
SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_ResourcesManager *rm, SALOME_NamingService *ns);
~SALOME_ContainerManager();
- Engines::Container_ptr
- FindOrStartContainer(const Engines::MachineParameters& params,
- const Engines::MachineList& possibleComputer);
+ void Shutdown();
+ void ShutdownContainers();
Engines::Container_ptr
StartContainer(const Engines::MachineParameters& params,
- const Engines::MachineList& possibleComputer,
- Engines::ResPolicy policy,
+ const Engines::MachineList& possibleComputer,
const std::string& container_exe="SALOME_Container");
Engines::Container_ptr
- StartContainer(const Engines::MachineParameters& params,
- Engines::ResPolicy policy,
- const Engines::CompoList& componentList);
+ StartContainer(const Engines::MachineParameters& params);
Engines::Container_ptr
- GiveContainer(const Engines::MachineParameters& params,
- Engines::ResPolicy policy,
- const Engines::CompoList& componentList);
+ GiveContainer(const Engines::MachineParameters& params);
- void Shutdown();
- void ShutdownContainers();
+ Engines::Container_ptr
+ FindOrStartContainer(const Engines::MachineParameters& params);
static const char *_ContainerManagerNameInNS;
// Parallel extension
Engines::Container_ptr
- FindOrStartParallelContainer(const Engines::MachineParameters& params,
- const Engines::MachineList& possibleComputer);
+ FindOrStartParallelContainer(const Engines::MachineParameters& params);
protected:
Engines::Container_ptr
FindContainer(const Engines::MachineParameters& params,
- const Engines::MachineList& possibleComputers);
+ const Engines::MachineList& possibleComputers);
Engines::Container_ptr
FindContainer(const Engines::MachineParameters& params,
- const char *theMachine);
+ const char *theMachine);
// Parallel extension
CORBA::Object_ptr
// verify if cluster is in resources catalog
machineParams params;
params.hostname = clusterName;
- vector<string> aCompoList ;
try{
- aMachineList = _ResManager->GetFittingResources(params, aCompoList);
+ aMachineList = _ResManager->GetFittingResources(params);
}
catch(const ResourcesException &ex){
throw LauncherException(ex.msg.c_str());
throw LauncherException("Batch parameters are bad (see informations above)");
// find a cluster matching the structure params
- vector<string> aCompoList ;
try{
- aMachineList = _ResManager->GetFittingResources(params, aCompoList);
+ aMachineList = _ResManager->GetFittingResources(params);
}
catch(const ResourcesException &ex){
throw LauncherException(ex.msg.c_str());
throw LauncherException("You must set Resources Manager to Launcher!!");
// find a cluster matching params structure
- vector<string> aCompoList ;
- vector<string> aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ;
+ vector<string> aMachineList = _ResManager->GetFittingResources( params ) ;
ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]);
string clustername(p.Alias);
throw LauncherException("You must set Resources Manager to Launcher!!");
// find a cluster matching params structure
- vector<string> aCompoList ;
- vector<string> aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ;
+ vector<string> aMachineList = _ResManager->GetFittingResources( params ) ;
ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]);
string clustername(p.Alias);
if(!_ResManager)
throw LauncherException("You must set Resources Manager to Launcher!!");
- vector<string> aCompoList ;
- vector<string> aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ;
+ vector<string> aMachineList = _ResManager->GetFittingResources( params ) ;
ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]);
string clustername(p.Alias);
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");
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");
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 (! 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();
}
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();
}
{
params.container_name = "";
params.hostname = "";
- params.alias = "";
- params.protocol = "";
- params.username = "";
- params.applipath = "";
//param.componentList = 0;
//param.computerList = 0;
params.OS = "";
params.nb_proc_per_node = 0;
params.nb_node = 0;
params.isMPI = false;
- params.mpiImpl="";
- params.batch="";
params.workingdir = "";
params.mode = "";
params.policy = "";
* \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
*/
//=============================================================================
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);
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();
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);
}
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;
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();
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";
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;
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)
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
# Scripts to be installed
dist_salomescript_PYTHON = \
LifeCycleCORBA_SWIGTest.py \
+ testresourcemanager.py \
+ testcontainermanager.py \
TestLifeCycleCORBA_SWIG.py
#
--- /dev/null
+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 :
+<!DOCTYPE ResourcesCatalog>
+<resources>
+ <machine hostname="claui2c6" >
+ </machine>
+ <machine hostname="clt10br" >
+ </machine>
+</resources>
+"""
+ 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()
+
--- /dev/null
+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:
+<!DOCTYPE ResourcesCatalog>
+<resources>
+ <machine hostname="m1" />
+ <machine hostname="m2" />
+ <machine hostname="m3" >
+ <modules moduleName="tutu" />
+ </machine>
+ <machine hostname="m4" >
+ <component name="sub" moduleName="tata" />
+ </machine>
+ <machine hostname="claui2c6" >
+ <modules moduleName="toto" />
+ <component name="add" moduleName="titi" />
+ </machine>
+</resources>
+"""
+ 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()
+
{
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));
{
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)
#include <sys/types.h>
#include <sys/stat.h>
+#include <unistd.h>
#include <libxml/parser.h>
#include <algorithm>
_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!!");
}
//=============================================================================
+//! 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<std::string>
-ResourcesManager_cpp::GetFittingResources(const machineParams& params,
- const std::vector<std::string>& componentList) throw(ResourcesException)
+ResourcesManager_cpp::GetFittingResources(const machineParams& params) throw(ResourcesException)
{
vector <std::string> vec;
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());
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);
{
string base(OS);
- for (map<string, ParserResourcesType>::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<string, ParserResourcesType>::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<string> vec=hosts;
+ hosts.clear();
+ vector<string>::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);
+ }
}
}
vector<string>::const_iterator itt = find(mapOfComponentsOfCurrentHost.begin(),
mapOfComponentsOfCurrentHost.end(),
compoi);
-// componentList[i]);
if (itt == mapOfComponentsOfCurrentHost.end()){
erasedHost = true;
break;
unsigned int nb_proc_per_node;
unsigned int cpu_clock;
unsigned int mem_mb;
+ std::vector<std::string> componentList;
+ std::vector<std::string> computerList;
};
class RESOURCESMANAGER_EXPORT ResourcesException
~ResourcesManager_cpp();
std::vector<std::string>
- GetFittingResources(const machineParams& params,
- const std::vector<std::string>& componentList) throw(ResourcesException);
+ GetFittingResources(const machineParams& params) throw(ResourcesException);
std::string Find(const std::string& policy, const std::vector<std::string>& listOfMachines);
}
//=============================================================================
+//! 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;
p.cpu_clock = params.cpu_clock;
p.mem_mb = params.mem_mb;
- vector<string> cl;
- for(unsigned int i=0;i<componentList.length();i++)
- cl.push_back(string(componentList[i]));
+ for(unsigned int i=0;i<params.componentList.length();i++)
+ p.componentList.push_back(string(params.componentList[i]));
+
+ for(unsigned int i=0;i<params.computerList.length();i++)
+ p.computerList.push_back(string(params.computerList[i]));
Engines::MachineList *ret=new Engines::MachineList;
try{
- vector <std::string> vec = _rm.GetFittingResources(p,cl);
+ vector <std::string> vec = _rm.GetFittingResources(p);
ret->length(vec.size());
for(unsigned int i=0;i<vec.size();i++)
(*ret)[i] = (vec[i]).c_str();
~SALOME_ResourcesManager();
Engines::MachineList *
- GetFittingResources(const Engines::MachineParameters& params,
- const Engines::CompoList& componentList);
+ GetFittingResources(const Engines::MachineParameters& params);
char* FindFirst(const Engines::MachineList& listOfMachines);
char* Find(const char *policy, const Engines::MachineList& listOfMachines);