Committed by
Gerrit Code Review
Use thread safe sets for listeners in OpenFlowControllerImpl
Change-Id: Ieaae89cad1d65c70afad8cde12b17282d7fe357e
Showing
1 changed file
with
6 additions
and
7 deletions
| ... | @@ -18,7 +18,6 @@ package org.onosproject.openflow.controller.impl; | ... | @@ -18,7 +18,6 @@ package org.onosproject.openflow.controller.impl; |
| 18 | import com.google.common.collect.ArrayListMultimap; | 18 | import com.google.common.collect.ArrayListMultimap; |
| 19 | import com.google.common.collect.Lists; | 19 | import com.google.common.collect.Lists; |
| 20 | import com.google.common.collect.Multimap; | 20 | import com.google.common.collect.Multimap; |
| 21 | -import com.google.common.collect.Sets; | ||
| 22 | import org.apache.felix.scr.annotations.Activate; | 21 | import org.apache.felix.scr.annotations.Activate; |
| 23 | import org.apache.felix.scr.annotations.Component; | 22 | import org.apache.felix.scr.annotations.Component; |
| 24 | import org.apache.felix.scr.annotations.Deactivate; | 23 | import org.apache.felix.scr.annotations.Deactivate; |
| ... | @@ -61,10 +60,10 @@ import org.slf4j.LoggerFactory; | ... | @@ -61,10 +60,10 @@ import org.slf4j.LoggerFactory; |
| 61 | import java.util.Collection; | 60 | import java.util.Collection; |
| 62 | import java.util.Dictionary; | 61 | import java.util.Dictionary; |
| 63 | import java.util.HashMap; | 62 | import java.util.HashMap; |
| 64 | -import java.util.HashSet; | ||
| 65 | import java.util.Map; | 63 | import java.util.Map; |
| 66 | import java.util.Set; | 64 | import java.util.Set; |
| 67 | import java.util.concurrent.ConcurrentHashMap; | 65 | import java.util.concurrent.ConcurrentHashMap; |
| 66 | +import java.util.concurrent.CopyOnWriteArraySet; | ||
| 68 | import java.util.concurrent.ExecutorService; | 67 | import java.util.concurrent.ExecutorService; |
| 69 | import java.util.concurrent.Executors; | 68 | import java.util.concurrent.Executors; |
| 70 | import java.util.concurrent.locks.Lock; | 69 | import java.util.concurrent.locks.Lock; |
| ... | @@ -89,19 +88,19 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -89,19 +88,19 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
| 89 | Executors.newFixedThreadPool(4, groupedThreads("onos/of", "event-barrier-%d")); | 88 | Executors.newFixedThreadPool(4, groupedThreads("onos/of", "event-barrier-%d")); |
| 90 | 89 | ||
| 91 | protected ConcurrentHashMap<Dpid, OpenFlowSwitch> connectedSwitches = | 90 | protected ConcurrentHashMap<Dpid, OpenFlowSwitch> connectedSwitches = |
| 92 | - new ConcurrentHashMap<Dpid, OpenFlowSwitch>(); | 91 | + new ConcurrentHashMap<>(); |
| 93 | protected ConcurrentHashMap<Dpid, OpenFlowSwitch> activeMasterSwitches = | 92 | protected ConcurrentHashMap<Dpid, OpenFlowSwitch> activeMasterSwitches = |
| 94 | - new ConcurrentHashMap<Dpid, OpenFlowSwitch>(); | 93 | + new ConcurrentHashMap<>(); |
| 95 | protected ConcurrentHashMap<Dpid, OpenFlowSwitch> activeEqualSwitches = | 94 | protected ConcurrentHashMap<Dpid, OpenFlowSwitch> activeEqualSwitches = |
| 96 | - new ConcurrentHashMap<Dpid, OpenFlowSwitch>(); | 95 | + new ConcurrentHashMap<>(); |
| 97 | 96 | ||
| 98 | protected OpenFlowSwitchAgent agent = new OpenFlowSwitchAgent(); | 97 | protected OpenFlowSwitchAgent agent = new OpenFlowSwitchAgent(); |
| 99 | - protected Set<OpenFlowSwitchListener> ofSwitchListener = new HashSet<>(); | 98 | + protected Set<OpenFlowSwitchListener> ofSwitchListener = new CopyOnWriteArraySet<>(); |
| 100 | 99 | ||
| 101 | protected Multimap<Integer, PacketListener> ofPacketListener = | 100 | protected Multimap<Integer, PacketListener> ofPacketListener = |
| 102 | ArrayListMultimap.create(); | 101 | ArrayListMultimap.create(); |
| 103 | 102 | ||
| 104 | - protected Set<OpenFlowEventListener> ofEventListener = Sets.newHashSet(); | 103 | + protected Set<OpenFlowEventListener> ofEventListener = new CopyOnWriteArraySet<>(); |
| 105 | 104 | ||
| 106 | protected Multimap<Dpid, OFFlowStatsEntry> fullFlowStats = | 105 | protected Multimap<Dpid, OFFlowStatsEntry> fullFlowStats = |
| 107 | ArrayListMultimap.create(); | 106 | ArrayListMultimap.create(); | ... | ... |
-
Please register or login to post a comment