]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
destroy container name in naming service on shutdown
authorsecher <secher>
Wed, 25 May 2005 09:01:00 +0000 (09:01 +0000)
committersecher <secher>
Wed, 25 May 2005 09:01:00 +0000 (09:01 +0000)
idl/SALOME_MPIContainer.idl
src/Container/Container_i.cxx
src/Container/SALOME_ContainerManager.cxx
src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx
src/MPIContainer/MPIContainer_i.cxx
src/MPIContainer/MPIContainer_i.hxx
src/NamingService/SALOME_NamingService.cxx
src/NamingService/SALOME_NamingService.hxx

index 8265c7380425796268ea6a409a5da2f29015db68..dfe23ec5ebb6f636d2ffa1472ce06041533a8b60 100644 (file)
@@ -31,13 +31,10 @@ module Engines
 {
   interface MPIContainer:Container,MPIObject
   {
-    // start MPI container executable
-    MPIContainer start_MPIimpl( in string ContainerName, in short nbproc );
-
     // asynchronous version to load and remove parallel component in parallel
-    oneway void SPload_impl(in string nameToRegister, in string componentName);
-    oneway void SPremove_impl(in Component component_i);
-    oneway void SPfinalize_removal();
+    oneway void Asload_impl(in string nameToRegister, in string componentName);
+    oneway void Asremove_impl(in Component component_i);
+    oneway void Asfinalize_removal();
   };
 } ;
 
index 919bbf03bbd138950211a0ae9facde332680ea9b..ed5140f7f500db7074100c0657edf7bdd306647a 100644 (file)
@@ -146,7 +146,7 @@ void Engines_Container_i::ping()
 void Engines_Container_i::Shutdown()
 {
   MESSAGE("Engines_Container_i::Shutdown()");
-  _NS->Destroy_Name(_containerName.c_str());
+  _NS->Destroy_FullDirectory(_containerName.c_str());
   //_remove_ref();
   //_poa->deactivate_object(*_id);
   if(_isServantAloneInProcess)
index d3b5f53ffe52b1b0500bb050f23f810905046348..38b104c0e69a8df026be90c2a37d4107839bffd4 100644 (file)
@@ -51,7 +51,6 @@ void SALOME_ContainerManager::ShutdownContainers()
   vector<string> vec=_NS->list_directory_recurs();
   for(vector<string>::iterator iter=vec.begin();iter!=vec.end();iter++)
     {
-      cerr << "SALOME_ContainerManager::ShutdownContainers : " << (*iter).c_str() << endl;
       SCRUTE((*iter));
       CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
       Engines::Container_var cont=Engines::Container::_narrow(obj);
@@ -76,7 +75,6 @@ Engines::Container_ptr SALOME_ContainerManager::FindOrStartContainer(const Engin
     command=_ResManager->BuildTempFileToLaunchRemoteContainer(theMachine,params);
   _ResManager->RmTmpFile();
   int status=system(command.c_str());
-  cerr << status << endl;
   if (status == -1) {
     MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status -1)");
     return Engines::Container::_nil();
index 82408c66afc620447506c745a152e1aaf96db432..be445e1d84071a3e590f506861dd72620e956872 100644 (file)
@@ -176,7 +176,6 @@ Engines::Component_ptr SALOME_LifeCycleCORBA::FindComponent(const Engines::Machi
 {
   const char *containerName = params.container_name;
   int nbproc = NbProc(params);
-  cerr << nbproc << endl;;
 
   if (! isKnownComponentClass(componentName)) return Engines::Component::_nil();
 
index f95236226d14923137e954b4557862987072972b..77467d78f27ad31aa84b42f3a36f00f0bf90d043 100644 (file)
@@ -81,107 +81,6 @@ Engines_MPIContainer_i::~Engines_MPIContainer_i(void)
   }
 }
 
-// Start MPI Container
-Engines::MPIContainer_ptr Engines_MPIContainer_i::start_MPIimpl(
-                                        const char* ContainerName,
-                                        CORBA::Short nbproc )
-{
-
-  char nbp[1024];
-
-  MESSAGE("[" << _numproc << "] start_impl argc " << _argc << " ContainerName " << ContainerName
-          << hex << this << dec) ;
-  _numInstanceMutex.lock() ; // lock on the instance number
-
-  CORBA::Object_var obj = Engines::MPIContainer::_nil() ;
-  bool nilvar = true ;
-  try {
-    string cont("/Containers/");
-    cont += machineName() ;
-    cont += "/" ;
-    cont += ContainerName;
-    INFOS("[" << _numproc << "] " << machineName() << " start_impl unknown container " << cont.c_str()
-          << " try to Resolve" );
-    obj = _NS->Resolve( cont.c_str() );
-    nilvar = CORBA::is_nil( obj ) ;
-    if ( nilvar ) {
-      INFOS("[" << _numproc << "] " << machineName() << " start_impl unknown container "
-            << ContainerName);
-    }
-  }
-  catch (ServiceUnreachable&) {
-    INFOS("[" << _numproc << "] " << machineName() << "Caught exception: Naming Service Unreachable");
-  }
-  catch (...) {
-    INFOS("[" << _numproc << "] " << machineName() << "Caught unknown exception.");
-  }
-  if ( !nilvar ) {
-    _numInstanceMutex.unlock() ;
-    MESSAGE("[" << _numproc << "] start_impl container found without new launch") ;
-    return Engines::MPIContainer::_narrow(obj);
-  }
-  int i = 0 ;
-  while ( _argv[ i ] ) {
-    MESSAGE("[" << _numproc << "]            argv" << i << " " << _argv[ i ]) ;
-    i++ ;
-  }
-  sprintf(nbp,"mpirun -np %d SALOME_MPIContainer ",nbproc);
-  string shstr(nbp);
-  shstr += ContainerName ;
-  if ( _argc == 4 ) {
-    shstr += " " ;
-    shstr += _argv[ 2 ] ;
-    shstr += " " ;
-    shstr += _argv[ 3 ] ;
-  }
-  shstr += " > /tmp/" ;
-  shstr += ContainerName ;
-  shstr += ".log 2>&1 &" ;
-  MESSAGE("system(" << shstr << ")") ;
-  int status = system( shstr.c_str() ) ;
-  if (status == -1) {
-    INFOS("[" << _numproc << "] Engines_MPIContainer_i::start_impl SALOME_MPIContainer failed (system command status -1)") ;
-  }
-  else if (status == 217) {
-    INFOS("[" << _numproc << "] Engines_MPIContainer_i::start_impl SALOME_MPIContainer failed (system command status 217)") ;
-  }
-  INFOS("[" << _numproc << "] " << machineName() << " Engines_MPIContainer_i::start_impl SALOME_MPIContainer launch done");
-
-  obj = Engines::MPIContainer::_nil() ;
-  try {
-    string cont("/Containers/");
-    cont += machineName() ;
-    cont += "/" ;
-    cont += ContainerName;
-    nilvar = true ;
-    int count = 20 ;
-    while ( nilvar && count >= 0) {
-      sleep( 1 ) ;
-      obj = _NS->Resolve(cont.c_str());
-      nilvar = CORBA::is_nil( obj ) ;
-      if ( nilvar ) {
-        INFOS("[" << _numproc << "] " << count << ". " << machineName()
-              << " start_impl unknown container " << cont.c_str());
-        count -= 1 ;
-      }
-    }
-    _numInstanceMutex.unlock() ;
-    if ( !nilvar ) {
-      MESSAGE("[" << _numproc << "] start_impl container found after new launch of SALOME_MPIContainer") ;
-    }
-    return Engines::MPIContainer::_narrow(obj);
-  }
-  catch (ServiceUnreachable&) {
-    INFOS("[" << _numproc << "] " << machineName() << "Caught exception: Naming Service Unreachable");
-  }
-  catch (...) {
-    INFOS("[" << _numproc << "] " << machineName() << "Caught unknown exception.");
-  }
-  _numInstanceMutex.unlock() ;
-  MESSAGE("[" << _numproc << "] start_impl MPI container not found after new launch of SALOME_MPIContainer") ;
-  return Engines::MPIContainer::_nil() ;
-}
-
 // Load component
 Engines::Component_ptr Engines_MPIContainer_i::load_impl(const char* nameToRegister,
                                                 const char* componentName)
@@ -191,7 +90,7 @@ Engines::Component_ptr Engines_MPIContainer_i::load_impl(const char* nameToRegis
   if( _numproc == 0 ){
     // Invocation du chargement du composant dans les autres process
     for(ip= 1;ip<_nbproc;ip++)
-      (Engines::MPIContainer::_narrow((*_tior)[ip]))->SPload_impl(nameToRegister,
+      (Engines::MPIContainer::_narrow((*_tior)[ip]))->Asload_impl(nameToRegister,
                                                                componentName);
   }
 
@@ -200,7 +99,7 @@ Engines::Component_ptr Engines_MPIContainer_i::load_impl(const char* nameToRegis
 }
 
 // Load component
-void Engines_MPIContainer_i::SPload_impl(const char* nameToRegister,
+void Engines_MPIContainer_i::Asload_impl(const char* nameToRegister,
                                         const char* componentName)
 {
   Lload_impl(nameToRegister,componentName);
@@ -306,25 +205,20 @@ void Engines_MPIContainer_i::remove_impl(Engines::Component_ptr component_i)
     for(ip= 1;ip<_nbproc;ip++){
       spcptr = Engines::MPIObject::_narrow((*(pcptr->tior()))[ip]);
       cptr = (Engines::Component_ptr)spcptr;
-      (Engines::MPIContainer::_narrow((*_tior)[ip]))->SPremove_impl(cptr);
+      (Engines::MPIContainer::_narrow((*_tior)[ip]))->Asremove_impl(cptr);
     }
   }
 
   Lremove_impl(component_i);
 }
 
-void Engines_MPIContainer_i::SPremove_impl(Engines::Component_ptr component_i)
+void Engines_MPIContainer_i::Asremove_impl(Engines::Component_ptr component_i)
 {
   Lremove_impl(component_i);
 }
 
 void Engines_MPIContainer_i::Lremove_impl(Engines::Component_ptr component_i)
 {
-  int ip;
-  Engines::Component_ptr cptr;
-  Engines::MPIObject_ptr pcptr;
-  Engines::MPIObject_ptr spcptr;
-
   BEGIN_OF("[" << _numproc << "] MPIContainer_i::Lremove_impl");
 
   ASSERT(! CORBA::is_nil(component_i));
@@ -359,13 +253,13 @@ void Engines_MPIContainer_i::finalize_removal()
   if( _numproc == 0 ){
     // Invocation de la destruction du composant dans les autres process
     for(ip= 1;ip<_nbproc;ip++)
-      (Engines::MPIContainer::_narrow((*_tior)[ip]))->SPfinalize_removal();
+      (Engines::MPIContainer::_narrow((*_tior)[ip]))->Asfinalize_removal();
   }
 
   Lfinalize_removal();
 }
 
-void Engines_MPIContainer_i::SPfinalize_removal()
+void Engines_MPIContainer_i::Asfinalize_removal()
 {
   Lfinalize_removal();
 }
@@ -396,8 +290,7 @@ void Engines_MPIContainer_i::Shutdown()
   int ip;
   MESSAGE("[" << _numproc << "] shutdown of MPI Corba Server");
   if( _numproc == 0 ){
-    MESSAGE("[" << _numproc << "] destroy from Naming Service of " << _containerName);
-    _NS->Destroy_Name(_containerName.c_str());
+    _NS->Destroy_FullDirectory(_containerName.c_str());
     for(ip= 1;ip<_nbproc;ip++)
       (Engines::MPIContainer::_narrow((*_tior)[ip]))->Shutdown();
   }
index d58aef574f5f18a110d40ad04224c4e002626cbd..a805639a11c82d04b9c251ac9bd784e423479c39 100644 (file)
@@ -48,10 +48,6 @@ class Engines_MPIContainer_i : public POA_Engines::MPIContainer,
   // Destructor
   ~Engines_MPIContainer_i();
 
-  // Launch a new MPI container from the current container
-  Engines::MPIContainer_ptr start_MPIimpl(const char* ContainerName,
-                                         CORBA::Short nbproc);
-
   // Load a component in current MPI container
   // synchronous version for process 0
   Engines::Component_ptr load_impl(const char* nameToRegister,
@@ -60,18 +56,18 @@ class Engines_MPIContainer_i : public POA_Engines::MPIContainer,
   void Shutdown();
 
   // asynchronous version for other process
-  void SPload_impl(const char* nameToRegister, const char* componentName);
+  void Asload_impl(const char* nameToRegister, const char* componentName);
 
   // Unload a component from current MPI container
   // synchronous version for process 0
   void remove_impl(Engines::Component_ptr component_i);
   // asynchronous version for other process
-  void SPremove_impl(Engines::Component_ptr component_i);
+  void Asremove_impl(Engines::Component_ptr component_i);
 
   // synchronous version for process 0
   void finalize_removal();
   // asynchronous version for other process
-  void SPfinalize_removal();
+  void Asfinalize_removal();
 
  private:
   // local version to not duplicate code 
index 70ea6e56ae0a270b20ae8d7d20cbdd274eb41f3f..845c8be3efda7eacf05192dbe04ddbb717b0828b 100644 (file)
@@ -1157,6 +1157,27 @@ void SALOME_NamingService::Destroy_Directory(const char* Path)
   delete[] resultat_resolve_Path ;
 }
 
+//----------------------------------------------------------------------
+/*! Function : Destroy_Directory.
+ *  Purpose  : method to destroy a directory if it is empty.
+ *  WARNING : The complete Path  to the directory (from the root_context)
+ *  to destroy should be given.
+ *  If the NamingService is out, the exception ServiceUnreachable is thrown.
+ * \param Path const char* arguments
+ */
+//----------------------------------------------------------------------
+
+void SALOME_NamingService::Destroy_FullDirectory(const char* Path)
+  throw(ServiceUnreachable)
+{
+  Change_Directory(Path);
+  vector<string> contList = list_directory();
+  for(unsigned int ind = 0; ind < contList.size(); ind++)
+    Destroy_Name(contList[ind].c_str());
+  Destroy_Directory(Path);
+  Destroy_Name(Path);
+}
+
 //----------------------------------------------------------------------
 /*! Function : _initialize_root_context
  * Purpose  :  method called by constructor to initialize _root_context
index 31866d4c8d972574aefba55e31c7f7abdcccd3c9..3e5ff8f81b7909c3940b88b16353f26bcccb78ac 100644 (file)
@@ -109,6 +109,10 @@ public:
   virtual void Destroy_Directory(const char* Path)
     throw(ServiceUnreachable);
 
+  //! method to destroy a directory even if it is not empty
+  virtual void Destroy_FullDirectory(const char* Path)
+    throw(ServiceUnreachable);
+
   //! get IORstring naming service address 
   char * getIORaddr();