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
50493d12
Commit
50493d12
authored
7 years ago
by
Rowan Powell
Browse files
Options
Downloads
Patches
Plain Diff
cpu usage function scales on requests
parent
391e83c6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mediaServiceSim/LineProtocolGenerator.py
+61
-3
61 additions, 3 deletions
src/mediaServiceSim/LineProtocolGenerator.py
src/mediaServiceSim/serviceSim.py
+10
-7
10 additions, 7 deletions
src/mediaServiceSim/serviceSim.py
with
71 additions
and
10 deletions
src/mediaServiceSim/LineProtocolGenerator.py
+
61
−
3
View file @
50493d12
...
...
@@ -138,7 +138,7 @@ def _configure_service_function(state, max_connected_clients):
return
result
# Simulating telegraf reporting
def
generate_CPU_report
(
time
):
def
generate_CPU_report
(
requests
,
time
):
# Measurement
result
=
'
cpu
'
# meta tag
...
...
@@ -146,8 +146,8 @@ def generate_CPU_report(time):
result
+=
'
,cpu=
"
cpu-total
"'
result
+=
'
'
# field
s
teal
=
randint
(
0
,
50
)
s
ystem
=
randint
(
0
,
100
-
s
teal
)
s
ystem
=
randint
(
0
,
min
(
100
,
requests
*
5
)
)
s
teal
=
randint
(
0
,
100
-
s
ystem
)
idle
=
100
-
(
system
+
steal
)
result
+=
'
usage_steal=
'
+
str
(
steal
/
100
)
result
+=
'
,usage_system=
'
+
str
(
system
/
100
)
...
...
@@ -174,6 +174,64 @@ def generate_mem_report(total_mem, time):
print
(
result
)
return
result
def
generate_compute_node_config
(
slice_id
,
location
,
node_id
,
cpus
,
mem
,
storage
,
time
):
# Measurement
result
=
'
compute_node_config
'
# CommonContext Tag
result
+=
'
,slide_id=
'
+
quote_wrap
(
slice_id
)
# Tag
result
+=
'
,location=
'
+
quote_wrap
(
location
)
result
+=
'
,comp_node_id=
'
+
quote_wrap
(
node_id
)
result
+=
'
'
# field
result
+=
'
cpus=
'
+
str
(
cpus
)
result
+=
'
,memory=
'
+
str
(
mem
)
result
+=
'
,storage=
'
+
str
(
storage
)
result
+=
'
'
# Time
result
+=
str
(
_getNSTime
(
time
))
print
(
result
)
return
result
def
generate_network_resource_config
(
slice_id
,
network_id
,
bandwidth
,
time
):
# Measurement
result
=
'
network_resource_config
'
# Meta Tag
result
+=
'
,slice_id=
'
+
quote_wrap
(
slice_id
)
# Tag
result
+=
'
network_id=
'
+
quote_wrap
(
network_id
)
result
+=
'
'
# field
result
+=
'
bandwidth=
'
+
str
(
bandwidth
)
result
+=
'
'
# Time
result
+=
str
(
_getNSTime
(
time
))
print
(
result
)
return
result
def
generate_network_interface_config
(
slice_id
,
comp_node_id
,
port_id
,
rx_constraint
,
tx_constraint
,
time
):
# Measurement
result
=
'
network_interface_config
'
# Meta Tag
result
+=
'
,slice_id
'
+
quote_wrap
(
slice_id
)
# Tags
result
+=
'
,comp_node_id=
'
+
quote_wrap
(
comp_node_id
)
result
+=
'
,port_id=
'
+
quote_wrap
(
port_id
)
result
+=
'
'
# field
result
+=
'
rx_constraint=
'
+
str
(
rx_constraint
)
result
+=
'
,tx_constraint=
'
+
str
(
tx_constraint
)
result
+=
'
'
# Time
result
+=
str
(
_getNSTime
(
time
))
print
(
result
)
return
result
# Influx needs strings to be quoted, this provides a utility interface to do this
def
quote_wrap
(
str
):
return
"
\"
"
+
str
+
"
\"
"
...
...
This diff is collapsed.
Click to expand it.
src/mediaServiceSim/serviceSim.py
+
10
−
7
View file @
50493d12
...
...
@@ -162,10 +162,9 @@ class Node():
# DemoServer is the class that simulates the behaviour of the MPEG-DASH server
class
DemoServer
(
object
):
def
__init__
(
self
,
cc
,
si
,
db_url
,
db_name
,
server_id
,
server_location
):
def
__init__
(
self
,
si
,
db_url
,
db_name
,
server_id
,
server_location
):
self
.
influxDB
=
db_name
# InfluxDB database name
self
.
id
=
uuid
.
uuid4
()
# MPEG-DASH server ID
self
.
clientCount
=
cc
# Number of clients to simulate
self
.
simIterations
=
si
# Number of iterations to make for this simulation
self
.
influxURL
=
db_url
# InfluxDB connection URL
self
.
currentTime
=
int
(
round
(
time
.
time
()
*
1000
))
# The current time
...
...
@@ -290,11 +289,11 @@ class DemoServer(object):
print
(
"
Configuring
"
)
self
.
configure_VM
(
'
starting
'
)
self
.
configure_VM
(
'
running
'
)
time
.
sleep
(
0.1
)
#
time.sleep(0.1)
self
.
configure_server
(
server_id
,
server_location
)
self
.
_sendInfluxData
(
lp
.
_configure_port
(
'
01
'
,
'
running
'
,
'
1GB/s
'
,
self
.
currentTime
))
self
.
_sendInfluxData
(
lp
.
_configure_service_function
(
'
starting
'
,
100
))
time
.
sleep
(
0.1
)
#
time.sleep(0.1)
self
.
_sendInfluxData
(
lp
.
_configure_service_function
(
'
running
'
,
100
))
def
_cpuUsage
(
self
,
clientCount
):
...
...
@@ -393,10 +392,11 @@ class DemoServer(object):
# Entry point
# -----------------------------------------------------------------------------------------------
print
(
"
Preparing simulation
"
)
clients
=
10
# Iterations is time in seconds for each server to simulate
iterations
=
3000
# port 8086: Direct to DB specified
# port 8186: To telegraf, telegraf specifies DB
start_time
=
time
.
localtime
()
database_manager
=
DatabaseManager
(
'
http://localhost:8186
'
,
'
testDB
'
)
# Set up InfluxDB (need to wait a little while)
database_manager
.
database_teardown
()
...
...
@@ -404,8 +404,8 @@ time.sleep(2)
database_manager
.
database_up
()
time
.
sleep
(
2
)
# configure servers
demoServer_southampton
=
DemoServer
(
clients
,
iterations
,
'
http://localhost:8186
'
,
'
testDB
'
,
"
Server1
"
,
"
Southampton
"
)
demoServer_bristol
=
DemoServer
(
clients
,
iterations
,
'
http://localhost:8186
'
,
'
testDB
'
,
"
Server2
"
,
"
Bristol
"
)
demoServer_southampton
=
DemoServer
(
iterations
,
'
http://localhost:8186
'
,
'
testDB
'
,
"
Server1
"
,
"
Southampton
"
)
demoServer_bristol
=
DemoServer
(
iterations
,
'
http://localhost:8186
'
,
'
testDB
'
,
"
Server2
"
,
"
Bristol
"
)
telegraf_node
=
Node
(
'
http://localhost:8186
'
,
'
testDB
'
,
True
)
server_list
=
[
demoServer_southampton
,
demoServer_bristol
]
client_manager
=
ClientManager
(
server_list
)
...
...
@@ -427,3 +427,6 @@ while True:
for
server
in
server_list
:
server
.
shutdown
()
print
(
"
\n
Finished
"
)
end_time
=
time
.
localtime
()
print
(
"
Started at {0} ended at {1}, total run time {2}
"
.
format
(
start_time
,
end_time
,(
end_time
-
start_time
)))
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