Added an always_underloaded underload detection algorithm
This commit is contained in:
parent
b1d4f75cca
commit
cdef1fcbb0
@ -22,6 +22,25 @@ import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@contract
|
||||
def always_underloaded_factory(time_step, migration_time, params):
|
||||
""" Creates an algorithm that always considers the host underloaded.
|
||||
|
||||
:param time_step: The length of the simulation time step in seconds.
|
||||
:type time_step: int,>=0
|
||||
|
||||
:param migration_time: The VM migration time in time seconds.
|
||||
:type migration_time: float,>=0
|
||||
|
||||
:param params: A dictionary containing the algorithm's parameters.
|
||||
:type params: dict(str: *)
|
||||
|
||||
:return: A function implementing the algorithm.
|
||||
:rtype: function
|
||||
"""
|
||||
return lambda utilization, state=None: (True, {})
|
||||
|
||||
|
||||
@contract
|
||||
def threshold_factory(time_step, migration_time, params):
|
||||
""" Creates the threshold underload detection algorithm.
|
||||
|
@ -23,6 +23,15 @@ logging.disable(logging.CRITICAL)
|
||||
|
||||
class Trivial(TestCase):
|
||||
|
||||
@qc(10)
|
||||
def always_underloaded_factory(
|
||||
time_step=int_(min=0, max=10),
|
||||
migration_time=float_(min=0, max=10),
|
||||
utilization=list_(of=float)
|
||||
):
|
||||
alg = trivial.always_underloaded_factory(time_step, migration_time, {})
|
||||
assert alg(utilization) == (True, {})
|
||||
|
||||
def test_threshold_factory(self):
|
||||
alg = trivial.threshold_factory(300, 20., {'threshold': 0.5})
|
||||
self.assertEqual(alg([]), (False, {}))
|
||||
@ -32,7 +41,6 @@ class Trivial(TestCase):
|
||||
self.assertEqual(alg([0.0, 0.6]), (False, {}))
|
||||
self.assertEqual(alg([0.0, 1.0]), (False, {}))
|
||||
|
||||
|
||||
def test_last_n_average_threshold_factory(self):
|
||||
alg = trivial.last_n_average_threshold_factory(
|
||||
300, 20., {'threshold': 0.5,
|
||||
@ -47,7 +55,7 @@ class Trivial(TestCase):
|
||||
self.assertEqual(alg([0.0, 0.2, 1.0]), (False, {}))
|
||||
self.assertEqual(alg([0.0, 1.0, 1.0]), (False, {}))
|
||||
self.assertEqual(alg([0.0, 0.6, 0.6]), (False, {}))
|
||||
|
||||
|
||||
alg = trivial.last_n_average_threshold_factory(
|
||||
300, 20., {'threshold': 0.5,
|
||||
'n': 3})
|
||||
|
Loading…
x
Reference in New Issue
Block a user