root / trunk / src / haizea / policies / admission.py @ 641
1 |
# -------------------------------------------------------------------------- #
|
---|---|
2 |
# Copyright 2006-2009, University of Chicago #
|
3 |
# Copyright 2008-2009, Distributed Systems Architecture Group, Universidad #
|
4 |
# Complutense de Madrid (dsa-research.org) #
|
5 |
# #
|
6 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
7 |
# not use this file except in compliance with the License. You may obtain #
|
8 |
# a copy of the License at #
|
9 |
# #
|
10 |
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11 |
# #
|
12 |
# Unless required by applicable law or agreed to in writing, software #
|
13 |
# distributed under the License is distributed on an "AS IS" BASIS, #
|
14 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
15 |
# See the License for the specific language governing permissions and #
|
16 |
# limitations under the License. #
|
17 |
# -------------------------------------------------------------------------- #
|
18 |
|
19 |
"""This module provides pluggable lease admission policies. See the documentation
|
20 |
for haizea.core.schedule.policy.LeaseAdmissionPolicy for more details on
|
21 |
lease admission policies.
|
22 |
"""
|
23 |
|
24 |
|
25 |
from haizea.core.scheduler.policy import LeaseAdmissionPolicy |
26 |
from haizea.core.leases import Lease |
27 |
|
28 |
class AcceptAllPolicy(LeaseAdmissionPolicy): |
29 |
"""A simple admission policy: all lease requests are accepted.
|
30 |
"""
|
31 |
def __init__(self, slottable): |
32 |
"""Constructor
|
33 |
|
34 |
Argument
|
35 |
slottable -- A fully constructed SlotTable
|
36 |
"""
|
37 |
LeaseAdmissionPolicy.__init__(self, slottable)
|
38 |
|
39 |
def accept_lease(self, lease): |
40 |
"""Lease admission function
|
41 |
|
42 |
See class documentation for details on what policy is implemented here.
|
43 |
Returns True if the lease can be accepted, False if it should be rejected.
|
44 |
|
45 |
Argument
|
46 |
lease -- Lease request
|
47 |
"""
|
48 |
return True |
49 |
|
50 |
class NoARsPolicy(LeaseAdmissionPolicy): |
51 |
"""A simple admission policy: all lease requests, except AR requests,
|
52 |
are accepted.
|
53 |
"""
|
54 |
|
55 |
def __init__(self, slottable): |
56 |
"""Constructor
|
57 |
|
58 |
Argument
|
59 |
slottable -- A fully constructed SlotTable
|
60 |
"""
|
61 |
LeaseAdmissionPolicy.__init__(self, slottable)
|
62 |
|
63 |
def accept_lease(self, lease): |
64 |
"""Lease admission function
|
65 |
|
66 |
See class documentation for details on what policy is implemented here.
|
67 |
Returns True if the lease can be accepted, False if it should be rejected.
|
68 |
|
69 |
Argument
|
70 |
lease -- Lease request
|
71 |
"""
|
72 |
return lease.get_type() != Lease.ADVANCE_RESERVATION
|