From 10107cd69ad787188fc05b511c4d2d3efb634894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 30 Jan 2013 18:41:16 +0100 Subject: [PATCH] Feature #846: Skip the scheduling if there aren't any pending VMs, and omit empty logs --- src/scheduler/include/Scheduler.h | 7 +++++ src/scheduler/include/VirtualMachinePoolXML.h | 7 +++++ src/scheduler/include/VirtualMachineXML.h | 10 +++++++ .../src/pool/VirtualMachinePoolXML.cc | 5 ++++ src/scheduler/src/sched/Scheduler.cc | 27 +++++++++---------- 5 files changed, 41 insertions(+), 15 deletions(-) diff --git a/src/scheduler/include/Scheduler.h b/src/scheduler/include/Scheduler.h index a10ba27091..52b0f32da5 100644 --- a/src/scheduler/include/Scheduler.h +++ b/src/scheduler/include/Scheduler.h @@ -124,6 +124,13 @@ protected: virtual int schedule(); + /** + * Retrieves the pools + * + * @return 0 on success + * -1 on error + * -2 if no VMs need to be scheduled + */ virtual int set_up_pools(); private: diff --git a/src/scheduler/include/VirtualMachinePoolXML.h b/src/scheduler/include/VirtualMachinePoolXML.h index 12c493c22b..08cf34e4e1 100644 --- a/src/scheduler/include/VirtualMachinePoolXML.h +++ b/src/scheduler/include/VirtualMachinePoolXML.h @@ -34,6 +34,13 @@ public: ~VirtualMachinePoolXML(){}; + /** + * Retrieves the pending and rescheduling VMs + * + * @return 0 on success + * -1 on error + * -2 if no VMs need to be scheduled + */ int set_up(); /** diff --git a/src/scheduler/include/VirtualMachineXML.h b/src/scheduler/include/VirtualMachineXML.h index 04c09b185f..84f7726c38 100644 --- a/src/scheduler/include/VirtualMachineXML.h +++ b/src/scheduler/include/VirtualMachineXML.h @@ -112,14 +112,24 @@ public: */ friend ostream& operator<<(ostream& os, VirtualMachineXML& vm) { + if (vm.hosts.empty()) + { + return os; + } + vector::reverse_iterator i; vector::iterator j; + os << "\t PRI\tHID VM: " << vm.oid << endl + << "\t-----------------------" << endl; + for (i=vm.hosts.rbegin();i!=vm.hosts.rend();i++) { os << "\t" << (*i)->priority << "\t" << (*i)->hid << endl; } + os << endl; + return os; }; diff --git a/src/scheduler/src/pool/VirtualMachinePoolXML.cc b/src/scheduler/src/pool/VirtualMachinePoolXML.cc index f3d0ed84c9..7a75605283 100644 --- a/src/scheduler/src/pool/VirtualMachinePoolXML.cc +++ b/src/scheduler/src/pool/VirtualMachinePoolXML.cc @@ -26,6 +26,11 @@ int VirtualMachinePoolXML::set_up() if ( rc == 0 ) { + if (objects.empty()) + { + return -2; + } + oss.str(""); oss << "Pending and rescheduling VMs:" << endl; diff --git a/src/scheduler/src/sched/Scheduler.cc b/src/scheduler/src/sched/Scheduler.cc index b539c364e4..99999d7252 100644 --- a/src/scheduler/src/sched/Scheduler.cc +++ b/src/scheduler/src/sched/Scheduler.cc @@ -265,6 +265,17 @@ int Scheduler::set_up_pools() map::const_iterator it; map shares; + //-------------------------------------------------------------------------- + //Cleans the cache and get the pending VMs + //-------------------------------------------------------------------------- + + rc = vmpool->set_up(); + + if ( rc != 0 ) + { + return rc; + } + //-------------------------------------------------------------------------- //Cleans the cache and get the hosts ids //-------------------------------------------------------------------------- @@ -293,18 +304,6 @@ int Scheduler::set_up_pools() hpool->merge_clusters(clpool); - - //-------------------------------------------------------------------------- - //Cleans the cache and get the pending VMs - //-------------------------------------------------------------------------- - - rc = vmpool->set_up(); - - if ( rc != 0 ) - { - return rc; - } - //-------------------------------------------------------------------------- //Cleans the cache and get the ACLs //-------------------------------------------------------------------------- @@ -563,9 +562,7 @@ void Scheduler::dispatch() { vm = static_cast(vm_it->second); - oss << "\t PRI\tHID VM: " << vm->get_oid() << endl - << "\t-----------------------" << endl - << *vm << endl; + oss << *vm; } NebulaLog::log("SCHED",Log::INFO,oss);