Add missing synchronized
Change-Id: Ie391feb6ef0fa79ea859e89e8a2fd51d59f03cea
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java b/core/store/dist/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java
index ca3b29c..81f2bfd 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java
@@ -106,10 +106,11 @@
private final Logger log = getLogger(getClass());
+ // primary data:
+ // read/write needs to be synchronized
// store entries as a pile of rules, no info about device tables
- private final Multimap<DeviceId, StoredFlowEntry> flowEntries =
- ArrayListMultimap.<DeviceId, StoredFlowEntry>create();
-
+ private final Multimap<DeviceId, StoredFlowEntry> flowEntries
+ = ArrayListMultimap.<DeviceId, StoredFlowEntry>create();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ReplicaInfoService replicaInfoManager;
@@ -135,6 +136,7 @@
//.removalListener(listener)
.build();
+ // Cache of SMaps used for backup data. each SMap contain device flow table
private LoadingCache<DeviceId, SMap<FlowId, ImmutableList<StoredFlowEntry>>> smaps;
@@ -311,7 +313,7 @@
}
}
- private Set<FlowEntry> getFlowEntriesInternal(DeviceId deviceId) {
+ private synchronized Set<FlowEntry> getFlowEntriesInternal(DeviceId deviceId) {
Collection<? extends FlowEntry> rules = flowEntries.get(deviceId);
if (rules == null) {
return Collections.emptySet();
@@ -365,7 +367,9 @@
}
}
- private ListenableFuture<CompletedBatchOperation> storeBatchInternal(FlowRuleBatchOperation operation) {
+ private synchronized ListenableFuture<CompletedBatchOperation>
+ storeBatchInternal(FlowRuleBatchOperation operation) {
+
final List<StoredFlowEntry> toRemove = new ArrayList<>();
final List<StoredFlowEntry> toAdd = new ArrayList<>();
DeviceId did = null;