Thomas Vachuska

Fixed listener registry to eject listeners only if they indeed exceed the limit.

Change-Id: Ic9453b5b1eabc3d9c92af01e6817612e710bfba8
......@@ -30,6 +30,8 @@ import static org.slf4j.LoggerFactory.getLogger;
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 @@ public class ListenerRegistry<E extends Event, L extends EventListener<E>>
@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;
}
}
......
......@@ -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"
......