1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SALOME ParallelContainerProxyDummy : Proxy of a PaCO++ object using Dummy
24 // File : SALOME_ParallelContainerProxyDummy.cxx
25 // Author : André Ribes, EDF
26 // Module : SALOME PARALLEL
39 //#include "SALOME_ComponentPaCO_Engines_Container_server.h"
40 #include "SALOME_ParallelContainerProxy_i.hxx"
41 #include <paco_omni.h>
42 #include <paco_dummy.h>
44 #include "SALOME_NamingService.hxx"
46 #include "utilities.h"
47 #include "Basics_Utils.hxx"
48 #include "Utils_ORB_INIT.hxx"
49 #include "Utils_SINGLETON.hxx"
50 #include "SALOMETraceCollector.hxx"
53 #include "Container_init_python.hxx"
59 std::cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
60 std::cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
61 std::cerr << "SIGSEGV in :" << getpid() << std::endl;
62 std::cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
63 std::cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
68 int main(int argc, char* argv[])
70 INFOS("Launching a parallel proxy container");
73 signal(SIGSEGV, handler);
75 // Initialise the ORB.
76 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
77 KERNEL_PYTHON::init_python(argc,argv);
79 std::string containerName("");
81 containerName = argv[1];
86 sscanf(argv[4],"%d",&nbnodes);
89 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
90 ASSERT(!CORBA::is_nil(obj));
91 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
92 PortableServer::POAManager_var pman = root_poa->the_POAManager();
95 // add this container to the kill list
97 sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxyDummy", getpid());
101 SALOME_NamingService * ns = new SALOME_NamingService(orb);
104 paco_fabrique_manager* pfm = paco_getFabriqueManager();
105 pfm->register_com("dummy", new paco_dummy_fabrique());
106 pfm->register_thread("omnithread", new paco_omni_fabrique());
108 Container_proxy_impl_final * proxy =
109 new Container_proxy_impl_final(orb,
110 pfm->get_thread("omnithread"),
113 proxy->setLibCom("dummy", proxy);
114 proxy->setLibThread("omnithread");
115 // Topo of the parallel object
116 PaCO::PacoTopology_t serveur_topo;
117 serveur_topo.total = nbnodes;
118 proxy->setTopology(serveur_topo);
120 //PortableServer::ObjectId_var _id = root_poa->activate_object(proxy);
121 //obj = root_poa->id_to_reference(_id);
122 obj = proxy->_this();
124 // In the NamingService
125 std::string hostname = Kernel_Utils::GetHostname();
126 Engines::Container_var pCont = Engines::Container::_narrow(obj);
127 string _containerName = ns->BuildContainerNameForNS(containerName.c_str(),
129 std::cerr << "---------" << _containerName << "----------" << std::endl;
130 ns->Register(pCont, _containerName.c_str());
134 //Delete python container that destroy orb from python (pyCont._orb.destroy())
138 catch (PaCO::PACO_Exception& e)
140 INFOS("Caught PaCO::PACO_Exception");
141 std::cerr << e << std::endl;
143 catch(CORBA::SystemException&)
145 INFOS("Caught CORBA::SystemException.");
147 catch(PortableServer::POA::ServantAlreadyActive&)
149 INFOS("Caught CORBA::ServantAlreadyActiveException");
151 catch(CORBA::Exception&)
153 INFOS("Caught CORBA::Exception.");
155 catch(std::exception& exc)
157 INFOS("Caught std::exception - "<<exc.what());
161 INFOS("Caught unknown exception.");