From: ribes Date: Fri, 18 Jan 2008 09:20:35 +0000 (+0000) Subject: - Adapt code to the new PaCO++ version X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fae12c30e22dda95edc1012add589765a6cd73d4;p=modules%2Fkernel.git - Adapt code to the new PaCO++ version - Remove Parallel Idl compilation when PaCO++ is used --- diff --git a/idl/Makefile.am b/idl/Makefile.am index b6a3f3d0b..f864c7187 100644 --- a/idl/Makefile.am +++ b/idl/Makefile.am @@ -26,6 +26,10 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am +if WITH_PACO_PARALLEL +MAKEFLAGS = -j1 +endif + AM_CXXFLAGS = -fPIC BASEIDL_FILES = \ diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index ec691459d..679dc1906 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -344,6 +344,7 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params_const, const Engines::MachineList& possibleComputers) { CORBA::Object_var obj; + PaCO::InterfaceManager_var proxy; Engines::Container_ptr ret = Engines::Container::_nil(); Engines::MachineParameters params(params_const); @@ -376,6 +377,7 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params_const, params_proxy.nb_component_nodes = 0; obj = LaunchParallelContainer(command, params_proxy, _NS->ContainerName(params)); ret = Engines::Container::_narrow(obj); + proxy = PaCO::InterfaceManager::_narrow(obj); // Step 4 : starting parallel container nodes command = _ResManager->BuildCommandToLaunchLocalParallelContainer("SALOME_ParallelContainerNode", params, "xterm"); @@ -411,8 +413,9 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params_const, PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(obj); MESSAGE("[FindOrStartParallelContainer] Deploying node : " << name); - node->deploy(i); + node->deploy(); } + proxy->start(); } catch(CORBA::SystemException& e) { diff --git a/src/DSC/ParallelDSC/ParallelDSC_i.cxx b/src/DSC/ParallelDSC/ParallelDSC_i.cxx index c4f15adb5..291e3138c 100644 --- a/src/DSC/ParallelDSC/ParallelDSC_i.cxx +++ b/src/DSC/ParallelDSC/ParallelDSC_i.cxx @@ -25,19 +25,21 @@ #include "ParallelDSC_i.hxx" -Engines_ParallelDSC_i::Engines_ParallelDSC_i(CORBA::ORB_ptr orb, char * ior, +Engines_ParallelDSC_i::Engines_ParallelDSC_i(CORBA::ORB_ptr orb, + char * ior, + int rank, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId, const char *instanceName, const char *interfaceName, bool notif) : - Engines_Parallel_Component_i(orb, ior, poa, contId, instanceName, interfaceName, notif), - Engines::Parallel_DSC_serv(orb, ior), - Engines::DSC_serv(orb, ior), - Engines::Superv_Component_serv(orb, ior), - Engines::Component_serv(orb, ior), - Engines::Parallel_Component_serv(orb, ior), - InterfaceParallel_impl(orb,ior) + Engines_Parallel_Component_i(orb, ior, rank, poa, contId, instanceName, interfaceName, notif), + Engines::Parallel_DSC_serv(orb, ior, rank), + Engines::DSC_serv(orb, ior, rank), + Engines::Superv_Component_serv(orb, ior, rank), + Engines::Component_serv(orb, ior, rank), + Engines::Parallel_Component_serv(orb, ior, rank), + InterfaceParallel_impl(orb, ior, rank) { } @@ -56,10 +58,8 @@ Engines_ParallelDSC_i::set_paco_proxy(const CORBA::Object_ptr ref, Engines_DSC_interface::add_provides_port(Ports::Port::_narrow(ref), provides_port_name, port_prop); - PaCO_operation * global_ptr = getContext("global_paco_context"); - cerr << " my_comm : " << global_ptr->my_com << endl; // Waiting that all the nodes have the proxy - global_ptr->my_com->paco_barrier(); + _my_com->paco_barrier(); cerr << "set_paco_proxy node fin" << endl; } @@ -80,8 +80,8 @@ Engines_ParallelDSC_i::add_parallel_provides_proxy_port(const CORBA::Object_ptr { assert(provides_port_name); CORBA::Boolean rtn_bool = false; - CORBA::Object_ptr _comp_proxy = _orb->string_to_object(_ior.c_str()); - Engines::Parallel_DSC_var real_comp_proxy = Engines::Parallel_DSC::_narrow(_comp_proxy); + Engines::Parallel_DSC_var real_comp_proxy = + Engines::Parallel_DSC::_narrow(InterfaceParallel_impl::_proxy); real_comp_proxy->set_paco_proxy(ref, provides_port_name, port_prop); rtn_bool = true; return rtn_bool; @@ -114,7 +114,7 @@ Engines_ParallelDSC_i::add_parallel_provides_node_port(Ports::Port_PaCO_ptr ref, { CORBA::Boolean rtn_bool = false; PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(ref); - node->deploy(getMyRank()); + node->deploy(); rtn_bool = true; return rtn_bool; } diff --git a/src/DSC/ParallelDSC/ParallelDSC_i.hxx b/src/DSC/ParallelDSC/ParallelDSC_i.hxx index ed900566f..05859c002 100644 --- a/src/DSC/ParallelDSC/ParallelDSC_i.hxx +++ b/src/DSC/ParallelDSC/ParallelDSC_i.hxx @@ -39,7 +39,9 @@ class Engines_ParallelDSC_i: public virtual Engines_DSC_interface { public: - Engines_ParallelDSC_i(CORBA::ORB_ptr orb, char * ior, + Engines_ParallelDSC_i(CORBA::ORB_ptr orb, + char * ior, + int rank, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId, const char *instanceName, diff --git a/src/ParallelContainer/Parallel_Salome_file_i.cxx b/src/ParallelContainer/Parallel_Salome_file_i.cxx index 15f9338fb..7c9394863 100644 --- a/src/ParallelContainer/Parallel_Salome_file_i.cxx +++ b/src/ParallelContainer/Parallel_Salome_file_i.cxx @@ -26,11 +26,13 @@ #include "Parallel_Salome_file_i.hxx" #include "utilities.h" -Parallel_Salome_file_i::Parallel_Salome_file_i(CORBA::ORB_ptr orb, const char * ior) : - InterfaceParallel_impl(orb,ior), - Engines::Salome_file_serv(orb,ior), - Engines::fileTransfer_serv(orb,ior), - Engines::Parallel_Salome_file_serv(orb,ior) +Parallel_Salome_file_i::Parallel_Salome_file_i(CORBA::ORB_ptr orb, + const char * ior, + int rank) : + InterfaceParallel_impl(orb,ior,rank), + Engines::Salome_file_serv(orb,ior,rank), + Engines::fileTransfer_serv(orb,ior,rank), + Engines::Parallel_Salome_file_serv(orb,ior,rank) { CORBA::Object_ptr obj = _orb->string_to_object(ior); proxy = Engines::Parallel_Salome_file::_narrow(obj); @@ -168,8 +170,8 @@ Parallel_Salome_file_i::recvFiles_node() { // 2 cases : // Source file is a Salome_file // Source file is a Parallel_Salome_file - PaCO::ParallelKernel_var interface_manager = - PaCO::ParallelKernel::_narrow(_fileDistributedSource[file_infos.file_name.in()]); + PaCO::InterfaceManager_var interface_manager = + PaCO::InterfaceManager::_narrow(_fileDistributedSource[file_infos.file_name.in()]); if (CORBA::is_nil(interface_manager)) result = getDistributedFile(file_infos.file_name.in()); else diff --git a/src/ParallelContainer/Parallel_Salome_file_i.hxx b/src/ParallelContainer/Parallel_Salome_file_i.hxx index c3814a5c4..21384fef9 100644 --- a/src/ParallelContainer/Parallel_Salome_file_i.hxx +++ b/src/ParallelContainer/Parallel_Salome_file_i.hxx @@ -39,7 +39,9 @@ class CONTAINER_EXPORT Parallel_Salome_file_i: public virtual Engines::Parallel_Salome_file_serv { public: - Parallel_Salome_file_i(CORBA::ORB_ptr orb, const char * ior); + Parallel_Salome_file_i(CORBA::ORB_ptr orb, + const char * ior, + int rank); virtual ~Parallel_Salome_file_i(); virtual void setFileNode(const char* file_name, CORBA::Long node); diff --git a/src/ParallelContainer/SALOME_ParallelComponent_i.cxx b/src/ParallelContainer/SALOME_ParallelComponent_i.cxx index db60ae5e4..fab45e703 100644 --- a/src/ParallelContainer/SALOME_ParallelComponent_i.cxx +++ b/src/ParallelContainer/SALOME_ParallelComponent_i.cxx @@ -44,6 +44,7 @@ int SIGUSR11 = 1000; #endif #include +#include using namespace std; @@ -59,8 +60,10 @@ bool Engines_Parallel_Component_i::_isMultiInstance = false; */ //============================================================================= -Engines_Parallel_Component_i::Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior) : - InterfaceParallel_impl(orb,ior), Engines::Component_serv(orb,ior), Engines::Parallel_Component_serv(orb,ior) +Engines_Parallel_Component_i::Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior, int rank) : + InterfaceParallel_impl(orb,ior,rank), + Engines::Component_serv(orb,ior,rank), + Engines::Parallel_Component_serv(orb,ior,rank) { //ASSERT(0); INFOS("Default Constructor..."); @@ -79,15 +82,15 @@ Engines_Parallel_Component_i::Engines_Parallel_Component_i(CORBA::ORB_ptr orb, c */ //============================================================================= -Engines_Parallel_Component_i::Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior, +Engines_Parallel_Component_i::Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior, int rank, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId, const char *instanceName, const char *interfaceName, bool notif) : - InterfaceParallel_impl(orb,ior), - Engines::Component_serv(orb,ior), - Engines::Parallel_Component_serv(orb,ior), + InterfaceParallel_impl(orb,ior,rank), + Engines::Component_serv(orb,ior,rank), + Engines::Parallel_Component_serv(orb,ior,rank), _instanceName(instanceName), _interfaceName(interfaceName), _myConnexionToRegistry(0), @@ -818,34 +821,21 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name, // Firstly, we have to create the proxy object // of the Salome_file and transmit his // reference to the other nodes. + Engines::Parallel_Salome_file_proxy_impl * proxy = NULL; if (getMyRank() == 0) { - Engines::Parallel_Salome_file_proxy_impl * proxy = - new Engines::Parallel_Salome_file_proxy_impl(CORBA::ORB::_duplicate(_orb)); - PaCO_operation * proxy_global_ptr = proxy->getContext("global_paco_context"); - // We initialize the object with the context of the Parallel component - PaCO_operation * compo_global_ptr = getContext("global_paco_context"); - //compo_global_ptr->init_context(proxy_global_ptr); - proxy_global_ptr->init_context(compo_global_ptr); - - paco_fabrique_manager* pfm = paco_getFabriqueManager(); - pfm->register_com("dummy", new paco_dummy_fabrique()); - proxy_global_ptr->setComFab(NULL); - proxy_global_ptr->setLibCom("dummy",NULL); - - proxy_global_ptr->setTypeClient(true); - PaCO::PacoTopology_t client_topo; - client_topo.total = 1; - proxy_global_ptr->setClientTopo(client_topo); + proxy = new Engines::Parallel_Salome_file_proxy_impl(CORBA::ORB::_duplicate(_orb), + new paco_omni_fabrique()); + proxy->copyGlobalContext(this); PaCO::PacoTopology_t serveur_topo; serveur_topo.total = getTotalNode(); - proxy->setTopo(serveur_topo); + proxy->setTopology(serveur_topo); // We register the CORBA objet into the POA CORBA::Object_ptr proxy_ref = proxy->_this(); // We send the reference to all the nodes... - CORBA::Object_ptr comp_proxy = _orb->string_to_object(_ior.c_str()); - Engines::Parallel_Component_var component_proxy = Engines::Parallel_Component::_narrow(comp_proxy); + Engines::Parallel_Component_var component_proxy = + Engines::Parallel_Component::_narrow(InterfaceParallel_impl::_proxy); component_proxy->send_parallel_proxy_object(proxy_ref); // Adding proxy into the map @@ -863,32 +853,35 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name, for (int i = 0; i < getTotalNode(); i++) { if (i == getMyRank()) { Parallel_Salome_file_i * servant = - new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), proxy_ior.c_str()); - PaCO_operation * servant_global_ptr = servant->getContext("global_paco_context"); - - // We initialize the object with the context of the Parallel component - PaCO_operation * compo_global_ptr = this->getContext("global_paco_context"); -// compo_global_ptr->init_context(servant_global_ptr); - servant_global_ptr->init_context(compo_global_ptr); + new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), + proxy_ior.c_str(), + i); + servant->copyGlobalContext(this); // We register the CORBA objet into the POA servant->POA_PaCO::InterfaceParallel::_this(); // Register the servant - servant->deploy(getMyRank()); + servant->deploy(); // Adding servant to the map (*_map)[Salome_file_name] = servant; } - PaCO_operation * compo_global_ptr = this->getContext("global_paco_context"); - compo_global_ptr->my_com->paco_barrier(); + _my_com->paco_barrier(); + // start parallel object + if (getMyRank() == 0) { + proxy->start(); + _my_com->paco_barrier(); + } + else + _my_com->paco_barrier(); } - // Parallel_Salome_file is created and deployed delete _proxy; _proxy = NULL; } + pthread_mutex_unlock(deploy_mutex); proxy_ior = (*_IOR_proxy_map)[Salome_file_name]; CORBA::Object_ptr proxy_ref = _orb->string_to_object(proxy_ior.c_str()); @@ -918,6 +911,7 @@ Engines_Parallel_Component_i::setOutputFileToService(const char* service_name, // Try to find the Salome_file ... _Salome_file_map_it = _map->find(Salome_file_name); + Engines::Parallel_Salome_file_proxy_impl * proxy; if (_Salome_file_map_it == _map->end()) { // We create a new PaCO++ object. @@ -928,33 +922,19 @@ Engines_Parallel_Component_i::setOutputFileToService(const char* service_name, // of the Salome_file and transmit his // reference to the other nodes. if (getMyRank() == 0) { - Engines::Parallel_Salome_file_proxy_impl * proxy = - new Engines::Parallel_Salome_file_proxy_impl(CORBA::ORB::_duplicate(_orb)); - PaCO_operation * proxy_global_ptr = proxy->getContext("global_paco_context"); - // We initialize the object with the context of the Parallel component - PaCO_operation * compo_global_ptr = getContext("global_paco_context"); - //compo_global_ptr->init_context(proxy_global_ptr); - proxy_global_ptr->init_context(compo_global_ptr); - - paco_fabrique_manager* pfm = paco_getFabriqueManager(); - pfm->register_com("dummy", new paco_dummy_fabrique()); - proxy_global_ptr->setComFab(NULL); - proxy_global_ptr->setLibCom("dummy",NULL); - - proxy_global_ptr->setTypeClient(true); - PaCO::PacoTopology_t client_topo; - client_topo.total = 1; - proxy_global_ptr->setClientTopo(client_topo); + proxy = new Engines::Parallel_Salome_file_proxy_impl(CORBA::ORB::_duplicate(_orb), + new paco_omni_fabrique()); + proxy->copyGlobalContext(this); PaCO::PacoTopology_t serveur_topo; serveur_topo.total = getTotalNode(); - proxy->setTopo(serveur_topo); + proxy->setTopology(serveur_topo); // We register the CORBA objet into the POA CORBA::Object_ptr proxy_ref = proxy->_this(); // We send the reference to all the nodes... - CORBA::Object_ptr comp_proxy = _orb->string_to_object(_ior.c_str()); - Engines::Parallel_Component_var component_proxy = Engines::Parallel_Component::_narrow(comp_proxy); + Engines::Parallel_Component_var component_proxy = + Engines::Parallel_Component::_narrow(InterfaceParallel_impl::_proxy); component_proxy->send_parallel_proxy_object(proxy_ref); // Adding proxy into the map @@ -972,26 +952,29 @@ Engines_Parallel_Component_i::setOutputFileToService(const char* service_name, for (int i = 0; i < getTotalNode(); i++) { if (i == getMyRank()) { Parallel_Salome_file_i * servant = - new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), proxy_ior.c_str()); - PaCO_operation * servant_global_ptr = servant->getContext("global_paco_context"); - - // We initialize the object with the context of the Parallel component - PaCO_operation * compo_global_ptr = this->getContext("global_paco_context"); -// compo_global_ptr->init_context(servant_global_ptr); - servant_global_ptr->init_context(compo_global_ptr); + new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), + proxy_ior.c_str(), + i); + servant->copyGlobalContext(this); // We register the CORBA objet into the POA servant->POA_PaCO::InterfaceParallel::_this(); // Register the servant - servant->deploy(getMyRank()); + servant->deploy(); // Adding servant to the map (*_map)[Salome_file_name] = servant; } - PaCO_operation * compo_global_ptr = this->getContext("global_paco_context"); - compo_global_ptr->my_com->paco_barrier(); + _my_com->paco_barrier(); + // start parallel object + if (getMyRank() == 0) { + proxy->start(); + _my_com->paco_barrier(); + } + else + _my_com->paco_barrier(); } // Parallel_Salome_file is created and deployed diff --git a/src/ParallelContainer/SALOME_ParallelComponent_i.hxx b/src/ParallelContainer/SALOME_ParallelComponent_i.hxx index edadf93ce..218864970 100644 --- a/src/ParallelContainer/SALOME_ParallelComponent_i.hxx +++ b/src/ParallelContainer/SALOME_ParallelComponent_i.hxx @@ -64,8 +64,8 @@ class CONTAINER_EXPORT Engines_Parallel_Component_i: public virtual PortableServer::RefCountServantBase { public: - Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior); - Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior, + Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior, int rank); + Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior, int rank, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId, const char *instanceName, diff --git a/src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx b/src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx index 4f5d0d274..d3470b9de 100644 --- a/src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx +++ b/src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx @@ -54,12 +54,12 @@ using namespace std; #include void handler(int t) { - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - cerr << "SIGSEGV in :" << getpid() << endl; - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - while (1) {} + cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; + cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; + cerr << "SIGSEGV in :" << getpid() << endl; + cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; + cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; + while (1) {} } #endif @@ -78,13 +78,13 @@ sighandler_t setsig(int sig, sighandler_t handler) void AttachDebugger() { if(getenv ("DEBUGGER")) - { - std::stringstream exec; - exec << "$DEBUGGER SALOME_ParallelContainerNodeDummy " << getpid() << "&"; - std::cerr << exec.str() << std::endl; - system(exec.str().c_str()); - while(1); - } + { + std::stringstream exec; + exec << "$DEBUGGER SALOME_ParallelContainerNodeDummy " << getpid() << "&"; + std::cerr << exec.str() << std::endl; + system(exec.str().c_str()); + while(1); + } } void Handler(int theSigId) @@ -109,107 +109,104 @@ void unexpectedHandler(void) int main(int argc, char* argv[]) { - INFOS("Launching a parallel container node"); + INFOS("Launching a parallel container node"); -#ifdef _DEBUG_ -// signal(SIGSEGV, handler); -#endif if(getenv ("DEBUGGER")) - { - setsig(SIGSEGV,&Handler); - set_terminate(&terminateHandler); - set_unexpected(&unexpectedHandler); - } - - // Initialise the ORB. - ORB_INIT &init = *SINGLETON_::Instance(); - ASSERT(SINGLETON_::IsAlreadyExisting()); - CORBA::ORB_var orb = init(0, 0); - //CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); - - char * containerName = ""; - if(argc > 1) { - containerName = argv[1]; - } - - char * hostname = ""; - if(argc > 3) { - hostname = argv[3]; - } - - try { - CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); - PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); - PortableServer::POAManager_var pman = root_poa->the_POAManager(); + { + setsig(SIGSEGV,&Handler); + set_terminate(&terminateHandler); + set_unexpected(&unexpectedHandler); + } + + // Initialise the ORB. + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + + std::string containerName(""); + if(argc > 1) { + containerName = argv[1]; + } + std::string hostname(""); + if(argc > 3) { + hostname = argv[3]; + } + + try { + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); + PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); + PortableServer::POAManager_var pman = root_poa->the_POAManager(); #ifndef WNT - // add this container to the kill list - char aCommand[100]; - sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerNode", getpid()); - system(aCommand); + // add this container to the kill list + char aCommand[100]; + sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerNode", getpid()); + system(aCommand); #endif - SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb)); - // Get the proxy - string proxyNameInNS = ns->BuildContainerNameForNS(containerName, hostname); - obj = ns->Resolve(proxyNameInNS.c_str()); - char * proxy_ior = orb->object_to_string(obj); - - // Creating a node - string name(containerName); - string node_name = name + "Node"; - Engines_Parallel_Container_i * servant = new Engines_Parallel_Container_i(CORBA::ORB::_duplicate(orb), proxy_ior, - root_poa, - (char*) node_name.c_str(), - argc, argv); - // PaCO++ init - paco_fabrique_manager * pfm = paco_getFabriqueManager(); - pfm->register_com("dummy", new paco_dummy_fabrique()); - pfm->register_thread("omni", new paco_omni_fabrique()); - - // Global context - PaCO_operation * global_ptr = servant->getContext("global_paco_context"); - global_ptr->setLibCom("dummy",NULL); - global_ptr->setLibThread("omni"); - - // Activation - PortableServer::ObjectId * _id = root_poa->activate_object(servant); - servant->set_id(_id); - obj = root_poa->id_to_reference(*_id); - - // In the NamingService - string hostname = GetHostname(); - int myid = 0; - char buffer [5]; - snprintf(buffer, 5, "%d", myid); - node_name = node_name + buffer; - string _containerName = ns->BuildContainerNameForNS((char*) node_name.c_str(), - hostname.c_str()); - cerr << "---------" << _containerName << "----------" << endl; - ns->Register(obj, _containerName.c_str()); - pman->activate(); - orb->run(); - } - catch(CORBA::SystemException&) - { - INFOS("Caught CORBA::SystemException."); - } - catch(PortableServer::POA::ServantAlreadyActive&) - { - INFOS("Caught CORBA::ServantAlreadyActiveException"); - } - catch(CORBA::Exception&) - { - INFOS("Caught CORBA::Exception."); - } - catch(std::exception& exc) - { - INFOS("Caught std::exception - "<BuildContainerNameForNS(containerName.c_str(), + hostname.c_str()); + obj = ns->Resolve(proxyNameInNS.c_str()); + char * proxy_ior = orb->object_to_string(obj); + + // Creating a node + string node_name = containerName + "Node"; + Engines_Parallel_Container_i * servant = new Engines_Parallel_Container_i(CORBA::ORB::_duplicate(orb), + proxy_ior, + 0, + root_poa, + (char*) node_name.c_str(), + argc, argv); + // PaCO++ init + paco_fabrique_manager * pfm = paco_getFabriqueManager(); + pfm->register_com("dummy", new paco_dummy_fabrique()); + pfm->register_thread("omni", new paco_omni_fabrique()); + servant->setLibCom("dummy", servant); + servant->setLibThread("omni"); + + // Activation + PortableServer::ObjectId * _id = root_poa->activate_object(servant); + servant->set_id(_id); + obj = root_poa->id_to_reference(*_id); + + // In the NamingService + string hostname = GetHostname(); + int myid = 0; + char buffer [5]; + snprintf(buffer, 5, "%d", myid); + node_name = node_name + buffer; + string _containerName = ns->BuildContainerNameForNS((char*) node_name.c_str(), + hostname.c_str()); + cerr << "---------" << _containerName << "----------" << endl; + ns->Register(obj, _containerName.c_str()); + pman->activate(); + orb->run(); + } + catch (PaCO::PACO_Exception& e) + { + INFOS("Caught PaCO::PACO_Exception"); + std::cerr << e << std::endl; + } + catch(CORBA::SystemException&) + { + INFOS("Caught CORBA::SystemException."); + } + catch(PortableServer::POA::ServantAlreadyActive&) + { + INFOS("Caught CORBA::ServantAlreadyActiveException"); + } + catch(CORBA::Exception&) + { + INFOS("Caught CORBA::Exception."); + } + catch(std::exception& exc) + { + INFOS("Caught std::exception - "< void test(int sigval) { - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - cerr << "SIGSEGV in :" << getpid() << endl; - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - while (1) {} + cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; + cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; + cerr << "SIGSEGV in :" << getpid() << endl; + cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; + cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; + while (1) {} } void handler(int t) { - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - cerr << "SIGSEGV in :" << getpid() << endl; - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - while (1) {} + cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; + cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; + cerr << "SIGSEGV in :" << getpid() << endl; + cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; + cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; + while (1) {} } #endif @@ -90,13 +90,13 @@ sighandler_t setsig(int sig, sighandler_t handler) void AttachDebugger() { if(getenv ("DEBUGGER")) - { - std::stringstream exec; - exec << "$DEBUGGER SALOME_ParallelContainerNodeMpi " << getpid() << "&"; - std::cerr << exec.str() << std::endl; - system(exec.str().c_str()); - while(1); - } + { + std::stringstream exec; + exec << "$DEBUGGER SALOME_ParallelContainerNodeMpi " << getpid() << "&"; + std::cerr << exec.str() << std::endl; + system(exec.str().c_str()); + while(1); + } } void Handler(int theSigId) @@ -121,40 +121,31 @@ void unexpectedHandler(void) int main(int argc, char* argv[]) { - INFOS("Launching a parallel Mpi container node"); + INFOS("Launching a parallel Mpi container node"); -#ifdef _DEBUG_ -// struct sigaction action; -// action.sa_handler = &test; -// sigaction(SIGSEGV, &action, NULL); -#endif - - // MPI Init - int provided; - MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE ,&provided); + // MPI Init + int provided; + int myid; + MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE ,&provided); + MPI_Comm_rank(MPI_COMM_WORLD,&myid); if(getenv ("DEBUGGER")) - { - std::cerr << "Unexpected: unexpected exception !" << std::endl; - setsig(SIGSEGV,&Handler); - set_terminate(&terminateHandler); - set_unexpected(&unexpectedHandler); - } -#ifdef _DEBUG_ - cerr << "Level MPI_THREAD_SINGLE : " << MPI_THREAD_SINGLE << endl; - cerr << "Level MPI_THREAD_SERIALIZED : " << MPI_THREAD_SERIALIZED << endl; - cerr << "Level MPI_THREAD_FUNNELED : " << MPI_THREAD_FUNNELED << endl; - cerr << "Level MPI_THREAD_MULTIPLE : " << MPI_THREAD_MULTIPLE << endl; - cerr << "Level provided : " << provided << endl; -#endif - // Initialise the ORB. - ORB_INIT &init = *SINGLETON_::Instance(); - ASSERT(SINGLETON_::IsAlreadyExisting()); - CORBA::ORB_var orb = init(0, 0); - //CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); - - // Code pour choisir le reseau infiniband ..... -/* string hostname_temp = GetHostname(); + { + std::cerr << "Unexpected: unexpected exception !" << std::endl; + setsig(SIGSEGV,&Handler); + set_terminate(&terminateHandler); + set_unexpected(&unexpectedHandler); + } + cerr << "Level MPI_THREAD_SINGLE : " << MPI_THREAD_SINGLE << endl; + cerr << "Level MPI_THREAD_SERIALIZED : " << MPI_THREAD_SERIALIZED << endl; + cerr << "Level MPI_THREAD_FUNNELED : " << MPI_THREAD_FUNNELED << endl; + cerr << "Level MPI_THREAD_MULTIPLE : " << MPI_THREAD_MULTIPLE << endl; + cerr << "Level provided : " << provided << endl; + // Initialise the ORB. + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + + // Code pour choisir le reseau infiniband ..... + /* string hostname_temp = GetHostname(); hostent * t = gethostbyname(hostname_temp.c_str()); cerr << " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA " << t->h_addr << " " << hostname_temp << endl; cerr << t->h_addr << endl; @@ -165,96 +156,99 @@ int main(int argc, char* argv[]) string com = "giop:tcp:" + ip + ":"; const char* options[][2] = { { "endPoint", com.c_str() }, { 0, 0 } }; CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB4", options); -*/ - char * containerName = ""; - if(argc > 1) { - containerName = argv[1]; - } + */ + std::string containerName(""); + containerName = argv[1]; - char * hostname = ""; - if(argc > 3) { - hostname = argv[3]; - } + std::string hostname(""); + if(argc > 3) { + hostname = argv[3]; + } - try { - CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); - PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); - PortableServer::POAManager_var pman = root_poa->the_POAManager(); + try { + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); + PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); + PortableServer::POAManager_var pman = root_poa->the_POAManager(); #ifndef WNT - // add this container to the kill list - char aCommand[100]; - sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerNodeMpi", getpid()); - system(aCommand); + // add this container to the kill list + char aCommand[100]; + sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerNodeMpi", getpid()); + system(aCommand); #endif - SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb)); - // On récupère le proxy - string proxyNameInNS = ns->BuildContainerNameForNS(containerName, hostname); - obj = ns->Resolve(proxyNameInNS.c_str()); - char * proxy_ior = orb->object_to_string(obj); - - // Node creation - string name(containerName); - string node_name = name + "Node"; - Engines_Parallel_Container_i * servant = new Engines_Parallel_Container_i(CORBA::ORB::_duplicate(orb), proxy_ior, - root_poa, - (char*) node_name.c_str(), - argc, argv); - // PaCO++ init - paco_fabrique_manager * pfm = paco_getFabriqueManager(); - pfm->register_com("mpi", new paco_mpi_fabrique()); - pfm->register_thread("omni", new paco_omni_fabrique()); - - // Global context - PaCO_operation * global_ptr = servant->getContext("global_paco_context"); - MPI_Comm group = MPI_COMM_WORLD; - global_ptr->setLibCom("mpi", &group); - global_ptr->setLibThread("omni"); - - // Activation - PortableServer::ObjectId * _id = root_poa->activate_object(servant); - servant->set_id(_id); - obj = root_poa->id_to_reference(*_id); - - // In the NamingService - string hostname = GetHostname(); - - int myid; - MPI_Comm_rank(MPI_COMM_WORLD, &myid); - char buffer [5]; - snprintf(buffer, 5, "%d", myid); - node_name = node_name + buffer; - string _containerName = ns->BuildContainerNameForNS((char*) node_name.c_str(), - hostname.c_str()); - cerr << "---------" << _containerName << "----------" << endl; - ns->Register(obj, _containerName.c_str()); - pman->activate(); - orb->run(); - } - catch(CORBA::SystemException&) - { - INFOS("Caught CORBA::SystemException."); - } - catch(PortableServer::POA::ServantAlreadyActive&) - { - INFOS("Caught CORBA::ServantAlreadyActiveException"); - } - catch(CORBA::Exception&) - { - INFOS("Caught CORBA::Exception."); - } - catch(std::exception& exc) - { - INFOS("Caught std::exception - "<BuildContainerNameForNS(containerName.c_str(), + hostname.c_str()); + obj = ns->Resolve(proxyNameInNS.c_str()); + char * proxy_ior = orb->object_to_string(obj); + + // Node creation + string node_name = containerName + "Node"; + Engines_Parallel_Container_i * servant = + new Engines_Parallel_Container_i(CORBA::ORB::_duplicate(orb), + proxy_ior, + myid, + root_poa, + (char*) node_name.c_str(), + argc, argv); + // PaCO++ init + paco_fabrique_manager * pfm = paco_getFabriqueManager(); + pfm->register_com("mpi", new paco_mpi_fabrique()); + pfm->register_thread("omni", new paco_omni_fabrique()); + MPI_Comm group = MPI_COMM_WORLD; + servant->setLibCom("mpi", &group); + servant->setLibThread("omni"); + + // Activation + PortableServer::ObjectId * _id = root_poa->activate_object(servant); + servant->set_id(_id); + obj = root_poa->id_to_reference(*_id); + + // In the NamingService + string hostname = GetHostname(); + + int myid; + MPI_Comm_rank(MPI_COMM_WORLD, &myid); + char buffer [5]; + snprintf(buffer, 5, "%d", myid); + node_name = node_name + buffer; + string _containerName = ns->BuildContainerNameForNS(node_name.c_str(), + hostname.c_str()); + cerr << "---------" << _containerName << "----------" << endl; + ns->Register(obj, _containerName.c_str()); + pman->activate(); + orb->run(); + } + catch (PaCO::PACO_Exception& e) + { + INFOS("Caught PaCO::PACO_Exception"); + std::cerr << e << std::endl; + } + catch(CORBA::SystemException&) + { + INFOS("Caught CORBA::SystemException."); + } + catch(PortableServer::POA::ServantAlreadyActive&) + { + INFOS("Caught CORBA::ServantAlreadyActiveException"); + } + catch(CORBA::Exception&) + { + INFOS("Caught CORBA::Exception."); + } + catch(std::exception& exc) + { + INFOS("Caught std::exception - "<::Instance(); - ASSERT(SINGLETON_::IsAlreadyExisting()); - CORBA::ORB_var orb = init(0, 0); - //CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + std::string containerName(""); + if(argc > 1) { + containerName = argv[1]; + } - char *containerName = ""; - if(argc > 1) { - containerName = argv[1]; - } - - try { - CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); - ASSERT(!CORBA::is_nil(obj)); - PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); - PortableServer::POAManager_var pman = root_poa->the_POAManager(); + try { + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); + ASSERT(!CORBA::is_nil(obj)); + PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); + PortableServer::POAManager_var pman = root_poa->the_POAManager(); #ifndef WNT - // add this container to the kill list - char aCommand[100]; - sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxy", getpid()); - system(aCommand); + // add this container to the kill list + char aCommand[100]; + sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxy", getpid()); + system(aCommand); #endif - SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb)); - Engines::Container_proxy_impl * proxy = new Engines::Container_proxy_impl(CORBA::ORB::_duplicate(orb)); - - // PaCO++ code - paco_fabrique_manager* pfm = paco_getFabriqueManager(); - // Global context - PaCO_operation * global_ptr = proxy->getContext("global_paco_context"); - pfm->register_com("dummy", new paco_dummy_fabrique()); - global_ptr->setLibCom("dummy", NULL); - pfm->register_thread("omnithread", new paco_omni_fabrique()); - global_ptr->setLibThread("omnithread"); - global_ptr->setTypeClient(true); - // The proxy is a PaCO++ client - PaCO::PacoTopology_t client_topo; - client_topo.total = 1; - global_ptr->setClientTopo(client_topo); - // Topo of the parallel object - PaCO::PacoTopology_t serveur_topo; - serveur_topo.total = 1; - proxy->setTopo(serveur_topo); - - PortableServer::ObjectId_var _id = root_poa->activate_object(proxy); - obj = root_poa->id_to_reference(_id); - - // In the NamingService - string hostname = GetHostname(); - Engines::Container_var pCont = Engines::Container::_narrow(obj); - string _containerName = ns->BuildContainerNameForNS(containerName, - hostname.c_str()); - cerr << "---------" << _containerName << "----------" << endl; - ns->Register(pCont, _containerName.c_str()); - pman->activate(); - orb->run(); - } - catch(CORBA::SystemException&) - { - INFOS("Caught CORBA::SystemException."); - } - catch(PortableServer::POA::ServantAlreadyActive&) - { - INFOS("Caught CORBA::ServantAlreadyActiveException"); - } - catch(CORBA::Exception&) - { - INFOS("Caught CORBA::Exception."); - } - catch(std::exception& exc) - { - INFOS("Caught std::exception - "<register_com("dummy", new paco_dummy_fabrique()); + proxy->setLibCom("dummy", proxy); + pfm->register_thread("omnithread", new paco_omni_fabrique()); + proxy->setLibThread("omnithread"); + // Topo of the parallel object + PaCO::PacoTopology_t serveur_topo; + serveur_topo.total = 1; + proxy->setTopology(serveur_topo); + + PortableServer::ObjectId_var _id = root_poa->activate_object(proxy); + obj = root_poa->id_to_reference(_id); + + // In the NamingService + string hostname = GetHostname(); + Engines::Container_var pCont = Engines::Container::_narrow(obj); + string _containerName = ns->BuildContainerNameForNS(containerName.c_str(), + hostname.c_str()); + cerr << "---------" << _containerName << "----------" << endl; + ns->Register(pCont, _containerName.c_str()); + pman->activate(); + orb->run(); + } + catch (PaCO::PACO_Exception& e) + { + INFOS("Caught PaCO::PACO_Exception"); + std::cerr << e << std::endl; + } + catch(CORBA::SystemException&) + { + INFOS("Caught CORBA::SystemException."); + } + catch(PortableServer::POA::ServantAlreadyActive&) + { + INFOS("Caught CORBA::ServantAlreadyActiveException"); + } + catch(CORBA::Exception&) + { + INFOS("Caught CORBA::Exception."); + } + catch(std::exception& exc) + { + INFOS("Caught std::exception - "< void handler(int t) { - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - cerr << "SIGSEGV in :" << getpid() << endl; - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - while (1) {} + cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; + cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; + cerr << "SIGSEGV in :" << getpid() << endl; + cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; + cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; + while (1) {} } #endif int main(int argc, char* argv[]) { - INFOS("Launching a parallel Mpi proxy container"); + INFOS("Launching a parallel Mpi proxy container"); #ifdef DEBUG_PARALLEL - signal(SIGSEGV, handler); + signal(SIGSEGV, handler); #endif - // MPI Init - int provided; - MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED ,&provided); - - // Initialise the ORB. - ORB_INIT &init = *SINGLETON_::Instance(); - ASSERT(SINGLETON_::IsAlreadyExisting()); - CORBA::ORB_var orb = init(0, 0); - //CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); - - char *containerName = ""; - if(argc > 1) { - containerName = argv[1]; - } - - char * nb_nodes = ""; - if(argc > 2) { - nb_nodes = argv[2]; - } - - try { - CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); - ASSERT(!CORBA::is_nil(obj)); - PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); - PortableServer::POAManager_var pman = root_poa->the_POAManager(); + // MPI Init + int provided; + MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED ,&provided); + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + + std::string containerName(""); + containerName = argv[1]; + int nb_nodes; + sscanf(argv[2],"%d",&nb_nodes); + + try { + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); + ASSERT(!CORBA::is_nil(obj)); + PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); + PortableServer::POAManager_var pman = root_poa->the_POAManager(); #ifndef WNT - // add this container to the kill list - char aCommand[100]; - sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxyMpi", getpid()); - system(aCommand); + // add this container to the kill list + char aCommand[100]; + sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxyMpi", getpid()); + system(aCommand); #endif - SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb)); - Engines::Container_proxy_impl * proxy = new Engines::Container_proxy_impl(CORBA::ORB::_duplicate(orb)); - - // PaCO++ code - paco_fabrique_manager* pfm = paco_getFabriqueManager(); - // Global context - PaCO_operation * global_ptr = proxy->getContext("global_paco_context"); - pfm->register_com("mpi", new paco_mpi_fabrique()); - MPI_Comm group = MPI_COMM_WORLD; - global_ptr->setLibCom("mpi", &group); - pfm->register_thread("omnithread", new paco_omni_fabrique()); - global_ptr->setLibThread("omnithread"); - global_ptr->setTypeClient(true); - PaCO::PacoTopology_t client_topo; - client_topo.total = 1; - global_ptr->setClientTopo(client_topo); - PaCO::PacoTopology_t serveur_topo; - serveur_topo.total = atoi(nb_nodes); - proxy->setTopo(serveur_topo); - - // Activation - PortableServer::ObjectId_var _id = root_poa->activate_object(proxy); - obj = root_poa->id_to_reference(_id); - - // in the NamingService - string hostname = GetHostname(); - Engines::Container_var pCont = Engines::Container::_narrow(obj); - string _containerName = ns->BuildContainerNameForNS(containerName, - hostname.c_str()); - cerr << "---------" << _containerName << "----------" << endl; - ns->Register(pCont, _containerName.c_str()); - pman->activate(); - orb->run(); - } - catch(CORBA::SystemException&) - { - INFOS("Caught CORBA::SystemException."); - } - catch(PortableServer::POA::ServantAlreadyActive&) - { - INFOS("Caught CORBA::ServantAlreadyActiveException"); - } - catch(CORBA::Exception&) - { - INFOS("Caught CORBA::Exception."); - } - catch(std::exception& exc) - { - INFOS("Caught std::exception - "<register_com("mpi", new paco_mpi_fabrique()); + MPI_Comm group = MPI_COMM_WORLD; + proxy->setLibCom("mpi", &group); + pfm->register_thread("omnithread", new paco_omni_fabrique()); + proxy->setLibThread("omnithread"); + PaCO::PacoTopology_t serveur_topo; + serveur_topo.total = nb_nodes; + proxy->setTopology(serveur_topo); + + // Activation + PortableServer::ObjectId_var _id = root_poa->activate_object(proxy); + obj = root_poa->id_to_reference(_id); + + // in the NamingService + string hostname = GetHostname(); + Engines::Container_var pCont = Engines::Container::_narrow(obj); + string _containerName = ns->BuildContainerNameForNS(containerName.c_str(), + hostname.c_str()); + cerr << "---------" << _containerName << "----------" << endl; + ns->Register(pCont, _containerName.c_str()); + pman->activate(); + orb->run(); + } + catch (PaCO::PACO_Exception& e) + { + INFOS("Caught PaCO::PACO_Exception"); + std::cerr << e << std::endl; + } + catch(CORBA::SystemException&) + { + INFOS("Caught CORBA::SystemException."); + } + catch(PortableServer::POA::ServantAlreadyActive&) + { + INFOS("Caught CORBA::ServantAlreadyActiveException"); + } + catch(CORBA::Exception&) + { + INFOS("Caught CORBA::Exception."); + } + catch(std::exception& exc) + { + INFOS("Caught std::exception - "< #include "utilities.h" using namespace std; @@ -77,8 +78,11 @@ omni_mutex Engines_Parallel_Container_i::_numInstanceMutex ; */ //============================================================================= -Engines_Parallel_Container_i::Engines_Parallel_Container_i (CORBA::ORB_ptr orb, char * ior) : - InterfaceParallel_impl(orb,ior), Engines::Container_serv(orb,ior), +Engines_Parallel_Container_i::Engines_Parallel_Container_i (CORBA::ORB_ptr orb, + char * ior, + int rank) : + InterfaceParallel_impl(orb,ior,rank), + Engines::Container_serv(orb,ior,rank), _numInstance(0) { } @@ -89,14 +93,17 @@ Engines_Parallel_Container_i::Engines_Parallel_Container_i (CORBA::ORB_ptr orb, */ //============================================================================= -Engines_Parallel_Container_i::Engines_Parallel_Container_i (CORBA::ORB_ptr orb, char * ior, +Engines_Parallel_Container_i::Engines_Parallel_Container_i (CORBA::ORB_ptr orb, + char * ior, + int rank, PortableServer::POA_ptr poa, char *containerName , int argc , char* argv[], bool activAndRegist, bool isServantAloneInProcess ) : - InterfaceParallel_impl(orb,ior), Engines::Container_serv(orb,ior), + InterfaceParallel_impl(orb,ior,rank), + Engines::Container_serv(orb,ior,rank), _numInstance(0),_isServantAloneInProcess(isServantAloneInProcess) { _pid = (long)getpid(); @@ -257,7 +264,7 @@ Engines_Parallel_Container_i::load_component_Library(const char* componentName) } // To be sure that all the nodes of the component as loaded the library - global_paco_context_ptr->my_com->paco_barrier(); + _my_com->paco_barrier(); return ret; } @@ -652,6 +659,7 @@ Engines_Parallel_Container_i::createParallelInstance(string genericRegisterName, typedef PortableServer::ObjectId * (*FACTORY_FUNCTION) (CORBA::ORB_ptr, + paco_fabrique_thread *, PortableServer::POA_ptr, PortableServer::ObjectId *, const char *, @@ -680,7 +688,7 @@ Engines_Parallel_Container_i::createParallelInstance(string genericRegisterName, // --- Instanciate required CORBA object PortableServer::ObjectId *id ; //not owner, do not delete (nore use var) - id = (Component_factory) ( _orb, _poa, _id, instanceName.c_str(), getTotalNode()) ; + id = (Component_factory) ( _orb, new paco_omni_fabrique(), _poa, _id, instanceName.c_str(), getTotalNode()) ; // --- get reference & servant from id CORBA::Object_var obj = _poa->id_to_reference(*id); @@ -704,11 +712,11 @@ Engines_Parallel_Container_i::createParallelInstance(string genericRegisterName, // in the nameing service. _numInstanceMutex.lock() ; // lock on the instance number _numInstance++ ; -// int numInstance = _numInstance ; + // int numInstance = _numInstance ; _numInstanceMutex.unlock() ; } cerr << "Node " << getMyRank() << " entering in paco_barrier()" << endl; - global_paco_context_ptr->my_com->paco_barrier(); + _my_com->paco_barrier(); cerr << "Node " << getMyRank() << " quitting paco_barrier()" << endl; ////////////////////////////////////////////////////////////////////////// @@ -732,7 +740,7 @@ Engines_Parallel_Container_i::createParallelInstance(string genericRegisterName, string factory_name = aGenRegisterName + string("Engine_factory"); typedef PortableServer::ObjectId * (*FACTORY_FUNCTION) - (CORBA::ORB_ptr, char * ior, + (CORBA::ORB_ptr, char *, int, PortableServer::POA_ptr, PortableServer::ObjectId *, const char *, @@ -758,7 +766,7 @@ Engines_Parallel_Container_i::createParallelInstance(string genericRegisterName, // --- Instanciate required CORBA object PortableServer::ObjectId *id ; //not owner, do not delete (nore use var) - id = (Component_factory) ( _orb, proxy_ior, _poa, _id, instanceName.c_str(), + id = (Component_factory) ( _orb, proxy_ior, getMyRank(), _poa, _id, instanceName.c_str(), aGenRegisterName.c_str() ) ; // --- get reference & servant from id @@ -777,11 +785,17 @@ Engines_Parallel_Container_i::createParallelInstance(string genericRegisterName, ////////////////////////////////////////////////////////////////////////// // 3: Deployment Step - iobject2->deploy(getMyRank()); - global_paco_context_ptr->my_com->paco_barrier(); + iobject2->deploy(); + _my_com->paco_barrier(); cerr << "--------- createParallelInstance : End Deploy step ----------" << endl; + if (getMyRank() == 0) { + PaCO::InterfaceManager_var proxy = PaCO::InterfaceManager::_narrow(iobject); + proxy->start(); + _my_com->paco_barrier(); + } + else + _my_com->paco_barrier(); - // return obj_proxy._retn(); return iobject._retn(); } @@ -954,22 +968,22 @@ Engines_Parallel_Container_i::createFileRef(const char* origFileName) Engines::fileRef_var theFileRef = Engines::fileRef::_nil(); if (origName[0] != '/') - { - INFOS("path of file to copy must be an absolute path begining with '/'"); - return Engines::fileRef::_nil(); - } + { + INFOS("path of file to copy must be an absolute path begining with '/'"); + return Engines::fileRef::_nil(); + } if (CORBA::is_nil(_fileRef_map[origName])) - { - CORBA::Object_var obj=_poa->id_to_reference(*_id); - Engines::Container_var pCont = Engines::Container::_narrow(obj); - fileRef_i* aFileRef = new fileRef_i(pCont, origFileName); - theFileRef = Engines::fileRef::_narrow(aFileRef->_this()); - _numInstanceMutex.lock() ; // lock to be alone (stl container write) - _fileRef_map[origName] = theFileRef; - _numInstanceMutex.unlock() ; - } - + { + CORBA::Object_var obj=_poa->id_to_reference(*_id); + Engines::Container_var pCont = Engines::Container::_narrow(obj); + fileRef_i* aFileRef = new fileRef_i(pCont, origFileName); + theFileRef = Engines::fileRef::_narrow(aFileRef->_this()); + _numInstanceMutex.lock() ; // lock to be alone (stl container write) + _fileRef_map[origName] = theFileRef; + _numInstanceMutex.unlock() ; + } + theFileRef = Engines::fileRef::_duplicate(_fileRef_map[origName]); ASSERT(! CORBA::is_nil(theFileRef)); return theFileRef._retn(); @@ -996,25 +1010,25 @@ Engines_Parallel_Container_i::createSalome_file(const char* origFileName) { string origName(origFileName); if (CORBA::is_nil(_Salome_file_map[origName])) + { + Salome_file_i* aSalome_file = new Salome_file_i(); + try { - Salome_file_i* aSalome_file = new Salome_file_i(); - try - { - aSalome_file->setLocalFile(origFileName); - aSalome_file->recvFiles(); - } - catch (const SALOME::SALOME_Exception& e) - { - return Engines::Salome_file::_nil(); - } - - Engines::Salome_file_var theSalome_file = Engines::Salome_file::_nil(); - theSalome_file = Engines::Salome_file::_narrow(aSalome_file->_this()); - _numInstanceMutex.lock() ; // lock to be alone (stl container write) - _Salome_file_map[origName] = theSalome_file; - _numInstanceMutex.unlock() ; + aSalome_file->setLocalFile(origFileName); + aSalome_file->recvFiles(); } - + catch (const SALOME::SALOME_Exception& e) + { + return Engines::Salome_file::_nil(); + } + + Engines::Salome_file_var theSalome_file = Engines::Salome_file::_nil(); + theSalome_file = Engines::Salome_file::_narrow(aSalome_file->_this()); + _numInstanceMutex.lock() ; // lock to be alone (stl container write) + _Salome_file_map[origName] = theSalome_file; + _numInstanceMutex.unlock() ; + } + Engines::Salome_file_ptr theSalome_file = Engines::Salome_file::_duplicate(_Salome_file_map[origName]); ASSERT(!CORBA::is_nil(theSalome_file)); diff --git a/src/ParallelContainer/SALOME_ParallelContainer_i.hxx b/src/ParallelContainer/SALOME_ParallelContainer_i.hxx index 962bc9a1d..7eaef5c7b 100644 --- a/src/ParallelContainer/SALOME_ParallelContainer_i.hxx +++ b/src/ParallelContainer/SALOME_ParallelContainer_i.hxx @@ -64,8 +64,8 @@ class CONTAINER_EXPORT Engines_Parallel_Container_i: public virtual PortableServer::RefCountServantBase { public: - Engines_Parallel_Container_i(CORBA::ORB_ptr orb, char * ior); - Engines_Parallel_Container_i(CORBA::ORB_ptr orb, char * ior, + Engines_Parallel_Container_i(CORBA::ORB_ptr orb, char * ior, int rank); + Engines_Parallel_Container_i(CORBA::ORB_ptr orb, char * ior, int rank, PortableServer::POA_ptr poa, char * containerName , int argc, char* argv[],