Version: 9.15.0
YACS::ENGINE::SalomeHPContainer Class Reference

#include <SalomeHPContainer.hxx>

Inheritance diagram for YACS::ENGINE::SalomeHPContainer:
Collaboration diagram for YACS::ENGINE::SalomeHPContainer:

Public Member Functions

 SalomeHPContainer ()
 
 SalomeHPContainer (const SalomeHPContainer &other)
 
void assignPG (const PlayGround *pg) override
 
void setSizeOfPool (int sz)
 
int getSizeOfPool () const
 
std::size_t getNumberOfFreePlace () const
 
void allocateFor (const std::vector< const Task * > &nodes)
 
void release (const Task *node) override
 
void lock ()
 For thread safety for concurrent load operation on same Container. More...
 
void unLock ()
 For thread safety for concurrent load operation on same Container. More...
 
std::string getKind () const
 
std::string getDiscreminantStrOfThis (const Task *askingNode) const
 
bool isAlreadyStarted (const Task *askingNode) const
 
void start (const Task *askingNode)
 
void shutdown (int level)
 
std::string getPlacementId (const Task *askingNode) const
 
std::string getFullPlacementId (const Task *askingNode) const
 
Containerclone () const
 
ContainercloneAlways () const
 
void setProperty (const std::string &name, const std::string &value)
 
std::string getProperty (const std::string &name) const
 
void clearProperties ()
 
void addComponentName (const std::string &name)
 
std::map< std::string, std::string > getProperties () const
 
std::map< std::string, std::string > getResourceProperties (const std::string &name) const
 
void checkCapabilityToDealWith (const ComponentInstance *inst) const
 
std::vector< std::string > getKernelContainerNames () const
 
int getNumberOfCoresPerWorker () const
 
std::size_t locateTask (const Task *askingNode) const
 
const SalomeContainerToolsgetContainerInfo () const
 
std::vector< std::string > getComponentNames () const
 
int getShutdownLev () const
 
SalomeContainerMonoHelpergetHelperOfTask (const Task *node)
 
const SalomeContainerMonoHelpergetHelperOfTask (const Task *node) const
 
- Public Member Functions inherited from YACS::ENGINE::HomogeneousPoolContainer
void attachOnCloning () const
 
void dettachOnCloning () const
 
bool isAttachedOnCloning () const
 
void setAttachOnCloningStatus (bool val) const
 
std::mutex & getLocker () const
 
- Public Member Functions inherited from YACS::ENGINE::Container
virtual void start (const Task *askingNode, const std::string &resource_name, const std::string &container_name)
 
virtual bool canAcceptImposedResource ()
 
virtual bool isUsingPythonCache ()
 
virtual void usePythonCache (bool v)
 
virtual bool isSupportingRTODefNbOfComp () const
 
virtual void setProperties (const std::map< std::string, std::string > &properties)
 
virtual std::string getName () const
 
void setName (std::string name)
 WARNING ! name is used in edition to identify different containers, it is not the runtime name of the container More...
 
void setProc (Proc *proc)
 
ProcgetProc ()
 
- Public Member Functions inherited from YACS::ENGINE::RefCounter
unsigned int getRefCnt () const
 
void incrRef () const
 
bool decrRef () const
 

Static Public Attributes

static const char KIND [] ="HPSalome"
 
- Static Public Attributes inherited from YACS::ENGINE::HomogeneousPoolContainer
static const char SIZE_OF_POOL_KEY [] ="SizeOfPool"
 
static const char INITIALIZE_SCRIPT_KEY [] ="InitializeScriptKey"
 
- Static Public Attributes inherited from YACS::ENGINE::Container
static const char KIND_ENTRY [] ="container_kind"
 
static const char AOC_ENTRY [] ="attached_on_cloning"
 
static const char USE_PYCACHE_PROPERTY [] ="use_py_cache"
 
- Static Public Attributes inherited from YACS::ENGINE::RefCounter
static unsigned int _totalCnt =0
 

Protected Member Functions

 ~SalomeHPContainer ()
 
- Protected Member Functions inherited from YACS::ENGINE::HomogeneousPoolContainer
 HomogeneousPoolContainer ()
 
virtual ~HomogeneousPoolContainer ()
 
const PlayGroundgetPG () const
 
- Protected Member Functions inherited from YACS::ENGINE::Container
 Container ()
 
virtual ~Container ()
 
- Protected Member Functions inherited from YACS::ENGINE::RefCounter
 RefCounter ()
 
 RefCounter (const RefCounter &other)
 
virtual ~RefCounter ()
 

Protected Attributes

std::mutex _lock
 
int _shutdownLevel
 
SalomeContainerTools _sct
 
std::vector< std::string > _componentNames
 
SalomeHPContainerVectOfHelper _launchModeType
 
std::string _initScript
 
- Protected Attributes inherited from YACS::ENGINE::Container
std::string _name
 
bool _isAttachedOnCloning
 
Proc_proc
 
- Protected Attributes inherited from YACS::ENGINE::RefCounter
unsigned int _cnt
 

Detailed Description

Definition at line 44 of file SalomeHPContainer.hxx.

Constructor & Destructor Documentation

◆ SalomeHPContainer() [1/2]

SalomeHPContainer::SalomeHPContainer ( )

Definition at line 32 of file SalomeHPContainer.cxx.

Referenced by cloneAlways().

◆ SalomeHPContainer() [2/2]

SalomeHPContainer::SalomeHPContainer ( const SalomeHPContainer other)

Definition at line 36 of file SalomeHPContainer.cxx.

◆ ~SalomeHPContainer()

SalomeHPContainer::~SalomeHPContainer ( )
protected

Definition at line 93 of file SalomeHPContainer.cxx.

94 {
95 }

Member Function Documentation

◆ addComponentName()

void SalomeHPContainer::addComponentName ( const std::string &  name)
virtual

Implements YACS::ENGINE::Container.

Definition at line 211 of file SalomeHPContainer.cxx.

212 {
213  _componentNames.push_back(name);
214 }

References _componentNames.

◆ allocateFor()

void SalomeHPContainer::allocateFor ( const std::vector< const Task * > &  nodes)
virtual

Implements YACS::ENGINE::HomogeneousPoolContainer.

Definition at line 80 of file SalomeHPContainer.cxx.

81 {
82  std::vector<std::size_t> workerIdsAllocated(getPG()->allocateFor(nodes.size(),this->getNumberOfCoresPerWorker()));
83  std::vector<std::pair<const Task *,std::size_t>> nodesAndIds(PairVecIterator(&nodes,&workerIdsAllocated,0),PairVecIterator(&nodes,&workerIdsAllocated,nodes.size()));
84  _launchModeType.allocateForCrude(nodesAndIds);
85 }
void allocateForCrude(const std::vector< std::pair< const Task *, std::size_t >> &nodes)
void allocateFor(const std::vector< const Task * > &nodes)
SalomeHPContainerVectOfHelper _launchModeType

References _launchModeType, YACS::ENGINE::SalomeHPContainerVectOfHelper::allocateForCrude(), and YACS::ENGINE::HomogeneousPoolContainer::getPG().

◆ assignPG()

void SalomeHPContainer::assignPG ( const PlayGround pg)
overridevirtual

◆ checkCapabilityToDealWith()

void SalomeHPContainer::checkCapabilityToDealWith ( const ComponentInstance inst) const
virtual

Implements YACS::ENGINE::Container.

Definition at line 231 of file SalomeHPContainer.cxx.

232 {
233  if(inst->getKind()!=SalomeHPComponent::KIND)
234  throw Exception("SalomeHPContainer::checkCapabilityToDealWith : SalomeContainer is not able to deal with this type of ComponentInstance.");
235 }
virtual std::string getKind() const
Return the component kind.

References YACS::ENGINE::ComponentInstance::getKind(), and YACS::ENGINE::SalomeHPComponent::KIND.

◆ clearProperties()

void SalomeHPContainer::clearProperties ( )
virtual

Implements YACS::ENGINE::Container.

Definition at line 205 of file SalomeHPContainer.cxx.

206 {
207  _initScript.clear();
209 }

References _initScript, _sct, and YACS::ENGINE::SalomeContainerTools::clearProperties().

◆ clone()

Container * SalomeHPContainer::clone ( ) const
virtual

It is not a bug here ! clone for homogeneous container is not supposed to be copied !

Implements YACS::ENGINE::Container.

Definition at line 156 of file SalomeHPContainer.cxx.

157 {
158  incrRef();
159  return const_cast<SalomeHPContainer*>(this);
160 }

References YACS::ENGINE::RefCounter::incrRef().

◆ cloneAlways()

Container * SalomeHPContainer::cloneAlways ( ) const
virtual

Implements YACS::ENGINE::Container.

Definition at line 162 of file SalomeHPContainer.cxx.

163 {
164  return new SalomeHPContainer(*this);
165 }

References SalomeHPContainer().

◆ getComponentNames()

std::vector<std::string> YACS::ENGINE::SalomeHPContainer::getComponentNames ( ) const
inline

Definition at line 83 of file SalomeHPContainer.hxx.

83 { return _componentNames; }

Referenced by YACS::ENGINE::SalomeContainerTmpForHP::BuildFrom().

◆ getContainerInfo()

const SalomeContainerTools& YACS::ENGINE::SalomeHPContainer::getContainerInfo ( ) const
inline

Definition at line 82 of file SalomeHPContainer.hxx.

82 { return _sct; }

Referenced by YACS::ENGINE::SalomeContainerTmpForHP::BuildFrom().

◆ getDiscreminantStrOfThis()

std::string SalomeHPContainer::getDiscreminantStrOfThis ( const Task askingNode) const
virtual

Reimplemented from YACS::ENGINE::Container.

Definition at line 102 of file SalomeHPContainer.cxx.

103 {
105  return tmpCont->getDiscreminantStrOfThis(askingNode);
106 }
static SalomeContainerTmpForHP * BuildFrom(const SalomeHPContainer *cont, const Task *askingNode)

References YACS::ENGINE::SalomeContainerTmpForHP::BuildFrom().

◆ getFullPlacementId()

std::string SalomeHPContainer::getFullPlacementId ( const Task askingNode) const
virtual

Implements YACS::ENGINE::Container.

Definition at line 143 of file SalomeHPContainer.cxx.

144 {
145  const SalomeContainerMonoHelper *helper(nullptr);
146  {
147  std::lock_guard<std::mutex> lg(getPG()->getLocker());
148  helper=_launchModeType.getHelperOfTask(askingNode);
149  }
150  return SalomeContainerTools::GetFullPlacementId(helper,this,askingNode);
151 }
static std::string GetFullPlacementId(const SalomeContainerHelper *launchModeType, const Container *cont, const Task *askingNode)
const SalomeContainerMonoHelper * getHelperOfTask(const Task *node) const

References _launchModeType, YACS::ENGINE::SalomeContainerToolsBase::GetFullPlacementId(), YACS::ENGINE::SalomeHPContainerVectOfHelper::getHelperOfTask(), YACS::ENGINE::HomogeneousPoolContainer::getLocker(), and YACS::ENGINE::HomogeneousPoolContainer::getPG().

◆ getHelperOfTask() [1/2]

SalomeContainerMonoHelper* YACS::ENGINE::SalomeHPContainer::getHelperOfTask ( const Task node)
inline

Definition at line 85 of file SalomeHPContainer.hxx.

85 { return _launchModeType.getHelperOfTask(node); }

Referenced by YACS::ENGINE::SalomeContainerTmpForHP::BuildFrom().

◆ getHelperOfTask() [2/2]

const SalomeContainerMonoHelper* YACS::ENGINE::SalomeHPContainer::getHelperOfTask ( const Task node) const
inline

Definition at line 86 of file SalomeHPContainer.hxx.

86 { return _launchModeType.getHelperOfTask(node); }

◆ getKernelContainerNames()

std::vector< std::string > SalomeHPContainer::getKernelContainerNames ( ) const

Definition at line 237 of file SalomeHPContainer.cxx.

238 {
240 }
std::vector< std::string > getKernelContainerNames(const SalomeHPContainer *cont) const

References _launchModeType, and YACS::ENGINE::SalomeHPContainerVectOfHelper::getKernelContainerNames().

◆ getKind()

std::string SalomeHPContainer::getKind ( ) const
virtual

Implements YACS::ENGINE::Container.

Definition at line 97 of file SalomeHPContainer.cxx.

98 {
99  return KIND;
100 }

References KIND.

◆ getNumberOfCoresPerWorker()

int SalomeHPContainer::getNumberOfCoresPerWorker ( ) const
virtual

◆ getNumberOfFreePlace()

std::size_t SalomeHPContainer::getNumberOfFreePlace ( ) const
virtual

◆ getPlacementId()

std::string SalomeHPContainer::getPlacementId ( const Task askingNode) const
virtual

Implements YACS::ENGINE::Container.

Definition at line 133 of file SalomeHPContainer.cxx.

134 {
135  const SalomeContainerMonoHelper *helper(nullptr);
136  {
137  std::lock_guard<std::mutex> lg(getPG()->getLocker());
138  helper=_launchModeType.getHelperOfTask(askingNode);
139  }
140  return SalomeContainerTools::GetPlacementId(helper,this,askingNode);
141 }
static std::string GetPlacementId(const SalomeContainerHelper *launchModeType, const Container *cont, const Task *askingNode)

References _launchModeType, YACS::ENGINE::SalomeHPContainerVectOfHelper::getHelperOfTask(), YACS::ENGINE::HomogeneousPoolContainer::getLocker(), YACS::ENGINE::HomogeneousPoolContainer::getPG(), and YACS::ENGINE::SalomeContainerToolsBase::GetPlacementId().

◆ getProperties()

std::map< std::string, std::string > SalomeHPContainer::getProperties ( ) const
virtual

Implements YACS::ENGINE::Container.

Definition at line 216 of file SalomeHPContainer.cxx.

217 {
218  std::map<std::string,std::string> ret(_sct.getProperties());
219  std::ostringstream oss; oss << getSizeOfPool();
220  ret[SIZE_OF_POOL_KEY]=oss.str();
221  if(!_initScript.empty())
223  return ret;
224 }
const std::map< std::string, std::string > & getProperties() const override

References _initScript, _sct, YACS::ENGINE::SalomeContainerTools::getProperties(), getSizeOfPool(), YACS::ENGINE::HomogeneousPoolContainer::INITIALIZE_SCRIPT_KEY, and YACS::ENGINE::HomogeneousPoolContainer::SIZE_OF_POOL_KEY.

◆ getProperty()

std::string SalomeHPContainer::getProperty ( const std::string &  name) const
virtual

Implements YACS::ENGINE::Container.

Definition at line 186 of file SalomeHPContainer.cxx.

187 {
188  if(name==AOC_ENTRY)
189  {
190  return std::string("1");
191  }
192  else if(name==SIZE_OF_POOL_KEY)
193  {
194  std::ostringstream oss; oss << getSizeOfPool();
195  return oss.str();
196  }
197  else if(name==INITIALIZE_SCRIPT_KEY)
198  {
199  return _initScript;
200  }
201  else
202  return _sct.getProperty(name);
203 }
static const char AOC_ENTRY[]
Definition: Container.hxx:88
std::string getProperty(const std::string &name) const override

References _initScript, _sct, YACS::ENGINE::Container::AOC_ENTRY, YACS::ENGINE::SalomeContainerTools::getProperty(), getSizeOfPool(), YACS::ENGINE::HomogeneousPoolContainer::INITIALIZE_SCRIPT_KEY, and YACS::ENGINE::HomogeneousPoolContainer::SIZE_OF_POOL_KEY.

◆ getResourceProperties()

std::map< std::string, std::string > SalomeHPContainer::getResourceProperties ( const std::string &  name) const
virtual

Implements YACS::ENGINE::Container.

Definition at line 226 of file SalomeHPContainer.cxx.

227 {
228  return _sct.getResourceProperties(name);
229 }
std::map< std::string, std::string > getResourceProperties(const std::string &name) const override

References _sct, and YACS::ENGINE::SalomeContainerTools::getResourceProperties().

◆ getShutdownLev()

int YACS::ENGINE::SalomeHPContainer::getShutdownLev ( ) const
inline

Definition at line 84 of file SalomeHPContainer.hxx.

84 { return _shutdownLevel; }

Referenced by YACS::ENGINE::SalomeContainerTmpForHP::BuildFrom().

◆ getSizeOfPool()

int SalomeHPContainer::getSizeOfPool ( ) const
virtual

◆ isAlreadyStarted()

bool SalomeHPContainer::isAlreadyStarted ( const Task askingNode) const
virtual

Implements YACS::ENGINE::Container.

Definition at line 108 of file SalomeHPContainer.cxx.

109 {
111  return helper->isAlreadyStarted(askingNode);
112 }
const SalomeContainerMonoHelper * getHelperOfTaskThreadSafe(const SalomeHPContainer *cont, const Task *node) const

References _launchModeType, YACS::ENGINE::SalomeHPContainerVectOfHelper::getHelperOfTaskThreadSafe(), and YACS::ENGINE::SalomeContainerMonoHelper::isAlreadyStarted().

◆ locateTask()

std::size_t YACS::ENGINE::SalomeHPContainer::locateTask ( const Task askingNode) const
inline

Definition at line 81 of file SalomeHPContainer.hxx.

81 { return _launchModeType.locateTask(askingNode); }
std::size_t locateTask(const Task *node) const

Referenced by YACS::ENGINE::SalomeContainerTmpForHP::BuildFrom().

◆ lock()

void YACS::ENGINE::SalomeHPContainer::lock ( )
inlinevirtual

For thread safety for concurrent load operation on same Container.

Implements YACS::ENGINE::Container.

Definition at line 57 of file SalomeHPContainer.hxx.

57 { _lock.lock(); }

◆ release()

void SalomeHPContainer::release ( const Task node)
overridevirtual

◆ setProperty()

void SalomeHPContainer::setProperty ( const std::string &  name,
const std::string &  value 
)
virtual

Implements YACS::ENGINE::Container.

Definition at line 167 of file SalomeHPContainer.cxx.

168 {
169  if(name==AOC_ENTRY)//no sense to set it ! It is always true ! ignore it !
170  return ;
171  else if(name==SIZE_OF_POOL_KEY)
172  {
173  std::istringstream iss(value);
174  int val(0);
175  iss >> val;
176  setSizeOfPool(val);
177  }
178  else if(name==INITIALIZE_SCRIPT_KEY)
179  {
180  _initScript=value;
181  }
182  else
183  _sct.setProperty(name,value);
184 }
void setProperty(const std::string &name, const std::string &value) override

References _initScript, _sct, YACS::ENGINE::Container::AOC_ENTRY, YACS::ENGINE::HomogeneousPoolContainer::INITIALIZE_SCRIPT_KEY, YACS::ENGINE::SalomeContainerTools::setProperty(), setSizeOfPool(), and YACS::ENGINE::HomogeneousPoolContainer::SIZE_OF_POOL_KEY.

◆ setSizeOfPool()

void SalomeHPContainer::setSizeOfPool ( int  sz)
virtual

◆ shutdown()

void SalomeHPContainer::shutdown ( int  level)
virtual

Implements YACS::ENGINE::Container.

Definition at line 121 of file SalomeHPContainer.cxx.

122 {
123  if(level < _shutdownLevel)
124  return;
125  _shutdownLevel=999;
126  for(std::size_t i=0;i<_launchModeType.size();i++)
127  {
129  helper->shutdown();
130  }
131 }
const SalomeContainerMonoHelper * at(std::size_t pos) const

References _launchModeType, _shutdownLevel, YACS::ENGINE::SalomeHPContainerVectOfHelper::at(), yacsorb.CORBAEngineTest::i, YACS::ENGINE::SalomeContainerMonoHelper::shutdown(), and YACS::ENGINE::SalomeHPContainerVectOfHelper::size().

◆ start()

void SalomeHPContainer::start ( const Task askingNode)
virtual

Implements YACS::ENGINE::Container.

Definition at line 114 of file SalomeHPContainer.cxx.

115 {
119 }
static void Start(const std::vector< std::string > &compoNames, SalomeContainerHelper *schelp, SalomeContainerToolsBase &sct, int &shutdownLevel, const Container *cont, const Task *askingNode)

References _componentNames, _launchModeType, _sct, _shutdownLevel, YACS::ENGINE::SalomeHPContainerVectOfHelper::getHelperOfTaskThreadSafe(), getNumberOfCoresPerWorker(), YACS::ENGINE::HomogeneousPoolContainer::getPG(), and YACS::ENGINE::SalomeContainerToolsBase::Start().

◆ unLock()

void YACS::ENGINE::SalomeHPContainer::unLock ( )
inlinevirtual

For thread safety for concurrent load operation on same Container.

Implements YACS::ENGINE::Container.

Definition at line 59 of file SalomeHPContainer.hxx.

59 { _lock.unlock(); }

Member Data Documentation

◆ _componentNames

std::vector<std::string> YACS::ENGINE::SalomeHPContainer::_componentNames
protected

Definition at line 98 of file SalomeHPContainer.hxx.

Referenced by addComponentName(), and start().

◆ _initScript

std::string YACS::ENGINE::SalomeHPContainer::_initScript
protected

Definition at line 101 of file SalomeHPContainer.hxx.

Referenced by clearProperties(), getProperties(), getProperty(), and setProperty().

◆ _launchModeType

◆ _lock

std::mutex YACS::ENGINE::SalomeHPContainer::_lock
protected

Definition at line 95 of file SalomeHPContainer.hxx.

◆ _sct

SalomeContainerTools YACS::ENGINE::SalomeHPContainer::_sct
protected

◆ _shutdownLevel

int YACS::ENGINE::SalomeHPContainer::_shutdownLevel
protected

Definition at line 96 of file SalomeHPContainer.hxx.

Referenced by shutdown(), and start().

◆ KIND

const char SalomeHPContainer::KIND ="HPSalome"
static

Definition at line 89 of file SalomeHPContainer.hxx.

Referenced by getKind().


The documentation for this class was generated from the following files: