*/
void disconnect(in connectionId id,
in Engines::DSC::Message message) raises(Engines::ConnectionManager::BadId,
- Engines::DSC::PortNotDefined,
- Engines::DSC::PortNotConnected,
- Engines::DSC::BadPortReference);
+ Engines::DSC::PortNotDefined,
+ Engines::DSC::PortNotConnected,
+ Engines::DSC::BadPortReference);
//! Shutdown the ConnectionManager process.
oneway void ShutdownWithExit();
PAR_LIB = libSalomeParallelIDLKernel.la
IDL_PACO = SALOME_ComponentPaCO.idl SALOME_PortsPaCO.idl DSC_EnginesPaCO.idl \
- SALOME_ParamPorts.idl SALOME_PACOExtension.idl
+ SALOME_ParamPortsPaCO.idl SALOME_PACOExtensionPaCO.idl
GEN_PACO = SALOME_ComponentPaCO_Engines_Container_server.cxx \
SALOME_ComponentPaCO_Engines_Container_client.cxx \
// Replicated Method used by the proxy to create
// a PACO Component
void create_paco_component_node_instance(in string registeredName,
- in long studyId);
+ in long studyId) raises(SALOME::SALOME_Exception);
};
/*--------------------------------------------------------------------------------------------*/
MESSAGE("Creating component instance");
// @PARALLEL@ permits to identify that the component requested
// is a parallel component.
- string name = string(componentName) + string("@PARALLEL@");
+ string name = string(componentName);
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 !");
#include "SALOMETraceCollector.hxx"
#include "OpUtil.hxx"
+#include "Container_init_python.hxx"
+
using namespace std;
#ifdef _DEBUG_
// Initialise the ORB.
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
+ KERNEL_PYTHON::init_python(argc,argv);
std::string containerName("");
if(argc > 1) {
myid,
root_poa,
(char*) node_name.c_str(),
+ containerName,
argc, argv);
// PaCO++ init
paco_fabrique_manager * pfm = paco_getFabriqueManager();
servant->setLibThread("omni");
// Activation
- PortableServer::ObjectId * _id = root_poa->activate_object(servant);
- servant->set_id(_id);
- obj = root_poa->id_to_reference(*_id);
+ obj = servant->_this();
// In the NamingService
string hostname = Kernel_Utils::GetHostname();
ns->Register(obj, _containerName.c_str());
pman->activate();
orb->run();
+ PyGILState_Ensure();
+ //Delete python container that destroy orb from python (pyCont._orb.destroy())
+ Py_Finalize();
}
catch (PaCO::PACO_Exception& e)
{
#include "SALOMETraceCollector.hxx"
#include "OpUtil.hxx"
+#include "Container_init_python.hxx"
+
using namespace std;
#ifdef _DEBUG_
cerr << "Level provided : " << provided << endl;
// Initialise the ORB.
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
+ KERNEL_PYTHON::init_python(argc,argv);
// Code pour choisir le reseau infiniband .....
/* string hostname_temp = GetHostname();
myid,
root_poa,
(char*) node_name.c_str(),
+ containerName,
argc, argv);
// PaCO++ init
paco_fabrique_manager * pfm = paco_getFabriqueManager();
servant->setLibCom("mpi", ¶llel_object_group);
servant->setLibThread("omni");
- // Activation
- PortableServer::ObjectId * _id = root_poa->activate_object(servant);
- servant->set_id(_id);
- obj = root_poa->id_to_reference(*_id);
+ obj = servant->_this();
// In the NamingService
string hostname = Kernel_Utils::GetHostname();
ns->Register(obj, _containerName.c_str());
pman->activate();
orb->run();
+ PyGILState_Ensure();
+ //Delete python container that destroy orb from python (pyCont._orb.destroy())
+ Py_Finalize();
}
catch (PaCO::PACO_Exception& e)
{
serveur_topo.total = nbnodes;
proxy->setTopology(serveur_topo);
- PortableServer::ObjectId_var _id = root_poa->activate_object(proxy);
- obj = root_poa->id_to_reference(_id);
+ //PortableServer::ObjectId_var _id = root_poa->activate_object(proxy);
+ //obj = root_poa->id_to_reference(_id);
+ obj = proxy->_this();
// In the NamingService
string hostname = Kernel_Utils::GetHostname();
proxy->setTopology(serveur_topo);
// Activation
- PortableServer::ObjectId_var _id = root_poa->activate_object(proxy);
- obj = root_poa->id_to_reference(_id);
+ //PortableServer::ObjectId_var _id = root_poa->activate_object(proxy);
+ //obj = root_poa->id_to_reference(_id);
+ obj = proxy->_this();
// in the NamingService
string hostname = Kernel_Utils::GetHostname();
//Test if lib could contain a parallel component
- std::string paco_test_fct_signature("isAPACO_Component");
+ std::string paco_test_fct_signature = aCompName + std::string("_isAPACO_Component");
+ INFOS("SIG is : " << paco_test_fct_signature);
PACO_TEST_FUNCTION paco_test_fct = NULL;
#ifndef WIN32
paco_test_fct = (PACO_TEST_FUNCTION)dlsym(handle, paco_test_fct_signature.c_str());
#else
paco_test_fct = (PACO_TEST_FUNCTION)GetProcAddress((HINSTANCE)handle, paco_test_fct_signature.c_str());
#endif
- if (!paco_test_fct)
+ if (paco_test_fct)
{
// PaCO Component found
MESSAGE("PACO LIB FOUND");
_libtype_map[aCompName] = "par";
- _parlibfct_map[aCompName] = paco_test_fct;
+ }
+ else
+ {
+ MESSAGE("SEQ LIB FOUND");
+#ifndef WIN32
+ MESSAGE("dlerror() result is : " << dlerror());
+#endif
}
}
_numInstanceMutex.unlock();
}
// If ret is false -> lib is not loaded !
- _libtype_map.erase(aCompName);
+ if (!ret)
+ _libtype_map.erase(aCompName);
return ret;
}
if (_libtype_map.count(aCompName) == 0)
{
// Component is not loaded !
- INFOS("Proxy: component is not loaded !");
+ INFOS("Proxy: component is not loaded ! : " << aCompName);
return Engines::Component::_nil();
}
if (_libtype_map[aCompName] == "seq")
return Engines::Container_proxy_impl::create_component_instance(componentName, studyId);
- // Test if the component inside the parallel lib
- // is parallel or sequential
- bool parallel_component = (_parlibfct_map[aCompName]) (componentName);
- if (!parallel_component)
- return Engines::Container_proxy_impl::create_component_instance(componentName, studyId);
-
// Parallel Component !
Engines::Component_var component_proxy = Engines::Component::_nil();
CORBA::Object_var obj = _poa->id_to_reference(*id);
component_proxy = Engines::Component::_narrow(obj) ;
- _cntInstances_map[impl_name] += 1;
+ if (!CORBA::is_nil(component_proxy))
+ {
+ _cntInstances_map[impl_name] += 1;
- // --- register the engine under the name
- // containerName(.dir)/instanceName(.object)
- _NS->Register(component_proxy , component_registerName.c_str()) ;
- MESSAGE(component_registerName.c_str() << " bound" ) ;
+ // --- register the engine under the name
+ // containerName(.dir)/instanceName(.object)
+ _NS->Register(component_proxy , component_registerName.c_str()) ;
+ MESSAGE(component_registerName.c_str() << " bound" ) ;
+ }
+ else
+ {
+ INFOS("The factory returns a nil object !");
+ return Engines::Component::_nil();
+ }
+
}
catch (...)
{
return Engines::Component::_nil();
}
+ // Create on each node a work node
+ for (CORBA::ULong i = 0; i < _infos.nodes.length(); i++)
+ {
+ MESSAGE("Call create_paco_component_node_instance on work node : " << i);
+ CORBA::Object_var object = _orb->string_to_object(_infos.nodes[i]);
+ Engines::PACO_Container_var node = Engines::PACO_Container::_narrow(object);
+ if (!CORBA::is_nil(node))
+ {
+ try
+ {
+ node->create_paco_component_node_instance(componentName, studyId);
+ MESSAGE("Call create_paco_component_node_instance done on node : " << i);
+ }
+ catch (SALOME::SALOME_Exception & ex)
+ {
+ INFOS("SALOME_EXCEPTION : " << ex.details.text);
+ return Engines::Component::_nil();
+ }
+ catch (...)
+ {
+ INFOS("Unknown Exception catch during create_paco_component_node_instance on node : " << i);
+ return Engines::Component::_nil();
+ }
+ }
+ else
+ {
+ INFOS("Cannot call create_paco_component_node_instance on node " << i << " ref is nil !");
+ return Engines::Component::_nil();
+ }
+ }
+
+ // Start Parallel object
+ PaCO::InterfaceManager_var paco_proxy = PaCO::InterfaceManager::_narrow(component_proxy);
+ paco_proxy->start();
+
return component_proxy;
}
private:
std::map<std::string, std::string> _libtype_map; // libname -> libtype (seq ou par)
- typedef bool (*PACO_TEST_FUNCTION) (const char *);
+ typedef void (*PACO_TEST_FUNCTION) ();
typedef PortableServer::ObjectId * (*FACTORY_FUNCTION) (CORBA::ORB_ptr,
paco_fabrique_thread *,
PortableServer::POA_ptr,
PortableServer::ObjectId *,
const char *,
int);
- std::map<std::string, PACO_TEST_FUNCTION> _parlibfct_map;
int _numInstance;
std::string _containerName;
PortableServer::POA_var _poa;
char * ior,
int rank,
PortableServer::POA_ptr poa,
- char *containerName ,
+ char *containerName,
+ std::string proxy_containerName,
int argc , char* argv[],
bool isServantAloneInProcess
) :
_NS = new SALOME_NamingService();
_NS->init_orb(_orb);
_containerName = _NS->BuildContainerNameForNS(containerName, _hostname.c_str());
- _NS->Register(container_node, _containerName.c_str());
+ _proxy_containerName = proxy_containerName;
+ //_NS->Register(container_node, _containerName.c_str());
// Init Python container part
CORBA::String_var sior = _orb->object_to_string(container_node);
Engines_Parallel_Container_i::create_paco_component_node_instance(const char* componentName,
CORBA::Long studyId)
{
+ // Init de la méthode
+ char * proxy_ior;
+ Engines::Component_PaCO_var work_node;
+ std::string aCompName = componentName;
+#ifndef WIN32
+ string impl_name = string ("lib") + aCompName +string("Engine.so");
+#else
+ string impl_name = aCompName +string("Engine.dll");
+#endif
+ void* handle = _library_map[impl_name];
+ _numInstanceMutex.lock() ; // lock on the instance number
+ _numInstance++ ;
+ _numInstanceMutex.unlock() ;
+ char aNumI[12];
+ sprintf( aNumI , "%d" , _numInstance ) ;
+ string instanceName = aCompName + "_inst_" + aNumI ;
+
+ // Step 1 : Get proxy !
+ string component_registerName = _proxy_containerName + "/" + instanceName;
+ CORBA::Object_var temp = _NS->Resolve(component_registerName.c_str());
+ Engines::Component_var obj_proxy = Engines::Component::_narrow(temp);
+ if (CORBA::is_nil(obj_proxy))
+ {
+ INFOS("Proxy reference from NamingService is nil !");
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "Proxy reference from NamingService is nil !";
+ throw SALOME::SALOME_Exception(es);
+ }
+ proxy_ior = _orb->object_to_string(obj_proxy);
+
+ // Get factory
+ string factory_name = aCompName + string("Engine_factory");
+ FACTORY_FUNCTION Component_factory = (FACTORY_FUNCTION) dlsym(handle, factory_name.c_str());
+ if (!Component_factory)
+ {
+ INFOS("Can't resolve symbol : " + factory_name);
+#ifndef WIN32
+ INFOS("dlerror() result is : " << dlerror());
+#endif
+ std::string ex_text = "Can't resolve symbol : " + factory_name;
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = CORBA::string_dup(ex_text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
+
+ try
+ {
+ char aNumI2[12];
+ sprintf(aNumI2 , "%d" , getMyRank()) ;
+ string instanceName = aCompName + "_inst_" + aNumI + "_work_node_" + aNumI2;
+ string component_registerName = _containerName + aNumI2 + "/" + instanceName;
+
+ // --- Instanciate work node
+ PortableServer::ObjectId *id ; //not owner, do not delete (nore use var)
+ id = (Component_factory) (_orb, proxy_ior, getMyRank(), _poa, _id, instanceName.c_str(), componentName);
+
+ // --- get reference & servant from id
+ CORBA::Object_var obj = _poa->id_to_reference(*id);
+ work_node = Engines::Component_PaCO::_narrow(obj) ;
+ if (CORBA::is_nil(work_node))
+ {
+ INFOS("work_node reference from factory is nil !");
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "work_node reference from factory is nil !";
+ throw SALOME::SALOME_Exception(es);
+ }
+ work_node->deploy();
+ _NS->Register(work_node, component_registerName.c_str());
+ MESSAGE(component_registerName.c_str() << " bound" );
+ }
+ catch (...)
+ {
+ INFOS("Container_i::create_paco_component_node_instance exception catched");
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "Container_i::create_paco_component_node_instance exception catched";
+ throw SALOME::SALOME_Exception(es);
+ }
}
Engines::Component_ptr
Engines_Parallel_Container_i(CORBA::ORB_ptr orb, char * ior, int rank,
PortableServer::POA_ptr poa,
char * containerName ,
+ std::string proxy_containerName,
int argc, char* argv[],
bool isServantAloneInProcess = true);
virtual ~Engines_Parallel_Container_i();
std::string _hostname;
std::string _library_path;
std::string _containerName;
+ std::string _proxy_containerName;
std::string _logfilename;
CORBA::ORB_var _orb;
PortableServer::POA_var _poa;
_fileRef_map_t _fileRef_map;
_Salome_file_map_t _Salome_file_map;
+ typedef PortableServer::ObjectId * (*FACTORY_FUNCTION) (CORBA::ORB_ptr, char *, int,
+ PortableServer::POA_ptr,
+ PortableServer::ObjectId *,
+ const char *,
+ const char *);
};
#endif