From d7fa9896e7d62008608b99b50ec6f9a17e20cad6 Mon Sep 17 00:00:00 2001 From: caremoli Date: Thu, 15 Apr 2010 08:45:58 +0000 Subject: [PATCH] CCAR: add default resource in Resource Mananger (localhost) and catch salome_exception in LifeCycle --- src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx | 40 +++++++++++++++++-- src/ResourcesManager/ResourcesManager.cxx | 2 +- .../SALOME_ResourcesCatalog_Handler.cxx | 7 ++++ 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index 491f4ff3f..41481e449 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -140,7 +140,15 @@ SALOME_LifeCycleCORBA::FindComponent(const Engines::MachineParameters& params, convert(params, new_params); new_params.resource_params.componentList.length(1); new_params.resource_params.componentList[0] = componentName; - Engines::ResourceList_var listOfResources = _ResManager->GetFittingResources(new_params.resource_params); + Engines::ResourceList_var listOfResources; + try + { + listOfResources = _ResManager->GetFittingResources(new_params.resource_params); + } + catch( const SALOME::SALOME_Exception& ex ) + { + return Engines::Component::_nil(); + } Engines::Component_var compo = _FindComponent(new_params, componentName, @@ -175,7 +183,15 @@ SALOME_LifeCycleCORBA::LoadComponent(const Engines::MachineParameters& params, new_params.resource_params.componentList.length(1); new_params.resource_params.componentList[0] = componentName; - Engines::ResourceList_var listOfResources = _ResManager->GetFittingResources(new_params.resource_params); + Engines::ResourceList_var listOfResources; + try + { + listOfResources = _ResManager->GetFittingResources(new_params.resource_params); + } + catch( const SALOME::SALOME_Exception& ex ) + { + return Engines::Component::_nil(); + } new_params.resource_params.resList = listOfResources; Engines::Component_var compo = _LoadComponent(new_params, @@ -219,7 +235,15 @@ FindOrLoad_Component(const Engines::MachineParameters& params, new_params.resource_params.name = CORBA::string_dup(Kernel_Utils::GetHostname().c_str()); } - Engines::ResourceList_var listOfResources = _ResManager->GetFittingResources(new_params.resource_params); + Engines::ResourceList_var listOfResources; + try + { + listOfResources = _ResManager->GetFittingResources(new_params.resource_params); + } + catch( const SALOME::SALOME_Exception& ex ) + { + return Engines::Component::_nil(); + } Engines::Component_var compo = _FindComponent(new_params, componentName, @@ -252,7 +276,15 @@ FindOrLoad_Component(const Engines::ContainerParameters& params, new_params.resource_params.componentList.length(1); new_params.resource_params.componentList[0] = componentName; - Engines::ResourceList_var listOfResources = _ResManager->GetFittingResources(new_params.resource_params); + Engines::ResourceList_var listOfResources; + try + { + listOfResources = _ResManager->GetFittingResources(new_params.resource_params); + } + catch( const SALOME::SALOME_Exception& ex ) + { + return Engines::Component::_nil(); + } Engines::Component_var compo = _FindComponent(new_params, componentName, diff --git a/src/ResourcesManager/ResourcesManager.cxx b/src/ResourcesManager/ResourcesManager.cxx index 5beadabaa..e2c94b597 100644 --- a/src/ResourcesManager/ResourcesManager.cxx +++ b/src/ResourcesManager/ResourcesManager.cxx @@ -247,7 +247,7 @@ ResourcesManager_cpp::GetFittingResources(const resourceParams& params) throw(Re // Send an exception if return list is empty... if (vec.size() == 0) { - std::string error("[GetFittingResources] ResourcesManager doesn't find any resource that feets to your parameters"); + std::string error("[GetFittingResources] ResourcesManager doesn't find any resource that fits to your parameters"); throw ResourcesException(error); } diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx index 316c695d9..62ff12554 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx @@ -103,6 +103,13 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) // Empty private elements _resources_list.clear(); + //default resources + _resource.Clear(); + _resource.HostName = Kernel_Utils::GetHostname(); + _resource.Name = Kernel_Utils::GetHostname(); + _resource.DataForSort._Name = Kernel_Utils::GetHostname(); + _resources_list[Kernel_Utils::GetHostname()] = _resource; + // Get the document root node xmlNodePtr aCurNode = xmlDocGetRootElement(theDoc); -- 2.39.2