From: prascle Date: Thu, 22 Sep 2005 16:50:42 +0000 (+0000) Subject: PR: LifeCycle and Application X-Git-Tag: V302_lcrm_20051002~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=92cc007d4f2979b77ef5d72485d57f58491330eb;p=modules%2Fkernel.git PR: LifeCycle and Application --- diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index ddfcb3776..e9caaf315 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -15,6 +15,15 @@ using namespace std; const char *SALOME_ContainerManager::_ContainerManagerNameInNS = "/ContainerManager"; +//============================================================================= +/*! + * Constructor + * \param orb + * Define a CORBA single thread policy for the server, which avoid to deal + * with non thread-safe usage like Change_Directory in SALOME naming service + */ +//============================================================================= + SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb) { MESSAGE("constructor"); @@ -42,6 +51,12 @@ SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb) MESSAGE("constructor end"); } +//============================================================================= +/*! + * destructor + */ +//============================================================================= + SALOME_ContainerManager::~SALOME_ContainerManager() { MESSAGE("destructor"); @@ -49,6 +64,12 @@ SALOME_ContainerManager::~SALOME_ContainerManager() delete _ResManager; } +//============================================================================= +/*! CORBA method: + * shutdown all the containers, then the ContainerManager servant + */ +//============================================================================= + void SALOME_ContainerManager::Shutdown() { MESSAGE("Shutdown"); @@ -59,6 +80,12 @@ void SALOME_ContainerManager::Shutdown() } +//============================================================================= +/*! CORBA Method: + * Loop on all the containers listed in naming service, ask shutdown on each + */ +//============================================================================= + void SALOME_ContainerManager::ShutdownContainers() { MESSAGE("ShutdownContainers"); @@ -74,6 +101,14 @@ void SALOME_ContainerManager::ShutdownContainers() } } +//============================================================================= +/*! CORBA Method: + * Find a suitable Container in a list of machines, or start one + * \param params Machine Parameters required for the container + * \param possibleComputers list of machines usable for find or start + */ +//============================================================================= + Engines::Container_ptr SALOME_ContainerManager:: FindOrStartContainer(const Engines::MachineParameters& params, @@ -145,6 +180,12 @@ FindOrStartContainer(const Engines::MachineParameters& params, } } +//============================================================================= +/*! + * + */ +//============================================================================= + Engines::MachineList * SALOME_ContainerManager:: GetFittingResources(const Engines::MachineParameters& params, @@ -174,6 +215,12 @@ GetFittingResources(const Engines::MachineParameters& params, return ret; } +//============================================================================= +/*! + * + */ +//============================================================================= + char* SALOME_ContainerManager:: FindBest(const Engines::MachineList& possibleComputers) @@ -182,6 +229,12 @@ FindBest(const Engines::MachineList& possibleComputers) return CORBA::string_dup(theMachine.c_str()); } +//============================================================================= +/*! + * + */ +//============================================================================= + Engines::Container_ptr SALOME_ContainerManager:: FindContainer(const Engines::MachineParameters& params, @@ -195,6 +248,12 @@ FindContainer(const Engines::MachineParameters& params, return Engines::Container::_nil(); } +//============================================================================= +/*! + * + */ +//============================================================================= + Engines::Container_ptr SALOME_ContainerManager:: FindContainer(const Engines::MachineParameters& params, diff --git a/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i b/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i index b0cedeb17..af9877e01 100644 --- a/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i +++ b/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i @@ -51,6 +51,14 @@ if (PyDict_Check($input) == 1) { Engines::MachineParameters *param = new Engines::MachineParameters ; + param->container_name = CORBA::string_dup(""); + param->hostname = CORBA::string_dup(""); + param->OS = CORBA::string_dup(""); + param->mem_mb = 0; + param->cpu_clock = 0; + param->nb_proc_per_node = 0; + param->nb_node = 0; + param->isMPI = false; PyObject *key, *value; int pos = 0; while (PyDict_Next($input, &pos, &key, &value)) @@ -85,6 +93,10 @@ { param->nb_node = PyLong_AsLong(value); } + else if (strcmp(keystr,"isMPI")==0) + { + param->isMPI = PyLong_AsLong(value); + } } $1 = param; } diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index 7f01d24d8..2e826f613 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -21,6 +21,7 @@ #include #include +#include "utilities.h" #define MAX_SIZE_FOR_HOSTNAME 256; @@ -35,8 +36,12 @@ SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb,const char * 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"; +// _path_resources=getenv("KERNEL_ROOT_DIR"); +// _path_resources+="/share/salome/resources/CatalogResources.xml"; + _path_resources=getenv("HOME"); + _path_resources+="/"; + _path_resources+=getenv("APPLI"); + _path_resources+="/CatalogResources.xml"; ParseXmlFile(); } @@ -52,11 +57,10 @@ vector SALOME_ResourcesManager::GetFittingResources(const Engines::Machi //To be sure that we search in a correct list. ParseXmlFile(); const char *hostname=(const char *)params.hostname; - MESSAGE("ResourcesManager::GetFittingResources" << hostname << GetHostname().c_str()); + MESSAGE("GetFittingResources " << hostname << "" << GetHostname().c_str()); if(hostname[0]!='\0') { MESSAGE("ResourcesManager::GetFittingResources : hostname specified" ); - cout << "hostname specified" << endl; if( strcmp(hostname,"localhost") == 0 || strcmp(hostname,GetHostname().c_str()) == 0 ){ MESSAGE("ResourcesManager::GetFittingResources : localhost" ); ret.push_back(GetHostname().c_str()); @@ -209,27 +213,27 @@ bool isPythonContainer(const char* ContainerName) string SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer(const string& machine,const Engines::MachineParameters& params) { - _TmpFileName=BuildTemporaryFileName(); - ofstream tempOutputFile; - tempOutputFile.open(_TmpFileName.c_str(),ofstream::out ); +// _TmpFileName=BuildTemporaryFileName(); +// ofstream tempOutputFile; +// tempOutputFile.open(_TmpFileName.c_str(),ofstream::out ); const ParserResourcesType& resInfo=_resourcesList[machine]; - tempOutputFile << "#! /bin/sh" << endl; - //set env vars - for(map::const_iterator iter=resInfo.ModulesPath.begin();iter!=resInfo.ModulesPath.end();iter++) - { - string curModulePath((*iter).second); - tempOutputFile << (*iter).first << "_ROOT_DIR="<< curModulePath << endl; - tempOutputFile << "export " << (*iter).first << "_ROOT_DIR" << endl; - tempOutputFile << "LD_LIBRARY_PATH=" << curModulePath << "/lib/salome" << ":${LD_LIBRARY_PATH}" << endl; - tempOutputFile << "PYTHONPATH=" << curModulePath << "/bin/salome:" << curModulePath << "/lib/salome:" << curModulePath << "/lib/python2.2/site-packages/salome:"; - tempOutputFile << curModulePath << "/lib/python2.2/site-packages/salome/shared_modules:${PYTHONPATH}" << endl; - } - tempOutputFile << "export LD_LIBRARY_PATH" << endl; - tempOutputFile << "export PYTHONPATH" << endl; - tempOutputFile << "source " << resInfo.PreReqFilePath << endl; - // ! env vars +// tempOutputFile << "#! /bin/sh" << endl; +// //set env vars +// for(map::const_iterator iter=resInfo.ModulesPath.begin();iter!=resInfo.ModulesPath.end();iter++) +// { +// string curModulePath((*iter).second); +// tempOutputFile << (*iter).first << "_ROOT_DIR="<< curModulePath << endl; +// tempOutputFile << "export " << (*iter).first << "_ROOT_DIR" << endl; +// tempOutputFile << "LD_LIBRARY_PATH=" << curModulePath << "/lib/salome" << ":${LD_LIBRARY_PATH}" << endl; +// tempOutputFile << "PYTHONPATH=" << curModulePath << "/bin/salome:" << curModulePath << "/lib/salome:" << curModulePath << "/lib/python2.2/site-packages/salome:"; +// tempOutputFile << curModulePath << "/lib/python2.2/site-packages/salome/shared_modules:${PYTHONPATH}" << endl; +// } +// tempOutputFile << "export LD_LIBRARY_PATH" << endl; +// tempOutputFile << "export PYTHONPATH" << endl; +// tempOutputFile << "source " << resInfo.PreReqFilePath << endl; +// // ! env vars if(params.isMPI){ - tempOutputFile << "mpirun -np "; +// tempOutputFile << "mpirun -np "; int nbproc; if( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) ) nbproc = 1; @@ -239,56 +243,67 @@ string SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer(const strin 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(params.isMPI){ - if(isPythonContainer(params.container_name)) - tempOutputFile << "pyMPI SALOME_ContainerPy.py "; - else - tempOutputFile << "SALOME_MPIContainer "; - } - else{ - if(isPythonContainer(params.container_name)) - tempOutputFile << "SALOME_ContainerPy.py "; - else - tempOutputFile << "SALOME_Container "; - } - tempOutputFile << _NS->ContainerName(params) << " -"; - AddOmninamesParams(tempOutputFile); - tempOutputFile << " &" << endl; - tempOutputFile.flush(); - tempOutputFile.close(); - chmod(_TmpFileName.c_str(),0x1ED); +// std::ostringstream o; +// tempOutputFile << nbproc << " "; + } +// tempOutputFile << (*(resInfo.ModulesPath.find("KERNEL"))).second << "/bin/salome/"; +// if(params.isMPI){ +// if(isPythonContainer(params.container_name)) +// tempOutputFile << "pyMPI SALOME_ContainerPy.py "; +// else +// tempOutputFile << "SALOME_MPIContainer "; +// } +// else{ +// if(isPythonContainer(params.container_name)) +// tempOutputFile << "SALOME_ContainerPy.py "; +// else +// tempOutputFile << "SALOME_Container "; +// } +// tempOutputFile << _NS->ContainerName(params) << " -"; +// AddOmninamesParams(tempOutputFile); +// tempOutputFile << " &" << endl; +// tempOutputFile.flush(); +// tempOutputFile.close(); +// chmod(_TmpFileName.c_str(),0x1ED); //Build command string command; if(resInfo.Protocol==rsh) { command = "rsh "; - string commandRcp="rcp "; - commandRcp+=_TmpFileName; - commandRcp+=" "; - commandRcp+=machine; - commandRcp+=":"; - commandRcp+=_TmpFileName; - system(commandRcp.c_str()); +// string commandRcp="rcp "; +// commandRcp+=_TmpFileName; +// commandRcp+=" "; +// commandRcp+=machine; +// commandRcp+=":"; +// commandRcp+=_TmpFileName; +// system(commandRcp.c_str()); } else if(resInfo.Protocol==ssh) command = "ssh "; else throw SALOME_Exception("Unknown protocol"); - command+=machine; - _CommandForRemAccess=command; - command+=" "; - command+=_TmpFileName; - command += " > "; - command += "/tmp/"; +// command+=machine; +// _CommandForRemAccess=command; +// command+=" "; +// command+=_TmpFileName; +// command += " > "; +// command += "/tmp/"; +// command += _NS->ContainerName(params); +// command += "_"; +// command += machine; +// command += ".log 2>&1 &"; +// cout << "Command is ... " << command << endl; + command += machine; // on suppose le même user par defaut + command += " "; + command += getenv("APPLI"); // chemin relatif a $HOME + command += "/runRemote.sh "; + command += GetHostname(); // ********** A CHANGER, le naming service n'est pas obligatoirement ici + command += " "; + command += getenv("NSPORT"); + command += " SALOME_Container "; command += _NS->ContainerName(params); - command += "_"; - command += machine; - command += ".log 2>&1 &"; - cout << "Command is ... " << command << endl; + command += "&"; + MESSAGE("command =" << command); return command; }