From 43314550540f9bb5177f4130d9bb1e60c9677084 Mon Sep 17 00:00:00 2001 From: ribes Date: Fri, 13 Apr 2007 07:48:28 +0000 Subject: [PATCH] - Adding Load_ParallelComponent to LifeCycleCORBA --- src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx | 51 +++++++++++++++---- src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx | 9 +++- .../libSALOME_LifeCycleCORBA.i | 10 ++++ 3 files changed, 59 insertions(+), 11 deletions(-) diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index bdeddc58e..7f6ad28ac 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -476,16 +476,47 @@ _LoadComponent(const Engines::MachineParameters& params, return myInstance._retn(); } +Engines::Component_ptr +SALOME_LifeCycleCORBA::Load_ParallelComponent(const Engines::MachineParameters& params, + const char *componentName, + int studyId) +{ + MESSAGE("Entering LoadParallelComponent"); + +/*MESSAGE("Parameters : "); + MESSAGE("Container name : " << params.container_name); + MESSAGE("Number of component nodes : " << params.nb_component_nodes); + MESSAGE("Component Name : " << componentName);*/ + + MESSAGE("Building a list of machines"); + Engines::MachineList_var listOfMachines = _ContManager->GetFittingResources(params, componentName); + if (listOfMachines->length() == 0) + { + INFOS("No matching machines founded !"); + return Engines::Component::_nil(); + } + MESSAGE("Starting Parallel Container"); + Engines::Container_var cont = _ContManager->FindOrStartParallelContainer(params, listOfMachines); + if (CORBA::is_nil(cont)) { + INFOS("FindOrStartParallelContainer() returns a NULL container !"); + return Engines::Component::_nil(); + } - - - - - - - - - - + MESSAGE("Loading component library"); + bool isLoadable = cont->load_component_Library(componentName); + if (!isLoadable) { + INFOS(componentName <<" library is not loadable !"); + return Engines::Component::_nil(); + } + + MESSAGE("Creating component instance"); + // @PARALLEL@ permits to identify that the component requested + // is a parallel component. + string name = string(componentName) + string("@PARALLEL@"); + Engines::Component_var myInstance = cont->create_component_instance(name.c_str(), studyId); + if (CORBA::is_nil(myInstance)) + INFOS("create_component_instance returns a NULL component !"); + return myInstance._retn(); +} diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx index 5072ee4df..a8e0d5a88 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx @@ -39,7 +39,8 @@ #include #include CORBA_CLIENT_HEADER(SALOME_ContainerManager) #include CORBA_CLIENT_HEADER(SALOME_Component) - +#include +using namespace std; #ifdef WNT # if defined LIFECYCLECORBA_EXPORTS # define LIFECYCLECORBA_EXPORT __declspec( dllexport ) @@ -85,6 +86,12 @@ public: FindOrLoad_Component(const char *containerName, const char *componentName); // for compatibility + // Parallel extension + Engines::Component_ptr + Load_ParallelComponent(const Engines::MachineParameters& params, + const char *componentName, + int studyId); + bool isKnownComponentClass(const char *componentName); bool isMpiContainer(const Engines::MachineParameters& params) diff --git a/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i b/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i index b017bb535..feaca2631 100644 --- a/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i +++ b/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i @@ -163,6 +163,8 @@ struct omniORBpyAPI { param->nb_proc_per_node = 0; param->nb_node = 0; param->isMPI = false; + param->parallelLib = CORBA::string_dup(""); + param->nb_component_nodes = 0; PyObject *key, *value; int pos = 0; while (PyDict_Next($input, &pos, &key, &value)) @@ -201,6 +203,14 @@ struct omniORBpyAPI { { param->isMPI = PyLong_AsLong(value); } + else if (strcmp(keystr,"parallelLib")==0) + { + param->parallelLib = CORBA::string_dup(PyString_AsString(value)); + } + else if (strcmp(keystr,"nb_component_nodes")==0) + { + param->nb_component_nodes = PyLong_AsLong(value); + } } $1 = param; } -- 2.39.2