Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
703a3fe0
authored
Nov 25, 2013
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
manager: improve scheduling algorithm
parent
ed1080d0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
circle/manager/scheduler.py
+10
-5
No files found.
circle/manager/scheduler.py
View file @
703a3fe0
...
...
@@ -2,6 +2,7 @@ from django.db.models import Sum
class
NotEnoughMemoryException
(
Exception
):
def
__init__
(
self
,
message
=
None
):
if
message
is
None
:
message
=
"No node has enough memory to accomodate the guest."
...
...
@@ -10,6 +11,7 @@ class NotEnoughMemoryException(Exception):
class
TraitsUnsatisfiableException
(
Exception
):
def
__init__
(
self
,
message
=
None
):
if
message
is
None
:
message
=
"No node can satisfy all required traits of the guest."
...
...
@@ -32,7 +34,7 @@ def select_node(instance, nodes):
# sort nodes first by processor usage, then priority
nodes
.
sort
(
key
=
lambda
n
:
n
.
priority
,
reverse
=
True
)
nodes
.
sort
(
key
=
processor_usag
e
)
nodes
.
sort
(
key
=
free_cpu_time
,
reverse
=
Tru
e
)
return
nodes
[
0
]
...
...
@@ -59,9 +61,12 @@ def has_enough_ram(ram_size, node):
return
ram_size
<
unused
and
ram_size
<
free
def
processor_usag
e
(
node
):
"""Get a
number indicating processor usag
e on the node.
def
free_cpu_tim
e
(
node
):
"""Get a
n indicator number for idle processor tim
e on the node.
Lower values indicate lower usag
e.
Higher values indicate more idle tim
e.
"""
return
0
# TODO replace mock value with data from monitor
activity
=
0
inactivity
=
1
-
activity
cores
=
node
.
num_cores
return
cores
*
inactivity
# TODO replace mock value with data from monitor
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment