Ignore:
Timestamp:
01/03/23 19:06:42 (18 months ago)
Author:
ymipsl
Message:

Implementation of files service on dev branch

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS3/dev/XIOS_FILE_SERVICES/src/node/pool_node.cpp

    r2408 r2453  
    11#include "pool_node.hpp" 
     2#include "cxios.hpp" 
     3#include<cmath> 
    24 
    35namespace xios 
     
    57   
    68  CPoolNode::CPoolNode(void) : CObjectTemplate<CPoolNode>(), CPoolNodeAttributes() 
    7   { /* Ne rien faire de plus */ } 
     9  {  
     10    setVirtualServiceNodeGroup(CServiceNodeGroup::create(getId() + "_virtual_service_node_group")); 
     11  } 
    812 
    913  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  } 
    1117 
    1218  CPoolNode::~CPoolNode(void) 
     
    1723  { 
    1824    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    } 
    1933  } 
    2034 
    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  } 
    2267} 
    2368 
Note: See TracChangeset for help on using the changeset viewer.