Skip to content
Snippets Groups Projects
Commit f573ebb1 authored by Simon Crowle's avatar Simon Crowle
Browse files

Adds stopped->starting and running->stopping states

parent 1b0bf5ae
No related branches found
No related tags found
No related merge requests found
......@@ -79,7 +79,7 @@ class Sim(object):
# Simulation configuration of the media component (MC) state changes
# "MC state", [average (sec), stddev]
mc_config_delay_dist = { "starting": [5, 0.68], "stopping": [2, 0.68]}
mc_config_delay_dist = { "stopped":[1, 0.68], "starting": [5, 0.68], "running":[1, 0.68], "stopping": [2, 0.68]}
print("\nSimulation started. Generating data...")
......@@ -105,7 +105,20 @@ class Sim(object):
max_delay = max(delay_time, max_delay)
sim_time += max_delay
# move mpegdash_service endpoints state through from 'starting' to 'running'
# move mpegdash_service media component state from 'stopped' to 'starting'
max_delay = 0
for ip_endpoint in ip_endpoints:
agent_url = urllib.parse.urlparse(ip_endpoint["agent_url"])
agent_db_client = InfluxDBClient(host=agent_url.hostname, port=agent_url.port, database=self.influx_db_name, timeout=10)
delay_avg = mc_config_delay_dist['stopped'][0]
delay_std = delay_avg * mc_config_delay_dist['stopped'][1]
delay_time = self._changeMCState(agent_db_client, sim_time, "mpegdash_service_config", delay_avg, delay_std, 0.7, 'stopped', 'starting')
max_delay = max(delay_time, max_delay)
sim_time += max_delay
# move mpegdash_service media component state from 'starting' to 'running'
max_delay = 0
for ip_endpoint in ip_endpoints:
agent_url = urllib.parse.urlparse(ip_endpoint["agent_url"])
......@@ -193,7 +206,7 @@ class Sim(object):
# remove requests processed off the queue
ip_endpoint['request_queue'] -= int(requests_processed)
# update media component state (continuously 'running')
# update mpegdash_service media component state (continuously 'running')
state_stats = {}
state_stats['running'] = float(TICK_TIME)
state_stats['avg_running'] = float(TICK_TIME)
......@@ -202,7 +215,20 @@ class Sim(object):
sim_time += TICK_TIME
# Simulate tear-down of media components
# move mpegdash_service endpoints state through from 'running' to 'stopped'
# move mpegdash_service media component state from 'running' to 'stopping'
max_delay = 0
for ip_endpoint in ip_endpoints:
agent_url = urllib.parse.urlparse(ip_endpoint["agent_url"])
agent_db_client = InfluxDBClient(host=agent_url.hostname, port=agent_url.port, database=self.influx_db_name, timeout=10)
delay_avg = mc_config_delay_dist['running'][0]
delay_std = delay_avg * mc_config_delay_dist['running'][1]
delay_time = self._changeMCState(agent_db_client, sim_time, "mpegdash_service_config", delay_avg, delay_std, 0.7, 'running', 'stopping')
max_delay = max(delay_time, max_delay)
sim_time += max_delay
# move mpegdash_service media component state from 'stopping' to 'stopped'
max_delay = 0
for ip_endpoint in ip_endpoints:
agent_url = urllib.parse.urlparse(ip_endpoint["agent_url"])
......@@ -273,9 +299,9 @@ class Sim(object):
"""
# Calculate a randomized total time for the transition (and calculate relative ratios of time in transition and next state)
total_delay_time = random.normalvariate(mu, sigma)
transition_time = total_delay_time * trans_ratio
next_state_time = total_delay_time - transition_time
total_delay_time = max( random.normalvariate(mu, sigma), 1 ) # minimum total delay is 1 second
transition_time = total_delay_time * trans_ratio
next_state_time = total_delay_time - transition_time
mc_states = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment