Version: 9.16.0
YACS::ENGINE::WlmTask Class Reference

#include <WlmTask.hxx>

Inheritance diagram for YACS::ENGINE::WlmTask:
Collaboration diagram for YACS::ENGINE::WlmTask:

Public Member Functions

 WlmTask (Executor &executor, YACS::ENGINE::Task *yacsTask)
 
const WorkloadManager::ContainerType & type () const override
 
void run (const WorkloadManager::RunInfo &runInfo) override
 
bool isAccepted (const WorkloadManager::Resource &r) override
 

Static Public Member Functions

static void loadResources (WorkloadManager::WorkloadManager &wm)
 

Private Attributes

WorkloadManager::ContainerType _type
 
Executor_executor
 
YACS::ENGINE::Task_yacsTask
 

Detailed Description

Definition at line 29 of file WlmTask.hxx.

Constructor & Destructor Documentation

◆ WlmTask()

YACS::ENGINE::WlmTask::WlmTask ( Executor executor,
YACS::ENGINE::Task yacsTask 
)

Definition at line 28 of file WlmTask.cxx.

29: _type()
30, _executor(executor)
31, _yacsTask(yacsTask)
32{
33 Container * yacsContainer = yacsTask->getContainer();
34 if(yacsContainer != nullptr && yacsTask->canAcceptImposedResource())
35 {
36 _type.ignoreResources = false;
37 _type.name = yacsContainer->getName();
38 std::string nb_procs_str = yacsContainer->getProperty("nb_parallel_procs");
39 float needed_cores = 0.0;
40 if(!nb_procs_str.empty())
41 needed_cores = std::stof(nb_procs_str);
42 _type.neededCores = needed_cores;
43 }
44 else
45 {
46 _type.ignoreResources = true;
47 _type.name = "test";
48 _type.neededCores = 0;
49 }
50 _type.id = 0;
51}
virtual bool canAcceptImposedResource()
Definition: Task.hxx:57
virtual Container * getContainer()=0
WorkloadManager::ContainerType _type
Definition: WlmTask.hxx:39
Executor & _executor
Definition: WlmTask.hxx:40
YACS::ENGINE::Task * _yacsTask
Definition: WlmTask.hxx:41

References _type, YACS::ENGINE::Task::canAcceptImposedResource(), YACS::ENGINE::Task::getContainer(), YACS::ENGINE::Container::getName(), and YACS::ENGINE::Container::getProperty().

Member Function Documentation

◆ isAccepted()

bool YACS::ENGINE::WlmTask::isAccepted ( const WorkloadManager::Resource &  r)
override

Definition at line 74 of file WlmTask.cxx.

75{
76 Container * yacsContainer = _yacsTask->getContainer();
77 std::string hostname = yacsContainer->getProperty("hostname");
78 bool accept = true;
79 if(!hostname.empty())
80 accept = (hostname == r.name);
81 return accept;
82}
virtual std::string getProperty(const std::string &name) const =0

References _yacsTask, YACS::ENGINE::Task::getContainer(), YACS::ENGINE::Container::getProperty(), and testCppPluginInvokation::r.

◆ loadResources()

void YACS::ENGINE::WlmTask::loadResources ( WorkloadManager::WorkloadManager &  wm)
static

Definition at line 84 of file WlmTask.cxx.

85{
86 Runtime *r(getRuntime());
87 if(!r)
88 throw YACS::Exception("loadResources : no runtime !");
89 std::vector< std::pair<std::string,int> > data(r->getCatalogOfComputeNodes());
90 int id = 0;
91 for(const std::pair<std::string,int>& res : data)
92 {
93 WorkloadManager::Resource newResource;
94 newResource.name = res.first;
95 newResource.id = id;
96 id++;
97 newResource.nbCores = res.second;
98 wm.addResource(newResource);
99 }
100 wm.freezeResources();
101}
YACSLIBENGINE_EXPORT Runtime * getRuntime()
Definition: Runtime.cxx:61

References YACS::ENGINE::getRuntime(), and testCppPluginInvokation::r.

Referenced by YACS::ENGINE::Executor::runWlm().

◆ run()

void YACS::ENGINE::WlmTask::run ( const WorkloadManager::RunInfo &  runInfo)
override

Definition at line 58 of file WlmTask.cxx.

59{
60 if(runInfo.isOk)
61 {
66 }
67 else
68 {
69 _executor.failTask(_yacsTask, runInfo.error_message);
70 }
71 delete this; // provisoire
72}
void failTask(Task *task, const std::string &message)
Definition: Executor.cxx:1524
void makeDatastreamConnections(Task *task)
Definition: Executor.cxx:1605
YACS::Event runTask(Task *task)
Definition: Executor.cxx:1535
void endTask(Task *task, YACS::Event ev)
Definition: Executor.cxx:1473
void loadTask(Task *task, const WorkloadManager::RunInfo &runInfo)
Definition: Executor.cxx:1423
Event
Definition: define.hxx:56

References _executor, _yacsTask, YACS::ENGINE::Executor::endTask(), YACS::ENGINE::Executor::failTask(), YACS::ENGINE::Executor::loadTask(), YACS::ENGINE::Executor::makeDatastreamConnections(), and YACS::ENGINE::Executor::runTask().

◆ type()

const WorkloadManager::ContainerType & YACS::ENGINE::WlmTask::type ( ) const
override

Definition at line 53 of file WlmTask.cxx.

54{
55 return _type;
56}

References _type.

Member Data Documentation

◆ _executor

Executor& YACS::ENGINE::WlmTask::_executor
private

Definition at line 40 of file WlmTask.hxx.

Referenced by run().

◆ _type

WorkloadManager::ContainerType YACS::ENGINE::WlmTask::_type
private

Definition at line 39 of file WlmTask.hxx.

Referenced by type(), and WlmTask().

◆ _yacsTask

YACS::ENGINE::Task* YACS::ENGINE::WlmTask::_yacsTask
private

Definition at line 41 of file WlmTask.hxx.

Referenced by isAccepted(), and run().


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