-
Notifications
You must be signed in to change notification settings - Fork 1
/
SYSTEMMODEL.py
196 lines (144 loc) · 11 KB
/
SYSTEMMODEL.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 16 10:56:02 2017
@author: carlos
"""
import copy
import random as random
import math as math
class SYSTEMMODEL:
def __init__(self):
self.numberMicroServices = 0
self.nodenumber = 0
self.requestPerApp = []
self.serviceTupla= []
self.plantillasMaquinas = []
self.nodeFeatures = []
self.cpdNetwork = []
self.rnd = random.Random()
self.rnd.seed(100)
def normalizeConfiguration(self):
for i,v in enumerate(self.serviceTupla):
self.serviceTupla[i]['scaleLevel']= int(math.ceil((self.serviceTupla[i]['computationalResources']*self.serviceTupla[i]['requestNumber']*self.requestPerApp[self.serviceTupla[i]['application']])/self.serviceTupla[i]['threshold']))
self.serviceTupla[i]['containerUsage']= self.serviceTupla[i]['computationalResources']/self.serviceTupla[i]['scaleLevel']
def configurationA(self,nodes, apps, req):
self.nodenumber = nodes
self.requestPerApp = []
self.serviceTupla= []
for i in range(apps):
self.requestPerApp.append(4.0*float(req))
self.serviceTupla.append({"application" : i, "requestNumber" : 0.01, "computationalResources": 0.2, "threshold": 0.04, "failrate": 0.08, "consumeServices": []})
self.serviceTupla.append({"application" : i, "requestNumber" : 0.01, "computationalResources": 0.2, "threshold": 0.04, "failrate": 0.08, "consumeServices": [0]})
self.serviceTupla.append({"application" : i, "requestNumber" : 0.01, "computationalResources": 0.2, "threshold": 0.04, "failrate": 0.08, "consumeServices": [1,0]})
self.serviceTupla.append({"application" : i, "requestNumber" : 0.01, "computationalResources": 0.2, "threshold": 0.04, "failrate": 0.08, "consumeServices": [2]})
self.serviceTupla.append({"application" : i, "requestNumber" : 0.01, "computationalResources": 0.2, "threshold": 0.04, "failrate": 0.08, "consumeServices": [2,0]})
self.serviceTupla.append({"application" : i, "requestNumber" : 0.01, "computationalResources": 0.2, "threshold": 0.04, "failrate": 0.08, "consumeServices": [2,3,4]})
self.numberMicroServices = len(self.serviceTupla)
#definimos las "plantillas" de máquinas
self.plantillasMaquinas = []
self.plantillasMaquinas.append({"name": "tinny", "capacity" : 10.0, "failrate": 0.01})
self.plantillasMaquinas.append({"name": "small", "capacity" : 20.0, "failrate": 0.01})
self.plantillasMaquinas.append({"name": "medium", "capacity" : 40.0, "failrate": 0.01})
self.plantillasMaquinas.append({"name": "big", "capacity" : 80.0, "failrate": 0.01})
#asignamos un tipo/plantilla de máquina a cada uno de los nodos del sistema
#igual número de máquinas de cada tipo
self.nodeFeatures = []
for n in range(self.nodenumber):
self.nodeFeatures.append(self.plantillasMaquinas[n % len(self.plantillasMaquinas)])
#self.nodeFeatures.append(self.plantillasMaquinas[self.rnd.randint(0,len(self.plantillasMaquinas)-1)])
#******************************************************************************************
# Definición de la red del CPD
#******************************************************************************************
self.cpdNetwork = [[0 for x in range(self.nodenumber)] for y in range(self.nodenumber)]
#las máquinas se distribuyen en dos racks.
for r in range(0,self.nodenumber/2):
for s in range(0,self.nodenumber/2):
self.cpdNetwork[r][s]=1.0
self.cpdNetwork[s][r]=1.0
for r in range(0,self.nodenumber/2):
for s in range(self.nodenumber/2,self.nodenumber):
self.cpdNetwork[r][s]=4.0
self.cpdNetwork[s][r]=4.0
for r in range(self.nodenumber/2,self.nodenumber):
for s in range(0,self.nodenumber/2):
self.cpdNetwork[r][s]=4.0
self.cpdNetwork[s][r]=4.0
for r in range(self.nodenumber/2,self.nodenumber):
for s in range(self.nodenumber/2,self.nodenumber):
self.cpdNetwork[r][s]=1.0
self.cpdNetwork[s][r]=1.0
#******************************************************************************************
# END Definición de la red del CPD
#******************************************************************************************
#******************************************************************************************
# BEGIN cálculo del escalado ajustado a threshold
#******************************************************************************************
self.normalizeConfiguration()
#******************************************************************************************
# END cálculo del escalado ajustado a threshold
#******************************************************************************************
def configurationB(self,nodes, apps, req):
self.nodenumber = nodes
self.requestPerApp = []
self.serviceTupla= []
for i in range(apps):
self.requestPerApp.append(4.0*float(req))
self.serviceTupla.append({"application" : i, "requestNumber" : 3.2 , "computationalResources": 0.1 , "threshold": 1.0 , "failrate": 0.04 , "consumeServices": []})
self.serviceTupla.append({"application" : i, "requestNumber" : 1.8 , "computationalResources": 11.7 , "threshold": 25.0 , "failrate": 0.02 , "consumeServices": [12]})
self.serviceTupla.append({"application" : i, "requestNumber" : 3.2 , "computationalResources": 20.0 , "threshold": 200.0 , "failrate": 0.02 , "consumeServices": [1,3]})
self.serviceTupla.append({"application" : i, "requestNumber" : 1.4 , "computationalResources": 0.1 , "threshold": 10.0 , "failrate": 0.0002 , "consumeServices": []})
self.serviceTupla.append({"application" : i, "requestNumber" : 2.3 , "computationalResources": 27.1 , "threshold": 80.0 , "failrate": 0.02 , "consumeServices": [2,3,9,10,11]})
self.serviceTupla.append({"application" : i, "requestNumber" : 0.8 , "computationalResources": 2.8 , "threshold": 30.0 , "failrate": 0.0001 , "consumeServices": []})
self.serviceTupla.append({"application" : i, "requestNumber" : 15.1 , "computationalResources": 3.8 , "threshold": 50.0 , "failrate": 0.003 , "consumeServices": [4,5,8]})
self.serviceTupla.append({"application" : i, "requestNumber" : 15.1 , "computationalResources": 0.5 , "threshold": 10.0 , "failrate": 0.0001 , "consumeServices": [6]})
self.serviceTupla.append({"application" : i, "requestNumber" : 12.0 , "computationalResources": 0.2 , "threshold": 3.0 , "failrate": 0.0006 , "consumeServices": []})
self.serviceTupla.append({"application" : i, "requestNumber" : 3.2 , "computationalResources": 41.3 , "threshold": 100.0 , "failrate": 0.02 , "consumeServices": [11]})
self.serviceTupla.append({"application" : i, "requestNumber" : 0.1 , "computationalResources": 45.1 , "threshold": 100.0 , "failrate": 0.003 , "consumeServices": [11]})
self.serviceTupla.append({"application" : i, "requestNumber" : 3.2 , "computationalResources": 26.3 , "threshold": 80.0 , "failrate": 0.04 , "consumeServices": []})
self.serviceTupla.append({"application" : i, "requestNumber" : 3.2 , "computationalResources": 4.0 , "threshold": 40.0 , "failrate": 0.0006 , "consumeServices": [0,2]})
self.serviceTupla.append({"application" : i, "requestNumber" : 3.2 , "computationalResources": 13.2 , "threshold": 100.0 , "failrate": 0.0003 , "consumeServices": []})
self.numberMicroServices = len(self.serviceTupla)
#definimos las "plantillas" de máquinas
self.plantillasMaquinas = []
self.plantillasMaquinas.append({"name": "tinny", "capacity" : 100.0, "failrate": 0.025})
self.plantillasMaquinas.append({"name": "small", "capacity" : 200.0, "failrate": 0.025})
self.plantillasMaquinas.append({"name": "medium", "capacity" : 400.0, "failrate": 0.025})
self.plantillasMaquinas.append({"name": "big", "capacity" : 800.0, "failrate": 0.025})
#asignamos un tipo/plantilla de máquina a cada uno de los nodos del sistema
#igual número de máquinas de cada tipo
self.nodeFeatures = []
for n in range(self.nodenumber):
self.nodeFeatures.append(self.plantillasMaquinas[n % len(self.plantillasMaquinas)])
#self.nodeFeatures.append(self.plantillasMaquinas[self.rnd.randint(0,len(self.plantillasMaquinas)-1)])
#******************************************************************************************
# Definición de la red del CPD
#******************************************************************************************
self.cpdNetwork = [[0 for x in range(self.nodenumber)] for y in range(self.nodenumber)]
#las máquinas se distribuyen en dos racks.
for r in range(0,self.nodenumber/2):
for s in range(0,self.nodenumber/2):
self.cpdNetwork[r][s]=1.0
self.cpdNetwork[s][r]=1.0
for r in range(0,self.nodenumber/2):
for s in range(self.nodenumber/2,self.nodenumber):
self.cpdNetwork[r][s]=4.0
self.cpdNetwork[s][r]=4.0
for r in range(self.nodenumber/2,self.nodenumber):
for s in range(0,self.nodenumber/2):
self.cpdNetwork[r][s]=4.0
self.cpdNetwork[s][r]=4.0
for r in range(self.nodenumber/2,self.nodenumber):
for s in range(self.nodenumber/2,self.nodenumber):
self.cpdNetwork[r][s]=1.0
self.cpdNetwork[s][r]=1.0
#******************************************************************************************
# END Definición de la red del CPD
#******************************************************************************************
#******************************************************************************************
# BEGIN cálculo del escalado ajustado a threshold
#******************************************************************************************
self.normalizeConfiguration()
#******************************************************************************************
# END cálculo del escalado ajustado a threshold
#******************************************************************************************