]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
OK for SALOME_Launcher
authorAnthony GEAY <anthony.geay@edf.fr>
Fri, 19 Feb 2021 15:00:38 +0000 (16:00 +0100)
committerAnthony GEAY <anthony.geay@edf.fr>
Fri, 19 Feb 2021 15:00:38 +0000 (16:00 +0100)
src/Container/SALOME_ContainerManager.cxx
src/Launcher/SALOME_Launcher.cxx
src/Launcher/SALOME_Launcher.hxx
src/NamingService/SALOME_Fake_NamingService.cxx
src/NamingService/SALOME_Fake_NamingService.hxx
src/NamingService/SALOME_NamingService.cxx
src/NamingService/SALOME_NamingService.hxx
src/NamingService/SALOME_NamingService_Abstract.hxx [new file with mode: 0644]
src/ResourcesManager/SALOME_ResourcesManager.cxx

index dec227ae99dd484bbbb45348f82d2267424540f6..8134f28cd0e818d22926d00d9f1ac19cab13a20a 100644 (file)
@@ -99,10 +99,9 @@ SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableSer
   threadPol->destroy();
   PortableServer::ObjectId_var id = _poa->activate_object(this);
   CORBA::Object_var obj = _poa->id_to_reference(id);
-  Engines::ContainerManager_var refContMan =
-    Engines::ContainerManager::_narrow(obj);
-
-  _NS->Register(refContMan,_ContainerManagerNameInNS);
+  Engines::ContainerManager_var refContMan = Engines::ContainerManager::_narrow(obj);
+  if(_NS)
+    _NS->Register(refContMan,_ContainerManagerNameInNS);
   _isAppliSalomeDefined = (GetenvThreadSafe("APPLI") != 0);
 
 #ifdef HAVE_MPI2
@@ -195,7 +194,8 @@ void SALOME_ContainerManager::Shutdown()
 {
   MESSAGE("Shutdown");
   ShutdownContainers();
-  _NS->Destroy_Name(_ContainerManagerNameInNS);
+  if(_NS)
+    _NS->Destroy_Name(_ContainerManagerNameInNS);
   PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
   _poa->deactivate_object(oid);
 }
@@ -209,7 +209,8 @@ void SALOME_ContainerManager::Shutdown()
 void SALOME_ContainerManager::ShutdownContainers()
 {
   MESSAGE("ShutdownContainers");
-
+  if(!_NS)
+    return ;
   SALOME::Session_var session = SALOME::Session::_nil();
   CORBA::Long pid = 0;
   CORBA::Object_var objS = _NS->Resolve("/Kernel/Session");
index 0698b184f26f4ef24b46cf5fd1e99edadd5bfe07..2655efc7d613c0e285fc3a45b1df3a463f424df2 100644 (file)
@@ -58,13 +58,24 @@ const char *SALOME_Launcher::_LauncherNameInNS = "/SalomeLauncher";
  *  \param orb
  */
 //=============================================================================
-SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa) : _l()
+SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa)
 {
   MESSAGE("SALOME_Launcher constructor");
   _NS = new SALOME_NamingService(orb);
-  _ResManager = new SALOME_ResourcesManager(orb,poa,_NS);
+  init(orb,poa);
+  MESSAGE("SALOME_Launcher constructor end");
+}
+
+SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *externalNS):_NS(externalNS)
+{
+  init(orb,poa);
+}
+
+void SALOME_Launcher::init(CORBA::ORB_ptr orb, PortableServer::POA_var poa)
+{
+  _ResManager = new SALOME_ResourcesManager(orb,poa,tradNS());
   _l.SetResourcesManager(_ResManager->GetImpl());
-  _ContManager = new SALOME_ContainerManager(orb,poa,_NS);
+  _ContManager = new SALOME_ContainerManager(orb,poa,tradNS());
   _ResManager->_remove_ref();
   _ContManager->_remove_ref();
 
@@ -73,9 +84,7 @@ SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa
   PortableServer::ObjectId_var id = _poa->activate_object(this);
   CORBA::Object_var obj = _poa->id_to_reference(id);
   Engines::SalomeLauncher_var refContMan = Engines::SalomeLauncher::_narrow(obj);
-
   _NS->Register(refContMan,_LauncherNameInNS);
-  MESSAGE("SALOME_Launcher constructor end");
 }
 
 //=============================================================================
@@ -373,6 +382,8 @@ SALOME_Launcher::testBatch(const Engines::ResourceParameters& params)
 void SALOME_Launcher::Shutdown()
 {
   MESSAGE("Shutdown");
+  if(!_NS)
+    return;
   _NS->Destroy_Name(_LauncherNameInNS);
   _ContManager->Shutdown();
   _ResManager->Shutdown();
@@ -691,3 +702,20 @@ SALOME_Launcher::JobParameters_CPP2CORBA(const JobParameters_cpp& job_parameters
   result->launcher_args = CORBA::string_dup(job_parameters.launcher_args.c_str());
   return result;
 }
+
+static SALOME_Launcher *_launcher_singleton_ssl = nullptr;
+
+#include "SALOME_Fake_NamingService.hxx"
+
+SALOME_Launcher *KERNEL::getLauncherSA()
+{
+  if(!_launcher_singleton_ssl)
+  {
+    int argc(0);
+    CORBA::ORB_var orb = CORBA::ORB_init(argc,nullptr);
+    PortableServer::POA_var root_poa=PortableServer::POA::_the_root_poa();
+    SALOME_Fake_NamingService *ns=new SALOME_Fake_NamingService(orb);
+    _launcher_singleton_ssl = new SALOME_Launcher(orb,root_poa,ns);//3rd arg is important to skip NS !
+  }
+  return _launcher_singleton_ssl;
+}
index 963799d474a34a94980505bf8edadbcc19accd89..eb0e6a618d661b14ef53e6d31820a86cc028ab4d 100644 (file)
 
 #include "SALOME_Launcher_defs.hxx"
 
-#include <SALOMEconfig.h>
+#include "SALOME_NamingService.hxx"
+#include "SALOMEconfig.h"
 #include CORBA_CLIENT_HEADER(SALOME_Launcher)
 #include "Launcher.hxx"
 
 #include <string>
 #include <list>
 
-class SALOME_NamingService;
 class SALOME_ContainerManager;
 class SALOME_ResourcesManager;
 
@@ -43,8 +43,8 @@ class SALOMELAUNCHER_EXPORT SALOME_Launcher:
 
 public:
   SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa);
+  SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *externalNS);
   virtual ~SALOME_Launcher();
-
   // Main methods
   CORBA::Long createJob    (const Engines::JobParameters & job_parameters);
   void        launchJob    (CORBA::Long job_id);
@@ -86,20 +86,30 @@ public:
   static Engines::JobParameters_var
     JobParameters_CPP2CORBA(const JobParameters_cpp& job_parameters);
 
+  SALOME_NamingService *tradNS() { return SALOME_NamingService::GetTraditionalNS(_NS); }
+
 protected:
   // Internal methods
   virtual void notifyObservers(const std::string & event_name, const std::string & event_data);
-
+  void init(CORBA::ORB_ptr orb, PortableServer::POA_var poa);
 protected:
   CORBA::ORB_var _orb;
   PortableServer::POA_var _poa;
   SALOME_ContainerManager *_ContManager;
   SALOME_ResourcesManager *_ResManager;
-  SALOME_NamingService *_NS;
+  SALOME_NamingService_Abstract *_NS = nullptr;
 
   std::list<Engines::SalomeLauncherObserver_var> _observers;
 
   Launcher_cpp _l;
 };
 
+/*!
+ * Methods to be used in SSL mode to skip NS.
+ */
+namespace KERNEL
+{
+  SALOMELAUNCHER_EXPORT SALOME_Launcher *getLauncherSA();
+}
+
 #endif
index 026c224930d8a0bf1cb4eb2d49cedfd849725ec5..7babdc7bf9244beac2ce23fff4f9ad897bc55f0d 100644 (file)
 #include "SALOME_Fake_NamingService.hxx"
 #include "Utils_SALOME_Exception.hxx"
 
-SALOME_Fake_NamingService::SALOME_Fake_NamingService(CORBA::ORB_ptr orb):_orb(CORBA::ORB::_duplicate(orb))
+std::mutex SALOME_Fake_NamingService::_mutex;
+std::map<std::string,CORBA::Object_var> SALOME_Fake_NamingService::_map;
+
+SALOME_Fake_NamingService::SALOME_Fake_NamingService(CORBA::ORB_ptr orb)
 {
 }
 
@@ -31,6 +34,10 @@ void SALOME_Fake_NamingService::Register(CORBA::Object_ptr ObjRef, const char* P
   _map[Path] = ObjRefAuto;
 }
 
+void SALOME_Fake_NamingService::Destroy_Name(const char* Path)
+{
+}
+
 CORBA::Object_ptr SALOME_Fake_NamingService::Resolve(const char* Path)
 {
   std::string pathCpp(Path);
index 9f7fc28bd01b5cd834cf80271df757ec2a337552..6393b204256eb6d6344b78a54734b671fc642fd5 100644 (file)
 
 #include "omniORB4/CORBA.h"
 
+#include "SALOME_NamingService_Abstract.hxx"
+
 #include <mutex>
 #include <string>
 #include <map>
 
-class SALOME_Fake_NamingService
+class NAMINGSERVICE_EXPORT SALOME_Fake_NamingService : public SALOME_NamingService_Abstract
 {
 public:
     SALOME_Fake_NamingService(CORBA::ORB_ptr orb);
-    void Register(CORBA::Object_ptr ObjRef, const char* Path);
-    CORBA::Object_ptr Resolve(const char* Path);
-private:    
-    CORBA::ORB_var _orb;
-    std::mutex _mutex;
-    std::map<std::string,CORBA::Object_var> _map;
+    void Register(CORBA::Object_ptr ObjRef, const char* Path) override;
+    CORBA::Object_ptr Resolve(const char* Path) override;
+    void Destroy_Name(const char* Path) override;
+private:
+    static std::mutex _mutex;
+    static std::map<std::string,CORBA::Object_var> _map;
 };
index 7dc133b02f3c08b5587a316e0729891c0f19134e..e5601f327a75f1a8bcd42f91118e6515c855aa00 100644 (file)
@@ -87,6 +87,12 @@ SALOME_NamingService::~SALOME_NamingService()
   //MESSAGE("SALOME_NamingService destruction");
 }
 
+SALOME_NamingService *SALOME_NamingService::GetTraditionalNS(SALOME_NamingService_Abstract *ns)
+{
+  SALOME_NamingService *nsc(dynamic_cast<SALOME_NamingService *>(ns));
+  return nsc;
+}
+
 // ============================================================================
 /*! \brief initializes ORB reference and naming service root context.
  *
index 879c375663eec99e773b62976d3a730708e50afe..d7bc3cd000c2e6d7bd42a48bddb71634053b1619 100644 (file)
 #include "Utils_Mutex.hxx"
 #include "ServiceUnreachable.hxx"
 
-#include "SALOME_NamingService_defs.hxx"
+#include "SALOME_NamingService_Abstract.hxx"
 
 #ifdef WIN32
 //#pragma warning(disable:4290) // Warning Exception ...
 #endif
 
-class NAMINGSERVICE_EXPORT SALOME_NamingService
+class NAMINGSERVICE_EXPORT SALOME_NamingService : public SALOME_NamingService_Abstract
 {
 public:
   SALOME_NamingService();
   SALOME_NamingService(CORBA::ORB_ptr orb);
 
   virtual ~SALOME_NamingService();
+  
+  static SALOME_NamingService *GetTraditionalNS(SALOME_NamingService_Abstract *ns);
 
   void init_orb(CORBA::ORB_ptr orb=0);
-  void Register(CORBA::Object_ptr ObjRef, const char* Path) ;
-  CORBA::Object_ptr Resolve(const char* Path) ; 
+  void Register(CORBA::Object_ptr ObjRef, const char* Path) override;
+  CORBA::Object_ptr Resolve(const char* Path) override
   CORBA::Object_ptr ResolveFirst(const char* Path) ; 
   CORBA::Object_ptr ResolveComponent(const char* hostname,
                                      const char* containerName,
@@ -73,7 +75,7 @@ public:
   std::vector<std::string> list_directory() ;
   std::vector<std::string> list_subdirs() ;
   std::vector<std::string> list_directory_recurs() ;
-  void Destroy_Name(const char* Path) ;
+  void Destroy_Name(const char* Path) override;
   virtual void Destroy_Directory(const char* Path) ;
   virtual void Destroy_FullDirectory(const char* Path) ;
   char *getIORaddr();
diff --git a/src/NamingService/SALOME_NamingService_Abstract.hxx b/src/NamingService/SALOME_NamingService_Abstract.hxx
new file mode 100644 (file)
index 0000000..ea6b373
--- /dev/null
@@ -0,0 +1,33 @@
+// 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 "omniORB4/CORBA.h"
+
+class NAMINGSERVICE_EXPORT SALOME_NamingService_Abstract
+{
+public:
+  virtual void Register(CORBA::Object_ptr ObjRef, const char* Path) = 0;
+  virtual CORBA::Object_ptr Resolve(const char* Path) = 0;
+  virtual void Destroy_Name(const char* Path) = 0;
+  virtual ~SALOME_NamingService_Abstract() { }
+};
index 6562acac54e19cba81e9ea99479c346a59dc792f..db1e537315b37ddbc5d7058b8e93380c3ca520e7 100644 (file)
@@ -111,7 +111,8 @@ SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb,
   PortableServer::ObjectId_var id = _poa->activate_object(this);
   CORBA::Object_var obj = _poa->id_to_reference(id);
   Engines::ResourcesManager_var refContMan = Engines::ResourcesManager::_narrow(obj);
-  _NS->Register(refContMan,_ResourcesManagerNameInNS);
+  if(_NS)
+    _NS->Register(refContMan,_ResourcesManagerNameInNS);
 
   MESSAGE("SALOME_ResourcesManager constructor end");
 }
@@ -137,6 +138,8 @@ SALOME_ResourcesManager::~SALOME_ResourcesManager()
 void SALOME_ResourcesManager::Shutdown()
 {
   MESSAGE("Shutdown");
+  if(!_NS)
+    return ;
   _NS->Destroy_Name(_ResourcesManagerNameInNS);
   PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
   _poa->deactivate_object(oid);