Changeset 2453 for XIOS3/dev/XIOS_FILE_SERVICES/src/node/pool_node.cpp
- Timestamp:
- 01/03/23 19:06:42 (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS3/dev/XIOS_FILE_SERVICES/src/node/pool_node.cpp
r2408 r2453 1 1 #include "pool_node.hpp" 2 #include "cxios.hpp" 3 #include<cmath> 2 4 3 5 namespace xios … … 5 7 6 8 CPoolNode::CPoolNode(void) : CObjectTemplate<CPoolNode>(), CPoolNodeAttributes() 7 { /* Ne rien faire de plus */ } 9 { 10 setVirtualServiceNodeGroup(CServiceNodeGroup::create(getId() + "_virtual_service_node_group")); 11 } 8 12 9 13 CPoolNode::CPoolNode(const StdString & id) : CObjectTemplate<CPoolNode>(id), CPoolNodeAttributes() 10 { /* Ne rien faire de plus */ } 14 { 15 setVirtualServiceNodeGroup(CServiceNodeGroup::create(getId() + "_virtual_service_node_group")); 16 } 11 17 12 18 CPoolNode::~CPoolNode(void) … … 17 23 { 18 24 SuperClass::parse(node); 25 if (node.goToChildElement()) 26 { 27 do 28 { 29 if (node.getElementName()=="service" || node.getElementName()=="service_group") this->getVirtualServiceNodeGroup()->parseChild(node); 30 } while (node.goToNextElement()); 31 node.goToParentElement(); 32 } 19 33 } 20 34 21 35 void CPoolNode::allocateRessources(void) 36 { 37 int nonEmpty=0 ; 38 if (!nprocs.isEmpty()) nonEmpty++ ; 39 if (!global_fraction.isEmpty()) nonEmpty++ ; 40 if (!remain_fraction.isEmpty()) nonEmpty++ ; 41 if (!remain.isEmpty()) nonEmpty++ ; 42 if (nonEmpty==0) ERROR("void CPoolNode::allocateRessources(void)",<<"A number a ressource for allocate pool must be specified." 43 <<"At least attributes, <nprocs> or <global_fraction> or <remain_fraction> or <remain> must be specified") 44 else if (nonEmpty>1) ERROR("void CPoolNode::allocateRessources(void)",<<"Only one of these attributes : <nprocs> or <global_fraction>" 45 <<" or <remain_fraction> or <remain> must be specified to determine allocated ressouces." 46 <<" More than one is currently specified") 47 auto ressourcesManager=CXios::getRessourcesManager() ; 48 int nbRessources ; 49 int globalRessources = ressourcesManager->getRessourcesSize() ; 50 int freeRessources = ressourcesManager->getFreeRessourcesSize() ; 51 if (!nprocs.isEmpty()) nbRessources = nprocs ; 52 if (!global_fraction.isEmpty()) nbRessources = std::round(globalRessources * global_fraction) ; 53 if (!remain_fraction.isEmpty()) nbRessources = std::round(freeRessources * remain_fraction) ; 54 if (!remain.isEmpty()) nbRessources = freeRessources ; 55 if (nbRessources>freeRessources) 56 ERROR("void CPoolNode::allocateRessources(void)",<<"Cannot allocate required ressources for the pool." 57 <<" Required is : "<<nbRessources<<" but free ressource is currently : "<<freeRessources) 58 string poolId ; 59 if (!name.isEmpty()) poolId=name ; 60 else if (!hasAutoGeneratedId() ) poolId=getId() ; 61 else ERROR("void CPoolNode::allocateRessources(void)",<<"Pool has no name or id, attributes <id> or <name> must be specified") 62 ressourcesManager->createPool(poolId, nbRessources) ; 63 ressourcesManager->waitPoolRegistration(poolId) ; 64 auto services=this->getAllServiceNodes() ; 65 for(auto& service : services) service->allocateRessources(poolId) ; 66 } 22 67 } 23 68
Note: See TracChangeset
for help on using the changeset viewer.