#
def killSalome():
+ print "arret du serveur ContainersManager ==> arret des containers"
+ import os
+ import sys
+ import string
+ from omniORB import CORBA
+ import CosNaming
+ import Engines
+ import Containers
+ try :
+ orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
+ obj = orb.resolve_initial_references("NameService")
+ rootContext = obj._narrow(CosNaming.NamingContext)
+ if rootContext is None:
+ print "Name Service Reference is invalid"
+ else :
+ name = [CosNaming.NameComponent("Kernel","dir"),
+ CosNaming.NameComponent("ContainersManager","object")]
+ obj = rootContext.resolve( name )
+ MyContainersMgr = obj._narrow(Containers.Manager)
+ print "MyContainersMgr.ping :",MyContainersMgr.ping()
+ MyContainersMgr.destroy()
+ MyContainersMgrdestroyed = 1
+ except :
+ print "Cannot destroy the ContainersManager"
+ MyContainersMgrdestroyed = 0
+
print "arret des serveurs SALOME"
for pid, cmd in process_id.items():
- print "arret du process %s : %s"% (pid, cmd[0])
- try:
- os.kill(pid,signal.SIGKILL)
- except:
- print " ------------------ process %s : %s inexistant"% (pid, cmd[0])
+ if ((cmd[0] != 'ContainersManager_Server') | (MyContainersMgrdestroyed == 0)) & (cmd[0] != 'startContainer.py') :
+ print "arret du process %s : %s"% (pid, cmd[0])
+ try:
+ os.kill(pid,signal.SIGKILL)
+ except:
+ print " ------------------ process %s : %s inexistant"% (pid, cmd[0])
print "arret du naming service"
os.system("killall -9 omniNames")
#
def killSalome():
+ print "arret du serveur ContainersManager ==> arret des containers"
+ import os
+ import sys
+ import string
+ from omniORB import CORBA
+ import CosNaming
+ import Engines
+ import Containers
+ try :
+ orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
+ obj = orb.resolve_initial_references("NameService")
+ rootContext = obj._narrow(CosNaming.NamingContext)
+ if rootContext is None:
+ print "Name Service Reference is invalid"
+ else :
+ name = [CosNaming.NameComponent("Kernel","dir"),
+ CosNaming.NameComponent("ContainersManager","object")]
+ obj = rootContext.resolve( name )
+ MyContainersMgr = obj._narrow(Containers.Manager)
+ print "MyContainersMgr.ping :",MyContainersMgr.ping()
+ MyContainersMgr.destroy()
+ MyContainersMgrdestroyed = 1
+ except :
+ print "Cannot destroy the ContainersManager"
+ MyContainersMgrdestroyed = 0
+
print "arret des serveurs SALOME"
for pid, cmd in process_id.items():
- print "arret du process %s : %s"% (pid, cmd[0])
- try:
- os.kill(pid,signal.SIGKILL)
- except:
- print " ------------------ process %s : %s inexistant"% (pid, cmd[0])
+ if ((cmd[0] != 'ContainersManager_Server') | (MyContainersMgrdestroyed == 0)) & (cmd[0] != 'startContainer.py') :
+ print "arret du process %s : %s"% (pid, cmd[0])
+ try:
+ os.kill(pid,signal.SIGKILL)
+ except:
+ print " ------------------ process %s : %s inexistant"% (pid, cmd[0])
print "arret du naming service"
os.system("killall -9 omniNames")
boolean ping() ;
- Engines::Container FindOneContainer( in string aContainerName ) ;
+ Engines::Container FindOneContainer( in string aHostName ,
+ in string aContainerName ) ;
Engines::Container FindContainer( in MachineParameters MyParams ) ;
Engines::Component FindComponent( in MachineParameters MyParams ,
in string ComponentName ) ;
- Engines::Component FindOneComponent( in string aContainerName ,
+ Engines::Component FindOneComponent( in string aHostName ,
+ in string aContainerName ,
in string ComponentName ) ;
Engines::ListOfComponents FindComponents( in MachineParameters MyParams ,
Engines::Component FindOrLoad_Component( in MachineParameters MyParams ,
in string ComponentName ) ;
+ boolean DestroyContainer( in string aHostName , in string aContainerName ) ;
+
+ boolean DestroyContainers( in MachineParameters MyParams ) ;
+
void destroy() ;
} ;
using namespace std;
#include "SALOME_Component_i.hxx"
+#include "SALOME_NamingService.hxx"
#include "RegistryConnexion.hxx"
#include "OpUtil.hxx"
#include <stdio.h>
// _myConnexionToRegistry = 0 ;
}
+void Engines_Component_i::destroy()
+{
+ MESSAGE("Engines_Component_i::destroy()");
+
+ delete _notifSupplier;
+ _notifSupplier = 0;
+
+ delete _myConnexionToRegistry;
+ _myConnexionToRegistry = 0 ;
+ string aRegisteredName = GetContainerRef()->name() + string("/") + _interfaceName ;
+ SALOME_NamingService * _NamingService = new SALOME_NamingService( _orb ) ;
+ MESSAGE("Engines_Component_i::destroy NamingService->Destroy_Name " << aRegisteredName ) ;
+ _NamingService->Destroy_Name( aRegisteredName.c_str() ) ;
+ delete _NamingService ;
+ _poa->deactivate_object( *_id ) ;
+ CORBA::release( _poa ) ;
+ delete( _id ) ;
+ _thisObj->_remove_ref();
+ MESSAGE("Engines_Component_i::destroyed") ;
+}
+
char* Engines_Component_i::instanceName() {
return CORBA::string_dup(_instanceName.c_str()) ;
}
<< pthread_self());
}
-void Engines_Component_i::destroy()
-{
- MESSAGE("Engines_Component_i::destroy()");
-
- delete _notifSupplier;
- _notifSupplier = 0;
-
- delete _myConnexionToRegistry;
- _myConnexionToRegistry = 0 ;
- _poa->deactivate_object(*_id) ;
- CORBA::release(_poa) ;
- delete(_id) ;
- _thisObj->_remove_ref();
- MESSAGE("Engines_Component_i::destroyed") ;
-}
-
Engines::Container_ptr Engines_Component_i::GetContainerRef()
{
MESSAGE("Engines_Component_i::GetContainerRef");
void Engines_Container_i::destroy() {
MESSAGE( "Container_i::destroy" ) ;
- _poa->deactivate_object(*_id) ;
- CORBA::release(_poa) ;
- delete(_id) ;
+ _NS->Destroy_Name( _containerName.c_str() ) ;
+ _poa->deactivate_object( *_id ) ;
+ CORBA::release( _poa ) ;
+ delete( _id ) ;
this->_remove_ref();
}
}
shstr += " > /tmp/" ;
shstr += ContainerName ;
- shstr += ".log 2>&1 &" ;
+ shstr += ".log 2>&1" ;
+ shstr += " &" ;
MESSAGE("system(" << shstr << ")") ;
int status = system( shstr.c_str() ) ;
if (status == -1) {
{
ASSERT(! CORBA::is_nil(component_i));
string component_registerName = _containerName + "/" + component_i->interfaceName() ;
- _NS->Destroy_Name( component_registerName.c_str() ) ;
+// _NS->Destroy_Name( component_registerName.c_str() ) ;
string instanceName = component_i->instanceName() ;
MESSAGE("unload component " << instanceName);
component_i->destroy() ;
MESSAGE( "SALOME_ComponentPy_i::__init__" + " " + str (containerName) + " " + str(instanceName) + " " + str(interfaceName) )
self._orb = orb
self._poa = poa
+ self._contId = self._poa.reference_to_id( contID )
self._instanceName = instanceName
self._interfaceName = interfaceName
self._containerName = containerName
+ self._Id = None
self._notif = notif
self._myConnexionToRegistry = 0
self._graphName = ''
self._Executed = 0
naming_service = SALOME_NamingServicePy_i(self._orb)
+ self.naming_service = naming_service
Component_path = "/Containers/" + os.getenv( "HOSTNAME" ) + "/" + self._containerName + "/" + self._interfaceName
MESSAGE( 'SALOME_ComponentPy_i Register' + str( Component_path ) )
- naming_service.Register(self._this(), Component_path)
+ naming_service.Register( self._this(), Component_path )
+ self.Component_path = Component_path
# Add componentinstance to registry
obj = naming_service.Resolve('/Registry')
def destroy(self):
MESSAGE( "SALOME_ComponentPy_i::destroy" )
- poa.deactivate_object(self)
- CORBA.release(_poa)
+ self.naming_service.Destroy_Name( self.Component_path )
+ self._poa.deactivate_object( self._Id )
+ MESSAGE( "SALOME_ComponentPy_i::destroy _poa.deactivate_object done" )
+ #self._poa._release()
+ #self._delete( self._Id )
+ #self._remove_ref()
+ MESSAGE( "SALOME_ComponentPy_i::destroyed" )
#-------------------------------------------------------------------------
def GetContainerRef(self):
MESSAGE( "SALOME_ComponentPy_i::GetContainerRef" )
+ theContainer = None
+ try :
+ obj = self._poa.id_to_reference( self._contId )
+ try :
+ theContainer = obj._narrow( Engines.Container )
+ except :
+ print "SALOME_ComponentPy_i::GetContainerRef _narrow( Engines.Container ) exception"
+ except :
+ print "SALOME_ComponentPy_i::GetContainerRef _poa.id_to_reference( _contId ) exception"
+ return theContainer
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------
- def __init__(self, orb, poa, containerName):
- MESSAGE( "SALOME_ContainerPy_i::__init__" )
+ def __init__( self , orb , poa , containerName ):
+ MESSAGE( "SALOME_ContainerPy_i::__init__ " + containerName )
self._orb = orb
self._poa = poa
self._containerName = containerName
+ self._contId = self._poa.reference_to_id( self._this() )
myMachine=string.split(os.getenv( "HOSTNAME" ),'.')
self._machineName = myMachine[0]
- naming_service = SALOME_NamingServicePy_i(self._orb)
- self._naming_service = naming_service
+ self.naming_service = SALOME_NamingServicePy_i(self._orb)
Container_path = "/Containers/" + myMachine[0] + "/" + self._containerName
self._Name = Container_path
MESSAGE( str(Container_path) )
- naming_service.Register(self._this(), Container_path)
+ self.naming_service.Register( self._this() , Container_path )
#-------------------------------------------------------------------------
+ def destroy(self):
+ MESSAGE( "SALOME_ContainerPy_i::destroy" )
+ self.naming_service.Destroy_Name( self._Name ) ;
+ print "SALOME_ContainerPy_i::destroy _poa.deactivate_object id",self._contId
+ self._poa.deactivate_object( self._contId )
+ MESSAGE( "SALOME_ContainerPy_i::destroy _poa.deactivate_object done" )
+ self._poa._release()
+ MESSAGE( "SALOME_ContainerPy_i::destroy _poa._released" )
+ #self.delete( self._contId )
+ #MESSAGE( "SALOME_ContainerPy_i::destroy self._contId deleted" )
+ #self._remove_ref()
+ #MESSAGE( "SALOME_ContainerPy_i::destroy self _removed_ref" )
+ MESSAGE( "SALOME_ContainerPy_i::destroyed" )
+ sys.exit(0)
+
+ #-------------------------------------------------------------------------
+
def start_impl( self , ContainerName , ContainerType ) :
MESSAGE( "SALOME_ContainerPy_i::start_impl " + str(ContainerName) )
myMachine=string.split(os.getenv( "HOSTNAME" ),'.')
shstr += " > "
shstr += fileName
- shstr += " 2>&1 &"
-
- #shstr += " > /tmp/"
- #shstr += ContainerName
- #shstr += ".log 2>&1 &"
+ shstr += " 2>&1"
+ shstr += " &"
MESSAGE( "SALOME_ContainerPy_i::start_impl " + "os.system(" + str(shstr) + ")" )
os.system( shstr )
#initialise the ORB and find the root POA
orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
+print "CORBA.ORB_init done"
poa = orb.resolve_initial_references("RootPOA")
+print "orb.resolve_initial_references('RootPOA') done"
#create an instance of SALOME_ContainerPy_i and a Container reference
#containerName = "FactoryServerPy"
-MESSAGE( str(sys.argv) )
+MESSAGE( "SALOME_ContainerPy.py " + str(sys.argv) )
containerName = sys.argv[1]
cpy_i = SALOME_ContainerPy_i(orb, poa, containerName)
cpy_o = cpy_i._this()
#Block for ever
orb.run()
-
-
-
-
+print "SALOME_ContainerPy --> orb.destroy"
+orb.destroy()
+print "SALOME_ContainerPy orb.destroyed"
for ( i = 0 ; i < _ListOfEnginesComponents.size() ; i++ ) {
try {
// _NamingService->Destroy_Name( _ListOfComponentsNames[ i ].c_str() ) ;
+ MESSAGE( "Manager_i::destroy try destroy Component " << _ListOfComponentsNames[ i ] ) ;
_ListOfEnginesComponents[ i ]->destroy() ;
- MESSAGE( "Manager_i::destroy Component " << _ListOfComponentsNames[ i ] ) ;
+ MESSAGE( "Manager_i::destroy Component " << _ListOfComponentsNames[ i ] << " destroyed" ) ;
}
catch ( ... ) {
MESSAGE( "Manager_i::destroy Component " << _ListOfComponentsNames[ i ] << " failed" ) ;
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 ;
-}
+//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::Container_ptr Manager_i::FindContainer( const Containers::MachineParameters & myParams ) {
Containers::MachineParameters MyParams = (Containers::MachineParameters & ) myParams ;
return Engines::Container::_duplicate( aContainer ) ;
}
-Engines::Container_ptr Manager_i::FindOneContainer( const char * aContainerName ) {
+Engines::Container_ptr Manager_i::FindOneContainer( const char * aHostName ,
+ const char * aContainerName ) {
Containers::MachineParameters * MyParams = Parameters() ;
- string theComputer ;
- string theContainer ;
- ContainerName( aContainerName , &theComputer , &theContainer ) ;
+ string theComputer = aHostName ;
+ string theContainer = aContainerName ;
+// ContainerName( aContainerName , &theComputer , &theContainer ) ;
MyParams->HostName = theComputer.c_str() ;
MyParams->ContainerName = theContainer.c_str() ;
- int l = strlen( aContainerName ) ;
- if ( strcmp( &aContainerName[ l-2 ] , "Py" ) ) {
- MyParams->ContainerType = Engines::Cpp ;
- }
- else {
- MyParams->ContainerType = Engines::Python ;
- }
+ MyParams->ContainerType = Engines::Undefined ;
if ( strcmp( MyParams->HostName ,"localhost" ) == 0 ) {
MyParams->HostName = GetHostname().c_str() ;
}
if ( strcmp( MyParams.HostName ,"localhost" ) == 0 ) {
MyParams.HostName = GetHostname().c_str() ;
}
- if ( strlen( MyParams.ContainerName ) && MyParams.ContainerType == Engines::Undefined ) {
- MyParams.ContainerType = Engines::Cpp ;
- }
MESSAGE( "Manager_i::FindContainers MutexManager pthread_mutex_lock :" ) ;
if ( pthread_mutex_lock( &_MutexManager ) ) {
perror("Manager_i::FindContainersMutexManager pthread_mutex_lock ") ;
if ( !CORBA::is_nil( _ContainerObject ) ) {
try {
_EnginesContainer = Engines::Container::_narrow( _ContainerObject ) ;
+ _EnginesContainer->ping() ;
if ( MyParams.ContainerType == Engines::Undefined ||
_EnginesContainer->type() == MyParams.ContainerType ) {
int size = _ListOfContainers->length() ;
}
catch( ... ) {
MESSAGE( "Manager_i::FindContainers " << _FullContainerName << " catched NOT responding" ) ;
+ _EnginesContainer = Engines::Container::_nil() ;
}
}
else {
<< _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 ) ;
}
catch ( ... ) {
MESSAGE( "Manager_i::FindOrStartContainerLocked catched NOT responding" ) ;
+ _EnginesComponent = Engines::Component::_nil() ;
}
}
}
MESSAGE( "Manager_i::FindOrStartContainerLocked Component " << _FullComponentName ) ;
_ComponentObject = _NamingService->Resolve( _FullComponentName.c_str() ) ;
if ( !CORBA::is_nil( _ComponentObject ) ) {
- MESSAGE( "Manager_i::FindOrStartContainerLocked --> " << _EnginesContainer->machineName() << " "
- << _EnginesContainer->name() << " Component " << _FullComponentName ) ;
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 {
Engines::Component_ptr aComponent = Engines::Component::_nil() ;
try {
_StartContainer = false ;
- aComponent = Find_Component( myParams , ComponentName ) ;
+ aComponent = FindComponentLocked( myParams , ComponentName ) ;
}
catch ( ... ) {
MESSAGE( "Manager_i::FindComponent catched" ) ;
return aComponent ;
}
-Engines::Component_ptr Manager_i::Find_Component( const Containers::MachineParameters & myParams ,
- const char * ComponentName ) {
+Engines::Component_ptr Manager_i::FindComponentLocked( 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
+ MESSAGE( "FindComponentLocked HostName " << MyParams.HostName << " ContainerName " << MyParams.ContainerName
<< " ComponentName " << ComponentName ) ;
FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ;
if ( CORBA::is_nil( _EnginesComponent ) ) {
- MESSAGE( "FindComponent ComponentName " << ComponentName << " NOT found" ) ;
+ MESSAGE( "FindComponentLocked ComponentName " << ComponentName << " NOT found" ) ;
}
else {
- MESSAGE( "FindComponent instanceName " << _EnginesComponent->instanceName() << " interfaceName "
- << _EnginesComponent->interfaceName() ) ;
+ MESSAGE( "FindComponentLocked instanceName " << _EnginesComponent->instanceName()
+ << " interfaceName " << _EnginesComponent->interfaceName() ) ;
}
return Engines::Component::_duplicate( _EnginesComponent ) ;
}
-Engines::Component_ptr Manager_i::FindOneComponent( const char * aContainerName ,
+Engines::Component_ptr Manager_i::FindOneComponent( const char * aHostName ,
+ const char * aContainerName ,
const char * ComponentName ) {
Containers::MachineParameters * MyParams = Parameters() ;
- string theComputer ;
- string theContainer ;
- ContainerName( aContainerName , &theComputer , &theContainer ) ;
+ string theComputer = aHostName ;
+ string theContainer = aContainerName ;
+// ContainerName( aContainerName , &theComputer , &theContainer ) ;
MyParams->HostName = theComputer.c_str() ;
MyParams->ContainerName = theContainer.c_str() ;
- int l = strlen( aContainerName ) ;
- if ( strcmp( &aContainerName[ l-2 ] , "Py" ) ) {
- MyParams->ContainerType = Engines::Cpp ;
- }
- else {
- MyParams->ContainerType = Engines::Python ;
- }
+ MyParams->ContainerType = Engines::Undefined ;
if ( strcmp( MyParams->HostName ,"localhost" ) == 0 ) {
MyParams->HostName = GetHostname().c_str() ;
}
- MESSAGE( "Manager_i::FindOneComponent " << MyParams->HostName << " " << MyParams->ContainerName ) ;
- MESSAGE( "FindComponents HostName " << MyParams->HostName << " ContainerName " << MyParams->ContainerName
+ 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 ) ) {
exit( 0 ) ;
}
MESSAGE( "Manager_i::FindOneComponent MutexManager pthread_mutex_locked" ) ;
- Engines::Component_ptr aComponent = Find_Component( *MyParams , ComponentName ) ;
+ Engines::Component_ptr aComponent = FindComponentLocked( *MyParams , ComponentName ) ;
if ( pthread_mutex_unlock( &_MutexManager ) ) {
perror("Manager_i::FindOneComponent MutexManager pthread_mutex_unlock ") ;
exit( 0 ) ;
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::FindComponentsMutexManager pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+ MESSAGE( "Manager_i::FindComponentsMutexManager 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 {
_StartContainer = false ;
_EnginesContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ;
if ( _ListOfComponents->length() ) {
- MESSAGE( "FindComponents " << _ListOfComponents->length() << " components" ) ;
+ MESSAGE( "FindComponentsLocked " << _ListOfComponents->length() << " components" ) ;
int i ;
for ( i = 0 ; i < _ListOfComponents->length() ; i++ ) {
- MESSAGE( "FindComponents" << i << " instanceName " << _ListOfComponents[ i ]->instanceName()
+ 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( "FindComponents instanceName " << _EnginesComponent->instanceName() << " interfaceName "
+ MESSAGE( "FindComponentsLocked instanceName " << _EnginesComponent->instanceName() << " interfaceName "
<< _EnginesComponent->interfaceName() << " " << _ListOfComponents->length() << " components" ) ;
_ListOfComponents[ 0 ]->ping() ;
}
else {
- MESSAGE( "FindComponents ComponentName " << ComponentName << " NOT found" ) ;
+ MESSAGE( "FindComponentsLocked ComponentName " << ComponentName << " NOT found" ) ;
}
aListOfComponents = _ListOfComponents ;
}
catch ( ... ) {
- MESSAGE( "Manager_i::FindComponents catched" ) ;
+ MESSAGE( "Manager_i::FindComponentsLocked catched" ) ;
}
- if ( pthread_mutex_unlock( &_MutexManager ) ) {
- perror("Manager_i::FindComponentsMutexManager pthread_mutex_unlock ") ;
- exit( 0 ) ;
- }
- MESSAGE( "Manager_i::FindComponentsMutexManager pthread_mutex_unlocked" ) ;
return aListOfComponents._retn() ;
}
MESSAGE( "Manager_i::FindOrLoad_ComponentPath MutexManager pthread_mutex_locked" ) ;
try {
_StartContainer = true ;
- EnginesComponent = Find_Component( MyParams , ComponentName ) ;
+ EnginesComponent = FindComponentLocked( MyParams , ComponentName ) ;
if ( CORBA::is_nil( EnginesComponent ) ) {
MESSAGE("FindOrLoad_ComponentPath Component not found " << _ComponentName ) ;
// aContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ;
if ( strcmp( MyParams.HostName ,"localhost" ) == 0 ) {
MyParams.HostName = GetHostname().c_str() ;
}
- BEGIN_OF("FindOrLoad_Component( const Containers::MachineParameters & MyParams , const char * ComponentName )");
+ 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 ") ;
MESSAGE( "Manager_i::FindOrLoad_Component MutexManager pthread_mutex_locked" ) ;
try {
_StartContainer = true ;
- EnginesComponent = Find_Component( MyParams , ComponentName ) ;
+ EnginesComponent = FindComponentLocked( MyParams , ComponentName ) ;
if ( CORBA::is_nil( EnginesComponent ) ) {
MESSAGE("FindOrLoad_Component Component not found " << _FullComponentName ) ;
// aContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ;
}
MESSAGE( "Manager_i::FindOrLoad_Component MutexManager pthread_mutex_unlocked" ) ;
if ( !CORBA::is_nil( aContainer ) && CORBA::is_nil( EnginesComponent ) ) {
- MESSAGE("FindOrLoad_Component Component not found ! trying to load " << aFullComponentName ) ;
- string ImplementationPath( "lib" ) ;
- ImplementationPath += ComponentName ;
- ImplementationPath += "Engine.so" ;
+ string ImplementationPath ;
+ if ( MyParams.ContainerType == Engines::Python ) {
+ 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 ) ) {
// 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::Undefined ;
+ 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 {
+ aListOfComponents[ i ]->destroy() ;
+ MESSAGE( "Manager_i::DestroyContainer component destroyed" ) ;
+ }
+ catch ( ... ) {
+ MESSAGE( "Manager_i::DestroyContainer destroy component catched" ) ;
+ }
+ }
+ try {
+ 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 ;
+}
+
vector< string > _ListOfComponentsNames ;
vector< Engines::Component_var > _ListOfEnginesComponents ;
- std::string ContainerName( const char * aComputerContainer ,
- std::string * theComputer ,
- std::string * theContainer ) ;
+// std::string ContainerName( const char * aComputerContainer ,
+// std::string * theComputer ,
+// std::string * theContainer ) ;
Engines::Container_ptr StartContainer( const Containers::MachineParameters & myParams ) ;
Engines::Container_ptr FindOrStartContainerLocked( Containers::MachineParameters & MyParams ,
const char * ComponentName ) ;
- Engines::Component_ptr Find_Component( const Containers::MachineParameters & MyParams ,
- const char * ComponentName ) ;
+ Engines::Component_ptr FindComponentLocked( const Containers::MachineParameters & MyParams ,
+ const char * ComponentName ) ;
+
+ Engines::ListOfComponents * FindComponentsLocked( const Containers::MachineParameters & MyParams ,
+ const char * ComponentName ) ;
public:
virtual Engines::Container_ptr FindContainer( const Containers::MachineParameters & MyParams ) ;
- virtual Engines::Container_ptr FindOneContainer( const char * aContainerName ) ;
+ virtual Engines::Container_ptr FindOneContainer( const char * aHostName ,
+ const char * aContainerName ) ;
virtual Engines::ListOfContainers * FindContainers( const Containers::MachineParameters & MyParams ) ;
virtual Engines::Component_ptr FindComponent( const Containers::MachineParameters & MyParams ,
const char * ComponentName ) ;
- virtual Engines::Component_ptr FindOneComponent( const char * aContainerName ,
+ virtual Engines::Component_ptr FindOneComponent( const char * aHostName ,
+ const char * aContainerName ,
const char * ComponentName ) ;
virtual Engines::ListOfComponents * FindComponents( const Containers::MachineParameters & MyParams ,
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 ) ;
+
} ;
#endif
#ContainersManager_Server -ORBInitRef NameService=corbaname::localhost
-import Engines
-
-import Containers
-
def ContainerParameters( Params ) :
print "ContainerParameters :"
print "Os :",Params.Os
print 'CasRoot ',env.CasRoot
+import Engines
+
+import Containers
+
+import Resources
+
MyContainersMgr = clt.waitNS("/Kernel/ContainersManager",Containers.Manager)
#ResourcesManager_Server -common /home/Salome2/KERNEL_install/share/salome/resources/ResourcesCatalog.xml -ORBInitRef NameService=corbaname::localhost
-import Resources
-
MyResourcesMgr = clt.waitNS("/Kernel/ResourcesManager",Resources.Manager)
MyResourcesMgr.ping()
aContainer = MyContainersMgr.FindContainer( DefaultParams )
print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type()
-aContainer = MyContainersMgr.FindOneContainer( 'FactoryServer' )
+aContainer = MyContainersMgr.FindOneContainer( 'localhost' , 'FactoryServer' )
print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type()
-aContainer = MyContainersMgr.FindOneContainer( 'FactoryServerPy' )
+aContainer = MyContainersMgr.FindOneContainer( 'localhost' , 'FactoryServerPy' )
print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type()
-aContainer = MyContainersMgr.FindOneContainer( 'SuperVisionContainer' )
+aContainer = MyContainersMgr.FindOneContainer( 'localhost' , 'SuperVisionContainer' )
print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type()
-aContainer = MyContainersMgr.FindOneContainer( 'localhost/FactoryServer' )
+aContainer = MyContainersMgr.FindOneContainer( '' , 'SuperVisionContainer' )
print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type()
-aContainer = MyContainersMgr.FindOneContainer( 'bojolex/SuperVisionContainer' )
-if aContainer is None :
- print "None Container : Ok"
-else :
- print "ERROR Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type()
-
DefaultParams.ContainerType = Engines.Cpp
Containers = MyContainersMgr.FindContainers( DefaultParams )
i = 0
print ListOfComponents[ i ].GetContainerRef()._get_name(),ListOfComponents[ i ]._get_instanceName(),ListOfComponents[ i ]._get_interfaceName()
i = i + 1
-aAddComponent = MyContainersMgr.FindOneComponent( 'FactoryServer' , "AddComponent" )
+
+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
+
+aAddComponent = MyContainersMgr.FindOneComponent( '' , 'FactoryServer' , "AddComponent" )
print aAddComponent.GetContainerRef()._get_name(),aAddComponent._get_instanceName(),aAddComponent._get_interfaceName()
-aSubComponent = MyContainersMgr.FindOneComponent( 'FactoryServer' , "SubComponent" )
+aSubComponent = MyContainersMgr.FindOneComponent( '' , 'FactoryServer' , "SubComponent" )
print aSubComponent.GetContainerRef()._get_name(),aSubComponent._get_instanceName(),aSubComponent._get_interfaceName()
-aSUPERVComponent = MyContainersMgr.FindOneComponent( 'SuperVisionContainer' , "SUPERV" )
+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( 'dunex' , '' , "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.Python
+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.Cpp
+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
orb = CORBA.ORB_init([''], CORBA.ORB_ID)
lcc = LifeCycleCORBA( orb )
-t = lcc.FindOrLoadComponent( 'FactoryServer' , 'SalomeTestComponent' )
-print t
+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()
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 = ''
lcctotoMulComponent = lcc.FindOrLoadComponent( DefaultParams , "MulComponent" )
+MyContainersMgr.DestroyContainer( '' , 'FactoryServer' )
+MyContainersMgr.DestroyContainer( '' , 'FactoryServerPy' )
+
+
+DefaultParams.HostName = ''
+DefaultParams.ContainerName = ''
+DefaultParams.ContainerType = Engines.Undefined
+
+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()
MESSAGE ( "Create_Directory : CORBA.COMM_FAILURE" )
+
+ #-------------------------------------------------------------------------
+ def Destroy_Name(self, Path):
+ #MESSAGE ( "SALOME_NamingServicePy_i::Destroy_Name" )
+ path_list = list(Path)
+ if path_list[0]=='/':
+ self._current_context = self._root_context
+ #delete first '/' before split
+ Path=Path[1:]
+
+ result_resolve_path = split(Path,'/')
+ _context_name=[]
+ print "Destroy_Name :"
+ for i in range(len(result_resolve_path)-1):
+ _context_name.append(CosNaming.NameComponent(result_resolve_path[i],"dir"))
+ print result_resolve_path[i],"dir"
+ #_context_name.append(CosNaming.NameComponent(result_resolve_path[len(result_resolve_path)-1],"object"))
+ print result_resolve_path[len(result_resolve_path)-1],"object"
+ try:
+ self._obj = self._current_context.resolve( _context_name )
+ self._current_context = self._obj._narrow(CosNaming.NamingContext)
+ _context_name=[]
+ _context_name.append(CosNaming.NameComponent(result_resolve_path[len(result_resolve_path)-1],"object"))
+ self._current_context.unbind( _context_name );
+ except CosNaming.NamingContext.NotFound, ex:
+ MESSAGE ( "Resolve : CosNaming.NamingContext.NotFound" )
+ self._obj = None
+ except CosNaming.NamingContext.InvalidName, ex:
+ MESSAGE ( "Resolve : CosNaming.NamingContext.InvalidName" )
+ self._obj = None
+ except CosNaming.NamingContext.CannotProceed, ex:
+ MESSAGE ( "Resolve : CosNaming.NamingContext.CannotProceed" )
+ self._obj = None
+ except CORBA.COMM_FAILURE, ex:
+ MESSAGE ( "Resolve : CORBA.COMM_FAILURE" )
+ self._obj = None
+
+
+
LIB = libSalomeTestComponentEngine.la
LIB_SRC = SALOME_TestComponent_i.cxx
-LIB_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl
+LIB_CLIENT_IDL = ContainersManager.idl SALOME_Component.idl SALOME_TestComponent.idl
# Executables targets
BIN = TestContainer TestLogger
return result
def __init__(self, orb, poa, contID, containerName, instanceName, interfaceName):
+ print "SALOME_TestComponentPy::__init__ --> SALOME_ComponentPy_i.__init__"
notif = 0
SALOME_ComponentPy_i.__init__(self, orb, poa, contID, containerName,
instanceName, interfaceName, notif)
- print "SALOME_TestComponentPy::__init__"
+ self._Id = self._poa.reference_to_id( self._this() )
+ print "SALOME_TestComponentPy::__init__ done"
# Module : SALOME
# $Header$
+#python /home/Salome2/KERNEL_install/bin/salome/SALOME_ContainerPy.py TestContainerPy
+
import os
import sys
import string
from omniORB import CORBA
import CosNaming
+
import Engines
+import Containers
+
+import SALOME_TestComponent_idl
#initialise the ORB
orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
print "Name Service Reference is invalid"
sys.exit(1)
-#resolve the name /Containers.dir/FactoryServerPy.object
-myMachine=string.split(os.getenv( "HOSTNAME" ),'.')
-machineName= myMachine[0]
-containerName = "FactoryServerPy"
-name = [CosNaming.NameComponent("Containers","dir"),
- CosNaming.NameComponent(machineName,"dir"),
- CosNaming.NameComponent(containerName,"object")]
+name = [CosNaming.NameComponent("Kernel","dir"),
+ CosNaming.NameComponent("ContainersManager","object")]
try:
- obj = rootContext.resolve(name)
+ obj = rootContext.resolve( name )
except CosNaming.NamingContext.NotFound, ex:
- print containerName , " not found in Naming Service"
+ print "/Kernel/ContainersManager not found in Naming Service"
sys.exit(1)
-container = obj._narrow(Engines.Container)
-print container._get_machineName()
-comp = container.load_impl("SALOME_TestComponentPy","SALOME_TestComponentPy")
-print comp._get_instanceName()
+MyContainersMgr = obj._narrow(Containers.Manager)
+
+MyContainersMgr.ping()
+
+Params = MyContainersMgr.Parameters()
+
+Params.ContainerName = 'TestContainerPy'
+Params.ContainerType = Engines.Python
+
+comp = MyContainersMgr.FindOrLoad_Component( Params , "SALOME_TestComponentPy" )
comp.ping()
+
comptest = comp._narrow(Engines.TestComponent)
if comptest is None:
- print "probleme cast"
-print comptest.Coucou(1)
+ print "probleme narrow(Engines.TestComponent)"
+ sys.exit(1)
+
+print "comptest",comptest.Coucou(1)
+
+container = comptest.GetContainerRef()
+container.ping()
+print "container._get_name()",container._get_name()
+print "container._get_machineName()",container._get_machineName()
+
+comptest.destroy()
+print "Component SALOME_TestComponentPy destroyed"
+
+try :
+ container.destroy()
+except :
+ print ""
+
+print "Container TestContainerPy destroyed"
+
+
+from LifeCycleCORBA import *
+lcc = LifeCycleCORBA( orb )
+
+lcccomptest = lcc.FindOrLoadComponent( 'TestContainerPy' , 'SALOME_TestComponentPy' )
+
+print "lcccomptest",lcccomptest.Coucou(1)
+
+lcccontainer = lcccomptest.GetContainerRef()
+lcccontainer.ping()
+print "lcccontainer._get_name()",lcccontainer._get_name()
+print "lcccontainer._get_machineName()",lcccontainer._get_machineName()
+
+lcccomptest.destroy()
+print "Component SALOME_TestComponentPy destroyed"
+
+try :
+ lcccontainer.destroy()
+except :
+ print ""
+
+print "Container TestContainerPy destroyed"
#include <unistd.h>
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(SALOME_Component)
+#include CORBA_CLIENT_HEADER(ContainersManager)
#include CORBA_CLIENT_HEADER(SALOME_TestComponent)
#include "SALOME_NamingService.hxx"
#include "Utils_SINGLETON.hxx"
#include "Utils_SALOME_Exception.hxx"
#include "Utils_CommException.hxx"
+
using namespace std;
int main (int argc, char * argv[])
SALOME_NamingService _NS(orb) ;
string containerName = "/Containers/" ;
string hostName = GetHostname();
- containerName += hostName + "/FactoryServer";
+ containerName += hostName + "/TestContainerCpp";
+ Engines::Container_var iGenFact = Engines::Container::_nil() ;
obj = _NS.Resolve(containerName.c_str()) ;
- Engines::Container_var iGenFact = Engines::Container::_narrow(obj);
-
+ if ( !CORBA::is_nil( obj ) ) {
+ try {
+ iGenFact = Engines::Container::_narrow( obj ) ;
+ iGenFact->ping() ;
+ }
+ catch ( ... ) {
+ INFOS("TestContainerCpp unreachable") ;
+ }
+ }
+ if ( CORBA::is_nil( iGenFact ) ) {
+ obj = _NS.Resolve( "/Kernel/ContainersManager" ) ;
+ if ( !CORBA::is_nil( obj ) ) {
+ try {
+ Containers::Manager_var MyContainersMgr = Containers::Manager::_narrow( obj ) ;
+ MyContainersMgr->ping() ;
+ Containers::MachineParameters * Params = MyContainersMgr->Parameters() ;
+ Params->ContainerName = "TestContainerCpp" ;
+ iGenFact = MyContainersMgr->FindOrStartContainer( *Params ) ;
+ }
+ catch ( ... ) {
+ INFOS("ContainersManager unreachable") ;
+ }
+ }
+ }
Engines::TestComponent_var m1;
for (int iter = 0; iter < 3 ; iter++)
// Clean-up.
iGenFact->finalize_removal() ;
INFOS("finalize_removal done" );
+ iGenFact->destroy() ;
+ INFOS("Container destroyed" );
orb->destroy();
INFOS("orb destroyed" );
}