Add missing synchronized
Change-Id: Ie391feb6ef0fa79ea859e89e8a2fd51d59f03cea
Showing
1 changed file
with
9 additions
and
5 deletions
... | @@ -106,10 +106,11 @@ public class DistributedFlowRuleStore | ... | @@ -106,10 +106,11 @@ public class DistributedFlowRuleStore |
106 | 106 | ||
107 | private final Logger log = getLogger(getClass()); | 107 | private final Logger log = getLogger(getClass()); |
108 | 108 | ||
109 | + // primary data: | ||
110 | + // read/write needs to be synchronized | ||
109 | // store entries as a pile of rules, no info about device tables | 111 | // store entries as a pile of rules, no info about device tables |
110 | - private final Multimap<DeviceId, StoredFlowEntry> flowEntries = | 112 | + private final Multimap<DeviceId, StoredFlowEntry> flowEntries |
111 | - ArrayListMultimap.<DeviceId, StoredFlowEntry>create(); | 113 | + = ArrayListMultimap.<DeviceId, StoredFlowEntry>create(); |
112 | - | ||
113 | 114 | ||
114 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 115 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
115 | protected ReplicaInfoService replicaInfoManager; | 116 | protected ReplicaInfoService replicaInfoManager; |
... | @@ -135,6 +136,7 @@ public class DistributedFlowRuleStore | ... | @@ -135,6 +136,7 @@ public class DistributedFlowRuleStore |
135 | //.removalListener(listener) | 136 | //.removalListener(listener) |
136 | .build(); | 137 | .build(); |
137 | 138 | ||
139 | + // Cache of SMaps used for backup data. each SMap contain device flow table | ||
138 | private LoadingCache<DeviceId, SMap<FlowId, ImmutableList<StoredFlowEntry>>> smaps; | 140 | private LoadingCache<DeviceId, SMap<FlowId, ImmutableList<StoredFlowEntry>>> smaps; |
139 | 141 | ||
140 | 142 | ||
... | @@ -311,7 +313,7 @@ public class DistributedFlowRuleStore | ... | @@ -311,7 +313,7 @@ public class DistributedFlowRuleStore |
311 | } | 313 | } |
312 | } | 314 | } |
313 | 315 | ||
314 | - private Set<FlowEntry> getFlowEntriesInternal(DeviceId deviceId) { | 316 | + private synchronized Set<FlowEntry> getFlowEntriesInternal(DeviceId deviceId) { |
315 | Collection<? extends FlowEntry> rules = flowEntries.get(deviceId); | 317 | Collection<? extends FlowEntry> rules = flowEntries.get(deviceId); |
316 | if (rules == null) { | 318 | if (rules == null) { |
317 | return Collections.emptySet(); | 319 | return Collections.emptySet(); |
... | @@ -365,7 +367,9 @@ public class DistributedFlowRuleStore | ... | @@ -365,7 +367,9 @@ public class DistributedFlowRuleStore |
365 | } | 367 | } |
366 | } | 368 | } |
367 | 369 | ||
368 | - private ListenableFuture<CompletedBatchOperation> storeBatchInternal(FlowRuleBatchOperation operation) { | 370 | + private synchronized ListenableFuture<CompletedBatchOperation> |
371 | + storeBatchInternal(FlowRuleBatchOperation operation) { | ||
372 | + | ||
369 | final List<StoredFlowEntry> toRemove = new ArrayList<>(); | 373 | final List<StoredFlowEntry> toRemove = new ArrayList<>(); |
370 | final List<StoredFlowEntry> toAdd = new ArrayList<>(); | 374 | final List<StoredFlowEntry> toAdd = new ArrayList<>(); |
371 | DeviceId did = null; | 375 | DeviceId did = null; | ... | ... |
-
Please register or login to post a comment