1 // Copyright (C) 2006-2022 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "WlmTask.hxx"
21 #include "Runtime.hxx"
22 #include "Container.hxx"
28 WlmTask::WlmTask(Executor& executor, YACS::ENGINE::Task* yacsTask)
33 Container * yacsContainer = yacsTask->getContainer();
34 if(yacsContainer != nullptr && yacsTask->canAcceptImposedResource())
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;
46 _type.ignoreResources = true;
48 _type.neededCores = 0;
53 const WorkloadManager::ContainerType& WlmTask::type()const
58 void WlmTask::run(const WorkloadManager::RunInfo& runInfo)
62 _executor.loadTask(_yacsTask, runInfo);
63 _executor.makeDatastreamConnections(_yacsTask);
64 YACS::Event ev = _executor.runTask(_yacsTask);
65 _executor.endTask(_yacsTask, ev);
69 _executor.failTask(_yacsTask, runInfo.error_message);
71 delete this; // provisoire
74 bool WlmTask::isAccepted(const WorkloadManager::Resource& r)
76 Container * yacsContainer = _yacsTask->getContainer();
77 std::string hostname = yacsContainer->getProperty("hostname");
80 accept = (hostname == r.name);
84 void WlmTask::loadResources(WorkloadManager::WorkloadManager& wm)
86 Runtime *r(getRuntime());
88 throw YACS::Exception("loadResources : no runtime !");
89 std::vector< std::pair<std::string,int> > data(r->getCatalogOfComputeNodes());
91 for(const std::pair<std::string,int>& res : data)
93 WorkloadManager::Resource newResource;
94 newResource.name = res.first;
97 newResource.nbCores = res.second;
98 wm.addResource(newResource);
100 wm.freezeResources();