-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#include "SALOME_LifeCycleCORBA.hxx"
#include "SALOME_ResourcesManager.hxx"
#include "SALOMESDS_DataServerManager.hxx"
+#include "SALOME_ExternalServerLauncher.hxx"
#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
#include CORBA_CLIENT_HEADER(SALOME_Session)
*/
//=============================================================================
-SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService *ns)
+SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService_Abstract *ns)
{
// be sure to have an instance of traceCollector, when used via SWIG
// in a Python module
// (in SALOMEDS for an example)
// not enough: set a current directory in naming service is not thread safe
// if naming service instance is shared among several threads...
- // ==> allways use absolute path and dot rely on current directory!
-
- CORBA::Object_var obj =
- _NS->Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS);
- if (CORBA::is_nil(obj))
- throw SALOME_Exception("Error: Cannot resolve ContainerManager in Naming Service");
- _ContManager=Engines::ContainerManager::_narrow(obj);
-
- obj = _NS->Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS);
- if (CORBA::is_nil(obj))
- throw SALOME_Exception("Error: Cannot resolve ResourceManager in Naming Service");
- _ResManager=Engines::ResourcesManager::_narrow(obj);
+ // ==> always use absolute path and don't rely on current directory!
+ //if( dynamic_cast<SALOME_NamingService *>(_NS) )
+ {
+ CORBA::Object_var obj =
+ _NS->Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS);
+ if (CORBA::is_nil(obj))
+ throw SALOME_Exception("Error: Cannot resolve ContainerManager in Naming Service");
+ _ContManager=Engines::ContainerManager::_narrow(obj);
+
+ obj = _NS->Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS);
+ if (CORBA::is_nil(obj))
+ throw SALOME_Exception("Error: Cannot resolve ResourceManager in Naming Service");
+ _ResManager=Engines::ResourcesManager::_narrow(obj);
+ }
}
//=============================================================================
*
* \param params container parameters like type or name...
* \param componentName the name of component class
- * \param studyId default = 0 : multistudy instance
* \return a CORBA reference of the component instance, or _nil if not found
*/
//=============================================================================
Engines::EngineComponent_ptr
SALOME_LifeCycleCORBA::FindComponent(const Engines::ContainerParameters& params,
- const char *componentName,
- int studyId)
+ const char *componentName)
{
if (! isKnownComponentClass(componentName))
return Engines::EngineComponent::_nil();
{
listOfResources = _ResManager->GetFittingResources(new_params.resource_params);
}
- catch( const SALOME::SALOME_Exception& ex )
+ catch( const SALOME::SALOME_Exception& /*ex*/ ) //!< TODO: unused variable
{
return Engines::EngineComponent::_nil();
}
Engines::EngineComponent_var compo = _FindComponent(new_params,
componentName,
- studyId,
listOfResources);
return compo._retn();
*
* \param params container parameters like type or name...
* \param componentName the name of component class
- * \param studyId default = 0 : multistudy instance
* \return a CORBA reference of the component instance, or _nil if problem
*/
//=============================================================================
Engines::EngineComponent_ptr
SALOME_LifeCycleCORBA::LoadComponent(const Engines::ContainerParameters& params,
- const char *componentName,
- int studyId)
+ const char *componentName)
{
// --- Check if Component Name is known in ModuleCatalog
{
listOfResources = _ResManager->GetFittingResources(new_params.resource_params);
}
- catch( const SALOME::SALOME_Exception& ex )
+ catch( const SALOME::SALOME_Exception& /*ex*/ ) //!< TODO: unused variable
{
return Engines::EngineComponent::_nil();
}
new_params.resource_params.resList = listOfResources;
Engines::EngineComponent_var compo = _LoadComponent(new_params,
- componentName,
- studyId);
+ componentName);
return compo._retn();
}
*
* \param params container parameters like type or name...
* \param componentName the name of component class
- * \param studyId default = 0 : multistudy instance
* \return a CORBA reference of the component instance, or _nil if problem
*/
//=============================================================================
Engines::EngineComponent_ptr
SALOME_LifeCycleCORBA::
FindOrLoad_Component(const Engines::ContainerParameters& params,
- const char *componentName,
- int studyId)
+ const char *componentName)
{
// --- Check if Component Name is known in ModuleCatalog
{
listOfResources = _ResManager->GetFittingResources(new_params.resource_params);
}
- catch( const SALOME::SALOME_Exception& ex )
+ catch( const SALOME::SALOME_Exception& /*ex*/ ) //!< TODO: unused variable
{
return Engines::EngineComponent::_nil();
}
Engines::EngineComponent_var compo = _FindComponent(new_params,
- componentName,
- studyId,
- listOfResources);
+ componentName,
+ listOfResources);
if(CORBA::is_nil(compo))
{
new_params.resource_params.resList = listOfResources;
compo = _LoadComponent(new_params,
- componentName,
- studyId);
+ componentName);
}
return compo._retn();
// --- Check if containerName contains machine name (if yes: rg>0)
char *stContainer=strdup(containerName);
std::string st2Container(stContainer);
- int rg=st2Container.find("/");
+ size_t rg=st2Container.find("/");
Engines::ContainerParameters params;
preSet(params);
- if (rg<0)
+ if (rg == std::string::npos)
{
// containerName doesn't contain "/" => Local container
params.container_name = CORBA::string_dup(stContainer);
*/
//=============================================================================
-void SALOME_LifeCycleCORBA::shutdownServers()
+void SALOME_LifeCycleCORBA::shutdownServers(bool shutdownLauncher)
{
// get each Container from NamingService => shutdown it
// (the order is inverse to the order of servers initialization)
if ( !CORBA::is_nil(connMan) && ( pid != connMan->getPID() ) )
connMan->ShutdownWithExit();
}
- catch(const CORBA::Exception& e)
+ catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
{
// ignore and continue
}
// 2) SALOMEDS
try
{
- CORBA::Object_var objSDS = _NS->Resolve("/myStudyManager");
- SALOMEDS::StudyManager_var studyManager = SALOMEDS::StudyManager::_narrow(objSDS) ;
- if ( !CORBA::is_nil(studyManager) && ( pid != studyManager->getPID() ) )
- studyManager->Shutdown();
+ CORBA::Object_var objSDS = _NS->Resolve("/Study");
+ SALOMEDS::Study_var study = SALOMEDS::Study::_narrow(objSDS) ;
+ if ( !CORBA::is_nil(study) && ( pid != study->getPID() ) )
+ study->Shutdown();
+ _NS->Destroy_Name("/Study");
}
- catch(const CORBA::Exception& e)
+ catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
{
// ignore and continue
}
SALOME_ModuleCatalog::ModuleCatalog_var catalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objMC);
if ( !CORBA::is_nil(catalog) && ( pid != catalog->getPID() ) )
catalog->shutdown();
+ _NS->Destroy_Name("/Kernel/ModulCatalog");
}
- catch(const CORBA::Exception& e)
+ catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
{
// ignore and continue
}
#ifndef WIN32
nanosleep(&ts_req,0);
#endif
- // 4 ) Remote ScopeServer (the DataServer is hosted by SalomeLauncher shutdown right after)
+ // 4 ) Remote ScopeServer (the DataServer is hosted by SalomeLauncher shutdown right after on point 6)
try
{
CORBA::Object_var objDSM(_NS->Resolve(SALOMESDS::DataServerManager::NAME_IN_NS));
if ( !CORBA::is_nil(dsm) )
dsm->shutdownScopes();
}
- catch(const CORBA::Exception& e)
+ catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
{
// ignore and continue
}
-
- // 5) SalomeLauncher
+ // 5) External server launcher (the ExternalServer is hosted by SalomeLauncher shutdown right after on point 6)
+ try
+ {
+ CORBA::Object_var objDSM(_NS->Resolve(SALOME_ExternalServerLauncher::NAME_IN_NS));
+ SALOME::ExternalServerLauncher_var dsm(SALOME::ExternalServerLauncher::_narrow(objDSM));
+ if ( !CORBA::is_nil(dsm) )
+ dsm->shutdownServers();
+ }
+ catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
+ {
+ // ignore and continue
+ }
+ // 6) SalomeLauncher
try
{
- CORBA::Object_var objSL = _NS->Resolve("/SalomeLauncher");
- Engines::SalomeLauncher_var launcher = Engines::SalomeLauncher::_narrow(objSL);
- if (!CORBA::is_nil(launcher) && (pid != launcher->getPID()))
- launcher->Shutdown();
+ if(shutdownLauncher){
+ CORBA::Object_var objSL = _NS->Resolve("/SalomeLauncher");
+ Engines::SalomeLauncher_var launcher = Engines::SalomeLauncher::_narrow(objSL);
+ if (!CORBA::is_nil(launcher) && (pid != launcher->getPID()))
+ launcher->Shutdown();
+ }
}
- catch(const CORBA::Exception& e)
+ catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
{
// ignore and continue
}
Registry::Components_var registry = Registry::Components::_narrow(objR);
if ( !CORBA::is_nil(registry) && ( pid != registry->getPID() ) )
registry->Shutdown();
+ _NS->Destroy_Name("/Registry");
}
- catch(const CORBA::Exception& e)
+ catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
{
// ignore and continue
}
*
* \param params machine parameters like type or name...
* \param componentName the name of component class
- * \param studyId default = 0 : multistudy instance
* \param listOfMachines list of machine address
* \return a CORBA reference of the component instance, or _nil if not found
*/
SALOME_LifeCycleCORBA::
_FindComponent(const Engines::ContainerParameters& params,
const char *componentName,
- int studyId,
const Engines::ResourceList& listOfResources)
{
// --- build the list of machines on which the component is already running
*
* \param params machine parameters like type or name...
* \param componentName the name of component class
- * \param studyId default = 0 : multistudy instance
* \return a CORBA reference of the component instance, or _nil if problem
*/
//=============================================================================
Engines::EngineComponent_ptr
SALOME_LifeCycleCORBA::
_LoadComponent(const Engines::ContainerParameters& params,
- const char *componentName,
- int studyId)
+ const char *componentName)
{
MESSAGE("_LoadComponent, required " << params.container_name <<
" " << componentName << " " << NbProc(params));
CORBA::string_free(reason);
Engines::EngineComponent_var myInstance =
- cont->create_component_instance(componentName, studyId);
+ cont->create_component_instance(componentName);
return myInstance._retn();
}
*
* \param params machine parameters like type or name...
* \param componentName the name of component class
- * \param studyId default = 0 : multistudy instance
* \return a CORBA reference of the parallel component instance, or _nil if problem
*/
//=============================================================================
Engines::EngineComponent_ptr
SALOME_LifeCycleCORBA::Load_ParallelComponent(const Engines::ContainerParameters& params,
- const char *componentName,
- int studyId)
+ const char *componentName)
{
MESSAGE("Entering LoadParallelComponent");
// @PARALLEL@ permits to identify that the component requested
// is a parallel component.
std::string name = std::string(componentName);
- Engines::EngineComponent_var myInstance = cont->create_component_instance(name.c_str(), studyId);
+ Engines::EngineComponent_var myInstance = cont->create_component_instance(name.c_str());
if (CORBA::is_nil(myInstance))
INFOS("create_component_instance returns a NULL component !");
return myInstance._retn();
*
* \return the naming service
*/
-SALOME_NamingService * SALOME_LifeCycleCORBA::namingService()
+SALOME_NamingService_Abstract * SALOME_LifeCycleCORBA::namingService()
{
return _NS;
}
*/
CORBA::ORB_ptr SALOME_LifeCycleCORBA::orb()
{
- return _NS->orb();
+ SALOME_NamingService *NSC = dynamic_cast<SALOME_NamingService *>(_NS);
+ if(!_NS)
+ THROW_SALOME_EXCEPTION("SALOME_LifeCycleCORBA::orb : not a CORBA SALOME_NamingService ");
+ return NSC->orb();
}