Skip to content
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

Remove Client Side Batching #493

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
28 changes: 10 additions & 18 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,24 +872,16 @@ def handle_link_down(self, event):
emit_event(self.controller, "failover_link_down",
content=failover_event_contents)

while switch_flows:
offset = settings.BATCH_SIZE or None
switches = list(switch_flows.keys())
for dpid in switches:
emit_event(
self.controller,
context="kytos.flow_manager",
name="flows.install",
content={
"dpid": dpid,
"flow_dict": {"flows": switch_flows[dpid][:offset]},
}
)
if offset is None or offset >= len(switch_flows[dpid]):
del switch_flows[dpid]
continue
switch_flows[dpid] = switch_flows[dpid][offset:]
time.sleep(settings.BATCH_INTERVAL)
for dpid, flows in switch_flows.items():
emit_event(
self.controller,
context="kytos.flow_manager",
name="flows.install",
content={
"dpid": dpid,
"flow_dict": {"flows": flows},
}
)

for evc in evcs_normal:
emit_event(
Expand Down
9 changes: 0 additions & 9 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@
# the maximum disjoint paths from unwanted_path
DISJOINT_PATH_CUTOFF = 10

# BATCH_INTERVAL: time interval between batch requests that will be sent to
# flow_manager (in seconds) - zero enable sending all the requests in a row
BATCH_INTERVAL = 0.5

# BATCH_SIZE: size of a batch request that will be sent to flow_manager, in
# number of FlowMod requests. Use 0 (zero) to disable BATCH mode, i.e. sends
# everything at a glance
BATCH_SIZE = 50

# Default values for EVPL and EPL respectively. They are use when sb_priority
# is not set in a request
EVPL_SB_PRIORITY = 20000
Expand Down
17 changes: 4 additions & 13 deletions tests/unit/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1854,9 +1854,8 @@ def test_handle_link_up(self):
evc_mock.handle_link_up.assert_called_with("abc")

@patch("time.sleep", return_value=None)
@patch("napps.kytos.mef_eline.main.settings")
@patch("napps.kytos.mef_eline.main.emit_event")
def test_handle_link_down(self, emit_event_mock, settings_mock, _):
def test_handle_link_down(self, emit_event_mock, _):
"""Test handle_link_down method."""
uni = create_autospec(UNI)
evc1 = MagicMock(id="1", service_level=0, creation_time=1,
Expand Down Expand Up @@ -1910,7 +1909,6 @@ def test_handle_link_down(self, emit_event_mock, settings_mock, _):
event = KytosEvent(name="test", content={"link": link})
self.napp.circuits = {"1": evc1, "2": evc2, "3": evc3, "4": evc4,
"5": evc5, "6": evc6}
settings_mock.BATCH_SIZE = 2
self.napp.handle_link_down(event)

assert evc5.service_level > evc4.service_level
Expand Down Expand Up @@ -1949,16 +1947,9 @@ def test_handle_link_down(self, emit_event_mock, settings_mock, _):
name="flows.install",
content={
"dpid": "3",
"flow_dict": {"flows": ["flow3", "flow4"]},
}
),
call(
self.napp.controller,
context="kytos.flow_manager",
name="flows.install",
content={
"dpid": "3",
"flow_dict": {"flows": ["flow5", "flow6"]},
"flow_dict": {
"flows": ["flow3", "flow4", "flow5", "flow6"]
},
}
),
])
Expand Down
Loading