feature #258: Added support to limit the number of VMs submitted to a host at a time

This commit is contained in:
Ruben S. Montero committed 2010-06-11 20:09:06 +02:00
1 parent 83c1b9d993
commit df272f8dbe
5 files changed
+47 -12

No files matched your search

+7 -1
View File
@@ -45,13 +45,14 @@ public:
protected:
Scheduler(string& _url, time_t _timer,
int _machines_limit, int _dispatch_limit):
int _machines_limit, int _dispatch_limit, int _host_dispatch_limit):
hpool(0),
vmpool(0),
timer(_timer),
url(_url),
machines_limit(_machines_limit),
dispatch_limit(_dispatch_limit),
host_dispatch_limit(_host_dispatch_limit),
threshold(0.9),
client(0)
{
@@ -141,6 +142,11 @@ private:
*/
unsigned int dispatch_limit;
/**
* Limit of virtual machines to be deployed simultaneously to a given host.
*/
unsigned int host_dispatch_limit;
/**
* Threshold value to round up freecpu
*/
+4 -1
View File
@@ -59,7 +59,10 @@ public:
/**
*
*/
int get_host(int& hid, HostPoolXML * hpool);
int get_host(int& hid,
HostPoolXML * hpool,
map<int,int>& host_vms,
int max_vms);
void get_requirements (int& cpu, int& memory, int& disk);
+15 -4
View File
@@ -130,7 +130,10 @@ void VirtualMachineXML::set_priorities(vector<float>& total)
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int VirtualMachineXML::get_host(int& hid, HostPoolXML * hpool)
int VirtualMachineXML::get_host(int& hid,
HostPoolXML * hpool,
map<int,int>& host_vms,
int max_vms)
{
vector<VirtualMachineXML::Host *>::reverse_iterator i;
@@ -141,6 +144,8 @@ int VirtualMachineXML::get_host(int& hid, HostPoolXML * hpool)
int mem;
int dsk;
pair<map<int,int>::iterator,bool> rc;
get_requirements(cpu,mem,dsk);
for (i=hosts.rbegin();i!=hosts.rend();i++)
@@ -154,10 +159,16 @@ int VirtualMachineXML::get_host(int& hid, HostPoolXML * hpool)
if (host->test_capacity(cpu,mem,dsk)==true)
{
host->add_capacity(cpu,mem,dsk);
hid = (*i)->hid;
rc = host_vms.insert(make_pair((*i)->hid,0));
return 0;
if ( rc.first->second < max_vms )
{
host->add_capacity(cpu,mem,dsk);
hid = (*i)->hid;
rc.first->second++;
return 0;
}
}
}
+3 -1
View File
@@ -393,6 +393,8 @@ void Scheduler::dispatch()
map<int, ObjectXML*>::const_iterator vm_it;
const map<int, ObjectXML*> pending_vms = vmpool->get_objects();
map<int, int> host_vms;
oss << "Select hosts" << endl;
oss << "\tPRI\tHID" << endl;
oss << "\t-------------------" << endl;
@@ -414,7 +416,7 @@ void Scheduler::dispatch()
{
vm = static_cast<VirtualMachineXML*>(vm_it->second);
rc = vm->get_host(hid,hpool);
rc = vm->get_host(hid,hpool,host_vms,host_dispatch_limit);
if (rc == 0)
{
+18 -5
View File
@@ -34,8 +34,13 @@ public:
RankScheduler(string url,
time_t timer,
unsigned int machines_limit,
unsigned int dispatch_limit
):Scheduler(url,timer,machines_limit, dispatch_limit),rp(0){};
unsigned int dispatch_limit,
unsigned int host_dispatch_limit
):Scheduler(url,
timer,
machines_limit,
dispatch_limit,
host_dispatch_limit),rp(0){};
~RankScheduler()
{
@@ -64,11 +69,12 @@ int main(int argc, char **argv)
time_t timer= 30;
unsigned int machines_limit = 400;
unsigned int dispatch_limit = 300;
unsigned int host_dispatch_limit = 3;
char opt;
ostringstream oss;
while((opt = getopt(argc,argv,"p:t:m:d:")) != -1)
while((opt = getopt(argc,argv,"p:t:m:d:h:")) != -1)
{
switch(opt)
{
@@ -84,9 +90,12 @@ int main(int argc, char **argv)
case 'd':
dispatch_limit = atoi(optarg);
break;
case 'h':
host_dispatch_limit = atoi(optarg);
break;
default:
cerr << "usage: " << argv[0] << " [-p port] [-t timer] ";
cerr << "[-m machines limit] [-d dispatch limit]\n";
cerr << "[-m machines limit] [-d dispatch limit] [-h host_dispatch_limit]\n";
exit(-1);
break;
}
@@ -96,7 +105,11 @@ int main(int argc, char **argv)
oss << "http://localhost:" << port << "/RPC2";
ss = new RankScheduler(oss.str(),timer, machines_limit, dispatch_limit);
ss = new RankScheduler(oss.str(),
timer,
machines_limit,
dispatch_limit,
host_dispatch_limit);
try
{