}
}
-// 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)
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);
}
}
// 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);
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));
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();
}
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();
}
// 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,
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
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