From: jfa Date: Mon, 5 Dec 2005 14:40:42 +0000 (+0000) Subject: PAL10761: improve remote launch of containers. A fix by Anthony GEAY. X-Git-Tag: T_2_2_7pre X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f7cc10bdf7cb36d139e631a9acaa556e44207a75;p=modules%2Fkernel.git PAL10761: improve remote launch of containers. A fix by Anthony GEAY. --- diff --git a/src/Communication/libSALOME_Comm.i b/src/Communication/libSALOME_Comm.i index 35c8e6061..14c7fa470 100644 --- a/src/Communication/libSALOME_Comm.i +++ b/src/Communication/libSALOME_Comm.i @@ -1,6 +1,8 @@ %{ #include "ReceiverFactory.hxx" #include "SALOME_Comm_i.hxx" + #include "SALOMEMultiComm.hxx" + #include "SenderFactory.hxx" %} %typemap(python,in) SALOME::SenderDouble_ptr @@ -33,6 +35,24 @@ $1 = t; } +%typemap(python,out) SALOME::SenderDouble_ptr +{ + PyObject* pdict = PyDict_New(); + PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); + PyRun_String("import CORBA", Py_single_input, pdict, pdict); + PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, + pdict, pdict); + PyObject* orb = PyDict_GetItemString(pdict, "o"); + // Get the orb Corba C++ + int argc = 0; + char *xargv = ""; + char **argv = &xargv; + CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); + string s = ORB->object_to_string($1); + PyObject * tmp = PyString_FromString(s.c_str()); + $result = PyObject_CallMethod(orb, "string_to_object", "O", tmp); +} + PyObject * getValueForSender(SALOME::SenderDouble_ptr senderDouble); %{ @@ -58,3 +78,26 @@ PyObject * getValueForSender(SALOME::SenderDouble_ptr senderDouble) return result; } %} + +SALOME::SenderDouble_ptr buildSenderFromList(PyObject *pylist); +%{ +SALOME::SenderDouble_ptr buildSenderFromList(PyObject *pylist) +{ + if (PyList_Check(pylist)) + { + int listLgth = PyList_Size(pylist); + double *tab=new double[listLgth]; + for (int i=0;i::Instance() ; - CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ; +#if OMNIORB_VERSION >= 4 + const char* options[][2] = { { "giopMaxMsgSize", "104857600" }, { 0, 0 } }; + CORBA::ORB_var orb = CORBA::ORB_init( argc , argv , "omniORB4", options) ; +#else + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3"); + omniORB::MaxMessageSize(100 * 1024 * 1024); +#endif // Obtain a reference to the root POA. SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); INFOS_COMPILATION; BEGIN_OF(argv[0]); diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 77cebf354..5e105f68d 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -11,7 +11,7 @@ using namespace std; const char *SALOME_ContainerManager::_ContainerManagerNameInNS="/ContainerManager"; -SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb) +SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb):_ResManager(orb) { _NS=new SALOME_NamingService(orb); PortableServer::POA_var root_poa=PortableServer::POA::_the_root_poa(); diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index 3d60c6ba2..30c0b6d14 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -25,8 +26,9 @@ SALOME_ResourcesManager::SALOME_ResourcesManager(const char *xmlFilePath):_path_ { } -SALOME_ResourcesManager::SALOME_ResourcesManager() +SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb) { + _NS = new SALOME_NamingService(orb); _path_resources=getenv("KERNEL_ROOT_DIR"); _path_resources+="/share/salome/resources/CatalogResources.xml"; ParseXmlFile(); @@ -34,6 +36,7 @@ SALOME_ResourcesManager::SALOME_ResourcesManager() SALOME_ResourcesManager::~SALOME_ResourcesManager() { + delete _NS; } vector SALOME_ResourcesManager::GetFittingResources(const Engines::MachineParameters& params,const char *moduleName) throw(SALOME_Exception) @@ -184,14 +187,15 @@ string SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer(const strin const ParserResourcesType& resInfo=_resourcesList[machine]; tempOutputFile << "#! /bin/sh" << endl; //set env vars + tempOutputFile << "python_version=`python -c \"import sys; print sys.version[:3]\"`" << endl; 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 << "PYTHONPATH=" << curModulePath << "/bin/salome:" << curModulePath << "/lib/salome:" << curModulePath << "/lib/python${python_version}/site-packages/salome:"; + tempOutputFile << curModulePath << "/lib/python${python_version}/site-packages/salome/shared_modules:${PYTHONPATH}" << endl; } tempOutputFile << "export LD_LIBRARY_PATH" << endl; tempOutputFile << "export PYTHONPATH" << endl; @@ -251,21 +255,16 @@ string SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer(const strin string SALOME_ResourcesManager::BuildCommandToLaunchLocalContainer(const char *containerName) { _TmpFileName=""; - string command; + ostringstream command; if(Engines_Container_i::isPythonContainer(containerName)) - command="SALOME_ContainerPy.py "; + command << "SALOME_ContainerPy.py "; else - command="SALOME_Container "; - command+=containerName; - command+=" -"; + command << "SALOME_Container "; + command << containerName << " -"; AddOmninamesParams(command); - command+=" > /tmp/"; - command+=containerName; - command += "_"; - command += GetHostname(); - command += ".log 2>&1 &" ; - cout << "Command is ... " << command << endl << flush; - return command; + command << " > /tmp/" << containerName << "_" << GetHostname() << ".log 2>&1 &"; + cout << "Command is ... " << command.str() << endl << flush; + return command.str(); } void SALOME_ResourcesManager::RmTmpFile() @@ -288,32 +287,26 @@ string SALOME_ResourcesManager::BuildCommand(const string& machine,const char *c // rsh -n ikkyo /export/home/rahuel/SALOME_ROOT/bin/runSession SALOME_Container -ORBInitRef NameService=corbaname::dm2s0017:1515 & const ParserResourcesType& resInfo=_resourcesList[machine]; bool pyCont=Engines_Container_i::isPythonContainer(containerName); - string command; + ostringstream command; if(resInfo.Protocol==rsh) - command = "rsh -n " ; + command << "rsh -n " ; else if(resInfo.Protocol==ssh) - command = "ssh -f -n "; + command << "ssh -f -n "; else throw SALOME_Exception("Not implemented yet..."); - command += machine; - command += " "; + command << machine << " "; string path = (*(resInfo.ModulesPath.find("KERNEL"))).second; - command +=path; - command += "/bin/salome/"; + command << path <<"/bin/salome/"; if ( pyCont ) - command += "SALOME_ContainerPy.py "; + command << "SALOME_ContainerPy.py "; else - command += "SALOME_Container "; - command += containerName; - command += " -"; + command << "SALOME_Container "; + command << containerName; + command << " -"; AddOmninamesParams(command); - command += " > /tmp/"; - command += containerName; - command += "_"; - command += machine; - command += ".log 2>&1 &" ; + command << " > /tmp/" << containerName << "_" << machine << ".log 2>&1 &" ; SCRUTE( command ); - return command; + return command.str(); } // Warning need an updated parsed list : _resourcesList @@ -339,40 +332,10 @@ void SALOME_ResourcesManager::KeepOnlyResourcesWithModule(vector& hosts, } } -void SALOME_ResourcesManager::AddOmninamesParams(string& command) const +void SALOME_ResourcesManager::AddOmninamesParams(ostream& fileStream) const { - string omniORBcfg( getenv( "OMNIORB_CONFIG" ) ) ; - ifstream omniORBfile( omniORBcfg.c_str() ) ; - char ORBInitRef[12] ; - char nameservice[132] ; - omniORBfile >> ORBInitRef ; - command += ORBInitRef ; - command += " " ; - omniORBfile >> nameservice ; - omniORBfile.close() ; - char * bsn = strchr( nameservice , '\n' ) ; - if ( bsn ) { - bsn[ 0 ] = '\0' ; - } - command += nameservice ; -} - -void SALOME_ResourcesManager::AddOmninamesParams(ofstream& fileStream) const -{ - string omniORBcfg( getenv( "OMNIORB_CONFIG" ) ) ; - ifstream omniORBfile( omniORBcfg.c_str() ) ; - char ORBInitRef[12] ; - char nameservice[132] ; - omniORBfile >> ORBInitRef ; - fileStream << ORBInitRef; - fileStream << " "; - omniORBfile >> nameservice ; - omniORBfile.close() ; - char * bsn = strchr( nameservice , '\n' ) ; - if ( bsn ) { - bsn[ 0 ] = '\0' ; - } - fileStream << nameservice; + char *iorstr = _NS->getIORaddr(); + fileStream << "ORBInitRef NameService=" << iorstr; } string SALOME_ResourcesManager::BuildTemporaryFileName() const @@ -387,5 +350,3 @@ string SALOME_ResourcesManager::BuildTemporaryFileName() const command += ".sh"; return command; } - - diff --git a/src/ResourcesManager/SALOME_ResourcesManager.hxx b/src/ResourcesManager/SALOME_ResourcesManager.hxx index c0b6ef385..0b1f00ce4 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.hxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.hxx @@ -6,6 +6,7 @@ #include #include "SALOME_ResourcesCatalog_Handler.hxx" #include "SALOME_LoadRateManager.hxx" +#include "SALOME_NamingService.hxx" #include CORBA_CLIENT_HEADER(SALOME_ContainerManager) #include #include @@ -18,7 +19,7 @@ class SALOME_ResourcesManager { public: //! standard constructor - SALOME_ResourcesManager(); + SALOME_ResourcesManager(CORBA::ORB_ptr orb); //!just for test SALOME_ResourcesManager(const char *xmlFilePath); @@ -72,15 +73,14 @@ private: //! method that keep from hosts only those having component of name moduleName. void KeepOnlyResourcesWithModule(std::vector& hosts,const char *moduleName) const throw(SALOME_Exception); - //! methode that add to command all options relative to naming service. - void AddOmninamesParams(std::string& command) const; - //! method that add to command all options relative to naming service. - void AddOmninamesParams(std::ofstream& fileStream) const; + void AddOmninamesParams(std::ostream& fileStream) const; //! method that generate a file name in /tmp directory std::string BuildTemporaryFileName() const; + SALOME_NamingService *_NS; + // will contain the path to the ressources catalog QString _path_resources;