-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task.py
89 lines (53 loc) · 1.71 KB
/
Task.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
'''
Created on Jan 9, 2015
@author: niuzhaojie
'''
from SchedulableStatus import SchedulableStatus
import abc
class Task(object):
__metaclass__ = abc.ABCMeta
def __init__(self, taskID, priority, resource):
'''
Constructor
'''
self._taskID = taskID
self._priority = priority
self._resource = resource
self._status = SchedulableStatus.WAITING
self._childs = []
self._parents = []
self._expectedNode = None
self._scheduledNode = None
def getTaskID(self):
return self._taskID
def nodeAllocate(self, node):
self._scheduledNode = node
def addChild(self, child):
self._childs.append(child)
child._parents.append(self)
def getParents(self):
return self._parents
def updateStatus(self, status):
self._status = status
def getStatus(self):
return self._status
def getResource(self):
return self._resource
def getPriority(self):
return self._priority
def getExpectedNode(self):
return self._expectedNode
def getAllocatedNode(self):
return self._scheduledNode
@abc.abstractmethod
def getWorkload(self):
return
def parentsAllFinished(self):
ret = True
for parent in self._parents:
if parent.getStatus() != SchedulableStatus.FINISHING:
ret = False
return ret
@abc.abstractmethod
def schedule(self, t):
return