From: rahuel Date: Mon, 8 Nov 2004 08:09:32 +0000 (+0000) Subject: Restore previous state without ContainersManager X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5e5832ed49a13619755fc77cc394874514b447cb;p=modules%2Fkernel.git Restore previous state without ContainersManager --- diff --git a/src/ContainersManager/ContainersManager_Server.cxx b/src/ContainersManager/ContainersManager_Server.cxx deleted file mode 100644 index 2473fcb71..000000000 --- a/src/ContainersManager/ContainersManager_Server.cxx +++ /dev/null @@ -1,173 +0,0 @@ -// SALOME ContainersManager -// -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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. -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : ContainersManager_Server.cxx -// Author : Jean Rahuel -// Module : SALOME -// $Header: - -#include -#include "SALOME_NamingService.hxx" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" - -#include "ContainersManager_i.hxx" - -using namespace std ; - -int main( int argc , char **argv ) { - try { - -// initialize the ORB -#if WITH_SINGLETON - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - CORBA::ORB_var &orb = init( argc , argv ) ; -#else - CORBA::ORB_var orb = CORBA::ORB_init(argc, argv) ; -#endif - - long TIMESleep = 250000000 ; - int NumberOfTries = 40 ; - int a ; - int i ; - int j ; - timespec ts_req ; - ts_req.tv_nsec=TIMESleep ; - ts_req.tv_sec=0 ; - timespec ts_rem ; - ts_rem.tv_nsec=0 ; - ts_rem.tv_sec=0 ; - -// initialize POA - CosNaming::NamingContext_var inc ; - PortableServer::POA_var poa ; - CORBA::Object_var theObj = CORBA::Object::_nil() ; - CORBA::Object_var obj = CORBA::Object::_nil() ; - CORBA::Object_var object = CORBA::Object::_nil() ; -#if WITH_SINGLETON - SALOME_NamingService &naming = *SINGLETON_::Instance() ; -#else - theObj = orb->resolve_initial_references("NameService"); - inc = CosNaming::NamingContext::_narrow(theObj); -#endif - int CONTAINERS_MANAGER = 0 ; - const char * Env = getenv("USE_LOGGER") ; - int EnvL =0; - if ( ( Env != NULL ) && ( strlen(Env ) ) ) { - EnvL=1 ; - } - CosNaming::Name name ; - name.length( 1 ) ; - name[0].id = CORBA::string_dup("Logger") ; - PortableServer::POAManager_var mgr ; - for ( i = 1 ; i <= NumberOfTries ; i++ ) { - if ( i != 1 ) { - a=nanosleep( &ts_req , &ts_rem ) ; - } - try { - obj = orb->resolve_initial_references( "RootPOA" ) ; - if ( !CORBA::is_nil( obj ) ) { - poa = PortableServer::POA::_narrow( obj ) ; - } - if ( !CORBA::is_nil( poa ) ) { - mgr = poa->the_POAManager() ; - } - if ( !CORBA::is_nil( orb ) ) { - theObj = orb->resolve_initial_references( "NameService" ) ; - } - if ( !CORBA::is_nil( theObj ) ) { - inc = CosNaming::NamingContext::_narrow(theObj) ; - } - } - catch ( CORBA::COMM_FAILURE& ) { - MESSAGE( "ContainersManager : CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) ; - } - if ( !CORBA::is_nil( inc ) ) { - MESSAGE( "ContainersManager : Naming Service was found" ) ; - if ( EnvL == 1 ) { - for ( j = 1 ; j <= NumberOfTries ; j++ ) { - if ( j !=1 ) { - a=nanosleep( &ts_req , &ts_rem ) ; - } - try { - object = inc->resolve( name ) ; - } - catch ( CosNaming::NamingContext::NotFound ) { - MESSAGE( "ContainersManager : Logger Server wasn't found" ) ; - } - catch (...) { - MESSAGE( "ContainersManager : Unknown exception" ) ; - } - if ( !CORBA::is_nil( object ) ) { - MESSAGE( "ContainersManager : Loger Server was found" ) ; - CONTAINERS_MANAGER = 1 ; - break; - } - } - } - } - if ( ( CONTAINERS_MANAGER == 1 ) || ( (EnvL ==0 ) && ( !CORBA::is_nil( inc ) ) ) ) { - break; - } - } - -// initialise Naming Service - SALOME_NamingService *_NS ; - _NS = new SALOME_NamingService( orb ) ; - -// Active ContainersManager -#if WITH_SINGLETON - Manager_i * MyContainersManager = SINGLETON_::Instance() ; - cout << "ContainersManager_Server -> MyContainersManager->Init" << endl ; - MyContainersManager->Init( orb , poa , _NS , argc , argv ) ; -#else - Manager_i * MyContainersManager = new Manager_i() ; - MyContainersManager->Init( orb , poa , _NS , argc , argv ) ; -#endif -// _Id = _Poa->activate_object ( MyContainersManager ) ; - cout << "ContainersManager_Server -> mgr->activate" << endl ; - mgr->activate() ; - CORBA::Object_ptr TheContainersManager = MyContainersManager->_this() ; - -// register ContainersManager in Naming Service - _NS->Register( TheContainersManager , "/Kernel/ContainersManager" ) ; - - MESSAGE("Running ContainersManager Server.") ; - - orb->run(); - - poa->destroy( 1 , 1 ) ; - - orb->destroy(); - - } - catch ( CORBA::SystemException& ) { - INFOS("Caught CORBA::SystemException.") ; - } - catch ( CORBA::Exception& ) { - INFOS("Caught CORBA::Exception.") ; - } - - return 0 ; -} diff --git a/src/ContainersManager/ContainersManager_i.cxx b/src/ContainersManager/ContainersManager_i.cxx deleted file mode 100644 index 10fac1063..000000000 --- a/src/ContainersManager/ContainersManager_i.cxx +++ /dev/null @@ -1,1338 +0,0 @@ -// SALOME ContainersManager -// -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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. -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : ContainersManager_i.cxx -// Author : Jean Rahuel -// Module : SALOME -// $Header: - -#include "Utils_SINGLETON.hxx" - -#include "utilities.h" -#include "ContainersManager_i.hxx" - -using namespace std ; - -Manager_i::Manager_i() { - MESSAGE( "Manager_i::Manager_i default constructor" ) ; -} - -void Manager_i::Init( CORBA::ORB_ptr orb , - PortableServer::POA_ptr poa , - SALOME_NamingService * NamingService , - int argc , - char ** argv ) { - _Orb = CORBA::ORB::_duplicate( orb ) ; - _Poa = PortableServer::POA::_duplicate( poa ) ; - _Id = _Poa->activate_object ( this ) ; - _NamingService = NamingService ; - CORBA::Object_var obj = NamingService->Resolve( "/Kernel/ResourcesManager" ) ; - _ResourcesManager = Resources::Manager::_narrow( obj ) ; - if ( CORBA::is_nil( _ResourcesManager ) ) { - MESSAGE( "Manager_i::Manager_i unable to locate the ResourcesManager in the NamingService" ) ; - exit( 1 ) ; - } - int i ; - i = 0 ; - while ( argv[ i ] ) { - MESSAGE(" argv" << i << " '" << argv[ i ] << "'" ) ; - i++ ; - } - if ( argc == 3 && strcmp( argv[1] , "-ORBInitRef" ) == NULL && - strcmp( argv[2] , "NameService=corbaname::localhost" ) == NULL ) { - string ORBInitRef = &argv[2][23] ; - for ( i = 0 ; i < strlen( ORBInitRef.c_str() ) ; i++ ) { - if ( ORBInitRef[i] == ':' ) { - const char * CPort = ORBInitRef.c_str() ; - int Port ; - sscanf( &CPort[i+1] ,"%d", &_NamingServicePort) ; - ORBInitRef[i] = '\0' ; - _NamingServiceHostName = ORBInitRef ; - } - } - if ( i == strlen( ORBInitRef.c_str() ) ) { - _NamingServiceHostName = ORBInitRef ; - _NamingServicePort = 2809 ; - } - if ( strcmp( _NamingServiceHostName.c_str() , "localhost" ) == 0 ) { - _NamingServiceHostName = GetHostname().c_str() ; - } - } - else { - _NamingServiceHostName = GetHostname().c_str() ; - _NamingServicePort = 2809 ; - system( "netstat -apn | grep -F -e omniNames > /tmp/NsComputer.log" ) ; - ifstream netstat( "/tmp/NsComputer.log" ) ; - string tcp,z,ORBInitRef ; - netstat >> tcp >> z >> z >> ORBInitRef ; - system( "rm -f /tmp/NsComputer.log" ) ; - for ( i = 0 ; i < strlen( ORBInitRef.c_str() ) ; i++ ) { - if ( ORBInitRef[i] == ':' ) { - const char * CPort = ORBInitRef.c_str() ; - int Port ; - sscanf( &CPort[i+1] ,"%d", &_NamingServicePort) ; - MESSAGE( "Manager_i::Manager_i NamingService on " << _NamingServiceHostName.c_str() << " with port " - << _NamingServicePort ) ; - } - } - } - MESSAGE( "Manager_i::Manager_i NamingServiceHostName " << _NamingServiceHostName << " _NamingServicePort " - << _NamingServicePort ) ; - - pthread_mutex_init( &_MutexManager , NULL ) ; - - _ListOfComputers = new Resources::ListOfComputers() ; - _ListOfContainers = new Engines::ListOfContainers() ; - _ListOfComponents = new Engines::ListOfComponents() ; - -} - -void Manager_i::destroy() { - MESSAGE( "Manager_i::destroy" ) ; - if ( pthread_mutex_unlock( &_MutexManager ) ) { - perror("Manager_i::destroy MutexManager pthread_mutex_unlock ") ; - } - int i ; - Containers::MachineParameters * MyParams = Parameters() ; - MyParams->ContainerType = Engines::UndefinedContainerType ; - MESSAGE( "Manager_i::destroy components FindComponents :" ) ; - Engines::ListOfComponents_var aListOfEnginesComponents = FindComponents( *MyParams , "" ) ; - MESSAGE( "Manager_i::destroy components FindContainers :" ) ; - Engines::ListOfContainers_var aListOfEnginesContainers = FindContainers( *MyParams ) ; - MESSAGE( "Manager_i::destroy " << aListOfEnginesComponents->length() << " components" ) ; - for ( i = 0 ; i < aListOfEnginesComponents->length() ; i++ ) { - string interfaceName = aListOfEnginesComponents[ i ]->interfaceName() ; - try { - MESSAGE( "Manager_i::destroy trying to destroy Component " << interfaceName ) ; - aListOfEnginesComponents[ i ]->destroy() ; - MESSAGE( "Manager_i::destroy Component " << interfaceName << " destroyed" ) ; - } - catch ( ... ) { - MESSAGE( "Manager_i::destroy Component " << interfaceName << " failed" ) ; - } - } - MESSAGE( "Manager_i::destroy " << aListOfEnginesContainers->length() << " containers" ) ; - for ( i = 0 ; i < aListOfEnginesContainers->length() ; i++ ) { - string aContainerName ; - string aComputerName ; - ostringstream astr ; - try { - aContainerName = aListOfEnginesContainers[ i ]->name() ; - aComputerName = aListOfEnginesContainers[ i ]->machineName() ; - astr << aListOfEnginesContainers[ i ]->getPID() ; - MESSAGE( "Manager_i::destroy trying to destroy Container " << aContainerName ) ; - aListOfEnginesContainers[ i ]->destroy() ; - MESSAGE( "Manager_i::destroy Container " << aContainerName << " destroyed" ) ; - } - catch ( ... ) { - MESSAGE( "Manager_i::destroy destroy of Container " << aContainerName << " failed" ) ; - } - string KillContainer ; - if ( strcmp( aComputerName.c_str() , GetHostname().c_str() ) ) { - if ( _ResourcesManager->SshAccess( aComputerName.c_str() ) ) { - KillContainer = "ssh " ; - } - else { - KillContainer = "rsh " ; - } - KillContainer += aComputerName ; - } - KillContainer += string( "kill " ) ; - KillContainer += astr.str() ; -// KillContainer += " &" ; - int status = system( KillContainer.c_str() ) ; - if ( status == 0 ) { - MESSAGE( "Manager_i::destroy kill of Container " << aContainerName << " " - << KillContainer << " successsed" ) ; - } - else { - MESSAGE( "Manager_i::destroy kill of Container " << aContainerName << " " - << KillContainer << " failed" ) ; - } - } - _Poa->deactivate_object( *_Id ) ; - CORBA::release( _Poa ) ; -#if !WITH_SINGLETON - delete( _Id ) ; - this->_remove_ref(); -#endif - MESSAGE( "Manager_i::destroy NamingService->Destroy_Name /Kernel/ContainersManager" ) ; - _NamingService->Destroy_Name( "/Kernel/ContainersManager" ) ; - MESSAGE( "Manager_i::destroyed" ) ; -} - -Manager_i::~Manager_i() { - MESSAGE( "Manager_i::~Manager_i" ) ; -} - -Containers::MachineParameters * Manager_i::Parameters() { - Containers::MachineParameters_var aMachineParameters = new Containers::MachineParameters() ; - aMachineParameters->with_xterm = 0 ; - aMachineParameters->Os = Containers::Linux ; - aMachineParameters->Memory = 0 ; - aMachineParameters->CpuClock = 0 ; - aMachineParameters->NbProc = 1 ; - aMachineParameters->NbNode = 1 ; - aMachineParameters->HostName = CORBA::string_dup( "" ) ; - aMachineParameters->ContainerName = CORBA::string_dup( "" ) ; - aMachineParameters->ContainerType = Engines::CppContainer ; - aMachineParameters->NsHostName = CORBA::string_dup( _NamingServiceHostName.c_str() ) ; - aMachineParameters->NsPort = _NamingServicePort ; - return aMachineParameters._retn(); -} - -bool Manager_i::ping() { - MESSAGE( "Manager_i::ping" ) ; - return true ; -} - -//string Manager_i::ContainerName( const char * aComputerContainer , -// string * theComputer , -// string * theContainer ) { -// char * ContainerName = new char [ strlen( aComputerContainer ) + 1 ] ; -// strcpy( ContainerName , aComputerContainer ) ; -// string theComputerContainer("/Containers/"); -// char * slash = strchr( ContainerName , '/' ) ; -// if ( !slash ) { -// *theComputer = GetHostname() ; -// theComputerContainer += *theComputer ; -// theComputerContainer += "/" ; -// *theContainer = ContainerName ; -// theComputerContainer += *theContainer ; -// } -// else { -// slash[ 0 ] = '\0' ; -// slash += 1 ; -// *theContainer = slash ; -// if ( !strcmp( ContainerName , "localhost" ) ) { -// *theComputer = GetHostname() ; -// } -// else { -// *theComputer = ContainerName ; -// } -// theComputerContainer += *theComputer ; -// theComputerContainer += "/" ; -// theComputerContainer += *theContainer ; -// } -// if ( strlen( theContainer->c_str() ) == 0 ) { -// theContainer = new string( "FactoryServer" ) ; -// } -// return theComputerContainer ; -//} - - -Engines::ListOfContainers * Manager_i::AllContainers() { - MESSAGE( "Manager_i::AllContainers" ) ; - Engines::ListOfContainers_var aListOfContainers ; - Containers::MachineParameters_var aMachineParameters = Parameters() ; - aMachineParameters->ContainerType = Engines::UndefinedContainerType ; - aListOfContainers = FindContainers( aMachineParameters ) ; - return aListOfContainers._retn() ; -} - - -Engines::Container_ptr Manager_i::FindContainer( const Containers::MachineParameters & myParams ) { - Containers::MachineParameters MyParams = (Containers::MachineParameters & ) myParams ; - Engines::Container_var aContainer = Engines::Container::_nil() ; - if ( strcmp( MyParams.HostName ,"localhost" ) == 0 ) { - MyParams.HostName = GetHostname().c_str() ; - } - MESSAGE( "Manager_i::FindContainer " << MyParams.HostName << " " << MyParams.ContainerName ) ; - MESSAGE( "Manager_i::FindContainer MutexManager pthread_mutex_lock :" ) ; - if ( pthread_mutex_lock( &_MutexManager ) ) { - perror("Manager_i::FindContainer MutexManager pthread_mutex_lock ") ; - exit( 0 ) ; - } - MESSAGE( "Manager_i::FindContainer MutexManager pthread_mutex_locked" ) ; - - aContainer = FindContainerLocked( MyParams ) ; - - if ( pthread_mutex_unlock( &_MutexManager ) ) { - perror("Manager_i::FindContainer MutexManager pthread_mutex_unlock ") ; - exit( 0 ) ; - } - MESSAGE( "Manager_i::FindContainer MutexManager pthread_mutex_unlocked" ) ; - return Engines::Container::_duplicate( aContainer ) ; -} - -Engines::Container_ptr Manager_i::FindContainerLocked( Containers::MachineParameters & MyParams ) { - Engines::Container_var aContainer = Engines::Container::_nil() ; - try { - _ListOfContainers = FindContainersLocked( MyParams , false ) ; - _EnginesContainer = Engines::Container::_nil() ; - if ( _ListOfContainers->length() ) { - _EnginesContainer = _ListOfContainers[ 0 ] ; - aContainer = _ListOfContainers[ 0 ] ; - MESSAGE( "Manager_i::FindContainerLocked --> " << aContainer->machineName() << " " - << aContainer->name() ) ; - } - else { - MESSAGE( "Manager_i::FindContainerLocked --> Engines::Container::_nil" ) ; - } - } - catch ( ... ) { - MESSAGE( "Manager_i::FindContainerLocked catched" ) ; - } - return Engines::Container::_duplicate( aContainer ) ; -} - -Engines::Container_ptr Manager_i::FindOneContainer( const char * aHostName , - const char * aContainerName ) { - Containers::MachineParameters * MyParams = Parameters() ; - string theComputer = aHostName ; - string theContainer = aContainerName ; -// ContainerName( aContainerName , &theComputer , &theContainer ) ; - MyParams->HostName = theComputer.c_str() ; - MyParams->ContainerName = theContainer.c_str() ; - MyParams->ContainerType = Engines::UndefinedContainerType ; - if ( strcmp( MyParams->HostName ,"localhost" ) == 0 ) { - MyParams->HostName = GetHostname().c_str() ; - } - MESSAGE( "Manager_i::FindOneContainer " << MyParams->HostName << " " << MyParams->ContainerName ) ; - Engines::Container_ptr aContainer = FindContainer( *MyParams ) ; - delete MyParams ; - return aContainer ; -} - -Engines::ListOfContainers * Manager_i::FindContainers( const Containers::MachineParameters & myParams ) { - Containers::MachineParameters MyParams = (Containers::MachineParameters & ) myParams ; - if ( strcmp( MyParams.HostName ,"localhost" ) == 0 ) { - MyParams.HostName = GetHostname().c_str() ; - } - MESSAGE( "Manager_i::FindContainers MutexManager pthread_mutex_lock :" ) ; - if ( pthread_mutex_lock( &_MutexManager ) ) { - perror("Manager_i::FindContainersMutexManager pthread_mutex_lock ") ; - exit( 0 ) ; - } - Engines::ListOfContainers_var aListOfContainers ; - MESSAGE( "Manager_i::FindContainers MutexManager pthread_mutex_locked" ) ; - try { - aListOfContainers = FindContainersLocked( MyParams , false ) ; - } - catch ( ... ) { - MESSAGE( "Manager_i::FindContainers catched" ) ; - } -// aListOfContainers->length( _ListOfContainers->length() ) ; -// int i ; -// for ( i = 0 ; i < _ListOfContainers->length() ; i++ ) { -// aListOfContainers[ i ] = Engines::Container::_duplicate( _ListOfContainers[ i ] ) ; -// MESSAGE( "Manager_i::FindContainers " << i << ". " << _ListOfContainers[ i ]->name() ) ; -// } - if ( pthread_mutex_unlock( &_MutexManager ) ) { - perror("Manager_i::FindContainers MutexManager pthread_mutex_unlock ") ; - exit( 0 ) ; - } - MESSAGE( "Manager_i::FindContainers MutexManager pthread_mutex_unlocked" ) ; - return aListOfContainers._retn() ; -} - -Engines::ListOfContainers * Manager_i::FindContainersLocked( Containers::MachineParameters & MyParams , bool _StartContainer ) { - MESSAGE( "Manager_i::FindContainersLocked GetComputers :" ) ; - _ListOfComputers = _ResourcesManager->GetComputers( MyParams ) ; - MESSAGE( "Manager_i::FindContainersLocked " << MyParams.HostName << " " - << MyParams.ContainerName << " " << _ListOfComputers->length() - << " computers found" ) ; - _ListOfContainers = new Engines::ListOfContainers() ; - _ListOfContainers->length( 0 ) ; - int NumberOfComputers = _ListOfComputers->length() ; - if ( NumberOfComputers == 0 ) { - NumberOfComputers = 1 ; - } - int i ; - for ( i = 0 ; i < NumberOfComputers ; i++ ) { - _FullHostName = string( "/Containers/" ) ; - if ( _ListOfComputers->length() ) { - _ResourcesComputer = _ListOfComputers[ i ] ; - _ComputerParameters = _ResourcesComputer->Parameters() ; - _FullHostName += _ComputerParameters->Alias ; - } - else { - _FullHostName += MyParams.HostName ; - } - if ( strlen( MyParams.ContainerName ) ) { - _FullContainerName = _FullHostName + "/" + string( (char * ) MyParams.ContainerName ) ; - _ContainerObject = _NamingService->Resolve( _FullContainerName.c_str() ) ; - MESSAGE( "Manager_i::FindContainersLocked NamingService->Resolve( " - << _FullContainerName << " )" ) ; - if ( !CORBA::is_nil( _ContainerObject ) ) { - try { - _EnginesContainer = Engines::Container::_narrow( _ContainerObject ) ; - _EnginesContainer->ping() ; - } - catch(...) { - _ContainerObject = CORBA::Object::_nil() ; - _EnginesContainer = Engines::Container::_nil() ; - MESSAGE( "Manager_i::FindContainersLocked " << _FullContainerName << " NOT responding" ) ; - } - } - if ( !CORBA::is_nil( _ContainerObject ) ) { - try { - _EnginesContainer = Engines::Container::_narrow( _ContainerObject ) ; - if ( MyParams.ContainerType == Engines::UndefinedContainerType || - _EnginesContainer->type() == MyParams.ContainerType ) { - int size = _ListOfContainers->length() ; - _ListOfContainers->length( size + 1 ) ; - _ListOfContainers[ size ] = Engines::Container::_duplicate( _EnginesContainer ) ; - MESSAGE( "Manager_i::FindContainersLocked --> " - << _EnginesContainer->machineName() << " " - << _EnginesContainer->name() << " " << _EnginesContainer->type() ) ; - } - else { - MESSAGE( "Manager_i::FindContainersLocked --> " - << _EnginesContainer->machineName() << " " - << _EnginesContainer->name() << " " - << _EnginesContainer->type() << " # " - << MyParams.ContainerType ) ; - } - } - catch ( ... ) { - MESSAGE( "Manager_i::FindContainersLocked " << _FullContainerName - << " catched NOT responding " ) ; - } - } - else { - MESSAGE( "Manager_i::FindContainers " << _FullContainerName << " unknown" ) ; - } - } - else { - if ( _NamingService->Change_Directory( _FullHostName.c_str() ) ) { - vector theListOfContainers = _NamingService->list_directory() ; - MESSAGE( "Manager_i::FindContainersLocked " << theListOfContainers.size() - << " containers found." ) ; - int j ; - for ( j = 0 ; j < theListOfContainers.size() ; j++ ) { - _FullContainerName = _FullHostName + "/" + theListOfContainers[ j ] ; - MESSAGE( "Manager_i::FindContainersLocked " << j << " " << _FullContainerName ) ; - _ContainerObject = _NamingService->Resolve( _FullContainerName.c_str() ) ; - if ( !CORBA::is_nil( _ContainerObject ) ) { - try { - _EnginesContainer = Engines::Container::_narrow( _ContainerObject ) ; - _EnginesContainer->ping() ; - if ( MyParams.ContainerType == Engines::UndefinedContainerType || - _EnginesContainer->type() == MyParams.ContainerType ) { - int size = _ListOfContainers->length() ; - _ListOfContainers->length( size + 1 ) ; - _ListOfContainers[ size ] = Engines::Container::_duplicate( _EnginesContainer ); - MESSAGE( "Manager_i::FindContainersLocked --> " - << _EnginesContainer->machineName() << " " - << _EnginesContainer->name() << " " - << _EnginesContainer->type() ) ; - } - else { - MESSAGE( "Manager_i::FindContainersLocked --> " - << _EnginesContainer->machineName() << " " - << _EnginesContainer->name() << " " - << _EnginesContainer->type() << " # " - << MyParams.ContainerType ) ; - _EnginesContainer = Engines::Container::_nil() ; - } - } - catch( ... ) { - MESSAGE( "Manager_i::FindContainersLocked " << _FullContainerName - << " catched NOT responding" ) ; - _EnginesContainer = Engines::Container::_nil() ; - } - } - else { - MESSAGE( "Manager_i::FindContainersLocked " << _FullContainerName - << " unknown" ) ; - } - } - } - else { -// MESSAGE( "Manager_i::FindContainersLocked " << _FullHostName.c_str() -// << " not found in Naming Service" ) ; - } - } - } - return _ListOfContainers._retn() ; -} - -Engines::Container_ptr Manager_i::FindOrStartContainer( const Containers::MachineParameters & myParams ) { - Containers::MachineParameters MyParams = (Containers::MachineParameters & ) myParams ; - if ( strcmp( MyParams.HostName ,"localhost" ) == 0 ) { - MyParams.HostName = GetHostname().c_str() ; - } - if ( MyParams.ContainerType == Engines::UndefinedContainerType ) { - MyParams.ContainerType == Engines::CppContainer ; - } - Engines::Container_var aContainer = Engines::Container::_nil() ; - MESSAGE( "Manager_i::FindOrStartContainer " << MyParams.HostName << " " - << MyParams.ContainerName - << " " << MyParams.ContainerType << " " << MyParams.Os << " " - << MyParams.Memory << " " - << MyParams.CpuClock << " " << MyParams.NbProc << " " - << MyParams.NbNode << " " - << MyParams.NsHostName << " " << MyParams.NsPort ) ; - MESSAGE( "Manager_i::FindOrStartContainer MutexManager pthread_mutex_lock :" ) ; - if ( pthread_mutex_lock( &_MutexManager ) ) { - perror("Manager_i::FindOrStartContainer MutexManager pthread_mutex_lock ") ; - exit( 0 ) ; - } - MESSAGE( "Manager_i::FindOrStartContainer MutexManager pthread_mutex_locked" ) ; - try { - aContainer = FindOrStartContainerLocked( MyParams , "" , true ) ; - } - catch ( ... ) { - MESSAGE("Manager_i::FindOrStartContainer catch") ; - } - if ( pthread_mutex_unlock( &_MutexManager ) ) { - perror("Manager_i::FindOrStartContainer MutexManager pthread_nriContainmutex_unlock ") ; - exit( 0 ) ; - } - MESSAGE( "Manager_i::FindOrStartContainer MutexManager pthread_mutex_unlocked" ) ; - return Engines::Container::_duplicate( aContainer ) ; -} - -Engines::Container_ptr Manager_i::FindOrStartContainerLocked( Containers::MachineParameters & myParams , - const char * aComponentName , - bool _StartContainer ) { - _EnginesContainer = Engines::Container::_nil() ; - _EnginesComponent = Engines::Component::_nil() ; - _ListOfComponents = new Engines::ListOfComponents() ; - _ListOfComponents->length( 0 ) ; - MESSAGE( "Manager_i::FindOrStartContainerLocked FindContainersLocked :" ) ; - _ListOfContainers = FindContainersLocked( myParams , _StartContainer ) ; - _ComponentName = aComponentName ; - MESSAGE( "MutexManager FindOrStartContainerLocked " - << _ListOfContainers->length() << " containers found" - << " CORBA::is_nil( _EnginesContainer ) " - << CORBA::is_nil( _EnginesContainer ) ) ; - if ( _ListOfContainers->length() ) { - _EnginesContainer = Engines::Container::_nil() ; - int i ; - for ( i = 0 ; i < _ListOfContainers->length() && ( ( _StartContainer && CORBA::is_nil( _EnginesContainer ) ) || !_StartContainer ) ; i++ ) { - _FullHostName = "/Containers/" ; - char * aHostName = _ListOfContainers[ i ]->machineName() ; - _HostName = string( aHostName ) ; - _FullHostName += _HostName ; - char * aContainerName = _ListOfContainers[ i ]->name() ; - aContainerName = strrchr( aContainerName , '/' ) + 1 ; - _ContainerName = string( aContainerName ) ; - _FullContainerName = _FullHostName + "/" + _ContainerName ; - MESSAGE( "Manager_i::FindOrStartContainerLocked Container " << i << " " - << _FullContainerName - << " searched Component '" << _ComponentName << "'" ) ; - if ( strlen( _ComponentName.c_str() ) ) { - _FullComponentName = _FullContainerName + "/" + _ComponentName ; - MESSAGE( "Manager_i::FindOrStartContainerLocked Component " - << _FullComponentName ) ; - _ComponentObject = _NamingService->Resolve( _FullComponentName.c_str() ) ; - if ( !CORBA::is_nil( _ComponentObject ) ) { - _EnginesContainer = _ListOfContainers[ i ] ; - MESSAGE( "Manager_i::FindOrStartContainerLocked --> " - << _EnginesContainer->machineName() << " " - << _EnginesContainer->name() << " Component " - << _ComponentName ) ; - try { - _EnginesComponent = Engines::Component::_duplicate( Engines::Component::_narrow( _ComponentObject ) ) ; - _EnginesComponent->ping() ; - int size = _ListOfComponents->length() ; - _ListOfComponents->length( size + 1 ) ; - _ListOfComponents[ size ] = Engines::Component::_duplicate( _EnginesComponent ) ; - MESSAGE( "Manager_i::FindOrStartContainerLocked --> " - << _EnginesComponent->instanceName() << " " - << _EnginesComponent->interfaceName() ) ; - } - catch( ... ) { - _EnginesComponent = Engines::Component::_nil() ; - MESSAGE( "Manager_i::FindOrStartContainerLocked --> " - << myParams.HostName << " " - << myParams.ContainerName << " " << _ComponentName - << " NOT responding" ) ; - } - } - else { - MESSAGE( "Manager_i::FindOrStartContainerLocked --> " - << myParams.HostName << " " - << myParams.ContainerName << " " << _ComponentName - << " NOT found" ) ; - } - } - else { - _EnginesContainer = _ListOfContainers[ i ] ; - if ( _NamingService->Change_Directory( _FullContainerName.c_str() ) ) { - vector theListOfComponents = _NamingService->list_directory() ; - MESSAGE( "Manager_i::FindOrStartContainerLocked " << theListOfComponents.size() - << " components found." ) ; - int j ; - for ( j = 0 ; j < theListOfComponents.size() ; j++ ) { - _FullComponentName = _FullContainerName + "/" + theListOfComponents[ j ] ; - MESSAGE( "Manager_i::FindOrStartContainerLocked " << j - << " Component " << _FullComponentName ) ; - _ComponentObject = _NamingService->Resolve( _FullComponentName.c_str() ) ; - if ( !CORBA::is_nil( _ComponentObject ) ) { - MESSAGE( "Manager_i::FindOrStartContainerLocked --> " - << _EnginesContainer->machineName() << " " - << _EnginesContainer->name() ) ; - try { - _EnginesComponent = Engines::Component::_duplicate( Engines::Component::_narrow( _ComponentObject ) ) ; - _EnginesComponent->ping() ; - int size = _ListOfComponents->length() ; - _ListOfComponents->length( size + 1 ) ; - _ListOfComponents[ size ] = Engines::Component::_duplicate( _EnginesComponent ) ; - MESSAGE( "Manager_i::FindOrStartContainerLocked --> " - << _EnginesComponent->instanceName() - << " " << _EnginesComponent->interfaceName() ) ; - } - catch ( ... ) { - MESSAGE( "Manager_i::FindOrStartContainerLocked catched NOT responding" ) ; - _EnginesComponent = Engines::Component::_nil() ; - } - } - } - } - } - } - } - else if ( !CORBA::is_nil( _EnginesContainer ) && strlen( _ComponentName.c_str() ) ) { - _FullComponentName = _FullContainerName + "/" + _ComponentName ; - MESSAGE( "Manager_i::FindOrStartContainerLocked Component " - << _FullComponentName ) ; - _ComponentObject = _NamingService->Resolve( _FullComponentName.c_str() ) ; - if ( !CORBA::is_nil( _ComponentObject ) ) { - try { - MESSAGE( "Manager_i::FindOrStartContainerLocked --> " - << _EnginesContainer->machineName() << " " - << _EnginesContainer->name() << " Component " - << _FullComponentName ) ; - _EnginesComponent = Engines::Component::_duplicate( Engines::Component::_narrow( _ComponentObject ) ) ; - _EnginesComponent->ping() ; - MESSAGE( "Manager_i::FindOrStartContainerLocked --> " - << _EnginesComponent->instanceName() << " " - << _EnginesComponent->interfaceName() ) ; - } - catch ( ... ) { - MESSAGE( "Manager_i::FindOrStartContainerLocked --> " - << myParams.HostName << " " - << myParams.ContainerName << " " << _ComponentName - << " catched NOT responding" ) ; - _EnginesComponent = Engines::Component::_nil() ; - } - } - else { - MESSAGE( "Manager_i::FindOrStartContainerLocked --> " << myParams.HostName - << " " << myParams.ContainerName << " " << _ComponentName - << " NOT found" ) ; - } - } - if ( CORBA::is_nil( _EnginesContainer ) && _StartContainer ) { - if ( _ListOfContainers->length() ) { - _EnginesContainer = _ListOfContainers[ 0 ] ; - } - else { - StartContainer( myParams ) ; - } - if ( strlen( _ComponentName.c_str() ) ) { - _FullComponentName = _FullContainerName + "/" + _ComponentName ; - } - } - MESSAGE( "return from FindOrStartContainerLocked " ) ; - return Engines::Container::_duplicate( _EnginesContainer ) ; -} - -Engines::Container_ptr Manager_i::StartContainer( const Containers::MachineParameters & myParams ) { - Containers::MachineParameters MyParams = (Containers::MachineParameters & ) myParams ; - MESSAGE( "Manager_i::StartContainer HostName '" << MyParams.HostName - << "' ContainerName '" << MyParams.ContainerName << "'" ) ; - if ( _ListOfContainers->length() ) { - MyParams.HostName = CORBA::string_dup( _ListOfContainers[ 0 ]->machineName() ) ; - char * aContainerName = _ListOfContainers[ 0 ]->name() ; - aContainerName = strrchr( aContainerName , '/' ) + 1 ; - MyParams.ContainerName = CORBA::string_dup( aContainerName ) ; - } - else if ( _ListOfComputers->length() ) { - Resources::Computer_var aComputer = _ResourcesManager->GetComputer( _ListOfComputers ) ; - if ( !CORBA::is_nil( aComputer ) ) { - MyParams.HostName = CORBA::string_dup( aComputer->Alias() ) ; - } - if ( strlen( MyParams.ContainerName ) == 0 ) { - if ( MyParams.ContainerType == Engines::CppContainer ) { - MyParams.ContainerName = "FactoryServer" ; - } - else { - MyParams.ContainerName = "FactoryServerPy" ; - } - } - Containers::MachineParameters MyContainerParams = MyParams ; - MyContainerParams.ContainerName = "" ; - FindContainerLocked( MyContainerParams ) ; - } - MESSAGE( "Manager_i::StartContainer MyParams " << MyParams.HostName << " " - << MyParams.ContainerName << " " << MyParams.ContainerType << " " - << MyParams.Os << " " << MyParams.Memory << " " << MyParams.CpuClock - << " " << MyParams.NbProc << " " << MyParams.NbNode << " " - << MyParams.NsHostName << " " << MyParams.NsPort << " " - << _ListOfContainers->length() << " containers " << _ListOfComputers->length() - << " computers localhost " << GetHostname().c_str() ) ; - _ResourcesComputer = _ResourcesManager->SearchComputer( MyParams.HostName ) ; - if ( CORBA::is_nil( _EnginesContainer ) ) { - Resources::ComputerEnvironment * aComputerEnvironment = NULL ; - if ( !CORBA::is_nil( _ResourcesComputer ) ) { - aComputerEnvironment = _ResourcesComputer->Environment() ; - } - string rsh( "" ) ; - char * HostName = MyParams.HostName ; - MESSAGE( "Manager_i::StartContainer MyParams '" << MyParams.HostName - << "' GetHostname '" << GetHostname().c_str() << "'" ) ; - if ( strcmp( HostName , GetHostname().c_str() ) ) { - if ( aComputerEnvironment == NULL || _ResourcesManager->SshAccess( HostName ) ) { - rsh += "ssh " ; - } - else { - rsh += "rsh " ; - } - if ( !CORBA::is_nil( _ResourcesComputer ) ) { - string aUserName = _ResourcesManager->UserName( HostName ) ; - if ( aUserName.length() ) { - rsh += "-l " ; - rsh += aUserName ; - rsh += " " ; - } - } - rsh += MyParams.HostName ; - rsh += " sh -c \"'" ; - if ( aComputerEnvironment != NULL ) { - int size = aComputerEnvironment->Module_Root_Dir_Names.length() ; - int i ; -// bool GeomModule = false ; - for ( i = 0 ; i < size ; i++ ) { - if ( i > 0 ) { - rsh += " ; " ; - } - rsh += aComputerEnvironment->Module_Root_Dir_Names[ i ] ; -// if ( strcmp( aComputerEnvironment->Module_Root_Dir_Names[ i ] , "GEOM_ROOT_DIR" ) == 0 ) { -// GeomModule = true ; -// } - rsh += "=" ; - rsh += aComputerEnvironment->Module_Root_Dir_Values[ i ] ; - rsh += " ; export " ; - rsh += aComputerEnvironment->Module_Root_Dir_Names[ i ] ; - } - if ( size > 0 ) { - rsh += " ; " ; - } -// rsh += "${PRODUCTS_ROOT_DIR}/env_products.sh ; " ; - rsh += "${KERNEL_ROOT_DIR}/env_products.sh ; " ; // Pour l'instant - rsh += "${KERNEL_ROOT_DIR}/env_modules.sh ; " ; -// rsh += "PATH=" ; -// int j ; -// string Path = (char * ) aComputerEnvironment->Path ; -// for ( j = 0 ; j < Path.size() ; j++ ) { -// if ( Path[ j ] == '$' ) { -// rsh += "\\" ; -// } -// rsh += Path[ j ] ; -// } -// rsh += " ; export PATH" ; -// rsh += " ; LD_LIBRARY_PATH=" ; -// string Ld_Library_Path = (char * ) aComputerEnvironment->Ld_Library_Path ; -// for ( j = 0 ; j < Ld_Library_Path.size() ; j++ ) { -// if ( Ld_Library_Path[ j ] == '$' ) { -// rsh += "\\" ; -// } -// rsh += Ld_Library_Path[ j ] ; -// } -// rsh += " ; export LD_LIBRARY_PATH" ; -// rsh += " ; PYTHONPATH=" ; -// string PythonPath = (char * ) aComputerEnvironment->PythonPath ; -// for ( j = 0 ; j < PythonPath.size() ; j++ ) { -// if ( PythonPath[ j ] == '$' ) { -// rsh += "\\" ; -// } -// rsh += PythonPath[ j ] ; -// } -// rsh += " ; export PYTHONPATH" ; -// rsh += " ; CASROOT=" ; -// rsh += aComputerEnvironment->CasRoot ; -// rsh += " ; export CASROOT" ; -// rsh += " ; CSF_PluginDefaults=" ; -// rsh += "\\" ; -// rsh += "${KERNEL_ROOT_DIR}/share/salome/resources" ; -// rsh += " ; export CSF_PluginDefaults" ; -// rsh += " ; CSF_SALOMEDS_ResourcesDefaults=" ; -// rsh += "\\" ; -// rsh += "${KERNEL_ROOT_DIR}/share/salome/resources" ; -// rsh += " ; export CSF_SALOMEDS_ResourcesDefaults" ; -// if ( GeomModule ) { -// rsh += " ; CSF_GEOMDS_ResourcesDefaults=" ; -// rsh += "\\" ; -// rsh += "${GEOM_ROOT_DIR}/share/salome/resources" ; -// rsh += " ; export CSF_GEOMDS_ResourcesDefaults" ; -// } -// rsh += " ; " ; - } - } - if ( MyParams.ContainerType == Engines::CppContainer || MyParams.ContainerType == Engines::UndefinedContainerType ) { - rsh += "SALOME_Container " ; - } - else if ( MyParams.ContainerType == Engines::PythonContainer ) { - rsh += "SALOME_ContainerPy.py " ; - } - rsh += MyParams.ContainerName ; - rsh += " -ORBInitRef NameService=corbaname::" ; - rsh += MyParams.NsHostName ; - if ( MyParams.NsPort != 0 ) { - rsh += ":" ; - ostringstream astr ; - astr << MyParams.NsPort ; - rsh += astr.str().c_str() ; - } - rsh += " > /tmp/" ; -//CCRT char * tmpdir = getenv( "TMPDIR" ) ; -//CCRT rsh += " > " ; -//CCRT if ( tmpdir ) { -//CCRT rsh += tmpdir ; -//CCRT rsh += "/" ; -//CCRT } -//CCRT else { -//CCRT rsh += "/tmp/" ; -//CCRT } - rsh += MyParams.ContainerName ; - if ( MyParams.ContainerType == Engines::CppContainer || MyParams.ContainerType == Engines::UndefinedContainerType ) { - rsh += "_Cpp_" ; - } - else if ( MyParams.ContainerType == Engines::PythonContainer ) { - rsh += "_Py_" ; - } - rsh += MyParams.HostName ; - rsh += ".log 2>&1 " ; - if ( strcmp( HostName , GetHostname().c_str() ) ) { - rsh += "'\"" ; - } - rsh += " &" ; - cout << endl << endl << "Manager_i::StartContainer " << rsh << endl << endl ; - MESSAGE( "Manager_i::StartContainer " << rsh ) ; - int status = system( rsh.c_str() ) ; - if (status == -1) { - INFOS("StartContainer rsh/ssh failed (system command status -1)") ; - } - else if (status == 217) { - INFOS("StartContainer rsh/ssh failed (system command status 217)") ; - } - else { - int count = 21 ; - while ( CORBA::is_nil( _EnginesContainer ) && count ) { - sleep( 1 ) ; - count-- ; - if ( count != 21 ) { - MESSAGE( "StartContainer" << count << ". Waiting for " - << MyParams.ContainerName << " on " << MyParams.HostName ) ; - } - FindContainersLocked( MyParams , false ) ; - } - if ( CORBA::is_nil( _EnginesContainer ) ) { - INFOS("StartContainer rsh/ssh failed " ) ; - } - } - } - else { - MESSAGE( "Manager_i::StartContainer -> Container start_impl( " << _EnginesContainer->name() << ") for " - << MyParams.ContainerName ) ; - _EnginesContainer = _EnginesContainer->start_impl( MyParams.ContainerName , MyParams.ContainerType ) ; - } - return Engines::Container::_duplicate( _EnginesContainer ) ; -} - -Engines::ListOfComponents * Manager_i::AllComponents() { - MESSAGE( "Manager_i::AllComponents" ) ; - Engines::ListOfComponents_var aListOfComponents ; - Containers::MachineParameters_var aMachineParameters = Parameters() ; - aMachineParameters->ContainerType = Engines::UndefinedContainerType ; - aListOfComponents = FindComponents( aMachineParameters , "" ) ; - return aListOfComponents._retn() ; -} - -Engines::Component_ptr Manager_i::FindComponent( const Containers::MachineParameters & myParams , - const char * ComponentName ) { - MESSAGE( "Manager_i::FindComponent MutexManager pthread_mutex_lock :" ) ; - if ( pthread_mutex_lock( &_MutexManager ) ) { - perror("Manager_i::FindComponent MutexManager pthread_mutex_lock ") ; - exit( 0 ) ; - } - MESSAGE( "Manager_i::FindComponent MutexManager pthread_mutex_locked" ) ; - Engines::Component_ptr aComponent = Engines::Component::_nil() ; - try { - aComponent = FindComponentLocked( myParams , ComponentName , false ) ; - } - catch ( ... ) { - MESSAGE( "Manager_i::FindComponent catched" ) ; - } - if ( pthread_mutex_unlock( &_MutexManager ) ) { - perror("Manager_i::FindComponent MutexManager pthread_mutex_unlock ") ; - exit( 0 ) ; - } - MESSAGE( "Manager_i::FindComponent MutexManager pthread_mutex_unlocked" ) ; - return aComponent ; -} - -Engines::Component_ptr Manager_i::FindComponentLocked( const Containers::MachineParameters & myParams , - const char * ComponentName , - bool _StartContainer ) { - Containers::MachineParameters MyParams = (Containers::MachineParameters & ) myParams ; - if ( strcmp( MyParams.HostName ,"localhost" ) == 0 ) { - MyParams.HostName = GetHostname().c_str() ; - } - MESSAGE( "FindComponentLocked HostName " << MyParams.HostName - << " ContainerName " << MyParams.ContainerName - << " ComponentName " << ComponentName ) ; - FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName , _StartContainer ) ; - if ( CORBA::is_nil( _EnginesComponent ) ) { - MESSAGE( "FindComponentLocked ComponentName " << ComponentName << " NOT found" ) ; - } - else { - MESSAGE( "FindComponentLocked instanceName " << _EnginesComponent->instanceName() - << " interfaceName " << _EnginesComponent->interfaceName() ) ; - } - return Engines::Component::_duplicate( _EnginesComponent ) ; -} - -Engines::Component_ptr Manager_i::FindOneComponent( const char * aHostName , - const char * aContainerName , - const char * ComponentName ) { - Containers::MachineParameters * MyParams = Parameters() ; - string theComputer = aHostName ; - string theContainer = aContainerName ; -// ContainerName( aContainerName , &theComputer , &theContainer ) ; - MyParams->HostName = theComputer.c_str() ; - MyParams->ContainerName = theContainer.c_str() ; - MyParams->ContainerType = Engines::UndefinedContainerType ; - if ( strcmp( MyParams->HostName ,"localhost" ) == 0 ) { - MyParams->HostName = GetHostname().c_str() ; - } - MESSAGE( "Manager_i::FindOneComponent HostName " << MyParams->HostName - << " ContainerName " << MyParams->ContainerName - << " ComponentName " << ComponentName ) ; - MESSAGE( "Manager_i::FindOneComponent MutexManager pthread_mutex_lock :" ) ; - if ( pthread_mutex_lock( &_MutexManager ) ) { - perror("Manager_i::FindOneComponent MutexManager pthread_mutex_lock ") ; - exit( 0 ) ; - } - MESSAGE( "Manager_i::FindOneComponent MutexManager pthread_mutex_locked" ) ; - Engines::Component_ptr aComponent = FindComponentLocked( *MyParams , ComponentName , false ) ; - if ( pthread_mutex_unlock( &_MutexManager ) ) { - perror("Manager_i::FindOneComponent MutexManager pthread_mutex_unlock ") ; - exit( 0 ) ; - } - MESSAGE( "Manager_i::FindOneComponent MutexManager pthread_mutex_unlocked" ) ; - delete MyParams ; - return aComponent ; -} - -Engines::ListOfComponents * Manager_i::FindComponents( const Containers::MachineParameters & myParams , - const char * ComponentName ) { - MESSAGE( "FindComponents HostName " << myParams.HostName << " ContainerName " - << myParams.ContainerName - << " ComponentName " << ComponentName ) ; - Containers::MachineParameters MyParams = (Containers::MachineParameters & ) myParams ; - if ( strcmp( MyParams.HostName ,"localhost" ) == 0 ) { - MyParams.HostName = GetHostname().c_str() ; - } - MESSAGE( "FindComponents HostName " << MyParams.HostName << " ContainerName " - << MyParams.ContainerName - << " ComponentName " << ComponentName ) ; - MESSAGE( "Manager_i::FindComponents MutexManager pthread_mutex_lock :" ) ; - if ( pthread_mutex_lock( &_MutexManager ) ) { - perror("Manager_i::FindComponents MutexManager pthread_mutex_lock ") ; - exit( 0 ) ; - } - MESSAGE( "Manager_i::FindComponents MutexManager pthread_mutex_locked" ) ; - Engines::ListOfComponents_var aListOfComponents = FindComponentsLocked( MyParams , ComponentName ) ; - if ( pthread_mutex_unlock( &_MutexManager ) ) { - perror("Manager_i::FindComponents MutexManager pthread_mutex_unlock ") ; - exit( 0 ) ; - } - MESSAGE( "Manager_i::FindComponents MutexManager pthread_mutex_unlocked" ) ; - return aListOfComponents._retn() ; -} - - -Engines::ListOfComponents * Manager_i::FindComponentsLocked( const Containers::MachineParameters & MyParams , - const char * ComponentName ) { - Engines::ListOfComponents_var aListOfComponents = new Engines::ListOfComponents() ; - try { - MESSAGE( "Manager_i::FindComponentsLocked FindOrStartContainerLocked :" ) ; - _EnginesContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName , false ) ; - if ( _ListOfComponents->length() ) { - MESSAGE( "FindComponentsLocked " << _ListOfComponents->length() << " components" ) ; - int i ; - for ( i = 0 ; i < _ListOfComponents->length() ; i++ ) { - MESSAGE( "FindComponentsLocked " << i << " instanceName " - << _ListOfComponents[ i ]->instanceName() - << " interfaceName " << _ListOfComponents[ i ]->interfaceName() ) ; - _ListOfComponents[ i ]->ping() ; - } - } - else if ( !CORBA::is_nil( _EnginesComponent ) ) { - _ListOfComponents->length( 1 ) ; - _ListOfComponents[ 0 ] = Engines::Component::_duplicate( _EnginesComponent ) ; - MESSAGE( "FindComponentsLocked instanceName " - << _EnginesComponent->instanceName() << " interfaceName " - << _EnginesComponent->interfaceName() << " " - << _ListOfComponents->length() << " components" ) ; - _ListOfComponents[ 0 ]->ping() ; - } - else { - MESSAGE( "FindComponentsLocked ComponentName " << ComponentName - << " NOT found" ) ; - } - aListOfComponents = _ListOfComponents ; - } - catch ( ... ) { - MESSAGE( "Manager_i::FindComponentsLocked catched" ) ; - } - return aListOfComponents._retn() ; -} - - -Engines::Component_ptr Manager_i::FindOrLoad_ComponentPath( const Containers::MachineParameters & myParams , - const char * ComponentName , - const char * ImplementationPath ) { - Engines::Container_var aContainer = Engines::Container::_nil() ; - Engines::Component_var EnginesComponent = Engines::Component::_nil() ; - Containers::MachineParameters MyParams = (Containers::MachineParameters & ) myParams ; - if ( strcmp( MyParams.HostName ,"localhost" ) == 0 ) { - MyParams.HostName = GetHostname().c_str() ; - } - BEGIN_OF("FindOrLoad_Component( const Containers::MachineParameters & MyParams , const char * ComponentName , const char * ImplementationPath 1)"); - MESSAGE( "Manager_i::FindOrLoad_ComponentPath MutexManager pthread_mutex_lock :" ) ; - if ( pthread_mutex_lock( &_MutexManager ) ) { - perror("Manager_i::FindOrLoad_ComponentPath MutexManager pthread_mutex_lock ") ; - exit( 0 ) ; - } - MESSAGE( "Manager_i::FindOrLoad_ComponentPath MutexManager pthread_mutex_locked" ) ; - try { - EnginesComponent = FindComponentLocked( MyParams , ComponentName , true ) ; - if ( CORBA::is_nil( EnginesComponent ) ) { - MESSAGE("FindOrLoad_ComponentPath Component not found " << _ComponentName ) ; -// aContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ; - } - else { - MESSAGE("FindOrLoad_ComponentPath Component was found " << _ComponentName ) ; - } - aContainer = _EnginesContainer ; - } - catch ( ... ) { - MESSAGE("FindOrLoad_ComponentPath catch") ; - } - string aComponentName = _ComponentName ; - string aFullComponentName = _FullComponentName ; - if ( pthread_mutex_unlock( &_MutexManager ) ) { - perror("Manager_i::FindOrLoad_ComponentPath MutexManager pthread_mutex_unlock ") ; - exit( 0 ) ; - } - MESSAGE( "Manager_i::FindOrLoad_ComponentPath MutexManager pthread_mutex_unlocked" ) ; - if ( !CORBA::is_nil( aContainer ) && CORBA::is_nil( EnginesComponent ) ) { - MESSAGE("FindOrLoad_ComponentPath Component not found ! trying to load " - << aFullComponentName ) ; - EnginesComponent = aContainer->load_impl( ComponentName, ImplementationPath ) ; - if ( !CORBA::is_nil( EnginesComponent ) ) { - MESSAGE( "FindOrLoad_ComponentPath Component launched ! " - << aFullComponentName ) ; - try { - EnginesComponent->ping() ; - } - catch ( CORBA::COMM_FAILURE& ) { - INFOS("FindOrLoad_ComponentPath Caught CORBA::SystemException CommFailure. Engine " - << aFullComponentName << "does not respond" ) ; - EnginesComponent = Engines::Component::_nil() ; - } - } - else { - MESSAGE( "FindOrLoad_ComponentPath Component NOT launched ! " - << aFullComponentName ) ; - } - } - return Engines::Component::_duplicate( EnginesComponent ) ; -} - -Engines::Component_ptr Manager_i::FindOrLoad_Component( const Containers::MachineParameters & myParams , - const char * ComponentName ) { - Engines::Container_var aContainer = Engines::Container::_nil() ; - Engines::Component_var EnginesComponent = Engines::Component::_nil() ; - Containers::MachineParameters MyParams = (Containers::MachineParameters & ) myParams ; - if ( strcmp( MyParams.HostName ,"localhost" ) == 0 ) { - MyParams.HostName = GetHostname().c_str() ; - } - if ( !strcmp( MyParams.ContainerName , "" ) && - MyParams.ContainerType == Engines::UndefinedContainerType ) { - MyParams.ContainerType = Engines::CppContainer ; - } - BEGIN_OF("FindOrLoad_Component HostName " << MyParams.HostName << " ContainerName " - << MyParams.ContainerName << " ContainerType " << MyParams.ContainerType - << " ComponentName " << ComponentName ); - MESSAGE( "Manager_i::FindOrLoad_Component MutexManager pthread_mutex_lock :" ) ; - if ( pthread_mutex_lock( &_MutexManager ) ) { - perror("Manager_i::FindOrLoad_Component MutexManager pthread_mutex_lock ") ; - exit( 0 ) ; - } - MESSAGE( "Manager_i::FindOrLoad_Component MutexManager pthread_mutex_locked" ) ; - try { - EnginesComponent = FindComponentLocked( MyParams , ComponentName , true ) ; - if ( CORBA::is_nil( EnginesComponent ) ) { - MESSAGE("FindOrLoad_Component Component not found " << _FullComponentName ) ; -// aContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ; - } - else { - MESSAGE("FindOrLoad_Component Component was found " << _FullComponentName ) ; - } - aContainer = _EnginesContainer ; - } - catch ( ... ) { - MESSAGE("FindOrLoad_Component catch") ; - } - string aComponentName = _ComponentName ; - string aFullComponentName = _FullComponentName ; - if ( pthread_mutex_unlock( &_MutexManager ) ) { - perror("Manager_i::FindOrLoad_Component MutexManager pthread_mutex_unlock ") ; - exit( 0 ) ; - } - MESSAGE( "Manager_i::FindOrLoad_Component MutexManager pthread_mutex_unlocked" ) ; - if ( !CORBA::is_nil( aContainer ) && CORBA::is_nil( EnginesComponent ) ) { - string ImplementationPath ; - if ( MyParams.ContainerType == Engines::PythonContainer ) { - ImplementationPath += ComponentName ; - } - else { - ImplementationPath += string( "lib" ) ; - ImplementationPath += ComponentName ; - ImplementationPath += "Engine.so" ; - } - MESSAGE("FindOrLoad_Component Component not found ! trying to load " - << aFullComponentName << " " << ImplementationPath ) ; - try { - EnginesComponent = aContainer->load_impl( ComponentName, ImplementationPath.c_str() ) ; - if ( !CORBA::is_nil( EnginesComponent ) ) { - MESSAGE( "FindOrLoad_Component Component launched ! " << _ComponentName - << " on " << aFullComponentName ) ; - try { - EnginesComponent->ping() ; - } - catch ( CORBA::COMM_FAILURE& ) { - INFOS("FindOrLoad_Component Caught CORBA::SystemException CommFailure. Engine " - << aFullComponentName << "does not respond" ) ; - EnginesComponent = Engines::Component::_nil() ; - } - } - else { - MESSAGE( "FindOrLoad_Component Component NOT launched ! " - << aFullComponentName ) ; - } - } - catch (...) { - EnginesComponent = Engines::Component::_nil() ; - MESSAGE( "Component NOT launched ! " << aFullComponentName << " load_impl catched" ) ; - } - } - return Engines::Component::_duplicate( EnginesComponent ) ; -} -// try { -// CORBA::Object_var obj = _NS->Resolve(path.c_str()); -// if ( CORBA::is_nil( obj ) ) { -// MESSAGE("Component not found ! trying to load " << path); -// CORBA::Object_var obj2 = _NS->Resolve("/Kernel/ModulCatalog"); -// SALOME_ModuleCatalog::ModuleCatalog_var Catalog = -// SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj2); - -// SALOME_ModuleCatalog::Acomponent_ptr compoInfo = -// Catalog->GetComponent(componentName); -// if (CORBA::is_nil (compoInfo)) -// { -// INFOS("Catalog Error : Component not found in the catalog") -// return Engines::Component::_nil(); -// exit (-1); -// } - -// string path; -// try -// { -// path = compoInfo->GetPathPrefix( machine ) ; -// path += "/" ; -// } -// catch (SALOME_ModuleCatalog::NotFound&) -// { -// MESSAGE("GetPathPrefix(" << machine << ") not found!" -// << "trying localhost"); -// try { -// path = compoInfo->GetPathPrefix("localhost") ; -// path += "/" ; -// } -// catch (SALOME_ModuleCatalog::NotFound&) { -// MESSAGE("GetPathPrefix(localhost) not found!") ; -// path = "" ; -// } -// } - -// SCRUTE(path); -// string implementation(path); -// implementation += "lib"; -// implementation += componentName; -// implementation += "Engine.so"; - -// Engines::Component_var compo -// = cont->load_impl(componentName, implementation.c_str()); - -// ASSERT(!CORBA::is_nil(compo)); -// MESSAGE("Component launched !" << path); -// return compo; -// } -// else -// { -// MESSAGE("Component found !" << path); -// Engines::Component_var compo = Engines::Component::_narrow(obj); -// ASSERT(!CORBA::is_nil(compo)); -// try -// { -// string instanceName = compo->instanceName(); -// } -// catch (CORBA::COMM_FAILURE&) -// { -// INFOS("Caught CORBA::SystemException CommFailure. Engine " -// << path << "does not respond" ); -// } -// return compo; -// } -// } -// catch (ServiceUnreachable&) -// { -// INFOS("Caught exception: Naming Service Unreachable"); -// } -// catch (...) -// { -// INFOS("Caught unknown exception."); -// } -// return Engines::Component::_nil(); -//} - -bool Manager_i::DestroyContainer( const char * aHostName , - const char * aContainerName ) { - Containers::MachineParameters * MyParams = Parameters() ; - string theComputer = aHostName ; - string theContainer = aContainerName ; - MyParams->HostName = theComputer.c_str() ; - MyParams->ContainerName = theContainer.c_str() ; - int l = strlen( aContainerName ) ; - MyParams->ContainerType = Engines::UndefinedContainerType ; - if ( strcmp( MyParams->HostName ,"localhost" ) == 0 ) { - MyParams->HostName = GetHostname().c_str() ; - } - MESSAGE( "Manager_i::DestroyContainer HostName " << MyParams->HostName - << " ContainerName " << MyParams->ContainerName ) ; - MESSAGE( "Manager_i::DestroyContainer MutexManager pthread_mutex_lock :" ) ; - if ( pthread_mutex_lock( &_MutexManager ) ) { - perror("Manager_i::DestroyContainer MutexManager pthread_mutex_lock ") ; - exit( 0 ) ; - } - MESSAGE( "Manager_i::DestroyContainer MutexManager pthread_mutex_locked" ) ; - Engines::ListOfComponents_var aListOfComponents = FindComponentsLocked( *MyParams , "" ) ; - Engines::Container_ptr aContainer = _EnginesContainer ; - if ( pthread_mutex_unlock( &_MutexManager ) ) { - perror("Manager_i::DestroyContainer MutexManager pthread_mutex_unlock ") ; - exit( 0 ) ; - } - MESSAGE( "Manager_i::DestroyContainer MutexManager pthread_mutex_unlocked" ) ; - int i ; - for ( i = 0 ; i < aListOfComponents->length() ; i++ ) { - try { - MESSAGE( "Manager_i::DestroyContainer trying to destroy component " - << aListOfComponents[ i ]->interfaceName() ) ; - aListOfComponents[ i ]->ping() ; - aListOfComponents[ i ]->destroy() ; - MESSAGE( "Manager_i::DestroyContainer component destroyed" ) ; - } - catch ( ... ) { - MESSAGE( "Manager_i::DestroyContainer destroy component catched" ) ; - } - } - try { - MESSAGE( "Manager_i::DestroyContainer trying to destroy container " << aContainer->name() ) ; - aContainer->ping() ; - aContainer->destroy() ; - MESSAGE( "Manager_i::DestroyContainer " << aContainerName << " on " << aHostName - << " destroyed" ) ; - } - catch ( ... ) { - MESSAGE( "Manager_i::DestroyContainer " << aContainerName << " on " << aHostName - << " catched" ) ; - } - delete MyParams ; - return true ; -} - -bool Manager_i::DestroyContainers( const Containers::MachineParameters & MyParams ) { - MESSAGE( "Manager_i::DestroyContainers HostName " << MyParams.HostName - << " ContainerName " << MyParams.ContainerName ) ; - MESSAGE( "Manager_i::DestroyContainers MutexManager pthread_mutex_lock :" ) ; - if ( pthread_mutex_lock( &_MutexManager ) ) { - perror("Manager_i::DestroyContainers MutexManager pthread_mutex_lock ") ; - exit( 0 ) ; - } - MESSAGE( "Manager_i::DestroyContainers MutexManager pthread_mutex_locked" ) ; - Engines::ListOfComponents_var aListOfComponents = FindComponentsLocked( MyParams , "" ) ; - Engines::ListOfContainers_var aListOfContainers = _ListOfContainers ; - if ( pthread_mutex_unlock( &_MutexManager ) ) { - perror("Manager_i::DestroyContainers MutexManager pthread_mutex_unlock ") ; - exit( 0 ) ; - } - MESSAGE( "Manager_i::DestroyContainers MutexManager pthread_mutex_unlocked" ) ; - int i ; - for ( i = 0 ; i < aListOfComponents->length() ; i++ ) { - try { - aListOfComponents[ i ]->destroy() ; - MESSAGE( "Manager_i::DestroyContainers component destroyed" ) ; - } - catch ( ... ) { - MESSAGE( "Manager_i::DestroyContainers destroy component catched" ) ; - } - } - for ( i = 0 ; i < aListOfContainers->length() ; i++ ) { - try { - MESSAGE( "Manager_i::DestroyContainers destroy of " << aListOfContainers[ i ]->name() ) ; - aListOfContainers[ i ]->destroy() ; - } - catch ( ... ) { - MESSAGE( "Manager_i::DestroyContainers catched" ) ; - } - } - return true ; -} - -ostream & operator<< (ostream & f ,const Engines::ContainerType & t ) { - switch (t) { - case Engines::UndefinedContainerType : - f << "UndefinedContainer"; - break; - case Engines::CppContainer : - f << "CppContainer"; - break; - case Engines::PythonContainer : - f << "PythonContainer"; - break; - default : - f << "UnknownContainerType"; - break; - } - - return f; -} - diff --git a/src/ContainersManager/ContainersManager_i.hxx b/src/ContainersManager/ContainersManager_i.hxx deleted file mode 100644 index 2613cbf5d..000000000 --- a/src/ContainersManager/ContainersManager_i.hxx +++ /dev/null @@ -1,162 +0,0 @@ -// SALOME ContainersManager -// -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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. -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : ContainersManager_i.hxx -// Author : Jean Rahuel -// Module : SALOME -// $Header: - -#ifndef __CONTAINERSMANAGER_I_HXX__ -#define __CONTAINERSMANAGER_I_HXX__ - -// std C++ headers -#include -#include -#include -#include -#include -#include -#include - -#include "utilities.h" -#include "OpUtil.hxx" - -#include - -#include "SALOME_NamingService.hxx" - -// IDL headers -#include -#include CORBA_SERVER_HEADER(ContainersManager) -#include CORBA_SERVER_HEADER(ResourcesManager) -#include CORBA_CLIENT_HEADER(SALOME_Component) - - -// use of normal destroy xor of ATEXIT -#define WITH_SINGLETON 1 - - - -class Manager_i : public POA_Containers::Manager , - public PortableServer::RefCountServantBase { - private: - - CORBA::ORB_ptr _Orb ; - PortableServer::POA_ptr _Poa ; - PortableServer::ObjectId * _Id ; - SALOME_NamingService * _NamingService ; - Resources::Manager_var _ResourcesManager ; - string _NamingServiceHostName ; - long _NamingServicePort ; - pthread_mutex_t _MutexManager ; - string _HostName ; - string _FullHostName ; - string _ContainerName ; - string _FullContainerName ; - Engines::ContainerType _ContainerType ; - string _ComponentName ; - string _FullComponentName ; - Resources::ListOfComputers_var _ListOfComputers ; - Resources::Computer_var _ResourcesComputer ; - Resources::ComputerParameters_var _ComputerParameters ; - Engines::ListOfContainers_var _ListOfContainers ; - CORBA::Object_var _ContainerObject ; - Engines::Container_var _EnginesContainer ; - Engines::ListOfComponents_var _ListOfComponents ; - CORBA::Object_var _ComponentObject ; - Engines::Component_var _EnginesComponent ; - - Engines::Container_ptr FindContainerLocked( Containers::MachineParameters & MyParams ) ; - Engines::Container_ptr StartContainer( const Containers::MachineParameters & myParams ) ; - - Engines::ListOfContainers * FindContainersLocked( Containers::MachineParameters & MyParams , bool _StartContainer ) ; - - Engines::Container_ptr FindOrStartContainerLocked( Containers::MachineParameters & MyParams , - const char * ComponentName , - bool _StartContainer ) ; - - Engines::Component_ptr FindComponentLocked( const Containers::MachineParameters & MyParams , - const char * ComponentName , - bool _StartContainer ) ; - - Engines::ListOfComponents * FindComponentsLocked( const Containers::MachineParameters & MyParams , - const char * ComponentName ) ; - - public: - - Manager_i() ; - - void Init( CORBA::ORB_ptr orb , - PortableServer::POA_ptr poa , - SALOME_NamingService * NamingService , - int argc , - char** argv ) ; - - virtual ~Manager_i() ; - - virtual void destroy() ; - - virtual bool ping() ; - - virtual Engines::ListOfContainers * AllContainers() ; - - virtual Containers::MachineParameters * Parameters() ; - - virtual Engines::Container_ptr FindContainer( const Containers::MachineParameters & MyParams ) ; - - virtual Engines::Container_ptr FindOneContainer( const char * aHostName , - const char * aContainerName ) ; - - virtual Engines::ListOfContainers * FindContainers( const Containers::MachineParameters & MyParams ) ; - - virtual Engines::Container_ptr FindOrStartContainer( const Containers::MachineParameters & MyParams ) ; - - virtual Engines::ListOfComponents * AllComponents() ; - - virtual Engines::Component_ptr FindComponent( const Containers::MachineParameters & MyParams , - const char * ComponentName ) ; - - virtual Engines::Component_ptr FindOneComponent( const char * aHostName , - const char * aContainerName , - const char * ComponentName ) ; - - virtual Engines::ListOfComponents * FindComponents( const Containers::MachineParameters & MyParams , - const char * ComponentName ) ; - - virtual Engines::Component_ptr FindOrLoad_ComponentPath( const Containers::MachineParameters & MyParams , - const char * ComponentName , - const char * ImplementationPath ) ; - - virtual Engines::Component_ptr FindOrLoad_Component( const Containers::MachineParameters & MyParams , - const char * ComponentName ) ; - - virtual bool DestroyContainer( const char * aHostName , - const char * aContainerName ) ; - - virtual bool DestroyContainers( const Containers::MachineParameters & MyParams ) ; - -} ; - -ostream & operator<< (ostream &,const Engines::ContainerType &); - -#endif diff --git a/src/ContainersManager/Makefile.in b/src/ContainersManager/Makefile.in deleted file mode 100755 index 995989910..000000000 --- a/src/ContainersManager/Makefile.in +++ /dev/null @@ -1,58 +0,0 @@ -# SALOME ContainersManager : data structure of SALOME and sources of Salome data server -# -# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# 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. -# -# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -# -# -# -# File : Makefile.in -# Author : Jean Rahuel -# Module : SALOME - -top_srcdir=@top_srcdir@ -top_builddir=../.. -srcdir=@srcdir@ -VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_srcdir)/idl - - -@COMMENCE@ - -EXPORT_PYSCRIPTS = runContainer.py ResourcesContainers.py TestContainersManager.py - -# Libraries targets - -LIB = libContainersManager.la -LIB_SRC = \ - ContainersManager_i.hxx \ - ContainersManager_i.cxx -# Executables targets -BIN = ContainersManager_Server -BIN_SRC = - -LIB_SERVER_IDL = ResourcesManager.idl ContainersManager.idl SALOME_Component.idl -BIN_SERVER_IDL = -BIN_CLIENT_IDL = - -#CPPFLAGS+= -#CXXFLAGS+= -LDFLAGS+= -lResourcesManager -lSalomeNS -lOpUtil -lSALOMELocalTrace - -@CONCLUDE@ - - diff --git a/src/ContainersManager/ResourcesContainers.py b/src/ContainersManager/ResourcesContainers.py deleted file mode 100644 index 6f7e9004e..000000000 --- a/src/ContainersManager/ResourcesContainers.py +++ /dev/null @@ -1,131 +0,0 @@ - -#ContainersManager_Server -ORBInitRef NameService=corbaname::localhost - -def ContainerParameters( Params ) : - print "ContainerParameters :" - print "Os :",Params.Os - print "Memory :",Params.Memory - print "CpuClock :",Params.CpuClock - print "NbProc :",Params.NbProc - print "NbNode :",Params.NbNode - print "HostName : '" + Params.HostName + "'" - print "ContainerName : '" + Params.ContainerName + "'" - print "ContainerType :",Params.ContainerType - print "NsHostName : '" + Params.NsHostName + "'" - print "NsPort :",Params.NsPort - -def ComputerParameters( Params ) : - print "ComputerParameters :" - print "FullName : '" + Params.FullName + "'" - print "Alias : '" + Params.Alias + "'" - print "SshAccess :",Params.SshAccess - print "Interactive :",Params.Interactive - print "Batch :",Params.Batch - print "UserName :",Params.UserName - print "Os :",Params.Os - print "Memory :",Params.Memory - print "Swap :",Params.Swap - print "CpuClock :",Params.CpuClock - print "NbProc :",Params.NbProc - print "NbNode :",Params.NbNode - - -def ComputerEnvironement( env ) : - rootNames = env.Module_Root_Dir_Names - rootValues = env.Module_Root_Dir_Values - j = 0 - while j < len( rootNames ) : - print rootNames[ j ],rootValues[ j ] - j = j + 1 - #print 'Path ',env.Path - #print 'Ld_Library_Path',env.Ld_Library_Path - #print 'PythonPath ',env.PythonPath - #print 'CasRoot ',env.CasRoot - -def ListComputers() : - AllComputers = MyResourcesMgr.AllComputers() - print '' - print 'ListComputers',len( AllComputers ),'computers found' - i = 0 - while i < len( AllComputers ) : - print AllComputers[i].FullName(),AllComputers[i].Alias(),'IsAlive',AllComputers[i].IsAlive() - i = i + 1 - -def ListContainers() : - AllContainers = MyContainersMgr.AllContainers() - print '' - print 'ListContainers',len( AllContainers ),'containers found' - i = 0 - while i < len( AllContainers ) : - print AllContainers[i]._get_name(),'on',AllContainers[i]._get_machineName(),AllContainers[i].type() - i = i + 1 - -def ListComponents() : - AllComponents = MyContainersMgr.AllComponents() - print '' - print 'ListComponents',len( AllComponents ),'components found' - i = 0 - while i < len( AllComponents ) : - print AllComponents[i]._get_instanceName(),'of interface',AllComponents[i]._get_interfaceName(),'on',AllComponents[i].GetContainerRef()._get_name(),'of',AllComponents[i].GetContainerRef()._get_machineName(),AllComponents[i].GetContainerRef().type() - i = i + 1 - - - -import sys,os,time -import string -from omniORB import CORBA - -# Import the stubs for the Naming service -import CosNaming - -import Engines - -import Containers - -import Resources - -from LifeCycleCORBA import * -orb = CORBA.ORB_init([''], CORBA.ORB_ID) -lcc = LifeCycleCORBA( orb ) - -# ------------------------NameService-------------------------------------------------- - -obj = orb.resolve_initial_references("NameService") -rootContext = obj._narrow(CosNaming.NamingContext) - -# ------------------------ContainersManager-------------------------------------------------- - -#MyContainersMgr = clt.waitNS("/Kernel/ContainersManager",Containers.Manager) -name = [CosNaming.NameComponent("Kernel","dir"), - CosNaming.NameComponent("ContainersManager","object")] -try: - obj = rootContext.resolve(name) -except CosNaming.NamingContext.NotFound, ex: - print "/Kernel.dir/ContainersManager.object not found in Naming Service" - exit(0) - -MyContainersMgr = obj._narrow( Containers.Manager ) - -MyContainersMgr.ping() - -#ResourcesManager_Server -common /home/Salome2/KERNEL_install/share/salome/resources/ResourcesCatalog.xml -ORBInitRef NameService=corbaname::localhost - -#gdb ResourcesManager_Server -#run -common /home/rahuel/SALOME_BR_JR2/KERNEL_build_withoutihm/share/salome/resources/ResourcesCatalog.xml - -# ------------------------ResourcesManager-------------------------------------------------- - -#MyResourcesMgr = clt.waitNS("/Kernel/ResourcesManager",Resources.Manager) -name = [CosNaming.NameComponent("Kernel","dir"), - CosNaming.NameComponent("ResourcesManager","object")] -try: - obj = rootContext.resolve(name) -except CosNaming.NamingContext.NotFound, ex: - print "/Kernel.dir/ResourcesManager.object not found in Naming Service" - exit(0) - -MyResourcesMgr = obj._narrow( Resources.Manager ) - -MyResourcesMgr.ping() - - diff --git a/src/ContainersManager/TestContainersManager.py b/src/ContainersManager/TestContainersManager.py deleted file mode 100644 index 2fc1596f3..000000000 --- a/src/ContainersManager/TestContainersManager.py +++ /dev/null @@ -1,620 +0,0 @@ - -#python bin/killSalome.py - -from ResourcesContainers import * - -# ------------------------FactoryServer-------------------------------------------------- - -DefaultParams = MyContainersMgr.Parameters() - -ContainerParameters( DefaultParams ) - -FactoryServer = MyContainersMgr.FindOrStartContainer( DefaultParams ) - -FactoryServer.ping() - -print "Container FactoryServer is running on",FactoryServer._get_machineName(),"with name",FactoryServer._get_name(),"and type",FactoryServer.type() - -FactoryServer.destroy() -clt.showNS() - -#python /home/rahuel/SALOME_BR_JR2/KERNEL_install_withoutihm/bin/salome/SALOME_ContainerPy.py FactoryServerPy -ORBInitRef NameService=corbaname::localhost -# ------------------------FactoryServerPy-------------------------------------------------- - -DefaultParams.ContainerType = Engines.PythonContainer - -FactoryServerPy = MyContainersMgr.FindOrStartContainer( DefaultParams ) - -FactoryServerPy.ping() - -print "Container FactoryServerPy is running on",FactoryServerPy._get_machineName(),"with name",FactoryServerPy._get_name(),"and type",FactoryServerPy.type() - -FactoryServerPy.destroy() -clt.showNS() - -# ------------------------SuperVisionContainer-------------------------------------------------- - -DefaultParams.ContainerType = Engines.UndefinedContainerType - -DefaultParams.ContainerName = "SuperVisionContainer" - -SuperVisionContainer = MyContainersMgr.FindOrStartContainer( DefaultParams ) - -SuperVisionContainer.ping() - -print "Container SuperVisionContainer is running on",SuperVisionContainer._get_machineName(),"with name",SuperVisionContainer._get_name(),"and type",SuperVisionContainer.type() - - -# ------------------------RunningContainers-------------------------------------------------- - -ListContainers() - - - -# ------------------------AllComputers-------------------------------------------------- - -ListComputers() - -AllComputers = MyResourcesMgr.AllComputers() -print 'AllComputers',len( AllComputers ),'computers found' -i = 0 -while i < len( AllComputers ) : - print '' - ComputerParameters( AllComputers[i].Parameters() ) - ComputerEnvironement( AllComputers[i].Environment() ) - i = i + 1 - -i = 0 -while i < len( AllComputers ) : - print '' - print AllComputers[i].FullName(),AllComputers[i].Alias(),'IsAlive',AllComputers[i].IsAlive() - i = i + 1 - -# ------------------------ListOfComputers( Params )--------------------------------------------- - -ListOfComputers = MyResourcesMgr.GetComputers( DefaultParams ) -print '' -print 'ListOfComputers',len( ListOfComputers ),'computers found' -i = 0 -while i < len( ListOfComputers ) : - print '' - ComputerParameters( ListOfComputers[i].Parameters() ) - ComputerEnvironement( ListOfComputers[i].Environment() ) - i = i + 1 - -i = 0 -while i < len( ListOfComputers ) : - print '' - print ListOfComputers[i].FullName(),ListOfComputers[i].Alias(),'IsAlive',ListOfComputers[i].IsAlive() - i = i + 1 - -# ------------------------SelectComputer( Params )---------------------------------------------- - -aComputer = MyResourcesMgr.SelectComputer( DefaultParams ) -print aComputer.Parameters().FullName,'IsAlive',aComputer.IsAlive() - -# ------------------------GetComputer( ListOfComputers )---------------------------------------- - -aComputer = MyResourcesMgr.GetComputer( ListOfComputers ) -print aComputer.Parameters().FullName,'IsAlive',aComputer.IsAlive() - -# ------------------------SearchComputer( HostName )-------------------------------------------- - -aComputer = MyResourcesMgr.SearchComputer("is109973") -print aComputer.Parameters().FullName,'IsAlive',aComputer.IsAlive() - -aComputer = MyResourcesMgr.SearchComputer("is109974") -print aComputer.Parameters().FullName,'IsAlive',aComputer.IsAlive() - -aComputer = MyResourcesMgr.SearchComputer("dunex") -print aComputer.Parameters().FullName,'IsAlive',aComputer.IsAlive() - -aComputer = MyResourcesMgr.SearchComputer("bojolex") -print aComputer.Parameters().FullName,'IsAlive',aComputer.IsAlive() - -aComputer = MyResourcesMgr.SearchComputer("xmen.saclay.opencascade.com") -print aComputer.Parameters().FullName,'IsAlive',aComputer.IsAlive() - -aComputer = MyResourcesMgr.SearchComputer("unknown") -if aComputer is None : - print "unknown is None Ok" -else : - print "Error :",aComputer.Parameters().FullName - - -# ------------------------GetComputers( Params )-------------------------------------------------- - -DefaultParams.Memory = 500 - -ListOfComputers = MyResourcesMgr.GetComputers( DefaultParams ) -print '' -print 'ListOfComputers',len( ListOfComputers ),'computers found' -i = 0 -while i < len( ListOfComputers ) : - print '' - ComputerParameters( ListOfComputers[i].Parameters() ) - ComputerEnvironement( ListOfComputers[i].Environment() ) - i = i + 1 - -i = 0 -while i < len( ListOfComputers ) : - print '' - print ListOfComputers[i].FullName(),ListOfComputers[i].Alias(),'Memory',ListOfComputers[i].Memory(),'IsAlive',ListOfComputers[i].IsAlive() - i = i + 1 - -# ------------------------SelectComputer( Params )------------------------------------------------ - -aComputer = MyResourcesMgr.SelectComputer( DefaultParams ) -aComputer.Parameters().FullName - -# ------------------------GetComputer( ListOfComputers )------------------------------------------ - -aComputer = MyResourcesMgr.GetComputer( ListOfComputers ) -aComputer.Parameters().FullName - -# ------------------------GetComputers( Params )-------------------------------------------------- - -DefaultParams.Memory = 1000 - -ListOfComputers = MyResourcesMgr.GetComputers( DefaultParams ) -print '' -if len( ListOfComputers ) > 0 : - print "Error",len( ListOfComputers ),"Computers found" - i = 0 - while i < len( ListOfComputers ) : - print '' - ComputerParameters( ListOfComputers[i].Parameters() ) - ComputerEnvironement( ListOfComputers[i].Environment() ) - i = i + 1 -else : - print 'ListOfComputers',len( ListOfComputers ),'computers found Ok' - -aComputer = MyResourcesMgr.SelectComputer( DefaultParams ) -if aComputer is None : - print "aComputer is None Ok" -else : - print "Error :",aComputer.Parameters().FullName - -aComputer = MyResourcesMgr.GetComputer( ListOfComputers ) -if aComputer is None : - print "aComputer is None Ok" -else : - print "Error :",aComputer.Parameters().FullName - - - -from ResourcesContainers import * - -# ------------------------FindOrStartContainer( Params )-------------------------------------------------- - -DefaultParams = MyContainersMgr.Parameters() - -DefaultParams.Memory = 500 -DefaultParams.ContainerName = '' -DefaultParams.ContainerType = Engines.CppContainer -ContainerParameters( DefaultParams ) - -is109974Server = MyContainersMgr.FindOrStartContainer( DefaultParams ) - -is109974Computer = MyResourcesMgr.SearchComputer( is109974Server._get_machineName() ) - -print "ping",is109974Computer.ping() -print "FullName",is109974Computer.FullName() -print "Alias",is109974Computer.Alias() -print "IsAlive",is109974Computer.IsAlive() -print "SshAccess",is109974Computer.SshAccess() -print "RshAccess",is109974Computer.RshAccess() -print "Interactive",is109974Computer.Interactive() -print "Batch",is109974Computer.Batch() -print "UserName",is109974Computer.UserName() -print "Os",is109974Computer.Os() -print "Memory",is109974Computer.Memory() -print "Swap",is109974Computer.Swap() -print "CpuClock",is109974Computer.CpuClock() -print "NbProc",is109974Computer.NbProc() -print "NbNode",is109974Computer.NbNode() - -ComputerEnvironement( is109974Computer.Environment() ) - -TestComponent = MyContainersMgr.FindOrLoad_Component( DefaultParams , "SalomeTestComponent" ) - -# ------------------------RunningContainers( DefaultParams )-------------------------------------------------- - -DefaultParams.ContainerName = '' -DefaultParams.ContainerType = Engines.UndefinedContainerType -ContainerParameters( DefaultParams ) -Containers = MyContainersMgr.FindContainers( DefaultParams ) -ContainerParameters( DefaultParams ) -i = 0 -while i < len( Containers ) : - print "Container running on",Containers[ i ]._get_machineName(),"with name",Containers[ i ]._get_name(),"and type",Containers[ i ].type() - i = i + 1 - -# ------------------------RunningContainers-------------------------------------------------- - -ListContainers() - - -# ------------------------FindOrLoad_Component( Params , "MED" )--------------------------------- - -ContainerParameters( DefaultParams ) - -MED = MyContainersMgr.FindOrLoad_Component( DefaultParams , "MED" ) - -MED._get_instanceName() -MED._get_interfaceName() -theContainer = MED.GetContainerRef() -theContainer.getHostName() - - -# ------------------------FindOrLoad_Component( Params , "AddComponent" )--------------------------------- - -AddComponent = MyContainersMgr.FindOrLoad_Component( DefaultParams , "AddComponent" ) - -AddComponent._get_instanceName() -AddComponent._get_interfaceName() -theContainer = AddComponent.GetContainerRef() -theContainer.getHostName() - - -# ------------------------RunningComponents-------------------------------------------------- - -ListComponents() - - -# ------------------------FindOrLoad_Component( Params , "AddComponent" )--------------------------------- - -DefaultParams.ContainerName = 'AddComponentServer' - -AddComponent = MyContainersMgr.FindOrLoad_Component( DefaultParams , "AddComponent" ) - -# ------------------------RunningComponents-------------------------------------------------- - -ListComponents() - - -# ------------------------RunningContainers-------------------------------------------------- - -ListContainers() - -DefaultParams.Memory = 0 -DefaultParams.ContainerName = '' - - - - -# ------------------------FindContainer-------------------------------------------------- - -aContainer = MyContainersMgr.FindContainer( DefaultParams ) -print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type() - -# ------------------------FindOneContainer-------------------------------------------------- - -aContainer = MyContainersMgr.FindOneContainer( 'localhost' , 'FactoryServer' ) -print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type() - -aContainer = MyContainersMgr.FindOneContainer( 'localhost' , 'FactoryServerPy' ) -print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type() - -aContainer = MyContainersMgr.FindOneContainer( 'localhost' , 'SuperVisionContainer' ) -print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type() - -aContainer = MyContainersMgr.FindOneContainer( '' , 'SuperVisionContainer' ) -print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type() - - -aContainer = MyContainersMgr.FindOneContainer( '' , 'AddComponentServer' ) -print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type() - - -# ------------------------C++ Servers-------------------------------------------------- - -DefaultParams.ContainerType = Engines.CppContainer -Containers = MyContainersMgr.FindContainers( DefaultParams ) -i = 0 -while i < len( Containers ) : - print "Container running on",Containers[ i ]._get_machineName(),"with name",Containers[ i ]._get_name(),"and type",Containers[ i ].type() - i = i + 1 - -# ------------------------Python Servers-------------------------------------------------- - -DefaultParams.ContainerType = Engines.PythonContainer -Containers = MyContainersMgr.FindContainers( DefaultParams ) -i = 0 -while i < len( Containers ) : - print "Container running on",Containers[ i ]._get_machineName(),"with name",Containers[ i ]._get_name(),"and type",Containers[ i ].type() - i = i + 1 - -# ------------------------AddComponentServer-------------------------------------------------- - -DefaultParams.ContainerType = Engines.UndefinedContainerType -DefaultParams.ContainerName = 'AddComponentServer' -aContainer = MyContainersMgr.FindOrStartContainer( DefaultParams ) -print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type() - -ContainerParameters( DefaultParams ) - -# ------------------------FactoryServers-------------------------------------------------- - -DefaultParams.ContainerName = 'FactoryServer' -DefaultParams.ContainerType = Engines.UndefinedContainerType -Containers = MyContainersMgr.FindContainers( DefaultParams ) -i = 0 -while i < len( Containers ) : - print "Container running on",Containers[ i ]._get_machineName(),"with name",Containers[ i ]._get_name(),"and type",Containers[ i ].type() - i = i + 1 - - -# ------------------------AddComponent-------------------------------------------------- - -DefaultParams.ContainerType = Engines.CppContainer -DefaultParams.ContainerName = 'FactoryServer' -FactoryServerAddComponent = MyContainersMgr.FindOrLoad_Component( DefaultParams , "AddComponent" ) -print FactoryServerAddComponent.GetContainerRef()._get_name(),FactoryServerAddComponent._get_instanceName(),FactoryServerAddComponent._get_interfaceName() - - -# ------------------------is109973 Containers-------------------------------------------------- - -DefaultParams.ContainerType = Engines.UndefinedContainerType -DefaultParams.ContainerName = '' -DefaultParams.HostName = 'is109973' -Containers = MyContainersMgr.FindContainers( DefaultParams ) -i = 0 -while i < len( Containers ) : - print "Container running on",Containers[ i ]._get_machineName(),"with name",Containers[ i ]._get_name(),"and type",Containers[ i ].type() - i = i + 1 - -# ------------------------is109974 Containers-------------------------------------------------- - -DefaultParams.HostName = 'is109974' -Containers = MyContainersMgr.FindContainers( DefaultParams ) -i = 0 -while i < len( Containers ) : - print "Container running on",Containers[ i ]._get_machineName(),"with name",Containers[ i ]._get_name(),"and type",Containers[ i ].type() - i = i + 1 - -# ------------------------is109974FactoryServerPy-------------------------------------------------- - -DefaultParams.Memory = 500 -DefaultParams.HostName = '' -DefaultParams.ContainerType = Engines.PythonContainer -is109974FactoryServerPy = MyContainersMgr.FindOrStartContainer( DefaultParams ) - -is109974FactoryServerPy.ping() - -# ------------------------Python Containers-------------------------------------------------- - -DefaultParams.Memory = 0 -DefaultParams.ContainerType = Engines.PythonContainer -DefaultParams.ContainerName = '' -Containers = MyContainersMgr.FindContainers( DefaultParams ) -i = 0 -while i < len( Containers ) : - print "Container running on",Containers[ i ]._get_machineName(),"with name",Containers[ i ]._get_name(),"and type",Containers[ i ].type() - i = i + 1 - -# ------------------------Python FactorialComponent-------------------------------------------------- - -DefaultParams.Memory = 500 -aFactorialComponent = MyContainersMgr.FindOrLoad_Component( DefaultParams , "FactorialComponent" ) -print aFactorialComponent.GetContainerRef()._get_name(),aFactorialComponent._get_instanceName(),aFactorialComponent._get_interfaceName() - - -# ------------------------RunningComponents-------------------------------------------------- - -ListComponents() - - - - -ContainerParameters( DefaultParams ) - -AddComponent = MyContainersMgr.FindComponent( DefaultParams , 'AddComponent' ) -print AddComponent.GetContainerRef()._get_name(),AddComponent._get_instanceName(),AddComponent._get_interfaceName() - -ListOfAddComponent = MyContainersMgr.FindComponents( DefaultParams , 'AddComponent' ) -i = 0 -while i < len( ListOfAddComponent ) : - print ListOfAddComponent[ i ].GetContainerRef()._get_name(),ListOfAddComponent[ i ]._get_instanceName(),ListOfAddComponent[ i ]._get_interfaceName() - i = i + 1 - -aSameAddComponent = MyContainersMgr.FindOrLoad_Component( DefaultParams , "AddComponent" ) -print aSameAddComponent.GetContainerRef()._get_name(),aSameAddComponent._get_instanceName(),aSameAddComponent._get_interfaceName() - -ListOfAddComponent = MyContainersMgr.FindComponents( DefaultParams , 'AddComponent' ) -i = 0 -while i < len( ListOfAddComponent ) : - print ListOfAddComponent[ i ].GetContainerRef()._get_name(),ListOfAddComponent[ i ]._get_instanceName(),ListOfAddComponent[ i ]._get_interfaceName() - i = i + 1 - -ContainerParameters( DefaultParams ) - -FactoryServerSubComponent = MyContainersMgr.FindOrLoad_Component( DefaultParams , "SubComponent" ) -ListOfComponents = MyContainersMgr.FindComponents( DefaultParams , '' ) -i = 0 -while i < len( ListOfComponents ) : - print ListOfComponents[ i ].GetContainerRef()._get_name(),ListOfComponents[ i ]._get_instanceName(),ListOfComponents[ i ]._get_interfaceName() - i = i + 1 - -DefaultParams.ContainerName = 'ServerPy' -ServerPy = FindOrStartContainer( DefaultParams ) -ServerPy = FindOrStartContainer( DefaultParams ) -ServerPy = MyContainersMgr.FindContainer( DefaultParams ) -print "Container running on",ServerPy._get_machineName(),"with name",ServerPy._get_name(),"and type",ServerPy.type() - -DefaultParams.ContainerName = 'SuperVisionContainer' -SuperVisionContainerAddComponent = MyContainersMgr.FindOrLoad_Component( DefaultParams , "AddComponent" ) -DefaultParams.ContainerName = '' -ListOfAddComponent = MyContainersMgr.FindComponents( DefaultParams , 'AddComponent' ) -i = 0 -while i < len( ListOfAddComponent ) : - print ListOfAddComponent[ i ].GetContainerRef()._get_name(),ListOfAddComponent[ i ]._get_instanceName(),ListOfAddComponent[ i ]._get_interfaceName() - i = i + 1 - - -ListOfComponents = MyContainersMgr.FindComponents( DefaultParams , '' ) -i = 0 -while i < len( ListOfComponents ) : - print ListOfComponents[ i ].GetContainerRef()._get_name(),ListOfComponents[ i ]._get_instanceName(),ListOfComponents[ i ]._get_interfaceName() - i = i + 1 - - -ListOfComponents = MyContainersMgr.FindComponents( DefaultParams , 'SubComponent' ) -i = 0 -while i < len( ListOfComponents ) : - print ListOfComponents[ i ].GetContainerRef()._get_name(),ListOfComponents[ i ]._get_instanceName(),ListOfComponents[ i ]._get_interfaceName() - i = i + 1 - -aAddComponent = MyContainersMgr.FindOneComponent( '' , 'FactoryServer' , "AddComponent" ) -print aAddComponent.GetContainerRef()._get_name(),aAddComponent._get_instanceName(),aAddComponent._get_interfaceName() - -aSubComponent = MyContainersMgr.FindOneComponent( '' , 'FactoryServer' , "SubComponent" ) -print aSubComponent.GetContainerRef()._get_name(),aSubComponent._get_instanceName(),aSubComponent._get_interfaceName() - -aSUPERVComponent = MyContainersMgr.FindOneComponent( '' , 'SuperVisionContainer' , "SUPERV" ) -print aSUPERVComponent.GetContainerRef()._get_name(),aSUPERVComponent._get_instanceName(),aSUPERVComponent._get_interfaceName() - -aAddComponent = MyContainersMgr.FindOneComponent( '' , '' , "AddComponent" ) -print aAddComponent.GetContainerRef()._get_name(),aAddComponent._get_instanceName(),aAddComponent._get_interfaceName() - -aSubComponent = MyContainersMgr.FindOneComponent( '' , '' , "SubComponent" ) -print aSubComponent.GetContainerRef()._get_name(),aSubComponent._get_instanceName(),aSubComponent._get_interfaceName() - -aSubComponent = MyContainersMgr.FindOneComponent( 'is109973' , '' , "SubComponent" ) -print aSubComponent.GetContainerRef()._get_name(),aSubComponent._get_instanceName(),aSubComponent._get_interfaceName() - -aSubComponent = MyContainersMgr.FindOneComponent( 'localhost' , '' , "SubComponent" ) -print aSubComponent.GetContainerRef()._get_name(),aSubComponent._get_instanceName(),aSubComponent._get_interfaceName() - -aSUPERVComponent = MyContainersMgr.FindOneComponent( '' , '' , "SUPERV" ) -print aSUPERVComponent.GetContainerRef()._get_name(),aSUPERVComponent._get_instanceName(),aSUPERVComponent._get_interfaceName() - -ServerPy = MyContainersMgr.FindOneContainer( '' , 'ServerPy' ) -print "Container running on",ServerPy._get_machineName(),"with name",ServerPy._get_name(),"and type",ServerPy.type() - -DefaultParams.ContainerType = Engines.PythonContainer -ContainerParameters( DefaultParams ) -TestComponentPy = MyContainersMgr.FindOrLoad_Component( DefaultParams , "SALOME_TestComponentPy" ) -print TestComponentPy.GetContainerRef()._get_name(),TestComponentPy._get_instanceName(),TestComponentPy._get_interfaceName() -ListOfComponents = MyContainersMgr.FindComponents( DefaultParams , '' ) -i = 0 -while i < len( ListOfComponents ) : - print ListOfComponents[ i ].GetContainerRef()._get_name(),ListOfComponents[ i ]._get_instanceName(),ListOfComponents[ i ]._get_interfaceName() - i = i + 1 - -DefaultParams.ContainerType = Engines.CppContainer -ContainerParameters( DefaultParams ) -TestComponent = MyContainersMgr.FindOrLoad_Component( DefaultParams , "SalomeTestComponent" ) -print TestComponent.GetContainerRef()._get_name(),TestComponent._get_instanceName(),TestComponent._get_interfaceName() -ListOfComponents = MyContainersMgr.FindComponents( DefaultParams , '' ) -i = 0 -while i < len( ListOfComponents ) : - print ListOfComponents[ i ].GetContainerRef()._get_name(),ListOfComponents[ i ]._get_instanceName(),ListOfComponents[ i ]._get_interfaceName() - i = i + 1 - - - - - -from LifeCycleCORBA import * -orb = CORBA.ORB_init([''], CORBA.ORB_ID) -lcc = LifeCycleCORBA( orb ) - -TestComponent = lcc.FindOrLoadComponent( 'FactoryServer' , 'SalomeTestComponent' ) -print TestComponent.GetContainerRef()._get_name(),TestComponent._get_instanceName(),TestComponent._get_interfaceName() - -TestComponent = lcc.FindOrLoadComponent( '' , 'SalomeTestComponent' ) -print TestComponent.GetContainerRef()._get_name(),TestComponent._get_instanceName(),TestComponent._get_interfaceName() - -TestComponentPy = lcc.FindOrLoadComponent( '' , 'SALOME_TestComponentPy' ) -if TestComponentPy is None : - print 'SALOME_TestComponentPy not found : Ok' -else : - print 'Error',TestComponentPy.GetContainerRef()._get_name(),TestComponentPy._get_instanceName(),TestComponentPy._get_interfaceName(),'was found' - -TestComponentPy = lcc.FindOrLoadComponent( 'ServerPy' , 'SALOME_TestComponentPy' ) -print TestComponentPy.GetContainerRef()._get_name(),TestComponentPy._get_instanceName(),TestComponentPy._get_interfaceName() - -lccMulComponent = lcc.FindOrLoadComponent( 'SuperVisionContainer' , "MulComponent" ) -print lccMulComponent.GetContainerRef()._get_name(),lccMulComponent._get_instanceName(),lccMulComponent._get_interfaceName() - -lccDivComponent = lcc.FindOrLoadComponent( 'DivComponentContainer' , "DivComponent" ) -print lccDivComponent.GetContainerRef()._get_name(),lccDivComponent._get_instanceName(),lccDivComponent._get_interfaceName() - - -DefaultParams = lcc.Parameters() - -DefaultParams.ContainerName = 'SuperVisionContainer' - -lccAddComponent = lcc.FindOrLoadComponent( DefaultParams , "AddComponent" ) -print lccAddComponent.GetContainerRef()._get_name(),lccAddComponent._get_instanceName(),lccAddComponent._get_interfaceName() - -DefaultParams.ContainerName = 'SubComponentContainer' -lccSubComponent = lcc.FindOrLoadComponent( DefaultParams , "SubComponent" ) -print lccSubComponent.GetContainerRef()._get_name(),lccSubComponent._get_instanceName(),lccSubComponent._get_interfaceName() - -aContainer = lcc.FindContainer( DefaultParams ) -print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type() - -aContainer = lcc.FindContainer( 'FactoryServer' ) -print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type() - -aContainer = lcc.FindContainer( 'localhost/FactoryServer' ) -print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type() - - -ContainerParameters( DefaultParams ) - -DefaultParams.ContainerName = '' - -ListOfContainers = lcc.FindContainers( DefaultParams ) -i = 0 -while i < len( ListOfContainers ) : - print "Container running on",ListOfContainers[ i ]._get_machineName(),"with name",ListOfContainers[ i ]._get_name(),"and type",ListOfContainers[ i ].type() - i = i + 1 - -ListOfComponents = lcc.FindComponents( DefaultParams , '' ) -i = 0 -while i < len( ListOfComponents ) : - print ListOfComponents[ i ].GetContainerRef()._get_name(),ListOfComponents[ i ]._get_instanceName(),ListOfComponents[ i ]._get_interfaceName() - i = i + 1 - - -aComponent = lcc.FindComponent( DefaultParams , 'SubComponent' ) -print aComponent.GetContainerRef()._get_name(),aComponent._get_instanceName(),aComponent._get_interfaceName() - -lccMulComponent = lcc.FindOrLoadComponent( DefaultParams , "MulComponent" ) -print lccMulComponent.GetContainerRef()._get_name(),lccMulComponent._get_instanceName(),lccMulComponent._get_interfaceName() - -DefaultParams.HostName = 'bojolex' - -lccbojolexMulComponent = lcc.FindOrLoadComponent( DefaultParams , "MulComponent" ) - -DefaultParams.HostName = 'toto' - -lcctotoMulComponent = lcc.FindOrLoadComponent( DefaultParams , "MulComponent" ) - - -MyContainersMgr.DestroyContainer( '' , 'FactoryServer' ) -MyContainersMgr.DestroyContainer( '' , 'FactoryServerPy' ) - - -DefaultParams.HostName = '' -DefaultParams.ContainerName = '' -DefaultParams.ContainerType = Engines.UndefinedContainerType - -ListOfContainers = lcc.FindContainers( DefaultParams ) -i = 0 -while i < len( ListOfContainers ) : - print "Container running on",ListOfContainers[ i ]._get_machineName(),"with name",ListOfContainers[ i ]._get_name(),"and type",ListOfContainers[ i ].type() - i = i + 1 - -ListOfComponents = lcc.FindComponents( DefaultParams , '' ) -i = 0 -while i < len( ListOfComponents ) : - print ListOfComponents[ i ].GetContainerRef()._get_name(),ListOfComponents[ i ]._get_instanceName(),ListOfComponents[ i ]._get_interfaceName() - i = i + 1 - - -MyContainersMgr.destroy() - diff --git a/src/ContainersManager/runContainer.py b/src/ContainersManager/runContainer.py deleted file mode 100644 index 4ee79d816..000000000 --- a/src/ContainersManager/runContainer.py +++ /dev/null @@ -1,62 +0,0 @@ -#! /usr/bin/env python -# -# SALOME runContainer : implementation of container and engine for Kernel -# -# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# 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. -# -# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -# -# -# -# File : runContainer.py -# Author : Jean Rahuel, CEA -# Module : SALOME -# $Header: - -import os -import sys -import string -from omniORB import CORBA, PortableServer -import Containers -import Engines -from SALOME_NamingServicePy import * - -if sys.argv[1] == '--help' : - print 'USAGE : runContainer.py ContainerName ContainerType NSHostName NSHostPort Path Ld_Library_Path PythonPath CasRoot' - print ' ContainerType : Engines.Cpp or Engines.Python' - sys.exit(0) - -if ContainerType == 'Engines.Cpp' : - Container = 'SALOME_Container ' -elif ContainerType == 'Engines.Python' : - Container = 'SALOME_ContainerPy.py ' -else : - print 'ContainerType is bad' - Container = '' - -if len( Container ) > 0 : - Container = Container + ' -ORBInitRef NameService=corbaname::' - Container = Container + NSHostName + ':' + NSHostPort - os.environ["PATH"] = Path - os.environ["LD_LIBRARY_PATH"] = Ld_Library_Path - os.environ["PYTHONPATH"] = PythonPath - os.environ["CASROOT"] = CasRoot - os.environ["CSF_PluginDefaults"] = os.path.join( CasRoot , "share" , "salome" , "resources" ) - print Container - exec Container -