-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
#include "SALOME_LoadRateManager.hxx"
#include <iostream>
#include <map>
-using namespace std;
-
-string SALOME_LoadRateManager::FindFirst(const vector<string>& hosts)
+std::string LoadRateManagerFirst::Find(const std::vector<std::string>& hosts,
+ MapOfParserResourcesType& resList)
{
if (hosts.size() == 0)
- return string("");
+ return std::string("");
- return string(hosts[0]);
+ return std::string(hosts[0]);
}
-string SALOME_LoadRateManager::FindNext(const vector<string>& hosts,MapOfParserResourcesType& resList)
+std::string LoadRateManagerCycl::Find(const std::vector<std::string>& hosts,
+ MapOfParserResourcesType& resList)
{
static int imachine = 0;
static int iproc = 0;
// if empty list return empty string
if (hosts.size() == 0)
- return string("");
+ return std::string("");
else{
- ParserResourcesType resource = resList[string(hosts[imachine])];
+ ParserResourcesType resource = resList[std::string(hosts[imachine])];
int nbproc = resource.DataForSort._nbOfProcPerNode * resource.DataForSort._nbOfNodes;
if( nbproc <= 0) nbproc = 1;
if( iproc < nbproc ){
iproc++;
- return string(hosts[imachine]);
+ return std::string(hosts[imachine]);
}
else{
iproc = 1;
imachine++;
- if(imachine == hosts.size())
- imachine = 0;
- return string(hosts[imachine]);
+ if(imachine >= (int)hosts.size())
+ imachine = 0;
+ return std::string(hosts[imachine]);
}
}
}
-string SALOME_LoadRateManager::FindBest(const vector<string>& hosts)
+std::string LoadRateManagerAltCycl::Find(const std::vector<std::string>& hosts,
+ MapOfParserResourcesType& resList)
{
- // for the moment then "maui" will be used for dynamic selection ...
- return FindFirst(hosts);
+ if (hosts.size() == 0)
+ return std::string("");
+
+ std::string selected=hosts[0];
+ int uses=0;
+ if(_numberOfUses.count(selected) != 0)
+ uses=_numberOfUses[selected];
+ else
+ uses=0;
+
+ for (std::vector<std::string>::const_iterator iter = hosts.begin(); iter != hosts.end(); iter++)
+ {
+ std::string machine=*iter;
+ if(_numberOfUses.count(machine) == 0)
+ _numberOfUses[machine]=0;
+ if(_numberOfUses[machine] < uses)
+ {
+ selected=machine;
+ uses=_numberOfUses[machine];
+ }
+ }
+
+ _numberOfUses[selected]=_numberOfUses[selected]+1;
+ std::cerr << "selected: " << selected << " " << _numberOfUses[selected] << std::endl;
+ return selected;
}
+