From 35159586f2a97bb8b5106df2c07828911d7a6252 Mon Sep 17 00:00:00 2001 From: ribes Date: Wed, 11 Apr 2007 14:44:43 +0000 Subject: [PATCH] Adding ParallelDSC Basic layer implementation --- configure.ac | 1 + src/DSC/Makefile.am | 6 +- src/DSC/ParallelDSC/Makefile.am | 75 +++++++++++ src/DSC/ParallelDSC/ParallelDSC_i.cxx | 96 ++++++++++++++ src/DSC/ParallelDSC/ParallelDSC_i.hxx | 183 ++++++++++++++++++++++++++ 5 files changed, 360 insertions(+), 1 deletion(-) create mode 100644 src/DSC/ParallelDSC/Makefile.am create mode 100644 src/DSC/ParallelDSC/ParallelDSC_i.cxx create mode 100644 src/DSC/ParallelDSC/ParallelDSC_i.hxx diff --git a/configure.ac b/configure.ac index 9e7b98ba9..61a80e169 100644 --- a/configure.ac +++ b/configure.ac @@ -565,6 +565,7 @@ AC_OUTPUT([ \ ./src/DSC/DSC_User/Datastream/Makefile \ ./src/DSC/DSC_User/Datastream/Palm/Makefile \ ./src/DSC/DSC_User/Datastream/Calcium/Makefile \ + ./src/DSC/ParallelDSC/Makefile \ ./src/GenericObj/Makefile \ ./src/HDFPersist/Makefile \ ./src/KERNEL_PY/Makefile \ diff --git a/src/DSC/Makefile.am b/src/DSC/Makefile.am index 587134f3f..fb949237f 100644 --- a/src/DSC/Makefile.am +++ b/src/DSC/Makefile.am @@ -23,4 +23,8 @@ # Author : André RIBES (EDF) # Module : KERNEL -SUBDIRS = DSC_Basic DSC_User +if WITH_PACO_PARALLEL +SUBDIR_PAR = ParallelDSC +endif + +SUBDIRS = DSC_Basic DSC_User $(SUBDIR_PAR) diff --git a/src/DSC/ParallelDSC/Makefile.am b/src/DSC/ParallelDSC/Makefile.am new file mode 100644 index 000000000..d9f562b32 --- /dev/null +++ b/src/DSC/ParallelDSC/Makefile.am @@ -0,0 +1,75 @@ +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# +# +# File : Makefile.am +# Author : André RIBES (EDF) +# Module : KERNEL + +include $(top_srcdir)/salome_adm/unix/make_common_starter.am + +# +# =============================================================== +# Header to be installed +# =============================================================== +# +# header files +salomeinclude_HEADERS = ParallelDSC_i.hxx + +# +# =============================================================== +# Local definitions +# =============================================================== +# + +# This local variable defines the list of CPPFLAGS common to all target in this package. +COMMON_CPPFLAGS= -I$(top_srcdir)/src/Container \ + -I$(top_srcdir)/src/ParallelContainer \ + -I$(top_srcdir)/src/Notification \ + -I$(top_srcdir)/src/SALOMELocalTrace \ + -I$(top_srcdir)/src/Basics \ + -I$(top_srcdir)/src/NamingService \ + -I$(top_srcdir)/src/Utils \ + -I$(top_srcdir)/src/DSC/DSC_Basic \ + -I$(top_builddir)/salome_adm/unix \ + -I$(top_builddir)/idl \ + -I$(top_srcdir)/src/Registry \ + -I$(top_srcdir)/src/Utils \ + @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ \ + @PACO_INCLUDES@ + +# This local variable defines the list of dependant libraries common to all target in this package. +COMMON_LIBS = + +# +# =============================================================== +# Libraries targets +# =============================================================== +# +lib_LTLIBRARIES = libSalomeParallelDSCContainer.la + +libSalomeParallelDSCContainer_la_SOURCES = ParallelDSC_i.cxx + +libSalomeParallelDSCContainer_la_CXXFLAGS = $(COMMON_CPPFLAGS) + +libSalomeParallelDSCContainer_la_LIBADD = $(COMMON_LIBS) + +libSalomeParallelDSCContainer_la_LDFLAGS = -no-undefined -version-info=0:0:0 + diff --git a/src/DSC/ParallelDSC/ParallelDSC_i.cxx b/src/DSC/ParallelDSC/ParallelDSC_i.cxx new file mode 100644 index 000000000..a6f71c179 --- /dev/null +++ b/src/DSC/ParallelDSC/ParallelDSC_i.cxx @@ -0,0 +1,96 @@ +// André Ribes EDF R&D - 2006 +// + +#include "ParallelDSC_i.hxx" + +Engines_ParallelDSC_i::Engines_ParallelDSC_i(CORBA::ORB_ptr orb, char * ior, + 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), + InterfaceParallel_impl(orb,ior) +{ +} + + +Engines_ParallelDSC_i::~Engines_ParallelDSC_i() {} + +// WARNING !!! +// CURRENTLY ERRORS ARE NOT SUPPORTED !!!!!!! +// WARNING !! + +void +Engines_ParallelDSC_i::set_paco_proxy(const CORBA::Object_ptr ref, + const char* provides_port_name, + Ports::PortProperties_ptr port_prop) { + assert(provides_port_name); + 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(); + cerr << "set_paco_proxy node fin" << endl; +} + +const char * +Engines_ParallelDSC_i::get_proxy(const char* provides_port_name) { + char * rtn_char = NULL; + Ports::Port_ptr proxy = Engines_DSC_interface::get_provides_port(provides_port_name, + 0); + if (!CORBA::is_nil(proxy)) + rtn_char = (char *) _orb->object_to_string(proxy); + return rtn_char; +} + +CORBA::Boolean +Engines_ParallelDSC_i::add_parallel_provides_proxy_port(const CORBA::Object_ptr ref, + const char * provides_port_name) +{ + 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); + real_comp_proxy->set_paco_proxy(ref, provides_port_name); + rtn_bool = true; + return rtn_bool; +} + +CORBA::Boolean +Engines_ParallelDSC_i::add_parallel_provides_proxy_wait(const char * provides_port_name) +{ + assert(provides_port_name); + char * proxy = NULL; + try { + proxy = (char *) get_proxy(provides_port_name); + } + catch(...) { + while(proxy == NULL) + { + sleep(1); + try { + proxy = (char *) get_proxy(provides_port_name); + } + catch(...) {} + } + } + return true; +} + +CORBA::Boolean +Engines_ParallelDSC_i::add_parallel_provides_node_port(Ports::Port_PaCO_ptr ref, + const char* provides_port_name) +{ + CORBA::Boolean rtn_bool = false; + PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(ref); + node->deploy(getMyRank()); + rtn_bool = true; + return rtn_bool; +} diff --git a/src/DSC/ParallelDSC/ParallelDSC_i.hxx b/src/DSC/ParallelDSC/ParallelDSC_i.hxx new file mode 100644 index 000000000..f5306fc1a --- /dev/null +++ b/src/DSC/ParallelDSC/ParallelDSC_i.hxx @@ -0,0 +1,183 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : ParallelDSC_i.hxx +// Author : André RIBES (EDF) +// Module : KERNEL + +#ifndef _PARALLEL_DSC_COMPONENT_I_HXX_ +#define _PARALLEL_DSC_COMPONENT_I_HXX_ + +#include +#include + +#include "DSC_EnginesPaCO_Engines_Parallel_DSC_server.h" +#include "DSC_interface.hxx" +#include "SALOME_ParallelComponent_i.hxx" + +class Engines_ParallelDSC_i: + public virtual Engines_Parallel_Component_i, + public virtual Engines::Parallel_DSC_serv, + public virtual Engines_DSC_interface +{ +public: + Engines_ParallelDSC_i(CORBA::ORB_ptr orb, char * ior, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName, + bool notif = false); + + virtual ~Engines_ParallelDSC_i(); + + + virtual CORBA::Boolean init_service(const char* service_name) {return true;}; + + /*! + * \see Engines::DSC::add_provides_port + */ + virtual void add_provides_port(Ports::Port_ptr ref, + const char* provides_port_name, + Ports::PortProperties_ptr port_prop) + throw (Engines::DSC::PortAlreadyDefined, + Engines::DSC::NilPort, + Engines::DSC::BadProperty) { + Engines_DSC_interface::add_provides_port(ref, + provides_port_name, + port_prop); + } + + /*! + * \see Engines::DSC::add_uses_port + */ + virtual void add_uses_port(const char* repository_id, + const char* uses_port_name, + Ports::PortProperties_ptr port_prop) + throw (Engines::DSC::PortAlreadyDefined, + Engines::DSC::BadProperty) { + Engines_DSC_interface::add_uses_port(repository_id, + uses_port_name, + port_prop); + } + + /*! + * \see Engines::DSC::get_provides_port + */ + virtual Ports::Port_ptr get_provides_port(const char* provides_port_name, + const CORBA::Boolean connection_error) + throw (Engines::DSC::PortNotDefined, + Engines::DSC::PortNotConnected) { + return Engines_DSC_interface::get_provides_port(provides_port_name, + connection_error); + } + + /*! + * \see Engines::DSC::get_uses_port + */ + virtual Engines::DSC::uses_port * get_uses_port(const char* uses_port_name) + throw (Engines::DSC::PortNotDefined, + Engines::DSC::PortNotConnected) { + return Engines_DSC_interface::get_uses_port(uses_port_name); + } + + /*! + * \see Engines::DSC::connect_provides_port + */ + virtual void connect_provides_port(const char* provides_port_name) + throw (Engines::DSC::PortNotDefined) { + Engines_DSC_interface::connect_provides_port(provides_port_name); + } + + /*! + * \see Engines::DSC::connect_uses_port + */ + virtual void connect_uses_port(const char* uses_port_name, + Ports::Port_ptr provides_port_ref) + throw (Engines::DSC::PortNotDefined, + Engines::DSC::BadPortType, + Engines::DSC::NilPort) { + Engines_DSC_interface::connect_uses_port(uses_port_name, + provides_port_ref); + } + + /*! + * \see Engines::DSC::is_connected + */ + virtual CORBA::Boolean is_connected(const char* port_name) + throw (Engines::DSC::PortNotDefined) { + return Engines_DSC_interface::is_connected(port_name); + } + + /*! + * \see Engines::DSC::disconnect_provides_port + */ + virtual void disconnect_provides_port(const char* provides_port_name, + const Engines::DSC::Message message) + throw (Engines::DSC::PortNotDefined, + Engines::DSC::PortNotConnected) { + Engines_DSC_interface::disconnect_provides_port(provides_port_name, + message); + } + + /*! + * \see Engines::DSC::disconnect_uses_port + */ + virtual void disconnect_uses_port(const char* uses_port_name, + Ports::Port_ptr provides_port_ref, + const Engines::DSC::Message message) + throw (Engines::DSC::PortNotDefined, + Engines::DSC::PortNotConnected, + Engines::DSC::BadPortReference) { + Engines_DSC_interface::disconnect_uses_port(uses_port_name, + provides_port_ref, + message); + } + + virtual Ports::PortProperties_ptr get_port_properties(const char* port_name) + throw (Engines::DSC::PortNotDefined) { + return Engines_DSC_interface::get_port_properties(port_name); + } + + // PaCO++ specific code + + // This method is used to registry the proxy of the parallel port into + // all the nodes of the parallel component. + virtual void set_paco_proxy(CORBA::Object_ptr ref, + const char* provides_port_name, + Ports::PortProperties_ptr port_prop); + + // This method by the node that want to add the parallel proxy port. + virtual CORBA::Boolean add_parallel_provides_proxy_port(const CORBA::Object_ptr ref, + const char * provides_port_name); + + // This method is used that the parallel componet node + // knows the CORBA reference of the parallel port. + virtual CORBA::Boolean add_parallel_provides_proxy_wait(const char * provides_port_name); + + // Permits to add a parallel node of a parallel port. + virtual CORBA::Boolean add_parallel_provides_node_port(Ports::Port_PaCO_ptr ref, + const char* provides_port_name); + // Used to get the proxy of the parallel port. + virtual const char * get_proxy(const char* provides_port_name); + +}; + +#endif -- 2.39.2