From: Anthony Geay Date: Thu, 15 Apr 2021 14:27:01 +0000 (+0200) Subject: Implementation d un servant embarque de FakeNS pour que le container lancé puisse... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a06e706dbc7034d84b2d7b910780d806ccb6c5c5;p=modules%2Fkernel.git Implementation d un servant embarque de FakeNS pour que le container lancé puisse enregistrer sa reference --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 652b7c175..1c523d38d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,7 +217,7 @@ IF(NOT SALOME_LIGHT_ONLY) DF SalomeLoggerServer with_loggerTraceCollector SalomeNS SalomeGenericObj Registry SalomeCatalog ResourcesManager SalomeResourcesManager SalomeNotification SalomeContainer SalomeSDS Launcher SalomeLauncher - SalomeLifeCycleCORBA SalomeDSClient TOOLSDS SalomeKernelHelpers + SalomeLifeCycleCORBA SalomeDSClient TOOLSDS SalomeKernelHelpers SalomeORB SalomeDSImpl SalomeDS SalomeCommunication SalomeDSCContainer) # Temporary solution for package src\DSC on windows IF(NOT WIN32) diff --git a/SalomeKERNELConfig.cmake.in b/SalomeKERNELConfig.cmake.in index 13c0d81c9..34de7a367 100644 --- a/SalomeKERNELConfig.cmake.in +++ b/SalomeKERNELConfig.cmake.in @@ -186,3 +186,4 @@ SET(KERNEL_TOOLSDS TOOLSDS) SET(KERNEL_UtilsTest UtilsTest) SET(KERNEL_with_loggerTraceCollector with_loggerTraceCollector) SET(KERNEL_SalomeKernelHelpers SalomeKernelHelpers) +SET(KERNEL_SalomeORB SalomeORB) diff --git a/idl/CMakeLists.txt b/idl/CMakeLists.txt index 2ca550e40..de7f9d9ee 100644 --- a/idl/CMakeLists.txt +++ b/idl/CMakeLists.txt @@ -55,6 +55,7 @@ SET(SalomeIDLKernel_IDLSOURCES SALOME_TestModuleCatalog.idl SALOME_CommonTypes.idl SALOME_ExternalServerLauncher.idl + SALOME_Embedded_NamingService.idl ${CMAKE_CURRENT_BINARY_DIR}/Calcium_Ports.idl ) diff --git a/idl/SALOME_Embedded_NamingService.idl b/idl/SALOME_Embedded_NamingService.idl new file mode 100644 index 000000000..c8c40207f --- /dev/null +++ b/idl/SALOME_Embedded_NamingService.idl @@ -0,0 +1,37 @@ +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D +// +// 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. +// +// 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 +// + +#ifndef _SALOME_EMBEDDED_NAMINGSERVICE_IDL_ +#define _SALOME_EMBEDDED_NAMINGSERVICE_IDL_ + +module Engines +{ + typedef sequence IORType; + + interface EmbeddedNamingService + { + void Register(in IORType ObjRef, in string Path); + void Destroy_FullDirectory(in string Path); + void Destroy_Name(in string Path); + IORType Resolve(in string Path); + IORType ResolveFirst(in string Path); + }; +}; + +#endif diff --git a/src/Container/SALOME_ContainerManager.hxx b/src/Container/SALOME_ContainerManager.hxx index 0a5fd143f..bc8587ce3 100644 --- a/src/Container/SALOME_ContainerManager.hxx +++ b/src/Container/SALOME_ContainerManager.hxx @@ -53,6 +53,8 @@ public: // C++ Methods void Shutdown(); + void DeclareUsingSalomeSession() { _isSSL = false; } + static const char *_ContainerManagerNameInNS; protected: @@ -114,6 +116,9 @@ protected: //! attribute that contains the number of processes used in batch mode by MPI containers int _nbprocUsed; + //! attribute that specifies the launch mode. + bool _isSSL = true; + static omni_mutex _numInstanceMutex ; // lib and instance protection //! attributes to allow concurrency for // GiveContainer diff --git a/src/KernelHelpers/CMakeLists.txt b/src/KernelHelpers/CMakeLists.txt index 9c8ce0461..f03b04cd7 100644 --- a/src/KernelHelpers/CMakeLists.txt +++ b/src/KernelHelpers/CMakeLists.txt @@ -36,8 +36,16 @@ INCLUDE_DIRECTORIES( ${PROJECT_BINARY_DIR}/idl ) +SET(SalomeORB_SOURCES + SALOME_KernelORB.cxx +) + +ADD_LIBRARY(SalomeORB ${SalomeORB_SOURCES}) +TARGET_LINK_LIBRARIES(SalomeORB ${OMNIORB_LIBRARIES}) +INSTALL(TARGETS SalomeORB EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + SET(SalomeKernelHelpers_LIBS - ${OMNIORB_LIBRARIES} + SalomeORB SalomeNS SALOMELocalTrace SALOMEBasics diff --git a/src/KernelHelpers/SALOME_KernelORB.cxx b/src/KernelHelpers/SALOME_KernelORB.cxx new file mode 100644 index 000000000..ed8b9da78 --- /dev/null +++ b/src/KernelHelpers/SALOME_KernelORB.cxx @@ -0,0 +1,36 @@ +// Copyright (C) 2021 CEA/DEN, EDF R&D +// +// 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. +// +// 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 +// + +#include "SALOME_KernelORB.hxx" + +namespace KERNEL { + /** + * This function returns a static reference to the orb. The orb can + * be used for example to initialize CORBA variables or to serialize + * and unserialize the CORBA objet to/from an IOR string. + */ + CORBA::ORB_ptr getORB() { + static CORBA::ORB_ptr orb; + if(CORBA::is_nil(orb)){ + int argc=0; + orb = CORBA::ORB_init(argc,0); + } + return orb; + } +} diff --git a/src/KernelHelpers/SALOME_KernelORB.hxx b/src/KernelHelpers/SALOME_KernelORB.hxx new file mode 100644 index 000000000..4c0980959 --- /dev/null +++ b/src/KernelHelpers/SALOME_KernelORB.hxx @@ -0,0 +1,31 @@ +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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. +// +// 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 +// + +// Author: Guillaume Boulant (EDF/R&D) + +#pragma once + +#include "KernelHelpers.hxx" + +#include + +namespace KERNEL +{ + KERNELHELPERS_EXPORT CORBA::ORB_ptr getORB(); +} diff --git a/src/KernelHelpers/SALOME_KernelServices.cxx b/src/KernelHelpers/SALOME_KernelServices.cxx index 61e59350b..efc9bf85e 100644 --- a/src/KernelHelpers/SALOME_KernelServices.cxx +++ b/src/KernelHelpers/SALOME_KernelServices.cxx @@ -31,20 +31,6 @@ std::unique_ptr _naming_service; namespace KERNEL { - /** - * This function returns a static reference to the orb. The orb can - * be used for example to initialize CORBA variables or to serialize - * and unserialize the CORBA objet to/from an IOR string. - */ - CORBA::ORB_ptr getORB() { - static CORBA::ORB_ptr orb; - if(CORBA::is_nil(orb)){ - int argc=0; - orb = CORBA::ORB_init(argc,0); - } - return orb; - } - void assignNamingServiceSL() { if ( !_naming_service.get() ) diff --git a/src/KernelHelpers/SALOME_KernelServices.hxx b/src/KernelHelpers/SALOME_KernelServices.hxx index decc6fd17..42f8dc638 100644 --- a/src/KernelHelpers/SALOME_KernelServices.hxx +++ b/src/KernelHelpers/SALOME_KernelServices.hxx @@ -34,11 +34,12 @@ #include "SALOME_NamingService.hxx" #include "SALOME_LifeCycleCORBA.hxx" +#include "SALOME_KernelORB.hxx" + namespace KERNEL { // --------------------------------------------- // SALOME KERNEL main services - KERNELHELPERS_EXPORT CORBA::ORB_ptr getORB(); KERNELHELPERS_EXPORT SALOME_NamingService_Abstract *getNamingService(); KERNELHELPERS_EXPORT void assignNamingServiceSL(); KERNELHELPERS_EXPORT SALOME_LifeCycleCORBA * getLifeCycleCORBA(); diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index e17bca3cd..11d16abac 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -241,6 +241,11 @@ SALOME_Launcher::getJobWorkFile(CORBA::Long job_id, const char * work_file, cons return rtn; } +void SALOME_Launcher::DeclareUsingSalomeSession() +{ + this->_ContManager->DeclareUsingSalomeSession(); +} + void SALOME_Launcher::removeJob(CORBA::Long job_id) { diff --git a/src/Launcher/SALOME_Launcher.hxx b/src/Launcher/SALOME_Launcher.hxx index 2e9b97569..9fcbc2023 100644 --- a/src/Launcher/SALOME_Launcher.hxx +++ b/src/Launcher/SALOME_Launcher.hxx @@ -77,6 +77,8 @@ public: // Save and load methods virtual void loadJobs(const char* jobs_file); virtual void saveJobs(const char* jobs_file); + + void DeclareUsingSalomeSession(); static const char *_LauncherNameInNS; diff --git a/src/Launcher/SALOME_LauncherServer.cxx b/src/Launcher/SALOME_LauncherServer.cxx index 34d6e5541..4692f5e2b 100644 --- a/src/Launcher/SALOME_LauncherServer.cxx +++ b/src/Launcher/SALOME_LauncherServer.cxx @@ -118,6 +118,7 @@ int main(int argc, char* argv[]) SALOME_CPythonHelper cPyh; cPyh.initializePython(argc,argv); SALOME_Launcher *lServ(new SALOME_Launcher(orb,safePOA)); + lServ->DeclareUsingSalomeSession(); lServ->_remove_ref(); // SALOMESDS::DataServerManager *dsm(new SALOMESDS::DataServerManager(&cPyh,orb,root_poa)); diff --git a/src/NamingService/CMakeLists.txt b/src/NamingService/CMakeLists.txt index 7009bac9a..b9a6fc4ed 100644 --- a/src/NamingService/CMakeLists.txt +++ b/src/NamingService/CMakeLists.txt @@ -24,6 +24,9 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../Basics ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace ${CMAKE_CURRENT_SOURCE_DIR}/../Utils + ${CMAKE_CURRENT_SOURCE_DIR}/../KernelHelpers + ${CMAKE_CURRENT_SOURCE_DIR}/../LifeCycleCORBA + ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_BINARY_DIR}/idl ) @@ -33,13 +36,13 @@ SET(SalomeNS_SOURCES NamingService_WaitForServerReadiness.cxx SALOME_Fake_NamingService.cxx SALOME_NamingService_Abstract.cxx + SALOME_Embedded_NamingService.cxx ) - ADD_DEFINITIONS(${OMNIORB_DEFINITIONS}) ADD_LIBRARY(SalomeNS ${SalomeNS_SOURCES}) ADD_DEPENDENCIES(SalomeNS SalomeIDLKernel) -TARGET_LINK_LIBRARIES(SalomeNS OpUtil) +TARGET_LINK_LIBRARIES(SalomeNS OpUtil SalomeORB) INSTALL(TARGETS SalomeNS EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) diff --git a/src/NamingService/SALOME_Embedded_NamingService.cxx b/src/NamingService/SALOME_Embedded_NamingService.cxx new file mode 100644 index 000000000..3eca13ba6 --- /dev/null +++ b/src/NamingService/SALOME_Embedded_NamingService.cxx @@ -0,0 +1,81 @@ +// Copyright (C) 2021 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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. +// +// 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 +// + +#include "SALOME_Embedded_NamingService.hxx" +#include "SALOME_Fake_NamingService.hxx" +#include "SALOME_KernelORB.hxx" + +#include +#include + +CORBA::Object_var IORToObject(const Engines::IORType& ObjRef) +{ + CORBA::ORB_ptr orb(KERNEL::getORB()); + CORBA::ULong size(ObjRef.length()); + std::unique_ptr pt(new char[size+1]); + pt[size] = '\0'; + for(CORBA::ULong i = 0 ; i < size ; ++i) + pt[i] = ObjRef[i]; + CORBA::Object_var obj = orb->string_to_object(pt.get()); + return obj; +} + +Engines::IORType *ObjectToIOR(CORBA::Object_ptr obj) +{ + std::unique_ptr ret(new Engines::IORType); + CORBA::ORB_ptr orb(KERNEL::getORB()); + CORBA::String_var ior = orb->object_to_string(obj); + auto len( strlen(ior) ); + ret->length( len ); + for(std::size_t i = 0 ; i < len ; ++i) + (*ret)[i] = ior[i]; + return ret.release(); +} + +void SALOME_Embedded_NamingService::Register(const Engines::IORType& ObjRef, const char *Path) +{ + SALOME_Fake_NamingService ns; + ns.Register(IORToObject(ObjRef),Path); +} + +void SALOME_Embedded_NamingService::Destroy_FullDirectory(const char *Path) +{ + SALOME_Fake_NamingService ns; + ns.Destroy_FullDirectory(Path); +} + +void SALOME_Embedded_NamingService::Destroy_Name(const char *Path) +{ + SALOME_Fake_NamingService ns; + ns.Destroy_Name(Path); +} + +Engines::IORType *SALOME_Embedded_NamingService::Resolve(const char *Path) +{ + SALOME_Fake_NamingService ns; + CORBA::Object_var obj = ns.Resolve(Path); + return ObjectToIOR(obj); +} + +Engines::IORType *SALOME_Embedded_NamingService::ResolveFirst(const char *Path) +{ + SALOME_Fake_NamingService ns; + CORBA::Object_var obj = ns.ResolveFirst(Path); + return ObjectToIOR(obj); +} diff --git a/src/NamingService/SALOME_Embedded_NamingService.hxx b/src/NamingService/SALOME_Embedded_NamingService.hxx new file mode 100644 index 000000000..38f76c758 --- /dev/null +++ b/src/NamingService/SALOME_Embedded_NamingService.hxx @@ -0,0 +1,35 @@ +// Copyright (C) 2021 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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. +// +// 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 +// + +#pragma once + +#include "SALOME_NamingService_defs.hxx" + +#include +#include CORBA_CLIENT_HEADER(SALOME_Embedded_NamingService) + +class NAMINGSERVICE_EXPORT SALOME_Embedded_NamingService : public virtual POA_Engines::EmbeddedNamingService +{ +public: + void Register(const Engines::IORType& ObjRef, const char *Path) override; + void Destroy_FullDirectory(const char *Path) override; + void Destroy_Name(const char *Path) override; + Engines::IORType *Resolve(const char *Path) override; + Engines::IORType *ResolveFirst(const char *Path) override; +};