Fixed listener registry to eject listeners only if they indeed exceed the limit.
Change-Id: Ic9453b5b1eabc3d9c92af01e6817612e710bfba8
Showing
2 changed files
with
11 additions
and
6 deletions
... | @@ -30,6 +30,8 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -30,6 +30,8 @@ import static org.slf4j.LoggerFactory.getLogger; |
30 | public class ListenerRegistry<E extends Event, L extends EventListener<E>> | 30 | public class ListenerRegistry<E extends Event, L extends EventListener<E>> |
31 | implements EventSink<E> { | 31 | implements EventSink<E> { |
32 | 32 | ||
33 | + private static final long LIMIT = 1_800; // ms | ||
34 | + | ||
33 | private final Logger log = getLogger(getClass()); | 35 | private final Logger log = getLogger(getClass()); |
34 | 36 | ||
35 | private long lastStart; | 37 | private long lastStart; |
... | @@ -80,10 +82,13 @@ public class ListenerRegistry<E extends Event, L extends EventListener<E>> | ... | @@ -80,10 +82,13 @@ public class ListenerRegistry<E extends Event, L extends EventListener<E>> |
80 | @Override | 82 | @Override |
81 | public void onProcessLimit() { | 83 | public void onProcessLimit() { |
82 | if (lastStart > 0) { | 84 | if (lastStart > 0) { |
83 | - log.error("Listener {} exceeded execution time limit: {} ms; ejected", | 85 | + long duration = System.currentTimeMillis() - lastStart; |
84 | - lastListener.getClass().getName(), | 86 | + if (duration > LIMIT) { |
85 | - System.currentTimeMillis() - lastStart); | 87 | + log.error("Listener {} exceeded execution time limit: {} ms; ejected", |
86 | - removeListener(lastListener); | 88 | + lastListener.getClass().getName(), |
89 | + duration); | ||
90 | + removeListener(lastListener); | ||
91 | + } | ||
87 | lastStart = 0; | 92 | lastStart = 0; |
88 | } | 93 | } |
89 | } | 94 | } | ... | ... |
... | @@ -19,11 +19,11 @@ | ... | @@ -19,11 +19,11 @@ |
19 | <step name="Ping-1" | 19 | <step name="Ping-1" |
20 | exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect \ 0% packet loss"/> | 20 | exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect \ 0% packet loss"/> |
21 | <step name="Link-1-Down" requires="Ping-1" | 21 | <step name="Link-1-Down" requires="Ping-1" |
22 | - exec="onos-mininet sendAndExpect link s4 s5 down --expect ."/> | 22 | + exec="onos-mininet sendAndExpect link s4 s7 down --expect ."/> |
23 | <step name="Ping-2" requires="Link-1-Down" | 23 | <step name="Ping-2" requires="Link-1-Down" |
24 | exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect \ 0% packet loss"/> | 24 | exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect \ 0% packet loss"/> |
25 | <step name="Link-2-Down" requires="Ping-2" | 25 | <step name="Link-2-Down" requires="Ping-2" |
26 | - exec="onos-mininet sendAndExpect link s4 s7 down --expect ."/> | 26 | + exec="onos-mininet sendAndExpect link s4 s5 down --expect ."/> |
27 | <step name="Ping-3" requires="Link-2-Down" | 27 | <step name="Ping-3" requires="Link-2-Down" |
28 | exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect 100% packet loss"/> | 28 | exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect 100% packet loss"/> |
29 | <step name="Link-1-Up" requires="Ping-3" | 29 | <step name="Link-1-Up" requires="Ping-3" | ... | ... |
-
Please register or login to post a comment