From: rahuel Date: Thu, 26 Feb 2004 16:15:26 +0000 (+0000) Subject: Use of ContainersManager and ResourcesManager X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=69042cbf157d604630e66f53bd6680c334a25453;p=modules%2Fkernel.git Use of ContainersManager and ResourcesManager --- diff --git a/src/LifeCycleCORBA/Makefile.in b/src/LifeCycleCORBA/Makefile.in index 33ee1ac81..d98e8e9c7 100644 --- a/src/LifeCycleCORBA/Makefile.in +++ b/src/LifeCycleCORBA/Makefile.in @@ -43,13 +43,13 @@ EXPORT_PYSCRIPTS = LifeCycleCORBA.py LIB = libSalomeLifeCycleCORBA.la LIB_SRC = SALOME_LifeCycleCORBA.cxx LIB_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl \ - SALOME_ModuleCatalog.idl + SALOME_ModuleCatalog.idl ContainersManager.idl # Executables targets BIN = TestLifeCycleCORBA BIN_SRC = BIN_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl \ - SALOME_ModuleCatalog.idl + SALOME_ModuleCatalog.idl ContainersManager.idl LDFLAGS += -lSalomeNS -lOpUtil -lSALOMELocalTrace diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index 844d02448..f759a0387 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -38,18 +38,21 @@ using namespace std; #include #include "SALOME_LifeCycleCORBA.hxx" -#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog) +//#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog) #include "SALOME_NamingService.hxx" SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA() { - _NS = NULL; + _NamingService = NULL; + _MyContainersMgr = NULL ; _FactoryServer = NULL ; } SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService *ns) { - _NS = ns; + _NamingService = ns; + CORBA::Object_var ContainersMgrObject = _NamingService->Resolve( "/Kernel/ContainersManager" ) ; + _MyContainersMgr = Containers::Manager::_narrow( ContainersMgrObject ) ; _FactoryServer = NULL ; } @@ -57,10 +60,9 @@ SALOME_LifeCycleCORBA::~SALOME_LifeCycleCORBA() { } -string SALOME_LifeCycleCORBA::ContainerName( - const char * aComputerContainer , - string * theComputer , - string * theContainer ) { +string SALOME_LifeCycleCORBA::ContainerName( const char * aComputerContainer , + string * theComputer , + string * theContainer ) { char * ContainerName = new char [ strlen( aComputerContainer ) + 1 ] ; strcpy( ContainerName , aComputerContainer ) ; string theComputerContainer("/Containers/"); @@ -89,333 +91,388 @@ string SALOME_LifeCycleCORBA::ContainerName( return theComputerContainer ; } -string SALOME_LifeCycleCORBA::ComputerPath( - const char * theComputer ) { - CORBA::String_var path; - CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog"); - SALOME_ModuleCatalog::ModuleCatalog_var Catalog = - SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ; - try { - path = Catalog->GetPathPrefix( theComputer ); - } - catch (SALOME_ModuleCatalog::NotFound&) { - MESSAGE("GetPathPrefix(" << theComputer << ") not found!"); - path = "" ; - } - SCRUTE( path ) ; - return CORBA::string_dup( path ) ; -} +//string SALOME_LifeCycleCORBA::ComputerPath( const char * theComputer ) { +// CORBA::String_var path; +// CORBA::Object_var obj = _NamingService->Resolve("/Kernel/ModulCatalog"); +// SALOME_ModuleCatalog::ModuleCatalog_var Catalog = +// SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ; +// try { +// path = Catalog->GetPathPrefix( theComputer ); +// } +// catch (SALOME_ModuleCatalog::NotFound&) { +// MESSAGE("GetPathPrefix(" << theComputer << ") not found!"); +// path = "" ; +// } +// SCRUTE( path ) ; +// return CORBA::string_dup( path ) ; +//} -Engines::Container_var SALOME_LifeCycleCORBA::FindContainer(const char *containerName ) { - ASSERT(_NS != NULL); - string cont ; - if ( strncmp( containerName , "/Containers/" , 12 ) ) { // Compatibility ... - string theComputer ; - string theContainer ; - cont = ContainerName( containerName , &theComputer , &theContainer ) ; +Engines::Container_var SALOME_LifeCycleCORBA::FindContainer( const char * containerName ) { + Containers::MachineParameters * MyParams = _MyContainersMgr->Parameters() ; + string theComputer ; + string theContainer ; + ContainerName( containerName , &theComputer , &theContainer ) ; + MyParams->HostName = theComputer.c_str() ; + MyParams->ContainerName = theContainer.c_str() ; + int l = strlen( containerName ) ; + if ( strcmp( &containerName[ l-2 ] , "Py" ) ) { + MyParams->ContainerType = Engines::Cpp ; } else { - cont = containerName ; + MyParams->ContainerType = Engines::Python ; } - try { - - SCRUTE( cont ); + return FindContainer( *MyParams ) ; +} - CORBA::Object_var obj = _NS->Resolve( cont.c_str() ); - if( !CORBA::is_nil( obj ) ) { - return Engines::Container::_narrow( obj ) ; - } - } - catch (ServiceUnreachable&) { - INFOS("Caught exception: Naming Service Unreachable"); - } - catch (...) { - INFOS("Caught unknown exception."); - } - return Engines::Container::_nil(); +Engines::Container_var SALOME_LifeCycleCORBA::FindContainer( const Containers::MachineParameters & MyParams ) { + return _MyContainersMgr->FindContainer( MyParams ) ; } +// ASSERT(_NamingService != NULL); +// string cont ; +// if ( strncmp( containerName , "/Containers/" , 12 ) ) { // Compatibility ... +// string theComputer ; +// string theContainer ; +// cont = ContainerName( containerName , &theComputer , &theContainer ) ; +// } +// else { + // cont = containerName ; +// } +// try { -Engines::Container_var SALOME_LifeCycleCORBA::FindOrStartContainer( - const string aComputerContainer , - const string theComputer , - const string theContainer ) { - Engines::Container_var aContainer = FindContainer( aComputerContainer.c_str() ) ; - Engines::Container_var aFactoryServer ; - SCRUTE( aComputerContainer ) ; - SCRUTE( theComputer ) ; - SCRUTE( theContainer ) ; - bool pyCont = false ; - int len = theContainer.length() ; - if ( !strcmp( &theContainer.c_str()[len-2] , "Py" ) ) { - pyCont = true ; - } - if ( !CORBA::is_nil( aContainer ) ) { - return aContainer ; - } - else { - string FactoryServer = theComputer ; - if ( pyCont ) { - FactoryServer += "/FactoryServerPy" ; - } - else { - FactoryServer += "/FactoryServer" ; - } - aFactoryServer = FindContainer( FactoryServer.c_str() ) ; - if ( CORBA::is_nil( aFactoryServer ) ) { +// SCRUTE( cont ); + +// CORBA::Object_var obj = _NamingService->Resolve( cont.c_str() ); +// if( !CORBA::is_nil( obj ) ) { +// return Engines::Container::_narrow( obj ) ; +// } +// } +// catch (ServiceUnreachable&) { +// INFOS("Caught exception: Naming Service Unreachable"); +// } +// catch (...) { +// INFOS("Caught unknown exception."); +// } +// return Engines::Container::_nil(); +//} + +//Engines::Container_var SALOME_LifeCycleCORBA::FindOrStartContainer( +// const string aComputerContainer , +// const string theComputer , +// const string theContainer ) { +// Engines::Container_var aContainer = FindContainer( aComputerContainer.c_str() ) ; +// Engines::Container_var aFactoryServer ; +// SCRUTE( aComputerContainer ) ; +// SCRUTE( theComputer ) ; +// SCRUTE( theContainer ) ; +// bool pyCont = false ; +// int len = theContainer.length() ; +// if ( !strcmp( &theContainer.c_str()[len-2] , "Py" ) ) { +// pyCont = true ; +// } +// if ( !CORBA::is_nil( aContainer ) ) { +// return aContainer ; +// } +// else { +// string FactoryServer = theComputer ; +// if ( pyCont ) { +// FactoryServer += "/FactoryServerPy" ; +// } +// else { +// FactoryServer += "/FactoryServer" ; +// } +// aFactoryServer = FindContainer( FactoryServer.c_str() ) ; +// if ( CORBA::is_nil( aFactoryServer ) ) { // rsh -n ikkyo /export/home/rahuel/SALOME_ROOT/bin/runSession SALOME_Container -ORBInitRef NameService=corbaname::dm2s0017:1515 & - string rsh( "" ) ; - if ( theComputer!= GetHostname() ) { - rsh += "rsh -n " ; - rsh += theComputer ; - rsh += " " ; - } - string path = ComputerPath( theComputer.c_str() ) ; - SCRUTE( path ) ; - if ( path[0] != '\0' ) { - rsh += path ; - rsh += "/../bin/" ; - } - rsh += "runSession " ; - if ( pyCont ) { - rsh += "SALOME_ContainerPy.py " ; - rsh += "FactoryServerPy -" ; - } - else { - rsh += "SALOME_Container " ; - rsh += "FactoryServer -" ; - } - string omniORBcfg( getenv( "OMNIORB_CONFIG" ) ) ; - ifstream omniORBfile( omniORBcfg.c_str() ) ; - char ORBInitRef[12] ; - char nameservice[132] ; - omniORBfile >> ORBInitRef ; - rsh += ORBInitRef ; - rsh += " " ; - omniORBfile >> nameservice ; - omniORBfile.close() ; - char * bsn = strchr( nameservice , '\n' ) ; - if ( bsn ) { - bsn[ 0 ] = '\0' ; - } - rsh += nameservice ; - if ( pyCont ) { - rsh += " > /tmp/FactoryServerPy_" ; - } - else { - rsh += " > /tmp/FactoryServer_" ; - } - rsh += theComputer ; - rsh += ".log 2>&1 &" ; - SCRUTE( rsh ); - int status = system( rsh.c_str() ) ; - if (status == -1) { - INFOS("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status -1)") ; - } - else if (status == 217) { - INFOS("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status 217)") ; - } - else { - int count = 21 ; - while ( CORBA::is_nil( aFactoryServer ) && count ) { - sleep( 1 ) ; - count-- ; - if ( count != 10 ) - MESSAGE( count << ". Waiting for FactoryServer on " << theComputer) - aFactoryServer = FindContainer( FactoryServer.c_str() ) ; - } - if ( CORBA::is_nil( aFactoryServer ) ) { - INFOS("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed") ; - } - else if ( strcmp( theComputer.c_str() , GetHostname().c_str() ) ) { - _FactoryServer = aFactoryServer ; - } - } - } - if ( !CORBA::is_nil( aFactoryServer ) ) { - if ( strcmp( theContainer.c_str() , "FactoryServer" ) || - strcmp( theContainer.c_str() , "FactoryServerPy" ) ) { - MESSAGE("Container not found ! trying to start " << aComputerContainer); - Engines::Container_var myContainer = aFactoryServer->start_impl( theContainer.c_str() ) ; - if ( !CORBA::is_nil( myContainer ) ) { - MESSAGE("Container " << aComputerContainer << " started"); - return myContainer ; - } - else { - MESSAGE("Container " << aComputerContainer << " NOT started"); - } - } - else { - MESSAGE("Container " << aComputerContainer << " started"); - return aFactoryServer ; - } - } - } - return Engines::Container::_nil(); -} +// string rsh( "" ) ; +// if ( theComputer!= GetHostname() ) { +// rsh += "rsh -n " ; +// rsh += theComputer ; +// rsh += " " ; +// } +// string path = ComputerPath( theComputer.c_str() ) ; +// SCRUTE( path ) ; +// if ( path[0] != '\0' ) { +// rsh += path ; +// rsh += "/../bin/" ; +// } +// rsh += "runSession " ; +// if ( pyCont ) { +// rsh += "SALOME_ContainerPy.py " ; +// rsh += "FactoryServerPy -" ; +// } +// else { +// rsh += "SALOME_Container " ; +// rsh += "FactoryServer -" ; +// } +// string omniORBcfg( getenv( "OMNIORB_CONFIG" ) ) ; +// ifstream omniORBfile( omniORBcfg.c_str() ) ; +// char ORBInitRef[12] ; +// char nameservice[132] ; +// omniORBfile >> ORBInitRef ; +// rsh += ORBInitRef ; +// rsh += " " ; +// omniORBfile >> nameservice ; +// omniORBfile.close() ; +// char * bsn = strchr( nameservice , '\n' ) ; +// if ( bsn ) { +// bsn[ 0 ] = '\0' ; +// } +// rsh += nameservice ; +// if ( pyCont ) { +// rsh += " > /tmp/FactoryServerPy_" ; +// } +// else { +// rsh += " > /tmp/FactoryServer_" ; +// } +// rsh += theComputer ; +// rsh += ".log 2>&1 &" ; +// SCRUTE( rsh ); +// int status = system( rsh.c_str() ) ; +// if (status == -1) { +// INFOS("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status -1)") ; +// } +// else if (status == 217) { +// INFOS("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status 217)") ; +// } +// else { +// int count = 21 ; +// while ( CORBA::is_nil( aFactoryServer ) && count ) { +// sleep( 1 ) ; +// count-- ; +// if ( count != 10 ) +// MESSAGE( count << ". Waiting for FactoryServer on " << theComputer) +// aFactoryServer = FindContainer( FactoryServer.c_str() ) ; +// } +// if ( CORBA::is_nil( aFactoryServer ) ) { +// INFOS("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed") ; +// } +// else if ( strcmp( theComputer.c_str() , GetHostname().c_str() ) ) { +// _FactoryServer = aFactoryServer ; +// } +// } +// } +// if ( !CORBA::is_nil( aFactoryServer ) ) { +// if ( strcmp( theContainer.c_str() , "FactoryServer" ) || +// strcmp( theContainer.c_str() , "FactoryServerPy" ) ) { +// MESSAGE("Container not found ! trying to start " << aComputerContainer); +// Engines::Container_var myContainer = aFactoryServer->start_impl( theContainer.c_str() ) ; +// if ( !CORBA::is_nil( myContainer ) ) { +// MESSAGE("Container " << aComputerContainer << " started"); +// return myContainer ; +// } +// else { +// MESSAGE("Container " << aComputerContainer << " NOT started"); +// } +// } +// else { +// MESSAGE("Container " << aComputerContainer << " started"); +// return aFactoryServer ; +// } +// } +// } +// return Engines::Container::_nil(); +//} -Engines::Component_var SALOME_LifeCycleCORBA::FindOrLoad_Component - (const char *containerName, - const char *componentName, - const char *implementation) -{ - BEGIN_OF("FindOrLoad_Component(1)"); - ASSERT(_NS != NULL); +Engines::Component_var SALOME_LifeCycleCORBA::FindOrLoad_Component( const char *containerName , + const char *componentName , + const char *implementation ) { + Containers::MachineParameters * MyParams = _MyContainersMgr->Parameters() ; string theComputer ; string theContainer ; - string theComputerContainer = ContainerName( containerName , - &theComputer , - &theContainer ) ; - Engines::Container_var cont = FindOrStartContainer( theComputerContainer , - theComputer , - theContainer ) ; + ContainerName( containerName , &theComputer , &theContainer ) ; + MyParams->HostName = theComputer.c_str() ; + MyParams->ContainerName = theContainer.c_str() ; + int l = strlen( containerName ) ; + if ( strcmp( &containerName[ l-2 ] , "Py" ) ) { + MyParams->ContainerType = Engines::Cpp ; + } + else { + MyParams->ContainerType = Engines::Python ; + } + return FindOrLoad_Component( *MyParams , componentName , implementation ) ; +} +Engines::Component_var SALOME_LifeCycleCORBA::FindOrLoad_Component( const Containers::MachineParameters & MyParams , + const char * componentName , + const char * implementation ) { + + return _MyContainersMgr->FindOrLoad_ComponentPath( MyParams , componentName , implementation ) ; +} +//{ +// BEGIN_OF("FindOrLoad_Component(1)"); +// ASSERT(_NamingService != NULL); +// string theComputer ; +// string theContainer ; +// string theComputerContainer = ContainerName( containerName , +// &theComputer , +// &theContainer ) ; +// Engines::Container_var cont = FindOrStartContainer( theComputerContainer , +// theComputer , +// theContainer ) ; // ASSERT(!CORBA::is_nil(cont)); - string path( theComputerContainer ); - path = path + "/"; - path = path + componentName; - SCRUTE(path); - try - { - CORBA::Object_var obj = _NS->Resolve(path.c_str()); - if (CORBA::is_nil(obj)) - { - MESSAGE("Component not found ! trying to load " << path); - Engines::Component_var compo - = cont->load_impl(componentName, implementation); +// string path( theComputerContainer ); +// path = path + "/"; +// path = path + componentName; +// SCRUTE(path); +// try +// { +// CORBA::Object_var obj = _NamingService->Resolve(path.c_str()); +// if (CORBA::is_nil(obj)) +// { +// MESSAGE("Component not found ! trying to load " << path); +// Engines::Component_var compo +// = cont->load_impl(componentName, implementation); // ASSERT(!CORBA::is_nil(compo)); - MESSAGE("Component launched !" << path); - return compo; - } - else - { - MESSAGE("Component found !" << path); - Engines::Component_var compo = Engines::Component::_narrow(obj); +// 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 - { - compo->ping(); - } - 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(); -} +// try +// { +// compo->ping(); +// } +// 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(); +//} -Engines::Component_var SALOME_LifeCycleCORBA::FindOrLoad_Component - (const char *containerName, - const char *componentName) -{ -// BEGIN_OF("FindOrLoad_Component(2)"); - ASSERT(_NS != NULL); +Engines::Component_var SALOME_LifeCycleCORBA::FindOrLoad_Component( const char *containerName, + const char *componentName) { + Containers::MachineParameters * MyParams = _MyContainersMgr->Parameters() ; string theComputer ; string theContainer ; - string theComputerContainer = ContainerName( containerName , - &theComputer , - &theContainer ) ; - Engines::Container_var cont = FindOrStartContainer( theComputerContainer , - theComputer , - theContainer ) ; - - if ( CORBA::is_nil( cont ) ) { - MESSAGE("Container not found ! " << theComputerContainer ); - return Engines::Component::_nil(); + ContainerName( containerName , &theComputer , &theContainer ) ; + MyParams->HostName = theComputer.c_str() ; + MyParams->ContainerName = theContainer.c_str() ; + int l = strlen( containerName ) ; + if ( strcmp( &containerName[ l-2 ] , "Py" ) ) { + MyParams->ContainerType = Engines::Cpp ; + } + else { + MyParams->ContainerType = Engines::Python ; } + return FindOrLoad_Component( *MyParams , componentName ) ; +} +Engines::Component_var SALOME_LifeCycleCORBA::FindOrLoad_Component( const Containers::MachineParameters & MyParams , + const char * componentName ) { + return _MyContainersMgr->FindOrLoad_Component( MyParams , componentName ) ; +} +// BEGIN_OF("FindOrLoad_Component(2)"); +// ASSERT(_NamingService != NULL); +// string theComputer ; +// string theContainer ; +// string theComputerContainer = ContainerName( containerName , +// &theComputer , +// &theContainer ) ; +// Engines::Container_var cont = FindOrStartContainer( theComputerContainer , +// theComputer , +// theContainer ) ; +// +// if ( CORBA::is_nil( cont ) ) { +// MESSAGE("Container not found ! " << theComputerContainer ); +// return Engines::Component::_nil(); +// } // char * machine = cont->machineName() ; - const char * machine = theComputer.c_str() ; +// const char * machine = theComputer.c_str() ; - string path( theComputerContainer ); - path += "/"; - path += componentName; - SCRUTE(path); +// string path( theComputerContainer ); +// path += "/"; +// path += componentName; +// SCRUTE(path); - 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); +// try { +// CORBA::Object_var obj = _NamingService->Resolve(path.c_str()); +// if ( CORBA::is_nil( obj ) ) { +// MESSAGE("Component not found ! trying to load " << path); +// CORBA::Object_var obj2 = _NamingService->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(); +// 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 = "" ; - } - } +// 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"; +// SCRUTE(path); +// string implementation(path); +// implementation += "lib"; +// implementation += componentName; +// implementation += "Engine.so"; - Engines::Component_var compo - = cont->load_impl(componentName, implementation.c_str()); +// 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); +// 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(); -} +// 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(); +//} diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx index 2338fe34c..79061af6a 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx @@ -36,6 +36,8 @@ #include #include CORBA_CLIENT_HEADER(SALOME_Component) +#include CORBA_CLIENT_HEADER( ContainersManager ) + class SALOME_NamingService; class SALOME_LifeCycleCORBA @@ -45,24 +47,31 @@ public: SALOME_LifeCycleCORBA(SALOME_NamingService *ns); virtual ~SALOME_LifeCycleCORBA(); - Engines::Container_var FindContainer(const char *containerName); - Engines::Component_var FindOrLoad_Component(const char *containerName, - const char *componentName, - const char *implementationPath); - Engines::Component_var FindOrLoad_Component(const char *containerName, - const char *componentName); + Engines::Container_var FindContainer( const char *containerName ) ; + Engines::Container_var FindContainer( const Containers::MachineParameters & MyParams ) ; + Engines::Component_var FindOrLoad_Component( const char *containerName , + const char *componentName , + const char *implementationPath ) ; + Engines::Component_var FindOrLoad_Component( const Containers::MachineParameters & MyParams , + const char *componentName , + const char *implementationPath ) ; + Engines::Component_var FindOrLoad_Component( const char *containerName , + const char *componentName ) ; + Engines::Component_var FindOrLoad_Component( const Containers::MachineParameters & MyParams , + const char *componentName ) ; protected: - SALOME_NamingService *_NS; - Engines::Container_var _FactoryServer ; + Containers::Manager_var _MyContainersMgr ; + SALOME_NamingService * _NamingService ; + Engines::Container_var _FactoryServer ; private: std::string ContainerName( const char * aComputerContainer , - std::string * theComputer , - std::string * theContainer ) ; - std::string ComputerPath( const char * theComputer ) ; - Engines::Container_var FindOrStartContainer(const std::string aComputerContainer , - const std::string theComputer , - const std::string theContainer ) ; + std::string * theComputer , + std::string * theContainer ) ; +// std::string ComputerPath( const char * theComputer ) ; +// Engines::Container_var FindOrStartContainer(const std::string aComputerContainer , +// const std::string theComputer , +// const std::string theContainer ) ; } ; diff --git a/src/LifeCycleCORBA/TestLifeCycleCORBA.cxx b/src/LifeCycleCORBA/TestLifeCycleCORBA.cxx index b67b988b6..40fd87761 100644 --- a/src/LifeCycleCORBA/TestLifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/TestLifeCycleCORBA.cxx @@ -40,8 +40,10 @@ using namespace std; int main (int argc, char * argv[]) { - try - { + try { + int i = 0 ; + while ( argv[ i ] ) { + MESSAGE(" argv" << i << " " << argv[ i ]) ; // Initializing omniORB CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); @@ -49,15 +51,26 @@ int main (int argc, char * argv[]) CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ; PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ; + MESSAGE( "SALOME_NamingService :" ) ; SALOME_NamingService _NS(orb) ; + MESSAGE( "SALOME_LifeCycleCORBA :" ) ; SALOME_LifeCycleCORBA _LCC(&_NS) ; // get a local container (with a name based on local hostname), // load an engine, and invoque methods on that engine - string containerName = GetHostname(); - + string containerName ; + if ( i == 0 ) { + containerName = GetHostname() ; + } + else { + containerName = argv[ i ] ; + } + containerName += "/" ; + containerName += "TestComponentCpp" ; + + MESSAGE("FindOrLoad_Component( " << containerName << " , SalomeTestComponent )" ) ; Engines::Component_var mycompo = _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent"); @@ -74,8 +87,17 @@ int main (int argc, char * argv[]) // get another container (with a fixed name), // load an engine, and invoque methods on that engine - string containerName2 = "FactoryServerPy"; - + string containerName2 ; + if ( i == 0 ) { + containerName2 = GetHostname() ; + } + else { + containerName2 = argv[ i ] ; + } + containerName2 += "/" ; + containerName2 += "TestComponentPy" ; + + MESSAGE("FindOrLoad_Component( " << containerName2 << " , SALOME_TestComponentPy )" ) ; Engines::Component_var mycompo2 = _LCC.FindOrLoad_Component(containerName2.c_str(),"SALOME_TestComponentPy"); @@ -88,23 +110,21 @@ int main (int argc, char * argv[]) SCRUTE(m2->instanceName()); MESSAGE("Coucou " << m2->Coucou(1L)); + i++ ; } - catch(CORBA::COMM_FAILURE& ex) - { - INFOS("Caught system exception COMM_FAILURE -- unable to contact the object."); - } - catch(CORBA::SystemException&) - { - INFOS("Caught a CORBA::SystemException."); - } - catch(CORBA::Exception&) - { - INFOS("Caught CORBA::Exception."); - } - catch(...) - { - INFOS("Caught unknown exception."); - } + } + catch(CORBA::COMM_FAILURE& ex) { + INFOS("Caught system exception COMM_FAILURE -- unable to contact the object."); + } + catch(CORBA::SystemException&) { + INFOS("Caught a CORBA::SystemException."); + } + catch(CORBA::Exception&) { + INFOS("Caught CORBA::Exception."); + } + catch(...) { + INFOS("Caught unknown exception."); + } return 0; }