Skip to content

SF will gracefully be removed from available list #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/coordsim/simulation/flowsimulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,14 @@ def process_flow(self, flow, sfc):
metrics.remove_active_flow(flow, current_node_id, current_sf)

# Remove load from sf
if sf in self.params.network.nodes[current_node_id]['available_sf']:
self.params.network.nodes[current_node_id]['available_sf'][sf]['load'] -= flow.dr
assert self.params.network.nodes[current_node_id]['available_sf'][sf]['load'] >= 0, \
'SF load cannot be less than 0!'
else:
log.debug(f"SF {sf} was removed from {current_node_id}, while flow {flow.flow_id} was being "
f"processed. Still assume the flow could finish processing successfully.")
# TODO: drop the flow instead? or at least account for sf resources?
# see https://github.com/RealVNF/coordination-simulation/pull/78#issuecomment-523921483
self.params.network.nodes[current_node_id]['available_sf'][sf]['load'] -= flow.dr
assert self.params.network.nodes[current_node_id]['available_sf'][sf][
'load'] >= 0, 'SF load cannot be less than 0!'
# Check if SF is not processing any more flows AND if SF is removed from placement. If so the SF will
# be removed from the load recording. This allows SFs to be handed gracefully.
if (self.params.network.nodes[current_node_id]['available_sf'][sf]['load'] == 0) and (
sf not in self.params.sf_placement[current_node_id]):
del self.params.network.nodes[current_node_id]['available_sf'][sf]

# Recalculation is necessary because other flows could have already arrived or departed at the node
used_total_capacity = 0.0
Expand Down
5 changes: 2 additions & 3 deletions src/coordsim/simulation/simulatorparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ def __init__(self, network, ing_nodes, sfc_list, sf_list, config, seed, schedule
self.sf_placement = sf_placement
# Update which sf is available at which node
for node_id, placed_sf_list in sf_placement.items():
available_sf = {}
for sf in placed_sf_list:
available_sf[sf] = self.network.nodes[node_id]['available_sf'].get(sf, {'load': 0.0})
self.network.nodes[node_id]['available_sf'] = available_sf
self.network.nodes[node_id]['available_sf'][sf] = self.network.nodes[node_id]['available_sf'].get(sf, {
'load': 0.0})
# Flow interarrival exponential distribution mean: float
self.inter_arr_mean = config['inter_arrival_mean']
# Flow data rate normal distribution mean: float
Expand Down
5 changes: 2 additions & 3 deletions src/siminterface/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,9 @@ def apply(self, actions: SimulatorAction):
self.simulator.params.sf_placement = actions.placement
# Update which sf is available at which node
for node_id, placed_sf_list in actions.placement.items():
available_sf = {}
for sf in placed_sf_list:
available_sf[sf] = self.simulator.params.network.nodes[node_id]['available_sf'].get(sf, {'load': 0.0})
self.simulator.params.network.nodes[node_id]['available_sf'] = available_sf
self.simulator.params.network.nodes[node_id]['available_sf'][sf] = \
self.simulator.params.network.nodes[node_id]['available_sf'].get(sf, {'load': 0.0})

# Get the new schedule from the SimulatorAction
# Set it in the params of the instantiated simulator object.
Expand Down