-
Notifications
You must be signed in to change notification settings - Fork 0
/
Resource.py
70 lines (41 loc) · 1.41 KB
/
Resource.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
'''
Created on Jan 8, 2015
@author: niuzhaojie
'''
class Resource(object):
'''
classdocs
'''
def __init__(self, memory, cpu, disk, network):
'''
Constructor
'''
self._memory = memory
self._cpu = cpu
self._disk = disk
self._network = network
def __eq__(self, obj):
return self._memory == obj.getMemory() and self._cpu == obj.getCPU() and self._disk == obj.getDisk() and self._network == obj.getNetwork()
def __str__(self):
return "<" + str(self._memory) + "," + str(self._cpu) + "," + str(self._disk) + "," + str(self._network) + ">"
def setMemory(self, memory):
self._memory = memory
def setCPU(self, cpu):
self._cpu = cpu
def setDisk(self, disk):
self._disk = disk
def setNetwork(self, network):
self._network = network
def getMemory(self):
return self._memory
def getCPU(self):
return self._cpu
def getDisk(self):
return self._disk
def getNetwork(self):
return self._network
def getResourceVector(self):
return [self._memory, self._cpu, self._disk, self._network]
def getDominantResource(self):
vec = self.getResourceVector()
return max(vec)