]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
improvement to shutdown salome properly and to launch exception if problem of connect...
authorsecher <secher>
Mon, 9 Jul 2007 14:31:33 +0000 (14:31 +0000)
committersecher <secher>
Mon, 9 Jul 2007 14:31:33 +0000 (14:31 +0000)
14 files changed:
bin/Makefile.am
bin/orbmodule.py
bin/shutdownSalome.py [new file with mode: 0755]
idl/SALOMEDS.idl
idl/SALOME_Registry.idl
src/Container/SALOME_ContainerManager.cxx
src/Container/SALOME_ContainerManager.hxx
src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx
src/Registry/RegistryService.cxx
src/Registry/RegistryService.hxx
src/Registry/SALOME_Registry_Server.cxx
src/ResourcesManager/SALOME_ResourcesManager.cxx
src/ResourcesManager/SALOME_ResourcesManager.hxx
src/SALOMEDS/SALOMEDS_StudyManager_i.hxx

index 97a23267f4645a701ebfa1c99dd7c3a61d4891e5..39cfba893d8b9902ca9c70ee83a3ab85346d40c7 100644 (file)
@@ -59,7 +59,8 @@ dist_salomescript_SCRIPTS=\
        addToKillList.py \
        NSparam.py \
        waitNS.py \
-       waitContainers.py
+       waitContainers.py \
+       shutdownSalome.py
 
 EXTRA_DIST = appliskel
 
index 86e67d6bf1e2447f6478a5fec70d2a1cbd64aeb7..407e9b7b5032e1713ae3d4ee4d0417d2aed15059 100755 (executable)
@@ -15,7 +15,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 # 
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-# 
+#
 import sys,os,time
 import string
 from omniORB import CORBA
diff --git a/bin/shutdownSalome.py b/bin/shutdownSalome.py
new file mode 100755 (executable)
index 0000000..78e1001
--- /dev/null
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+import orbmodule
+import Engines
+import Registry
+import SALOME
+import SALOMEDS
+import SALOME_ModuleCatalog
+clt=orbmodule.client()
+obj = clt.Resolve('Kernel/Session')
+if obj != None:
+  ses = obj._narrow(SALOME.Session)
+  ses.StopSession()
+obj = clt.Resolve('ContainerManager')
+if obj != None:
+  cm = obj._narrow(Engines.ContainerManager)
+  cm.Shutdown()
+obj = clt.Resolve('Kernel/ModulCatalog')
+if obj != None:
+  mc = obj._narrow(SALOME_ModuleCatalog.ModuleCatalog)
+  mc.shutdown()
+obj = clt.Resolve('Registry')
+if obj != None:
+  reg = obj._narrow(Registry.Components)
+  reg.Shutdown()
+obj = clt.Resolve('myStudyManager')
+if obj != None:
+  sm = obj._narrow(SALOMEDS.StudyManager)
+  sm.Shutdown()
index 8920ec25bbfb044d8f5ed272b47a3da5807525b8..6399acbd8c7c73eba2640ffd63757ebcf640656f 100644 (file)
@@ -708,6 +708,8 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin
 */
     void ping();
 
+    void Shutdown();
+
 /*! \brief Creation of a new study
 
      Creates a new study with a definite name.
index e33e2ccd11b6f43a23273877d00c9ce2cc5b1e91..8e44332155fb38b77937c111677e1076811ec763 100644 (file)
@@ -55,6 +55,7 @@ module Registry
                AllInfos history () ;
                oneway void end() ;
                oneway void hello( in unsigned long id ) ;
+               void Shutdown();
        } ;
 } ;
 
index 44383901a8a4fe7a60494d400ad4ae43f2a1e360..15dbff53a0f159ccb3d990641192feebd89c98ca 100644 (file)
@@ -58,6 +58,7 @@ SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb)
   PortableServer::POAManager_var pman = root_poa->the_POAManager();
   PortableServer::POA_var my_poa;
 
+  _orb = CORBA::ORB::_duplicate(orb) ;
   CORBA::PolicyList policies;
   policies.length(1);
   PortableServer::ThreadPolicy_var threadPol = 
@@ -99,6 +100,8 @@ void SALOME_ContainerManager::Shutdown()
 {
   MESSAGE("Shutdown");
   ShutdownContainers();
+  _orb->shutdown(0);
+  _NS->Destroy_Name(_ContainerManagerNameInNS);
   PortableServer::ObjectId_var oid = _default_POA()->servant_to_id(this);
   _default_POA()->deactivate_object(oid);
   _remove_ref();
@@ -114,36 +117,34 @@ void SALOME_ContainerManager::Shutdown()
 void SALOME_ContainerManager::ShutdownContainers()
 {
   MESSAGE("ShutdownContainers");
-  _NS->Change_Directory("/Containers");
-  vector<string> vec = _NS->list_directory_recurs();
-  list<string> lstCont;
-  for(vector<string>::iterator iter = vec.begin();iter!=vec.end();iter++)
-    {
+  bool isOK;
+  isOK = _NS->Change_Directory("/Containers");
+  if( isOK ){
+    vector<string> vec = _NS->list_directory_recurs();
+    list<string> lstCont;
+    for(vector<string>::iterator iter = vec.begin();iter!=vec.end();iter++){
       SCRUTE((*iter));
       CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
       Engines::Container_var cont=Engines::Container::_narrow(obj);
-      if(!CORBA::is_nil(cont))
-       {
-         lstCont.push_back((*iter));
-       }
+      if(!CORBA::is_nil(cont)){
+       lstCont.push_back((*iter));
+      }
     }
-  MESSAGE("Container list: ");
-  for(list<string>::iterator iter=lstCont.begin();iter!=lstCont.end();iter++)
-    {
+    MESSAGE("Container list: ");
+    for(list<string>::iterator iter=lstCont.begin();iter!=lstCont.end();iter++){
       SCRUTE((*iter));
     }
-  for(list<string>::iterator iter=lstCont.begin();iter!=lstCont.end();iter++)
-    {
+    for(list<string>::iterator iter=lstCont.begin();iter!=lstCont.end();iter++){
       SCRUTE((*iter));
       CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
       Engines::Container_var cont=Engines::Container::_narrow(obj);
-      if(!CORBA::is_nil(cont))
-       {
-         MESSAGE("ShutdownContainers: " << (*iter));
-         cont->Shutdown();
-       }
+      if(!CORBA::is_nil(cont)){
+       MESSAGE("ShutdownContainers: " << (*iter));
+       cont->Shutdown();
+      }
       else MESSAGE("ShutdownContainers: no container ref for " << (*iter));
     }
+  }
 }
 
 //=============================================================================
index 90ba170a75e7fad7b8b4ae61e837af97e67f71c4..f64950f876a791b73c50d68de60649aa011f06e0 100644 (file)
@@ -103,6 +103,7 @@ protected:
 
   long GetIdForContainer(void);
   long _id;
+  CORBA::ORB_var _orb;
 
   SALOME_ResourcesManager *_ResManager;
   SALOME_NamingService *_NS;
index d09e02da6ed8b189d3156852022e5f50a5332828..96e1a91a9e943599b0702d7683f81e9b1f765d09 100644 (file)
@@ -119,7 +119,7 @@ public:
 
   void ping(){};
 
-  void shutdown() { if (_orb) _orb->shutdown(1); };
+  void shutdown() { if (_orb) _orb->shutdown(0); };
 
 private:
   //! method to parse one module catalog
index 21524aa8d0296186dcb710b2f4ba3bdb84a86b51..8e37ce26a7a9efd260aa86228123b6003a530793 100644 (file)
@@ -47,7 +47,7 @@ using namespace std;
 RegistryService::RegistryService( void ) : _SessionName(0), _Compteur(0)
 {
        MESSAGE("Passage dans RegistryService::RegistryService()") ;
-
+       _orb = CORBA::ORB::_nil();
 }
 
 
index b52fa758d2ac2e712f5982d7daa12d6cadbe12e5..3629403a60fb8a0ea7187d36987888a87d5b74ca 100644 (file)
@@ -100,9 +100,13 @@ public :
 
        void SessionName( const char *sessionName ) ;
 
+        void SetOrb( CORBA::ORB_ptr orb ) { _orb = orb; return; }
+
+        void Shutdown() { if(!CORBA::is_nil(_orb)) _orb->shutdown(0); }
 
 protected :
 
+        CORBA::ORB_var _orb;
        const char              *_SessionName ;
        int                      _Compteur ;
        std::map<int,client_infos *>     _reg ;
index 7dc1b6817b319a9fd59c64d53d2acca251723e52..470cde40192af49a37a9cce5d8805aa65bde1f18 100644 (file)
@@ -168,6 +168,7 @@ int main( int argc , char **argv )
       naming.init_orb( orb ) ;
       RegistryService *ptrRegistry = SINGLETON_<RegistryService>::Instance() ;
       ptrRegistry->SessionName( ptrSessionName ) ;
+      ptrRegistry->SetOrb(orb);
       varComponents = ptrRegistry->_this() ;
       // The RegistryService must not already exist.
            
index b7627a8a53b1413d11178ac643ffea54da2de126..e0b17b02830ad24f8ef55d86c63c8a35edd1c8d7 100644 (file)
@@ -517,10 +517,12 @@ SALOME_ResourcesManager::BuildCommandToLaunchRemoteContainer
 void SALOME_ResourcesManager::CopyFileNamesToExecute(const std::string& machine,
                             const std::string& DirForTmpFiles ,
                             const std::string& PathFileNameToExecute ,
-                            const Engines::FilesToExportList& filesToExport) {
+                            const Engines::FilesToExportList& filesToExport) throw(SALOME_Exception)
+{
   BEGIN_OF("SALOME_ResourcesManager::CopyFileNamesToExecute");
   const ParserResourcesType& resInfo = _resourcesList[machine];
   string command;
+  int status;
 
   if (resInfo.Protocol == rsh)
     command = "rsh ";
@@ -538,7 +540,10 @@ void SALOME_ResourcesManager::CopyFileNamesToExecute(const std::string& machine,
   command += " \"mkdir -p ";
   command += DirForTmpFiles ;
   command += "\"" ;
-  system(command.c_str());
+  SCRUTE(command.c_str());
+  status = system(command.c_str());
+  if(status)
+    throw SALOME_Exception("Error of connection on remote host");    
 
   if (resInfo.Protocol == rsh)
     command = "rcp ";
@@ -558,7 +563,10 @@ void SALOME_ResourcesManager::CopyFileNamesToExecute(const std::string& machine,
   command += resInfo.Alias;
   command += ":";
   command += DirForTmpFiles ;
-  system(command.c_str());
+  SCRUTE(command.c_str());
+  status = system(command.c_str());
+  if(status)
+    throw SALOME_Exception("Error of connection on remote host");    
 
   int i ;
   for ( i = 0 ; i < filesToExport.length() ; i++ ) {
@@ -577,7 +585,10 @@ void SALOME_ResourcesManager::CopyFileNamesToExecute(const std::string& machine,
     command += resInfo.Alias;
     command += ":";
     command += DirForTmpFiles ;
-    system(command.c_str());
+    SCRUTE(command.c_str());
+    status = system(command.c_str());
+    if(status)
+      throw SALOME_Exception("Error of connection on remote host");    
   }
 
   END_OF("SALOME_ResourcesManager::CopyFileNamesToExecute");
@@ -605,8 +616,10 @@ void SALOME_ResourcesManager::CopyFileNamesToExecute(const std::string& machine,
 std::string SALOME_ResourcesManager::BuildCmdrunSalomeBatch(
                                        const std::string& machine,
                                        const std::string& DirForTmpFiles ,
-                                       const std::string& FileNameToExecute ) {
+                                       const std::string& FileNameToExecute ) throw(SALOME_Exception)
+{
   BEGIN_OF("SALOME_ResourcesManager::BuildCmdrunSalomeBatch");
+  int status;
   _TmpFileName = BuildTemporaryFileName();
   ofstream tempOutputFile;
   tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
@@ -634,6 +647,7 @@ std::string SALOME_ResourcesManager::BuildCmdrunSalomeBatch(
   tempOutputFile << "  sleep 1" << endl ;
   tempOutputFile << "  ./runSession waitContainers.py $arglist" << endl ;
   tempOutputFile << "  ./runSession python ~/" << DirForTmpFiles << "/" << FileNameToExecute << ".py" << endl;
+  tempOutputFile << "  ./runSession shutdownSalome.py" << endl;
   tempOutputFile << "else" << endl ;
   tempOutputFile << "  sleep 1" << endl ;
   tempOutputFile << "  ./runSession waitNS.py" << endl ;
@@ -664,7 +678,10 @@ std::string SALOME_ResourcesManager::BuildCmdrunSalomeBatch(
   command += "/runSalome_" ;
   command += FileNameToExecute ;
   command += "_Batch.sh" ;
-  system(command.c_str());
+  SCRUTE(command.c_str());
+  status = system(command.c_str());
+  if(status)
+    throw SALOME_Exception("Error of connection on remote host");    
   RmTmpFile();
 
   END_OF("SALOME_ResourcesManager::BuildCmdrunSalomeBatch");
@@ -686,8 +703,10 @@ std::string SALOME_ResourcesManager::BuildCmdFileNameToExecute_Batch(
                                        const std::string& machine,
                                        const long NumberOfProcessors,
                                        const std::string& DirForTmpFiles ,
-                                       const std::string& FileNameToExecute ) {
+                                       const std::string& FileNameToExecute ) throw(SALOME_Exception)
+{
   BEGIN_OF("SALOME_ResourcesManager::BuildCmdFileNameToExecute_Batch");
+  int status;
   _TmpFileName = BuildTemporaryFileName();
   ofstream tempOutputFile;
   tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
@@ -726,7 +745,10 @@ std::string SALOME_ResourcesManager::BuildCmdFileNameToExecute_Batch(
   command += "/" ;
   command += FileNameToExecute ;
   command += "_Batch.sh" ;
-  system(command.c_str());
+  SCRUTE(command.c_str());
+  status = system(command.c_str());
+  if(status)
+    throw SALOME_Exception("Error of connection on remote host");    
 
   RmTmpFile();
   END_OF("SALOME_ResourcesManager::BuildCmdFileNameToExecute_Batch");
@@ -747,9 +769,11 @@ std::string SALOME_ResourcesManager::BuildCmdFileNameToExecute_Batch(
 std::string SALOME_ResourcesManager::BuildCmdFileNameToExecute_bsub(
                                        const std::string& machine,
                                        const std::string& DirForTmpFiles ,
-                                       const std::string& FileNameToExecute ) {
+                                       const std::string& FileNameToExecute ) throw(SALOME_Exception)
+{
   BEGIN_OF("SALOME_ResourcesManager::BuildCmdFileNameToExecute_bsub");
   _TmpFileName = BuildTemporaryFileName();
+  int status;
   ofstream tempOutputFile;
   tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
   const ParserResourcesType& resInfo = _resourcesList[machine];
@@ -784,7 +808,11 @@ std::string SALOME_ResourcesManager::BuildCmdFileNameToExecute_bsub(
   command += "/" ;
   command += FileNameToExecute ;
   command += "_bsub.sh" ;
-  system(command.c_str());
+  SCRUTE(command.c_str());
+  status = system(command.c_str());
+  if(status)
+    throw SALOME_Exception("Error of connection on remote host");    
+
   RmTmpFile();
   END_OF("SALOME_ResourcesManager::BuildCmdFileNameToExecute_bsub");
 
@@ -801,11 +829,13 @@ std::string SALOME_ResourcesManager::BuildCmdFileNameToExecute_bsub(
 std::string SALOME_ResourcesManager::CmdToExecute_bsub(
                                        const std::string& machine,
                                        const std::string& DirForTmpFiles ,
-                                       const std::string& FileNameToExecute ) {
+                                       const std::string& FileNameToExecute ) throw(SALOME_Exception)
+{
   BEGIN_OF("SALOME_ResourcesManager::CmdToExecute_bsub");
   const ParserResourcesType& resInfo = _resourcesList[machine];
   string command;
-  resInfo.Print() ;
+  resInfo.Print();
+  int status;
 
   if (resInfo.Protocol == rsh)
     command = "rsh " ;
@@ -823,7 +853,11 @@ std::string SALOME_ResourcesManager::CmdToExecute_bsub(
   command += "/" ;
   command += FileNameToExecute ;
   command += "_bsub.sh\"" ;
-  system(command.c_str());
+  SCRUTE(command.c_str());
+  status = system(command.c_str());
+  if(status)
+    throw SALOME_Exception("Error of connection on remote host");    
+
   END_OF("SALOME_ResourcesManager::CmdToExecute_bsub");
 
   return command;
@@ -1123,8 +1157,10 @@ string SALOME_ResourcesManager::BuildTemporaryFileName() const
 string
 SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer
 (const string& machine,
- const Engines::MachineParameters& params)
+ const Engines::MachineParameters& params) throw(SALOME_Exception)
 {
+  int status;
+
   _TmpFileName = BuildTemporaryFileName();
   ofstream tempOutputFile;
   tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
@@ -1198,7 +1234,7 @@ SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer
       commandRcp += machine;
       commandRcp += ":";
       commandRcp += _TmpFileName;
-      system(commandRcp.c_str());
+      status = system(commandRcp.c_str());
     }
 
   else if (resInfo.Protocol == ssh)
@@ -1210,11 +1246,14 @@ SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer
       commandRcp += machine;
       commandRcp += ":";
       commandRcp += _TmpFileName;
-      system(commandRcp.c_str());
+      status = system(commandRcp.c_str());
     }
   else
     throw SALOME_Exception("Unknown protocol");
 
+  if(status)
+    throw SALOME_Exception("Error of connection on remote host");    
+
   command += machine;
   _CommandForRemAccess = command;
   command += " ";
index b4a8e5cb1e8baedbb062bfc842fbadd82e0487c5..952e400925d789b0ad760e6a2ec70b6e8dbbc78b 100644 (file)
@@ -79,20 +79,20 @@ class RESOURCESMANAGER_EXPORT SALOME_ResourcesManager
     void CopyFileNamesToExecute(const std::string& machine,
                                 const std::string& DirForTmpFiles ,
                                 const std::string& PathFileNameToExecute ,
-                                const Engines::FilesToExportList& filesToExport) ;
+                                const Engines::FilesToExportList& filesToExport) throw(SALOME_Exception);
     std::string BuildCmdrunSalomeBatch(const std::string& machine,
                                        const std::string& DirForTmpFiles ,
-                                       const std::string& FileNameToExecute ) ;
+                                       const std::string& FileNameToExecute ) throw(SALOME_Exception);
     std::string BuildCmdFileNameToExecute_Batch(const std::string& machine,
                                       const long NumberOfProcessors,
                                        const std::string& DirForTmpFiles ,
-                                       const std::string& FileNameToExecute ) ;
+                                       const std::string& FileNameToExecute ) throw(SALOME_Exception);
     std::string BuildCmdFileNameToExecute_bsub(const std::string& machine,
                                        const std::string& DirForTmpFiles ,
-                                       const std::string& FileNameToExecute ) ;
+                                       const std::string& FileNameToExecute ) throw(SALOME_Exception);
     std::string CmdToExecute_bsub(const std::string& machine,
                                   const std::string& DirForTmpFiles ,
-                                  const std::string& FileNameToExecute ) ;
+                                  const std::string& FileNameToExecute ) throw(SALOME_Exception);
 
     std::string BuildCommandToLaunchLocalContainer
     (const Engines::MachineParameters& params, const long id);
@@ -126,7 +126,7 @@ class RESOURCESMANAGER_EXPORT SALOME_ResourcesManager
 
     std::string BuildTempFileToLaunchRemoteContainer
     (const std::string& machine,
-     const Engines::MachineParameters& params);
+     const Engines::MachineParameters& params) throw(SALOME_Exception);
 
     void SelectOnlyResourcesWithOS(std::vector<std::string>& hosts,
                                   const char *OS) const
index 31c486f7b29e7b49646d4dfbe7233ee4d56f5de5..ec1db47082172671a381dbc58cbc90ad694e3e64 100644 (file)
@@ -145,6 +145,8 @@ public:
   virtual CORBA::LongLong GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal);
 
   static PortableServer::POA_ptr GetPOA(const SALOMEDS::Study_ptr theStudy);
+
+  void Shutdown() { _orb->shutdown(0); return; }
 };
 
 #endif