1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "SALOME_LoadRateManager.hxx"
27 std::string LoadRateManagerFirst::Find(const std::vector<std::string>& hosts,
28 MapOfParserResourcesType& resList)
30 if (hosts.size() == 0)
31 return std::string("");
33 return std::string(hosts[0]);
36 std::string LoadRateManagerCycl::Find(const std::vector<std::string>& hosts,
37 MapOfParserResourcesType& resList)
39 static int imachine = 0;
42 // if empty list return empty string
43 if (hosts.size() == 0)
44 return std::string("");
46 ParserResourcesType resource = resList[std::string(hosts[imachine])];
47 int nbproc = resource.DataForSort._nbOfProcPerNode * resource.DataForSort._nbOfNodes;
48 if( nbproc <= 0) nbproc = 1;
51 return std::string(hosts[imachine]);
56 if(imachine >= (int)hosts.size())
58 return std::string(hosts[imachine]);
63 std::string LoadRateManagerAltCycl::Find(const std::vector<std::string>& hosts,
64 MapOfParserResourcesType& resList)
66 if (hosts.size() == 0)
67 return std::string("");
69 std::string selected=hosts[0];
71 if(_numberOfUses.count(selected) != 0)
72 uses=_numberOfUses[selected];
76 for (std::vector<std::string>::const_iterator iter = hosts.begin(); iter != hosts.end(); iter++)
78 std::string machine=*iter;
79 if(_numberOfUses.count(machine) == 0)
80 _numberOfUses[machine]=0;
81 if(_numberOfUses[machine] < uses)
84 uses=_numberOfUses[machine];
88 _numberOfUses[selected]=_numberOfUses[selected]+1;
89 std::cerr << "selected: " << selected << " " << _numberOfUses[selected] << std::endl;