Fixed listener registry to eject listeners only if they indeed exceed the limit.
Change-Id: Ic9453b5b1eabc3d9c92af01e6817612e710bfba8
diff --git a/core/api/src/main/java/org/onosproject/event/ListenerRegistry.java b/core/api/src/main/java/org/onosproject/event/ListenerRegistry.java
index ff8fcde..c84fb68 100644
--- a/core/api/src/main/java/org/onosproject/event/ListenerRegistry.java
+++ b/core/api/src/main/java/org/onosproject/event/ListenerRegistry.java
@@ -30,6 +30,8 @@
public class ListenerRegistry<E extends Event, L extends EventListener<E>>
implements EventSink<E> {
+ private static final long LIMIT = 1_800; // ms
+
private final Logger log = getLogger(getClass());
private long lastStart;
@@ -80,10 +82,13 @@
@Override
public void onProcessLimit() {
if (lastStart > 0) {
- log.error("Listener {} exceeded execution time limit: {} ms; ejected",
- lastListener.getClass().getName(),
- System.currentTimeMillis() - lastStart);
- removeListener(lastListener);
+ long duration = System.currentTimeMillis() - lastStart;
+ if (duration > LIMIT) {
+ log.error("Listener {} exceeded execution time limit: {} ms; ejected",
+ lastListener.getClass().getName(),
+ duration);
+ removeListener(lastListener);
+ }
lastStart = 0;
}
}
diff --git a/tools/test/scenarios/net-link-down-up.xml b/tools/test/scenarios/net-link-down-up.xml
index fda756a..70a8fee 100644
--- a/tools/test/scenarios/net-link-down-up.xml
+++ b/tools/test/scenarios/net-link-down-up.xml
@@ -19,11 +19,11 @@
<step name="Ping-1"
exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect \ 0% packet loss"/>
<step name="Link-1-Down" requires="Ping-1"
- exec="onos-mininet sendAndExpect link s4 s5 down --expect ."/>
+ exec="onos-mininet sendAndExpect link s4 s7 down --expect ."/>
<step name="Ping-2" requires="Link-1-Down"
exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect \ 0% packet loss"/>
<step name="Link-2-Down" requires="Ping-2"
- exec="onos-mininet sendAndExpect link s4 s7 down --expect ."/>
+ exec="onos-mininet sendAndExpect link s4 s5 down --expect ."/>
<step name="Ping-3" requires="Link-2-Down"
exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect 100% packet loss"/>
<step name="Link-1-Up" requires="Ping-3"