From 784e65baf03356345cad6b5076f0caa5eeff312d Mon Sep 17 00:00:00 2001 From: rahuel Date: Tue, 2 Mar 2004 14:46:15 +0000 Subject: [PATCH] *** empty log message *** --- src/ContainersManager/ContainersManager_i.cxx | 43 ++- src/ContainersManager/ContainersManager_i.hxx | 3 + .../TestContainersManager.py | 94 ++++- src/LifeCycleCORBA/LifeCycleCORBA.py | 355 +++++++++++------- src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx | 8 +- src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx | 2 + 6 files changed, 332 insertions(+), 173 deletions(-) diff --git a/src/ContainersManager/ContainersManager_i.cxx b/src/ContainersManager/ContainersManager_i.cxx index d3c6255cf..b3a8414e6 100644 --- a/src/ContainersManager/ContainersManager_i.cxx +++ b/src/ContainersManager/ContainersManager_i.cxx @@ -166,7 +166,7 @@ Engines::ListOfContainers * Manager_i::FindContainers( const Containers::Machine if ( strlen( MyParams.ContainerName ) ) { _FullContainerName = _FullHostName + "/" + string( (char * ) MyParams.ContainerName ) ; _ContainerObject = _NamingService->Resolve( _FullContainerName.c_str() ) ; - MESSAGE( "Manager_i::FindContainers NamingService->Resolve( " << _FullContainerName << ")" ) ; + MESSAGE( "Manager_i::FindContainers NamingService->Resolve( " << _FullContainerName << " )" ) ; if ( !CORBA::is_nil( _ContainerObject ) ) { _EnginesContainer = Engines::Container::_narrow( _ContainerObject ) ; if ( _EnginesContainer->type() == MyParams.ContainerType ) { @@ -267,7 +267,7 @@ Engines::Container_ptr Manager_i::FindOrStartContainerLocked( Containers::Machin if ( _ListOfContainers->length() ) { _EnginesContainer = Engines::Container::_nil() ; int i ; - for ( i = 0 ; i < _ListOfContainers->length() && CORBA::is_nil( _EnginesContainer ) ; i++ ) { + for ( i = 0 ; i < _ListOfContainers->length() && ( ( _StartContainer && CORBA::is_nil( _EnginesContainer ) ) || !_StartContainer ) ; i++ ) { _FullHostName = "/Containers/" ; char * aHostName = _ListOfContainers[ i ]->machineName() ; _HostName = string( aHostName ) ; @@ -276,8 +276,8 @@ Engines::Container_ptr Manager_i::FindOrStartContainerLocked( Containers::Machin aContainerName = strrchr( aContainerName , '/' ) + 1 ; _ContainerName = string( aContainerName ) ; _FullContainerName = _FullHostName + "/" + _ContainerName ; - MESSAGE( "Manager_i::FindOrStartContainerLocked Container " << _FullContainerName << " searched Component " - << _ComponentName << " " << aContainerName << " " << _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 ) ; @@ -341,7 +341,12 @@ Engines::Container_ptr Manager_i::FindOrStartContainerLocked( Containers::Machin } } if ( CORBA::is_nil( _EnginesContainer ) && _StartContainer ) { - StartContainer( myParams ) ; + if ( _ListOfContainers->length() ) { + _EnginesContainer = _ListOfContainers[ 0 ] ; + } + else { + StartContainer( myParams ) ; + } } return Engines::Container::_duplicate( _EnginesContainer ) ; } @@ -513,13 +518,18 @@ Engines::Container_ptr Manager_i::StartContainer( const Containers::MachineParam Engines::Component_ptr Manager_i::FindComponent( const Containers::MachineParameters & myParams , const char * ComponentName ) { + _StartContainer = false ; + return Find_Component( myParams , ComponentName ) ; +} + +Engines::Component_ptr Manager_i::Find_Component( const Containers::MachineParameters & myParams , + const char * ComponentName ) { Containers::MachineParameters MyParams = (Containers::MachineParameters & ) myParams ; if ( strcmp( MyParams.HostName ,"localhost" ) == 0 ) { MyParams.HostName = GetHostname().c_str() ; } MESSAGE( "FindComponent HostName " << MyParams.HostName << " ContainerName " << MyParams.ContainerName << " ComponentName " << ComponentName ) ; - _StartContainer = false ; FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ; if ( CORBA::is_nil( _EnginesComponent ) ) { MESSAGE( "FindComponent ComponentName " << ComponentName << " NOT found" ) ; @@ -581,14 +591,16 @@ Engines::Component_ptr Manager_i::FindOrLoad_ComponentPath( const Containers::Ma } MESSAGE( "MutexManager pthread_mutex_locked" ) ; try { - EnginesComponent = FindComponent( MyParams , ComponentName ) ; + _StartContainer = true ; + EnginesComponent = Find_Component( MyParams , ComponentName ) ; if ( CORBA::is_nil( EnginesComponent ) ) { - _StartContainer = true ; - aContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ; + MESSAGE("Component not found " << _ComponentName ) ; +// aContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ; } else { - aContainer = _EnginesContainer ; + MESSAGE("Component was found " << _ComponentName ) ; } + aContainer = _EnginesContainer ; } catch ( ... ) { MESSAGE(" catch") ; @@ -634,15 +646,16 @@ Engines::Component_ptr Manager_i::FindOrLoad_Component( const Containers::Machin } MESSAGE( "MutexManager pthread_mutex_locked" ) ; try { - EnginesComponent = FindComponent( MyParams , ComponentName ) ; + _StartContainer = true ; + EnginesComponent = Find_Component( MyParams , ComponentName ) ; if ( CORBA::is_nil( EnginesComponent ) ) { - MESSAGE("Component not found " << _ComponentName << " --> FindOrStartContainerLocked" ) ; - _StartContainer = true ; - aContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ; + MESSAGE("Component not found " << _ComponentName ) ; +// aContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ; } else { - aContainer = _EnginesContainer ; + MESSAGE("Component was found " << _ComponentName ) ; } + aContainer = _EnginesContainer ; } catch ( ... ) { MESSAGE(" catch") ; diff --git a/src/ContainersManager/ContainersManager_i.hxx b/src/ContainersManager/ContainersManager_i.hxx index d8f34f4d9..f05863284 100644 --- a/src/ContainersManager/ContainersManager_i.hxx +++ b/src/ContainersManager/ContainersManager_i.hxx @@ -85,6 +85,9 @@ class Manager_i : public POA_Containers::Manager , Engines::Container_ptr FindOrStartContainerLocked( Containers::MachineParameters & MyParams , const char * ComponentName ) ; + Engines::Component_ptr Find_Component( const Containers::MachineParameters & MyParams , + const char * ComponentName ) ; + public: Manager_i() ; diff --git a/src/ContainersManager/TestContainersManager.py b/src/ContainersManager/TestContainersManager.py index b37f6fbad..e55ec58de 100644 --- a/src/ContainersManager/TestContainersManager.py +++ b/src/ContainersManager/TestContainersManager.py @@ -152,7 +152,6 @@ DefaultParams.Memory = 1000 ListOfComputers = MyResourcesMgr.GetComputers( DefaultParams ) print '' -print 'ListOfComputers',len( ListOfComputers ),'computers found' if len( ListOfComputers ) > 0 : print "Error",len( ListOfComputers ),"Computers found" i = 0 @@ -161,6 +160,8 @@ if len( ListOfComputers ) > 0 : 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 : @@ -188,9 +189,13 @@ Containers = MyContainersMgr.FindContainers( DefaultParams ) if len( Containers ) == 0 : print len( Containers ),"found Error" + + DefaultParams.Memory = 0 DefaultParams.ContainerName = '' +ContainerParameters( DefaultParams ) + DefaultParams.ContainerType = Engines.Undefined Containers = MyContainersMgr.FindContainers( DefaultParams ) i = 0 @@ -198,6 +203,15 @@ 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 +aContainer = MyContainersMgr.FindContainer( DefaultParams ) +print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainers.type() + +aContainer = MyContainersMgr.FindContainer( 'FactoryServer' ) ) +print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainers.type() + +aContainer = MyContainersMgr.FindContainer( 'localhost/FactoryServer' ) ) +print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainers.type() + DefaultParams.ContainerType = Engines.Cpp Containers = MyContainersMgr.FindContainers( DefaultParams ) i = 0 @@ -217,31 +231,38 @@ ContainerParameters( DefaultParams ) DefaultParams.ContainerType = Engines.Cpp DefaultParams.ContainerName = 'FactoryServer' FactoryServerAddComponent = MyContainersMgr.FindOrLoad_Component( DefaultParams , "AddComponent" ) -FactoryServerAddComponent._get_instanceName() -FactoryServerAddComponent._get_interfaceName() +print FactoryServerAddComponent.GetContainerRef()._get_name(),FactoryServerAddComponent._get_instanceName(),FactoryServerAddComponent._get_interfaceName() + +DefaultParams.ContainerType = Engines.Undefined +DefaultParams.ContainerName = '' + +ContainerParameters( DefaultParams ) AddComponent = MyContainersMgr.FindComponent( DefaultParams , 'AddComponent' ) -AddComponent._get_instanceName() -AddComponent._get_interfaceName() +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 ]._get_instanceName(),ListOfAddComponent[ i ]._get_interfaceName() + print ListOfAddComponent[ i ].GetContainerRef()._get_name(),ListOfAddComponent[ i ]._get_instanceName(),ListOfAddComponent[ i ]._get_interfaceName() i = i + 1 -MyContainersMgr.FindOrLoad_Component( DefaultParams , "AddComponent" ) +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 ]._get_instanceName(),ListOfAddComponent[ i ]._get_interfaceName() + print ListOfAddComponent[ i ].GetContainerRef()._get_name(),ListOfAddComponent[ i ]._get_instanceName(),ListOfAddComponent[ i ]._get_interfaceName() i = i + 1 +ContainerParameters( DefaultParams ) + FactoryServeSubComponent = MyContainersMgr.FindOrLoad_Component( DefaultParams , "SubComponent" ) ListOfComponents = MyContainersMgr.FindComponents( DefaultParams , '' ) i = 0 while i < len( ListOfComponents ) : - print ListOfComponents[ i ]._get_instanceName(),ListOfComponents[ i ]._get_interfaceName() + print ListOfComponents[ i ].GetContainerRef()._get_name(),ListOfComponents[ i ]._get_instanceName(),ListOfComponents[ i ]._get_interfaceName() i = i + 1 DefaultParams.ContainerName = 'SuperVisionContainer' @@ -250,25 +271,72 @@ DefaultParams.ContainerName = '' ListOfAddComponent = MyContainersMgr.FindComponents( DefaultParams , 'AddComponent' ) i = 0 while i < len( ListOfAddComponent ) : - print ListOfAddComponent[ i ]._get_instanceName(),ListOfAddComponent[ i ]._get_interfaceName() + 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 ]._get_instanceName(),ListOfComponents[ i ]._get_interfaceName() + 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 ) -DefaultParams.ContainerName = 'SuperVisionContainer' lccMulComponent = lcc.FindOrLoadComponent( 'SuperVisionContainer' , "MulComponent" ) -DefaultParams.ContainerName = 'DivComponentContainer' +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() + diff --git a/src/LifeCycleCORBA/LifeCycleCORBA.py b/src/LifeCycleCORBA/LifeCycleCORBA.py index 9c683e51f..5c86b2525 100644 --- a/src/LifeCycleCORBA/LifeCycleCORBA.py +++ b/src/LifeCycleCORBA/LifeCycleCORBA.py @@ -36,12 +36,16 @@ import SALOME_ModuleCatalog from SALOME_utilities import * +import Resources +import Containers + class LifeCycleCORBA: _orb = None _rootcontext = None - _containerRootContext = None - _catalog = None - + #_containerRootContext = None + #_catalog = None + _containermgr = None + #------------------------------------------------------------------------- def __init__(self, orb): @@ -54,27 +58,43 @@ class LifeCycleCORBA: if self._rootContext is None: MESSAGE( "Name Service Reference is invalid" ) - name = [CosNaming.NameComponent("Containers","dir")] - try: - self._containerRootContext = self._rootContext.bind_new_context(name) + #name = [CosNaming.NameComponent("Containers","dir")] + #try: + #self._containerRootContext = self._rootContext.bind_new_context(name) - except CosNaming.NamingContext.AlreadyBound, ex: - MESSAGE( "/Containers.dir Context already exists" ) - obj = self._rootContext.resolve(name) - self._containerRootContext = obj._narrow(CosNaming.NamingContext) - if self._containerRootContext is None: - MESSAGE( "Containers.dir exists but it is not a NamingContext" ) + #except CosNaming.NamingContext.AlreadyBound, ex: + #MESSAGE( "/Containers.dir Context already exists" ) + #obj = self._rootContext.resolve(name) + #self._containerRootContext = obj._narrow(CosNaming.NamingContext) + #if self._containerRootContext is None: + #MESSAGE( "Containers.dir exists but it is not a NamingContext" ) + + #name = [CosNaming.NameComponent("Kernel","dir"), + #CosNaming.NameComponent("ModulCatalog","object")] + #try: + #obj = self._rootContext.resolve(name) + #except CosNaming.NamingContext.NotFound, ex: + #MESSAGE( "/Kernel.dir/ModulCatalog.object not found in Naming Service" ) name = [CosNaming.NameComponent("Kernel","dir"), - CosNaming.NameComponent("ModulCatalog","object")] + CosNaming.NameComponent("ContainersManager","object")] try: obj = self._rootContext.resolve(name) except CosNaming.NamingContext.NotFound, ex: - MESSAGE( "/Kernel.dir/ModulCatalog.object not found in Naming Service" ) + MESSAGE( "/Kernel.dir/ContainersManager.object not found in Naming Service" ) + + self._containermgr = obj._narrow( Containers.Manager ) + self._containermgr.ping() + + #self._catalog = obj._narrow(SALOME_ModuleCatalog.ModuleCatalog) + #if self._catalog is None: + #MESSAGE( "/Kernel.dir/ModulCatalog.object exists but is not a ModulCatalog" ) + + #------------------------------------------------------------------------- + + def Parameters( self ): + return self._containermgr.Parameters() - self._catalog = obj._narrow(SALOME_ModuleCatalog.ModuleCatalog) - if self._catalog is None: - MESSAGE( "/Kernel.dir/ModulCatalog.object exists but is not a ModulCatalog" ) #------------------------------------------------------------------------- @@ -91,7 +111,7 @@ class LifeCycleCORBA: theComputer = os.getenv("HOSTNAME") computerSplitName = theComputer.split('.') theComputer = computerSplitName[0] - MESSAGE( theComputer + theContainer ) + MESSAGE( theComputer + '/' + theContainer ) return theComputer,theContainer #------------------------------------------------------------------------- @@ -106,140 +126,189 @@ class LifeCycleCORBA: #------------------------------------------------------------------------- def FindContainer(self, containerName): - theComputer,theContainer = self.ContainerName( containerName ) - name = [CosNaming.NameComponent(theComputer,"dir"), - CosNaming.NameComponent(theContainer,"object")] - obj = None - try: - obj = self._containerRootContext.resolve(name) - MESSAGE( containerName + ".object found in Naming Service" ) + try : + theComputer,theContainer = self.ContainerName( containerName ) + MyParams = self._containermgr.Parameters() + MyParams.HostName = theComputer + MyParams.ContainerName = theContainer + if theContainer.find('Py') == -1 : + MyParams.ContainerType = Engines.Cpp + else : + MyParams.ContainerType = Engines.Python + except : + MyParams = containerName + container = self._containermgr.FindContainer( MyParams ) + #name = [CosNaming.NameComponent(theComputer,"dir"), + # CosNaming.NameComponent(theContainer,"object")] + #obj = None + #try: + # obj = self._containerRootContext.resolve(name) + # MESSAGE( containerName + ".object found in Naming Service" ) - except CosNaming.NamingContext.NotFound, ex: - MESSAGE( containerName + ".object not found in Naming Service" ) - - if obj is None: - container = None - else: - container = obj._narrow(Engines.Container) - if container is None: - MESSAGE( containerName + ".object exists but is not a Container" ) + #except CosNaming.NamingContext.NotFound, ex: + # MESSAGE( containerName + ".object not found in Naming Service" ) + + #if obj is None: + # container = None + #else: + # container = obj._narrow(Engines.Container) + # if container is None: + # MESSAGE( containerName + ".object exists but is not a Container" ) return container #------------------------------------------------------------------------- - def FindOrStartContainer(self, theComputer , theContainer ): - MESSAGE( "FindOrStartContainer" + theComputer + theContainer ) - aContainer = self.FindContainer( theComputer + "/" + theContainer ) - if aContainer is None : - if (theContainer == "FactoryServer") | (theContainer == "FactoryServerPy") : - if theComputer == os.getenv("HOSTNAME") : - rshstr = "" - else : - rshstr = "rsh -n " + theComputer + " " - path = self.ComputerPath( theComputer ) - if path != "" : - rshstr = rshstr + path + "/../bin/" - else : - rshstr = rshstr + os.getenv( "SALOME_ROOT_DIR" ) + "/bin/" - if theContainer == "FactoryServer" : - rshstr = rshstr + "./runSession ./SALOME_Container " - else : - rshstr = rshstr + "./runSession ./SALOME_ContainerPy.py '" - rshstr = rshstr + theContainer + " -" - omniORBcfg = os.getenv( "OMNIORB_CONFIG" ) - file = os.open( omniORBcfg , os.O_RDONLY ) - ORBInitRef = os.read(file,132) - if ORBInitRef[len(ORBInitRef)-1] == '\n' : - ORBInitRef,bsn = ORBInitRef.split('\n') - os.close( file ) - rshstr = rshstr + ORBInitRef - if theContainer == "FactoryServerPy" : - rshstr = rshstr + "'" - rshstr = rshstr + " > /tmp/" + theContainer + "_" - rshstr = rshstr + theComputer - rshstr = rshstr + ".log 2>&1 &" - os.system( rshstr ) - MESSAGE( "FindOrStartContainer" + rshstr + " done" ) - else : - if theContainer.find('Py') == -1 : - aContainer = self.FindContainer( theComputer + "/" + "FactoryServer" ) - else : - aContainer = self.FindContainer( theComputer + "/" + "FactoryServerPy" ) - aContainer = aContainer.start_impl( theContainer ) - - count = 21 - while aContainer is None : - time.sleep(1) - count = count - 1 - MESSAGE( str(count) + ". Waiting for " + theComputer + "/" + theContainer ) - aContainer = self.FindContainer( theComputer + "/" + theContainer ) - if count == 0 : - return aContainer + def FindContainers( self , MyParams ) : + if MyParams.HostName == 'localhost' : + MyParams.HostName = os.getenv("HOSTNAME") + return self._containermgr.FindContainers( MyParams ) + + + #------------------------------------------------------------------------- + + def FindComponent( self , MyParams , ComponentName ) : + if MyParams.HostName == 'localhost' : + MyParams.HostName = os.getenv("HOSTNAME") + return self._containermgr.FindComponent( MyParams , ComponentName ) + + + #------------------------------------------------------------------------- + + def FindComponents( self , MyParams , ComponentName ) : + if MyParams.HostName == 'localhost' : + MyParams.HostName = os.getenv("HOSTNAME") + return self._containermgr.FindComponents( MyParams , ComponentName ) + + + #------------------------------------------------------------------------- + + #def FindOrStartContainer(self, theComputer , theContainer ): + #MESSAGE( "FindOrStartContainer" + theComputer + theContainer ) + #aContainer = self.FindContainer( theComputer + "/" + theContainer ) + #if aContainer is None : + #if (theContainer == "FactoryServer") | (theContainer == "FactoryServerPy") : + #if theComputer == os.getenv("HOSTNAME") : + #rshstr = "" + #else : + #rshstr = "rsh -n " + theComputer + " " + #path = self.ComputerPath( theComputer ) + #if path != "" : + #rshstr = rshstr + path + "/../bin/" + #else : + #rshstr = rshstr + os.getenv( "SALOME_ROOT_DIR" ) + "/bin/" + #if theContainer == "FactoryServer" : + #rshstr = rshstr + "./runSession ./SALOME_Container " + #else : + #rshstr = rshstr + "./runSession ./SALOME_ContainerPy.py '" + #rshstr = rshstr + theContainer + " -" + #omniORBcfg = os.getenv( "OMNIORB_CONFIG" ) + #file = os.open( omniORBcfg , os.O_RDONLY ) + #ORBInitRef = os.read(file,132) + #if ORBInitRef[len(ORBInitRef)-1] == '\n' : + #ORBInitRef,bsn = ORBInitRef.split('\n') + #os.close( file ) + #rshstr = rshstr + ORBInitRef + #if theContainer == "FactoryServerPy" : + #rshstr = rshstr + "'" + #rshstr = rshstr + " > /tmp/" + theContainer + "_" + #rshstr = rshstr + theComputer + #rshstr = rshstr + ".log 2>&1 &" + #os.system( rshstr ) + #MESSAGE( "FindOrStartContainer" + rshstr + " done" ) + #else : + #if theContainer.find('Py') == -1 : + #aContainer = self.FindContainer( theComputer + "/" + "FactoryServer" ) + #aContainerType = Engines.Cpp + #else : + #aContainer = self.FindContainer( theComputer + "/" + "FactoryServerPy" ) + #aContainerType = Engines.Python + #aContainer = aContainer.start_impl( theContainer , aContainerType ) + + #count = 21 + #while aContainer is None : + #time.sleep(1) + #count = count - 1 + #MESSAGE( str(count) + ". Waiting for " + theComputer + "/" + theContainer ) + #aContainer = self.FindContainer( theComputer + "/" + theContainer ) + #if count == 0 : + #return aContainer - return aContainer + #return aContainer #os.system("rsh -n dm2s0017 /export/home/SALOME_ROOT/bin/runSession SALOME_Container -ORBInitRef NameService=corbaname::dm2s0017:1515") #------------------------------------------------------------------------- def FindOrLoadComponent(self, containerName, componentName): - theComputer,theContainer = self.ContainerName( containerName ) - name = [CosNaming.NameComponent(theComputer,"dir"), - CosNaming.NameComponent(theContainer,"dir"), - CosNaming.NameComponent(componentName,"object")] - try: - obj = self._containerRootContext.resolve(name) - except CosNaming.NamingContext.NotFound, ex: - MESSAGE( "component " + componentName + " not found, trying to load" ) - container = self.FindContainer(theComputer + "/" + theContainer) - if container is None: - MESSAGE( "container " + theComputer + "/" + theContainer + " not found in Naming Service, trying to start" ) - if (theContainer != "FactoryServer") & (theContainer != "FactoryServerPy") : - if theContainer.find('Py') == -1 : - theFactorycontainer = "FactoryServer" - else : - theFactorycontainer = "FactoryServerPy" - Factorycontainer = self.FindContainer(theComputer + "/" + theFactorycontainer) - if Factorycontainer is None: - MESSAGE( "container " + theComputer + "/" + theFactorycontainer + " not found in Naming Service, trying to start" ) - Factorycontainer = self.FindOrStartContainer(theComputer,theFactorycontainer) - else: - Factorycontainer = self.FindOrStartContainer(theComputer,theContainer) - if Factorycontainer != None : - container = self.FindOrStartContainer(theComputer,theContainer) - - if container != None: - compoinfo = self._catalog.GetComponent(componentName) - if compoinfo is None: - MESSAGE( "component " + componentName + " not found in Module Catalog" ) - else: - try: - machineName = theComputer - path = compoinfo.GetPathPrefix(machineName) + "/" - except SALOME_ModuleCatalog.NotFound, ex: - MESSAGE( "machine " + machineName + " not found in Module Catalog" ) - MESSAGE( "trying localhost" ) - try: - path = compoinfo.GetPathPrefix("localhost") + "/" - except SALOME_ModuleCatalog.NotFound, ex: - path = "" - implementation = path + "lib" + componentName + "Engine.so" - MESSAGE( "Trying to load " + implementation ) - try: - component = container.load_impl(componentName, implementation) - MESSAGE( "component " + component._get_instanceName() + " launched !" ) - return component - except: - MESSAGE( "component " + componentName + " NOT launched !" ) - - else: - try: - component = obj._narrow(Engines.Component) - if component is None: - MESSAGE( componentName + " is not a component !" ) - else: - MESSAGE( "component " + component._get_instanceName() + " found !" ) - return component - except: - MESSAGE( componentName + " failure" ) - return None + + try : + theComputer,theContainer = self.ContainerName( containerName ) + MyParams = self._containermgr.Parameters() + MyParams.HostName = theComputer + MyParams.ContainerName = theContainer + if theContainer.find('Py') == -1 : + MyParams.ContainerType = Engines.Cpp + else : + MyParams.ContainerType = Engines.Python + except : + MyParams = containerName + return self._containermgr.FindOrLoad_Component( MyParams , componentName ) + #name = [CosNaming.NameComponent(theComputer,"dir"), + #CosNaming.NameComponent(theContainer,"dir"), + #CosNaming.NameComponent(componentName,"object")] + #try: + #obj = self._containerRootContext.resolve(name) + #except CosNaming.NamingContext.NotFound, ex: + #MESSAGE( "component " + componentName + " not found, trying to load" ) + #container = self.FindContainer(theComputer + "/" + theContainer) + #if container is None: + #MESSAGE( "container " + theComputer + "/" + theContainer + " not found in Naming Service, trying to start" ) + #if (theContainer != "FactoryServer") & (theContainer != "FactoryServerPy") : + #if theContainer.find('Py') == -1 : + #theFactorycontainer = "FactoryServer" + #else : + #theFactorycontainer = "FactoryServerPy" + #Factorycontainer = self.FindContainer(theComputer + "/" + theFactorycontainer) + #if Factorycontainer is None: + #MESSAGE( "container " + theComputer + "/" + theFactorycontainer + " not found in Naming Service, trying to start" ) + #Factorycontainer = self.FindOrStartContainer(theComputer,theFactorycontainer) + #else: + #Factorycontainer = self.FindOrStartContainer(theComputer,theContainer) + #if Factorycontainer != None : + #container = self.FindOrStartContainer(theComputer,theContainer) + + #if container != None: + #compoinfo = self._catalog.GetComponent(componentName) + #if compoinfo is None: + #MESSAGE( "component " + componentName + " not found in Module Catalog" ) + #else: + #try: + #machineName = theComputer + #path = compoinfo.GetPathPrefix(machineName) + "/" + #except SALOME_ModuleCatalog.NotFound, ex: + #MESSAGE( "machine " + machineName + " not found in Module Catalog" ) + #MESSAGE( "trying localhost" ) + #try: + #path = compoinfo.GetPathPrefix("localhost") + "/" + #except SALOME_ModuleCatalog.NotFound, ex: + #path = "" + #implementation = path + "lib" + componentName + "Engine.so" + #MESSAGE( "Trying to load " + implementation ) + #try: + #component = container.load_impl(componentName, implementation) + #MESSAGE( "component " + component._get_instanceName() + " launched !" ) + #return component + #except: + #MESSAGE( "component " + componentName + " NOT launched !" ) + + #else: + #try: + #component = obj._narrow(Engines.Component) + #if component is None: + #MESSAGE( componentName + " is not a component !" ) + #else: + #MESSAGE( "component " + component._get_instanceName() + " found !" ) + #return component + #except: + #MESSAGE( componentName + " failure" ) + #return None diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index d2f8e2453..226408382 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -60,6 +60,10 @@ SALOME_LifeCycleCORBA::~SALOME_LifeCycleCORBA() { } +Containers::MachineParameters_var SALOME_LifeCycleCORBA::Parameters() { + return _MyContainersMgr->Parameters() ; +} + string SALOME_LifeCycleCORBA::ContainerName( const char * aComputerContainer , string * theComputer , string * theContainer ) { @@ -287,7 +291,7 @@ Engines::ListOfContainers_var SALOME_LifeCycleCORBA::FindContainers( Containers: } Engines::Component_var SALOME_LifeCycleCORBA::FindComponent( Containers::MachineParameters & MyParams , - const char * ComponentName ) { + const char * ComponentName ) { if ( strcmp( MyParams.HostName ,"localhost" ) == 0 ) { MyParams.HostName = GetHostname().c_str() ; } @@ -295,7 +299,7 @@ Engines::Component_var SALOME_LifeCycleCORBA::FindComponent( Containers::Machine } Engines::ListOfComponents_var SALOME_LifeCycleCORBA::FindComponents( Containers::MachineParameters & MyParams , - const char * ComponentName ) { + const char * ComponentName ) { if ( strcmp( MyParams.HostName ,"localhost" ) == 0 ) { MyParams.HostName = GetHostname().c_str() ; } diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx index 48296f222..11e22308f 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx @@ -47,6 +47,8 @@ public: SALOME_LifeCycleCORBA(SALOME_NamingService *ns); virtual ~SALOME_LifeCycleCORBA(); + Containers::MachineParameters_var Parameters() ; + Engines::Container_var FindContainer( const char *containerName ) ; Engines::Container_var FindContainer( Containers::MachineParameters & MyParams ) ; Engines::ListOfContainers_var FindContainers( Containers::MachineParameters & MyParams ) ; -- 2.39.2