|
29 | 29 | import java.text.MessageFormat; |
30 | 30 | import java.util.AbstractMap; |
31 | 31 | import java.util.ArrayList; |
| 32 | +import java.util.Arrays; |
32 | 33 | import java.util.Base64; |
33 | 34 | import java.util.Collections; |
34 | 35 | import java.util.HashMap; |
| 36 | +import java.util.Iterator; |
35 | 37 | import java.util.LinkedList; |
36 | 38 | import java.util.List; |
37 | 39 | import java.util.Map; |
38 | | -import java.util.Map.Entry; |
39 | 40 | import java.util.Queue; |
40 | 41 | import java.util.Set; |
41 | 42 | import java.util.function.Predicate; |
@@ -393,17 +394,14 @@ public void removeRxFilters(int portIndex, int profileId) { |
393 | 394 | * @param ports Ports on which to execute the command |
394 | 395 | */ |
395 | 396 | public void waitOnTrafficToFinish(int timeoutInSecounds, int rxDelayMs, Port... ports) { |
396 | | - Map<Port, Boolean> portTrafficMap = new HashMap<>(); |
397 | 397 | long endTime = System.currentTimeMillis() + timeoutInSecounds * 1000; |
| 398 | + List<Port> portsNotIdleYet = new ArrayList<>(Arrays.asList(ports)); |
398 | 399 |
|
399 | | - for (Port port : ports) { |
400 | | - portTrafficMap.put(port, true); |
401 | | - } |
402 | | - while (portTrafficMap.containsValue(true)) { |
403 | | - for (Entry<Port, Boolean> entry : portTrafficMap.entrySet()) { |
404 | | - if (entry.getValue()) { // port is still true, meaning still running traffic |
405 | | - // set port to false if traffic is stopped(IDLE) |
406 | | - entry.setValue(!getPortStatus(entry.getKey().getIndex()).get().getState().equals("IDLE")); |
| 400 | + while (!portsNotIdleYet.isEmpty()) { |
| 401 | + Iterator<Port> iter = portsNotIdleYet.iterator(); |
| 402 | + while (iter.hasNext()) { |
| 403 | + if (getPortStatus(iter.next().getIndex()).get().getState().equals("IDLE")) { |
| 404 | + iter.remove(); |
407 | 405 | } |
408 | 406 | } |
409 | 407 | if (System.currentTimeMillis() > endTime) { |
|
0 commit comments