X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FParallelContainer%2FSALOME_ParallelContainerNodeDummy.cxx;h=8dbcf3a5a2c1c1ec2c288bc0f796970195bbb6a5;hb=d8edd4804d9e6513a17c497c1a30326d4ba0d677;hp=d3470b9de5334628228c15060e252beeac41f1b5;hpb=f14439749926cca959747bb79fda10529520bd0b;p=modules%2Fkernel.git diff --git a/src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx b/src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx index d3470b9de..8dbcf3a5a 100644 --- a/src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx +++ b/src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx @@ -1,35 +1,35 @@ -// SALOME ParallelContainerNodeDummy : launcher of a PaCO++ object +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. // -// Copyright (C) 2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + +// SALOME ParallelContainerNodeDummy : launcher of a PaCO++ object // File : SALOME_ParallelContainerNodeDummy.cxx // Author : André Ribes, EDF // Module : SALOME PARALLEL - +// #include #include #include -#ifndef WNT +#ifndef WIN32 #include #else #include @@ -43,22 +43,23 @@ #include "SALOME_NamingService.hxx" #include "utilities.h" +#include "Basics_Utils.hxx" #include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" #include "SALOMETraceCollector.hxx" #include "OpUtil.hxx" -using namespace std; +#include "Container_init_python.hxx" #ifdef _DEBUG_ #include void handler(int t) { - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - cerr << "SIGSEGV in :" << getpid() << endl; - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; + std::cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; + std::cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; + std::cerr << "SIGSEGV in :" << getpid() << std::endl; + std::cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; + std::cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; while (1) {} } #endif @@ -120,43 +121,46 @@ int main(int argc, char* argv[]) // Initialise the ORB. CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + KERNEL_PYTHON::init_python(argc,argv); std::string containerName(""); if(argc > 1) { containerName = argv[1]; } - std::string hostname(""); + std::string proxy_hostname(""); if(argc > 3) { - hostname = argv[3]; + proxy_hostname = argv[3]; } + int myid = 0; + if(argc > 4) + sscanf(argv[4],"%d",&myid); 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 +#ifndef WIN32 // 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)); + SALOME_NamingService * ns = new SALOME_NamingService(orb); // Get the proxy - string proxyNameInNS = ns->BuildContainerNameForNS(containerName.c_str(), - hostname.c_str()); + std::string proxyNameInNS = ns->BuildContainerNameForNS(containerName.c_str(), + proxy_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"; + std::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); + proxy_ior, + myid, + root_poa, + node_name); // PaCO++ init paco_fabrique_manager * pfm = paco_getFabriqueManager(); pfm->register_com("dummy", new paco_dummy_fabrique()); @@ -165,22 +169,24 @@ int main(int argc, char* argv[]) 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 = GetHostname(); - int myid = 0; + string hostname = Kernel_Utils::GetHostname(); 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; + hostname.c_str()); + std::cerr << "---------" << _containerName << "----------" << std::endl; 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(); + CORBA::string_free(proxy_ior); + delete ns; } catch (PaCO::PACO_Exception& e) { @@ -199,6 +205,13 @@ int main(int argc, char* argv[]) { INFOS("Caught CORBA::Exception."); } + catch(omniORB::fatalException& fe) + { + INFOS("Caught omniORB::fatalException:"); + INFOS(" file: " << fe.file()); + INFOS(" line: " << fe.line()); + INFOS(" mesg: " << fe.errmsg()); + } catch(std::exception& exc) { INFOS("Caught std::exception - "<