Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
flame-clmc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flame
flame-clmc
Commits
a3b7b74d
Commit
a3b7b74d
authored
7 years ago
by
Rowan Powell
Browse files
Options
Downloads
Patches
Plain Diff
Added Port and SF config measurements, refactored all line protocol generation into new file
parent
5d06259f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mediaServiceSim/serviceSim.py
+22
-120
22 additions, 120 deletions
src/mediaServiceSim/serviceSim.py
with
22 additions
and
120 deletions
src/mediaServiceSim/serviceSim.py
+
22
−
120
View file @
a3b7b74d
...
...
@@ -32,7 +32,7 @@ import datetime
import
uuid
import
urllib.parse
import
urllib.request
import
LineProtocolGenerator
as
lp
# DemoConfig is a configuration class used to set up the simulation
class
DemoConfig
(
object
):
...
...
@@ -134,7 +134,7 @@ class DemoServer(object):
ids
=
[
'
A
'
,
'
B
'
,
'
C
'
]
locations
=
[
'
locA
'
,
'
locB
'
,
'
locC
'
]
for
i
,
id
in
enumerate
(
ids
):
server_conf_block
.
append
(
self
.
_generateServerConfig
(
id
,
locations
[
i
],
8
,
'
100G
'
,
'
1T
'
,
self
.
_selectDelay
(
len
(
ids
))))
server_conf_block
.
append
(
lp
.
_generateServerConfig
(
id
,
locations
[
i
],
8
,
'
100G
'
,
'
1T
'
,
self
.
_selectDelay
(
len
(
ids
))))
self
.
_sendInfluxDataBlock
(
server_conf_block
)
def
configure_VMs
(
self
):
print
(
"
Configuring VM nodes
"
)
...
...
@@ -144,6 +144,14 @@ class DemoServer(object):
self
.
_sendInfluxDataBlock
(
VM_conf_block
)
def
configure_ports
(
self
):
print
(
"
Configuring Servers
"
)
server_conf_block
=
[]
for
i
in
range
(
0
,
10
):
server_conf_block
.
append
(
lp
.
_configure_port
())
self
.
_sendInfluxDataBlock
(
server_conf_block
)
def
shutdown_VMs
(
self
):
print
(
"
Shutting down VM nodes
"
)
VM_conf_block
=
[]
...
...
@@ -153,7 +161,7 @@ class DemoServer(object):
def
_generateVMS
(
self
,
state
,
amount
,
datablock
):
for
i
in
range
(
0
,
amount
):
datablock
.
append
(
self
.
_generateVMConfig
(
state
,
1
,
'
100G
'
,
'
1T
'
,
self
.
_selectDelay
(
amount
)))
datablock
.
append
(
lp
.
_generateVMConfig
(
state
,
1
,
'
100G
'
,
'
1T
'
,
self
.
_selectDelay
(
amount
)))
def
iterateService
(
self
):
# The simulation will run through 'X' iterations of the simulation
...
...
@@ -187,7 +195,7 @@ class DemoServer(object):
if
(
cReq
!=
None
):
clientsRequesting
.
append
(
client
)
requestBlock
.
append
(
self
.
_generateClientRequest
(
cReq
)
)
requestBlock
.
append
(
lp
.
_generateClientRequest
(
cReq
,
self
.
id
,
self
.
currentTime
)
)
...
...
@@ -202,20 +210,22 @@ class DemoServer(object):
# Generate some quality and delays based on the number of clients requesting for this iteration
qualitySelect
=
self
.
_selectQuality
(
client
.
getQuality
(),
clientReqCount
)
delaySelect
=
self
.
_selectDelay
(
clientReqCount
)
delaySelect
=
self
.
_selectDelay
(
clientReqCount
)
+
self
.
currentTime
qualityDifference
=
client
.
getQuality
()
-
qualitySelect
totalDifference
+=
qualityDifference
# print('totalDifference = ' + str(totalDifference) +'\n')
# print('totalDifference = ' + str(totalDifference) +'\n')
sumOfclientQuality
+=
client
.
getQuality
()
#print('sumOfclientQuality = ' + str(sumOfclientQuality) + '\n')
#
print('sumOfclientQuality = ' + str(sumOfclientQuality) + '\n')
percentageDifference
=
int
((
totalDifference
*
100
)
/
sumOfclientQuality
)
# print('percentageOfQualityDifference = ' + str(percentageDifference) + '%')
# print('percentageOfQualityDifference = ' + str(percentageDifference) + '%')
responseBlock
.
append
(
self
.
_generateServerResponse
(
client
.
getLastRequestID
(),
qualitySelect
,
delaySelect
,
cpuUsagePercentage
,
percentageDifference
)
)
SFBlock
.
append
(
self
.
_generateMpegDashReport
(
'
https://netflix.com/scream
'
,
qualitySelect
,
delaySelect
))
responseBlock
.
append
(
lp
.
_generateServerResponse
(
client
.
getLastRequestID
(),
qualitySelect
,
delaySelect
,
cpuUsagePercentage
,
percentageDifference
))
SFBlock
.
append
(
lp
.
_generateMpegDashReport
(
'
https://netflix.com/scream
'
,
qualitySelect
,
delaySelect
))
networkBlock
.
append
(
self
.
_generateNetworkReport
(
sumOfclientQuality
,
delaySelect
))
networkBlock
.
append
(
lp
.
_generateNetworkReport
(
sumOfclientQuality
,
delaySelect
))
# Iterate the service simulation
self
.
simIterations
-=
1
self
.
currentTime
+=
1000
# advance 1 second
...
...
@@ -226,7 +236,7 @@ class DemoServer(object):
self
.
_sendInfluxDataBlock
(
responseBlock
)
self
.
_sendInfluxDataBlock
(
networkBlock
)
self
.
_sendInfluxDataBlock
(
SFBlock
)
#
print("Sending influx data blocks")
print
(
"
Sending influx data blocks
"
)
return
self
.
simIterations
...
...
@@ -300,114 +310,6 @@ class DemoServer(object):
return
result
# Method to create a full InfluxDB request statement (based on partial statement from client)
def
_generateClientRequest
(
self
,
cReq
):
# Tags first
result
=
'
sid=
"'
+
str
(
self
.
id
)
+
'"
,
'
+
cReq
# Fields
# No additional fields here yet
# Timestamp
result
+=
'
'
+
str
(
self
.
_getNSTime
()
)
# Measurement
return
'
request,
'
+
result
# Method to create a full InfluxDB response statement
def
_generateServerResponse
(
self
,
reqID
,
quality
,
delay
,
cpuUsage
,
qualityDifference
):
# Tags first
result
=
'
'
# Fields
result
+=
'
quality=
'
+
str
(
quality
)
+
'
,
'
result
+=
'
cpuUsage=
'
+
str
(
cpuUsage
)
+
'
,
'
result
+=
'
qualityDifference=
'
+
str
(
qualityDifference
)
+
'
,
'
result
+=
'
requestID=
"'
+
str
(
reqID
)
+
'"
,
'
result
+=
'
index=
"'
+
str
(
uuid
.
uuid4
()
)
+
'"'
# Timestamp
result
+=
'
'
+
str
(
self
.
_getNSTime
(
delay
)
)
# Measurement
#print('response'+result)
return
'
response
'
+
result
def
_generateNetworkReport
(
self
,
sum_of_client_quality
,
delay
):
# Tags
result
=
'
,port_id=enps03
'
# Fields
result
+=
'
RX_BYTES_PORT_M=
'
+
str
(
sum_of_client_quality
*
32
)
+
"
,
"
result
+=
'
TX_BYTES_PORT_M=
'
+
str
(
sum_of_client_quality
*
1024
)
# Timestamp
result
+=
'
'
+
str
(
self
.
_getNSTime
(
delay
)
)
# Measurement
#print('network'+result)
return
'
net_port_io
'
+
result
def
_generateMpegDashReport
(
self
,
resource
,
quality
,
delay
):
# Tags
result
=
'
'
# Fields
requests
=
randint
(
10
,
30
)
avg_response_time
=
50
+
randint
(
0
,
100
)
+
randint
(
0
,
10
*
quality
)
peak_response_time
=
avg_response_time
+
randint
(
30
,
60
)
+
randint
(
5
,
10
)
*
quality
result
+=
'
cont_nav=
\"
'
+
str
(
resource
)
+
"
\"
,
"
result
+=
'
cont_rep=
'
+
str
(
quality
)
+
'
,
'
result
+=
'
requests=
'
+
str
(
requests
)
+
'
,
'
result
+=
'
avg_response_time=
'
+
str
(
avg_response_time
)
+
'
,
'
result
+=
'
peak_response_time=
'
+
str
(
peak_response_time
)
# Timestamp
result
+=
'
'
+
str
(
self
.
_getNSTime
(
delay
)
)
# Measurement
#print('mpegdash_service'+result)
return
'
mpegdash_service
'
+
result
def
_generateServerConfig
(
self
,
ID
,
location
,
cpu
,
mem
,
storage
,
delay
):
# metric
result
=
'
host_resource
'
# Tags
result
+=
'
,slide_id=
'
+
self
.
quote_wrap
(
ID
)
result
+=
'
,location=
'
+
self
.
quote_wrap
(
location
)
result
+=
'
'
# Fields
result
+=
'
cpu=
'
+
str
(
cpu
)
result
+=
'
,memory=
'
+
self
.
quote_wrap
(
mem
)
result
+=
'
,storage=
'
+
self
.
quote_wrap
(
storage
)
#Time
result
+=
'
'
+
str
(
self
.
_getNSTime
(
delay
)
)
print
(
result
)
return
result
def
_generateVMConfig
(
self
,
state
,
cpu
,
mem
,
storage
,
delay
):
# metric
result
=
'
vm_res_alloc
'
# Tags
result
+=
'
,vm_state=
'
+
self
.
quote_wrap
(
state
)
result
+=
'
'
# Fields
result
+=
'
cpu=
'
+
str
(
cpu
)
result
+=
'
,memory=
'
+
self
.
quote_wrap
(
mem
)
result
+=
'
,storage=
'
+
self
.
quote_wrap
(
storage
)
#Time
result
+=
'
'
+
str
(
self
.
_getNSTime
(
delay
)
)
print
(
result
)
return
result
def
quote_wrap
(
self
,
str
):
return
"
\"
"
+
str
+
"
\"
"
# InfluxDB likes to have time-stamps in nanoseconds
def
_getNSTime
(
self
,
offset
=
0
):
# Convert to nano-seconds
return
1000000
*
(
self
.
currentTime
+
offset
)
def
_createDB
(
self
):
self
.
_sendInfluxQuery
(
'
CREATE DATABASE
'
+
self
.
influxDB
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment