X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fevalyfx%2FYACSEvalResource.cxx;h=a79259d790988ca69cafa4c139d760d7e761fcf9;hb=fb3a657d28982730e1657cbef5f50420029c49b9;hp=92d1d419a9e16d054f9c21f6d965a3823c1624d2;hpb=385fd4049b8c622d76308eb72054cfd19cac4cc5;p=modules%2Fyacs.git diff --git a/src/evalyfx/YACSEvalResource.cxx b/src/evalyfx/YACSEvalResource.cxx index 92d1d419a..a79259d79 100644 --- a/src/evalyfx/YACSEvalResource.cxx +++ b/src/evalyfx/YACSEvalResource.cxx @@ -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()); @@ -380,7 +420,7 @@ bool YACSEvalListOfResources::isInteractive() const throw YACS::Exception(oss.str()); } const ParserResourcesType& elt((*it2).second); - status[ii]=(elt.ClusterInternalProtocol==sh || elt.ClusterInternalProtocol==rsh || elt.ClusterInternalProtocol==ssh); + status[ii]=(elt.Batch==none); } 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 +432,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() @@ -554,23 +606,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 +686,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; }