if ( _EnginesContainer->type() == MyParams.ContainerType ) {
int size = _ListOfContainers->length() ;
_ListOfContainers->length( size + 1 ) ;
- _ListOfContainers[ size ] = _EnginesContainer ;
+ _ListOfContainers[ size ] = Engines::Container::_duplicate( _EnginesContainer ) ;
MESSAGE( "Manager_i::FindContainers --> " << _EnginesContainer->machineName() << " "
<< _EnginesContainer->name() << " " << _EnginesContainer->type() ) ;
}
_EnginesContainer->type() == MyParams.ContainerType ) {
int size = _ListOfContainers->length() ;
_ListOfContainers->length( size + 1 ) ;
- _ListOfContainers[ size ] = _EnginesContainer ;
+ _ListOfContainers[ size ] = Engines::Container::_duplicate( _EnginesContainer );
MESSAGE( "Manager_i::FindContainers --> " << _EnginesContainer->machineName() << " "
<< _EnginesContainer->name() << " " << _EnginesContainer->type() ) ;
}
exit( 0 ) ;
}
MESSAGE( "MutexManager pthread_mutex_locked" ) ;
- _StartContainer = true ;
- _EnginesContainer = FindOrStartContainerLocked( MyParams , "" ) ;
+ try {
+ _StartContainer = true ;
+ _EnginesContainer = FindOrStartContainerLocked( MyParams , "" ) ;
+ }
+ catch ( ... ) {
+ MESSAGE(" catch") ;
+ }
if ( pthread_mutex_unlock( &_MutexManager ) ) {
perror("MutexManager pthread_nriContainmutex_unlock ") ;
exit( 0 ) ;
_ListOfComponents->length( 0 ) ;
_ListOfContainers = FindContainers( myParams ) ;
_ComponentName = aComponentName ;
- MESSAGE( "MutexManager FindOrStartContainerLocked " << _ListOfContainers->length() << " containers found" ) ;
+ MESSAGE( "MutexManager FindOrStartContainerLocked " << _ListOfContainers->length() << " containers found"
+ << " CORBA::is_nil( _EnginesContainer ) " << CORBA::is_nil( _EnginesContainer ) ) ;
if ( _ListOfContainers->length() ) {
+ _EnginesContainer = Engines::Container::_nil() ;
int i ;
for ( i = 0 ; i < _ListOfContainers->length() && CORBA::is_nil( _EnginesContainer ) ; i++ ) {
_FullHostName = "/Containers/" ;
- _HostName += _ListOfContainers[ i ]->machineName() ;
+ char * aHostName = _ListOfContainers[ i ]->machineName() ;
+ _HostName = string( aHostName ) ;
_FullHostName += _HostName ;
- _ContainerName = _ListOfContainers[ i ]->name() ;
+ char * aContainerName = _ListOfContainers[ i ]->name() ;
+ aContainerName = strrchr( aContainerName , '/' ) + 1 ;
+ _ContainerName = string( aContainerName ) ;
_FullContainerName = _FullHostName + "/" + _ContainerName ;
+ MESSAGE( "Manager_i::FindOrStartContainerLocked Container " << _FullContainerName << " searched Component "
+ << _ComponentName << " " << aContainerName << " " << _ContainerName ) ;
if ( strlen( _ComponentName.c_str() ) ) {
_FullComponentName = _FullContainerName + "/" + _ComponentName ;
+ MESSAGE( "Manager_i::FindOrStartContainerLocked Component " << _FullComponentName ) ;
_ComponentObject = _NamingService->Resolve( _FullComponentName.c_str() ) ;
if ( !CORBA::is_nil( _ComponentObject ) ) {
_EnginesContainer = _ListOfContainers[ i ] ;
MESSAGE( "Manager_i::FindOrStartContainerLocked --> " << _EnginesContainer->machineName() << " "
- << _EnginesContainer->name() ) ;
- _EnginesComponent = Engines::Component::_narrow( _ComponentObject ) ;
+ << _EnginesContainer->name() << " Component " << _ComponentName ) ;
+ _EnginesComponent = Engines::Component::_duplicate( Engines::Component::_narrow( _ComponentObject ) ) ;
int size = _ListOfComponents->length() ;
_ListOfComponents->length( size + 1 ) ;
- _ListOfComponents[ size ] = _EnginesComponent ;
+ _ListOfComponents[ size ] = Engines::Component::_duplicate( _EnginesComponent ) ;
MESSAGE( "Manager_i::FindOrStartContainerLocked --> " << _EnginesComponent->instanceName() << " "
<< _EnginesComponent->interfaceName() ) ;
}
else {
- MESSAGE( "Manager_i::FindOrStartContainerLocked --> " << _EnginesContainer->machineName() << " "
- << _EnginesContainer->name() << " " << _ComponentName << " NOT found" ) ;
+ MESSAGE( "Manager_i::FindOrStartContainerLocked --> " << myParams.HostName << " "
+ << myParams.ContainerName << " " << _ComponentName << " NOT found" ) ;
}
}
else {
+ _EnginesContainer = _ListOfContainers[ i ] ;
if ( _NamingService->Change_Directory( _FullContainerName.c_str() ) ) {
vector<string> theListOfComponents = _NamingService->list_directory() ;
MESSAGE( "Manager_i::FindOrStartContainerLocked " << theListOfComponents.size()
int j ;
for ( j = 0 ; j < theListOfComponents.size() ; j++ ) {
_FullComponentName = _FullContainerName + "/" + theListOfComponents[ j ] ;
- MESSAGE( "Manager_i::FindOrStartContainerLocked " << j << " " << _FullComponentName ) ;
+ MESSAGE( "Manager_i::FindOrStartContainerLocked " << j << " Component " << _FullComponentName ) ;
_ComponentObject = _NamingService->Resolve( _FullComponentName.c_str() ) ;
if ( !CORBA::is_nil( _ComponentObject ) ) {
- _EnginesContainer = _ListOfContainers[ i ] ;
MESSAGE( "Manager_i::FindOrStartContainerLocked --> " << _EnginesContainer->machineName() << " "
<< _EnginesContainer->name() ) ;
- _EnginesComponent = Engines::Component::_narrow( _ComponentObject ) ;
+ _EnginesComponent = Engines::Component::_duplicate( Engines::Component::_narrow( _ComponentObject ) ) ;
int size = _ListOfComponents->length() ;
_ListOfComponents->length( size + 1 ) ;
- _ListOfComponents[ size ] = _EnginesComponent ;
+ _ListOfComponents[ size ] = Engines::Component::_duplicate( _EnginesComponent ) ;
MESSAGE( "Manager_i::FindOrStartContainerLocked --> " << _EnginesComponent->instanceName()
<< " " << _EnginesComponent->interfaceName() ) ;
}
}
}
}
+ else if ( !CORBA::is_nil( _EnginesContainer ) && strlen( _ComponentName.c_str() ) ) {
+ _FullComponentName = _FullContainerName + "/" + _ComponentName ;
+ MESSAGE( "Manager_i::FindOrStartContainerLocked Component " << _FullComponentName ) ;
+ _ComponentObject = _NamingService->Resolve( _FullComponentName.c_str() ) ;
+ if ( !CORBA::is_nil( _ComponentObject ) ) {
+ MESSAGE( "Manager_i::FindOrStartContainerLocked --> " << _EnginesContainer->machineName() << " "
+ << _EnginesContainer->name() << " Component " << _ComponentName ) ;
+ _EnginesComponent = Engines::Component::_duplicate( Engines::Component::_narrow( _ComponentObject ) ) ;
+ MESSAGE( "Manager_i::FindOrStartContainerLocked --> " << _EnginesComponent->instanceName() << " "
+ << _EnginesComponent->interfaceName() ) ;
+ }
+ else {
+ MESSAGE( "Manager_i::FindOrStartContainerLocked --> " << myParams.HostName << " "
+ << myParams.ContainerName << " " << _ComponentName << " NOT found" ) ;
+ }
+ }
if ( CORBA::is_nil( _EnginesContainer ) && _StartContainer ) {
StartContainer( myParams ) ;
}
Engines::Container_ptr Manager_i::StartContainer( const Containers::MachineParameters & myParams ) {
Containers::MachineParameters MyParams = (Containers::MachineParameters & ) myParams ;
if ( _ListOfContainers->length() ) {
- MyParams.HostName = _ListOfContainers[ 0 ]->machineName() ;
- MyParams.ContainerName = _ListOfContainers[ 0 ]->name() ;
+ MyParams.HostName = CORBA::string_dup( _ListOfContainers[ 0 ]->machineName() ) ;
+ char * aContainerName = _ListOfContainers[ 0 ]->name() ;
+ aContainerName = strrchr( aContainerName , '/' ) + 1 ;
+ MyParams.ContainerName = CORBA::string_dup( aContainerName ) ;
}
else if ( _ListOfComputers->length() ) {
- MyParams.HostName = _ListOfComputers[ 0 ]->Alias() ;
+ MyParams.HostName = CORBA::string_dup( _ListOfComputers[ 0 ]->Alias() ) ;
if ( strlen( MyParams.ContainerName ) == 0 ) {
if ( MyParams.ContainerType == Engines::Cpp ) {
MyParams.ContainerName = "FactoryServer" ;
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" ) ;
+ }
+ else {
+ MESSAGE( "FindComponent instanceName " << _EnginesComponent->instanceName() << " interfaceName "
+ << _EnginesComponent->interfaceName() ) ;
+ }
return Engines::Component::_duplicate( _EnginesComponent ) ;
}
if ( strcmp( MyParams.HostName ,"localhost" ) == 0 ) {
MyParams.HostName = GetHostname().c_str() ;
}
+ MESSAGE( "FindComponents HostName " << MyParams.HostName << " ContainerName " << MyParams.ContainerName
+ << " ComponentName " << ComponentName ) ;
_StartContainer = false ;
_EnginesContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ;
- _ListOfComponents._retn() ;
+ if ( _ListOfComponents->length() ) {
+ MESSAGE( "FindComponents " << _ListOfComponents->length() << " components" ) ;
+ int i ;
+ for ( i = 0 ; i < _ListOfComponents->length() ; i++ ) {
+ MESSAGE( "FindComponents" << 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 "
+ << _EnginesComponent->interfaceName() << " " << _ListOfComponents->length() << " components" ) ;
+ _ListOfComponents[ 0 ]->ping() ;
+ }
+ else {
+ MESSAGE( "FindComponents ComponentName " << ComponentName << " NOT found" ) ;
+ }
+ return _ListOfComponents._retn() ;
}
Engines::Component_ptr Manager_i::FindOrLoad_ComponentPath( const Containers::MachineParameters & myParams ,
const char * ComponentName ,
const char * ImplementationPath ) {
+ Engines::Container_var aContainer = Engines::Container::_nil() ;
+ Engines::Component_var EnginesComponent = Engines::Component::_nil() ;
Containers::MachineParameters MyParams = (Containers::MachineParameters & ) myParams ;
if ( strcmp( MyParams.HostName ,"localhost" ) == 0 ) {
MyParams.HostName = GetHostname().c_str() ;
exit( 0 ) ;
}
MESSAGE( "MutexManager pthread_mutex_locked" ) ;
- Engines::Container_var aContainer = Engines::Container::_nil() ;
- Engines::Component_var EnginesComponent = FindComponent( MyParams , ComponentName ) ;
- if ( CORBA::is_nil( EnginesComponent ) ) {
- _StartContainer = true ;
- aContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ;
+ try {
+ EnginesComponent = FindComponent( MyParams , ComponentName ) ;
+ if ( CORBA::is_nil( EnginesComponent ) ) {
+ _StartContainer = true ;
+ aContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ;
+ }
+ else {
+ aContainer = _EnginesContainer ;
+ }
}
- else {
- aContainer = _EnginesContainer ;
+ catch ( ... ) {
+ MESSAGE(" catch") ;
}
if ( pthread_mutex_unlock( &_MutexManager ) ) {
perror("MutexManager pthread_mutex_unlock ") ;
Engines::Component_ptr Manager_i::FindOrLoad_Component( const Containers::MachineParameters & myParams ,
const char * ComponentName ) {
+ Engines::Container_var aContainer = Engines::Container::_nil() ;
+ Engines::Component_var EnginesComponent = Engines::Component::_nil() ;
Containers::MachineParameters MyParams = (Containers::MachineParameters & ) myParams ;
if ( strcmp( MyParams.HostName ,"localhost" ) == 0 ) {
MyParams.HostName = GetHostname().c_str() ;
exit( 0 ) ;
}
MESSAGE( "MutexManager pthread_mutex_locked" ) ;
- Engines::Container_var aContainer = Engines::Container::_nil() ;
- Engines::Component_var EnginesComponent = FindComponent( MyParams , ComponentName ) ;
- if ( CORBA::is_nil( EnginesComponent ) ) {
- _StartContainer = true ;
- aContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ;
+ try {
+ EnginesComponent = FindComponent( MyParams , ComponentName ) ;
+ if ( CORBA::is_nil( EnginesComponent ) ) {
+ MESSAGE("Component not found " << _ComponentName << " --> FindOrStartContainerLocked" ) ;
+ _StartContainer = true ;
+ aContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ;
+ }
+ else {
+ aContainer = _EnginesContainer ;
+ }
}
- else {
- aContainer = _EnginesContainer ;
+ catch ( ... ) {
+ MESSAGE(" catch") ;
}
if ( pthread_mutex_unlock( &_MutexManager ) ) {
perror("MutexManager pthread_mutex_unlock ") ;
print 'ListOfComputers',len( ListOfComputers ),'computers found'
if len( ListOfComputers ) > 0 :
print "Error",len( ListOfComputers ),"Computers found"
-
-i = 0
-while i < len( ListOfComputers ) :
- print ''
- ComputerParameters( ListOfComputers[i].Parameters() )
- ComputerEnvironement( ListOfComputers[i].Environment() )
- i = i + 1
+ i = 0
+ while i < len( ListOfComputers ) :
+ print ''
+ ComputerParameters( ListOfComputers[i].Parameters() )
+ ComputerEnvironement( ListOfComputers[i].Environment() )
+ i = i + 1
aComputer = MyResourcesMgr.SelectComputer( DefaultParams )
if aComputer is None :
xmenServer.ping()
-component = MyContainersMgr.FindOrLoadComponent( DefaultParams , "AddComponent" )
+component = MyContainersMgr.FindOrLoad_Component( DefaultParams , "AddComponent" )
Containers = MyContainersMgr.FindContainers( DefaultParams )
+if len( Containers ) == 0 :
+ print len( Containers ),"found Error"
+DefaultParams.Memory = 0
DefaultParams.ContainerName = ''
+DefaultParams.ContainerType = Engines.Undefined
+Containers = MyContainersMgr.FindContainers( DefaultParams )
+i = 0
+while i < len( Containers ) :
+ print "Container running on",Containers[ i ]._get_machineName(),"with name",Containers[ i ]._get_name(),"and type",Containers[ i ].type()
+ i = i + 1
+
+DefaultParams.ContainerType = Engines.Cpp
+Containers = MyContainersMgr.FindContainers( DefaultParams )
+i = 0
+while i < len( Containers ) :
+ print "Container running on",Containers[ i ]._get_machineName(),"with name",Containers[ i ]._get_name(),"and type",Containers[ i ].type()
+ i = i + 1
+
+DefaultParams.ContainerType = Engines.Python
Containers = MyContainersMgr.FindContainers( DefaultParams )
+i = 0
+while i < len( Containers ) :
+ print "Container running on",Containers[ i ]._get_machineName(),"with name",Containers[ i ]._get_name(),"and type",Containers[ i ].type()
+ i = i + 1
+
+ContainerParameters( DefaultParams )
+
+DefaultParams.ContainerType = Engines.Cpp
+DefaultParams.ContainerName = 'FactoryServer'
+FactoryServerAddComponent = MyContainersMgr.FindOrLoad_Component( DefaultParams , "AddComponent" )
+FactoryServerAddComponent._get_instanceName()
+FactoryServerAddComponent._get_interfaceName()
+
+AddComponent = MyContainersMgr.FindComponent( DefaultParams , 'AddComponent' )
+AddComponent._get_instanceName()
+AddComponent._get_interfaceName()
+
+ListOfAddComponent = MyContainersMgr.FindComponents( DefaultParams , 'AddComponent' )
+
+FactoryServeSubComponent = MyContainersMgr.FindOrLoad_Component( DefaultParams , "SubComponent" )
+
+from LifeCycleCORBA import *
+orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+lcc = LifeCycleCORBA( orb )
+
+DefaultParams.ContainerName = 'SuperVisionContainer'
+
+lccMulComponent = lcc.FindOrLoadComponent( 'SuperVisionContainer' , "MulComponent" )
+
+DefaultParams.ContainerName = 'DivComponentContainer'
+
+lccDivComponent = lcc.FindOrLoadComponent( 'DivComponentContainer' , "DivComponent" )