X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2Fevalyfx%2FYACSEvalResource.cxx;h=92b8b20d132c61bd3c98ad8d2e7d22283fdd98b2;hb=255150e4eec79294bbd06c7c464f309b4a264960;hp=92d1d419a9e16d054f9c21f6d965a3823c1624d2;hpb=385fd4049b8c622d76308eb72054cfd19cac4cc5;p=modules%2Fyacs.git diff --git a/src/evalyfx/YACSEvalResource.cxx b/src/evalyfx/YACSEvalResource.cxx index 92d1d419a..92b8b20d1 100644 --- a/src/evalyfx/YACSEvalResource.cxx +++ b/src/evalyfx/YACSEvalResource.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2015 CEA/DEN, EDF R&D +// Copyright (C) 2012-2023 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -15,7 +15,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// +// // Author : Anthony Geay (EDF R&D) #include "YACSEvalResource.hxx" @@ -73,6 +73,12 @@ void YACSEvalNonConstLocker::checkNonLocked() const throw YACS::Exception("YACSEvalNonConstLocker::checkNonLocked : this is locked and trying to invoke non-const method !"); } +void YACSEvalNonConstLocker::checkLocked() const +{ + if(!_isLocked) + throw YACS::Exception("YACSEvalNonConstLocker::checkLocked : this is NOT locked whereas it should be !"); +} + YACSEvalVirtualYACSContainer::YACSEvalVirtualYACSContainer():_gf(0),_cont(0) { } @@ -86,7 +92,8 @@ void YACSEvalVirtualYACSContainer::set(YACSEvalResource *gf, YACS::ENGINE::Conta if(_cont) _cont->decrRef(); _cont=cont; - _cont->incrRef(); + if(_cont) + _cont->incrRef(); _propertyMap=listOfPropertiesInYACSContainer(); } @@ -172,11 +179,14 @@ std::vector YACSEvalVirtualYACSContainer::listOfPropertyKeys() cons std::string YACSEvalVirtualYACSContainer::getValueOfKey(const char *key) const { + std::string skey(key); + if(skey==HOSTNAME_KEY) + return _chosenHost; std::map::const_iterator it; - it=_overloadedPropertyMap.find(key); + it=_overloadedPropertyMap.find(skey); if(it!=_overloadedPropertyMap.end()) return (*it).second; - it=_propertyMap.find(key); + it=_propertyMap.find(skey); if(it!=_propertyMap.end()) return (*it).second; return std::string(); @@ -185,25 +195,31 @@ std::string YACSEvalVirtualYACSContainer::getValueOfKey(const char *key) const void YACSEvalVirtualYACSContainer::setProperty(const std::string& key, const std::string &value) { checkNonLocked(); - _overloadedPropertyMap[key]=value; + if(key==HOSTNAME_KEY) + setWantedMachine(value); + else + _overloadedPropertyMap[key]=value; } -void YACSEvalVirtualYACSContainer::apply() +void YACSEvalVirtualYACSContainer::apply(bool interactiveStatus) { YACS::ENGINE::SalomeContainer *cont0(dynamic_cast(_cont)); YACS::ENGINE::SalomeHPContainer *cont1(dynamic_cast(_cont)); - if(cont0) - { - cont0->setProperty(HOSTNAME_KEY,getValueOfKey(HOSTNAME_KEY)); - return ; - } - else if(cont1) - { - cont1->setProperty(HOSTNAME_KEY,getValueOfKey(HOSTNAME_KEY)); - return ; - } - else + if(!cont0 && !cont1) throw YACS::Exception("YACSEvalVirtualYACSContainer::apply : unrecognized container !"); + if(interactiveStatus) + _cont->setProperty(HOSTNAME_KEY,getValueOfKey(HOSTNAME_KEY)); + else + {// in cluster mode no hostname and policy set to cycl by default + _cont->setProperty(HOSTNAME_KEY,std::string()); + _cont->setProperty("policy","cycl"); + } +} + +std::string YACSEvalVirtualYACSContainer::getName() const +{ + checkNotNullYACSContainer(); + return _cont->getName(); } unsigned int YACSEvalVirtualYACSContainer::getValueOfKeyUInt(const char *key) const @@ -229,6 +245,12 @@ std::map YACSEvalVirtualYACSContainer::listOfProperties return props; } +void YACSEvalVirtualYACSContainer::checkNotNullYACSContainer() const +{ + if(!_cont) + throw YACS::Exception("YACSEvalVirtualYACSContainer::checkNotNullYACSContainer : internal YACS container is NULL !"); +} + YACSEvalResource::~YACSEvalResource() { } @@ -266,10 +288,10 @@ YACSEvalVirtualYACSContainer *YACSEvalResource::at(std::size_t i) const return const_cast(&_containers[i]); } -void YACSEvalResource::apply() +void YACSEvalResource::apply(bool interactiveStatus) { for(std::vector< YACSEvalVirtualYACSContainer >::iterator it=_containers.begin();it!=_containers.end();it++) - (*it).apply(); + (*it).apply(interactiveStatus); } void YACSEvalResource::fitWithCurrentCatalogAbs() @@ -305,6 +327,24 @@ YACSEvalResource::YACSEvalResource(YACSEvalListOfResources *gf, const std::vecto _containers[i].set(this,conts[i]); } +void YACSEvalParamsForCluster::setExclusiveness(bool newStatus) +{ + if(newStatus) + throw YACS::Exception("YACSEvalParamsForCluster::setExclusiveness : exclusive mode set to true is not implemented yet !"); +} + +void YACSEvalParamsForCluster::checkConsistency() const +{ + if(_remoteWorkingDir.empty()) + throw YACS::Exception("YACSEvalParamsForCluster::checkConsistency : remote work dir is not set !"); + if(_localWorkingDir.empty()) + throw YACS::Exception("YACSEvalParamsForCluster::checkConsistency : local work dir is not set !"); + if(_wcKey.empty()) + throw YACS::Exception("YACSEvalParamsForCluster::checkConsistency : WC key is not set !"); + if(_nbOfProcs==0) + throw YACS::Exception("YACSEvalParamsForCluster::checkConsistency : nb procs must be != 0 !"); +} + YACSEvalListOfResources::YACSEvalListOfResources(int maxLevOfPara, ResourcesManager_cpp *rm, const YACS::ENGINE::DeploymentTree& dt):_maxLevOfPara(maxLevOfPara),_rm(rm),_dt(new YACS::ENGINE::DeploymentTree(dt)) { std::vector conts(_dt->getAllContainers()); @@ -365,7 +405,6 @@ YACSEvalResource *YACSEvalListOfResources::at(std::size_t i) const bool YACSEvalListOfResources::isInteractive() const { - const MapOfParserResourcesType& zeList(_rm->GetList()); std::vector allMachines(getAllChosenMachines()); if(allMachines.empty()) return true; @@ -373,14 +412,7 @@ bool YACSEvalListOfResources::isInteractive() const std::vector status(sz); for(std::vector::const_iterator it=allMachines.begin();it!=allMachines.end();it++,ii++) { - std::map::const_iterator it2(zeList.find(*it)); - if(it2==zeList.end()) - { - std::ostringstream oss; oss << "YACSEvalListOfResources::isInteractive : presence of non existing \"" << *it << "\" !"; - throw YACS::Exception(oss.str()); - } - const ParserResourcesType& elt((*it2).second); - status[ii]=(elt.ClusterInternalProtocol==sh || elt.ClusterInternalProtocol==rsh || elt.ClusterInternalProtocol==ssh); + status[ii]=isMachineInteractive(*it); } std::size_t trueRet(std::count(status.begin(),status.end(),true)),falseRet(std::count(status.begin(),status.end(),false)); if(trueRet==sz && falseRet==0) @@ -392,17 +424,29 @@ bool YACSEvalListOfResources::isInteractive() const unsigned int YACSEvalListOfResources::getNumberOfProcsDeclared() const { - std::vector chosen(getAllChosenMachines()); - unsigned int ret(0); - for(std::vector::const_iterator it=chosen.begin();it!=chosen.end();it++) - ret+=getNumberOfProcOfResource(*it); - return ret; + if(isInteractive()) + { + std::vector chosen(getAllChosenMachines()); + unsigned int ret(0); + for(std::vector::const_iterator it=chosen.begin();it!=chosen.end();it++) + ret+=getNumberOfProcOfResource(*it); + return ret; + } + else + return _paramsInCaseOfCluster.getNbProcs(); +} + +void YACSEvalListOfResources::checkOKForRun() const +{ + if(!isInteractive()) + _paramsInCaseOfCluster.checkConsistency(); } void YACSEvalListOfResources::apply() { + bool interactiveSt(isInteractive()); for(std::vector::iterator it=_resources.begin();it!=_resources.end();it++) - (*it)->apply(); + (*it)->apply(interactiveSt); } YACSEvalListOfResources::~YACSEvalListOfResources() @@ -412,6 +456,19 @@ YACSEvalListOfResources::~YACSEvalListOfResources() delete *it; } +bool YACSEvalListOfResources::isMachineInteractive(const std::string& machine) const +{ + const MapOfParserResourcesType& zeList(_rm->GetList()); + std::map::const_iterator it2(zeList.find(machine)); + if(it2==zeList.end()) + { + std::ostringstream oss; oss << "YACSEvalListOfResources::isMachineInteractive : no such machine with name \"" << machine << "\" !"; + throw YACS::Exception(oss.str()); + } + const ParserResourcesType& elt((*it2).second); + return (elt.Batch==none); +} + class EffectiveComparator { public: @@ -554,23 +611,59 @@ void YACSEvalListOfResources::notifyWantedMachine(YACSEvalVirtualYACSContainer * throw YACS::Exception("YACSEvalListOfResources::notifyWantedMachine : internal error !"); const ParserResourcesType& oldPRT((*itOld).second); const ParserResourcesType& newPRT((*itNew).second); - if(oldPRT.ClusterInternalProtocol==newPRT.ClusterInternalProtocol) + bool oldISt(oldPRT.Batch==none),newISt(newPRT.Batch==none);//interactive status + if(oldISt==newISt) return ; // the batch/interactive mode has changed -> try to change for all. std::queue sts; try { - for(std::vector::const_iterator it=_resources.begin();it!=_resources.end();it++) - { - std::size_t sz((*it)->size()); - for(std::size_t i=0;iat(i)); - if(cont==sender) - continue; - sts.push(cont->findDefault(newPRT.ClusterInternalProtocol==sh)); - } - } + if(newISt) + {// switching from interactive to batch -> In batch every YACSEvalVirtualYACSContainer instances in this must lie on newMachine. + for(std::vector::const_iterator it=_resources.begin();it!=_resources.end();it++) + { + std::vector fms((*it)->getAllFittingMachines()); + std::vector::iterator it0(std::find(fms.begin(),fms.end(),newMachine)); + if(it0==fms.end()) + { + std::ostringstream oss; oss << "In the context of switch to batch the requested cluster machine \"" << newMachine << "\" is not compatible for following list of containers : " << std::endl; + std::size_t sz((*it)->size()); + for(std::size_t i=0;iat(i)); + if(cont) + oss << " \"" << cont->getName() << "\", "; + } + throw YACS::Exception(oss.str()); + } + std::size_t sz((*it)->size()); + for(std::size_t i=0;isize()); + for(std::size_t i=0;iat(i)); + if(cont==sender) + continue; + sts.push(newMachine); + } + } + } + } + else + { + for(std::vector::const_iterator it=_resources.begin();it!=_resources.end();it++) + { + std::size_t sz((*it)->size()); + for(std::size_t i=0;iat(i)); + if(cont==sender) + continue; + sts.push(cont->findDefault(false)); + } + } + } } catch(YACS::Exception& e) { @@ -598,7 +691,7 @@ bool YACSEvalListOfResources::hasRightInteractiveStatus(const std::string& machi if(it==zeList.end()) throw YACS::Exception("YACSEvalListOfResources::hasRightInteractiveStatus : internal error !"); const ParserResourcesType& elt((*it).second); - bool myStatus(elt.ClusterInternalProtocol==sh); + bool myStatus(elt.Batch==none); return myStatus==isInteractive; }