Madan Jampani

Fix ONOS-2034 by serializing a immutable copy of the device flow table

Change-Id: Ie129b54bf77172abfe28de0464562ef816a5ec03
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
16 package org.onosproject.store.flow.impl; 16 package org.onosproject.store.flow.impl;
17 17
18 import com.google.common.base.Objects; 18 import com.google.common.base.Objects;
19 +import com.google.common.collect.ImmutableMap;
19 import com.google.common.collect.Iterables; 20 import com.google.common.collect.Iterables;
20 import com.google.common.collect.Maps; 21 import com.google.common.collect.Maps;
21 import com.google.common.collect.Sets; 22 import com.google.common.collect.Sets;
...@@ -641,11 +642,7 @@ public class NewDistributedFlowRuleStore ...@@ -641,11 +642,7 @@ public class NewDistributedFlowRuleStore
641 log.debug("Sending flowEntries for devices {} to {} as backup.", deviceIds, nodeId); 642 log.debug("Sending flowEntries for devices {} to {} as backup.", deviceIds, nodeId);
642 Map<DeviceId, Map<FlowId, Set<StoredFlowEntry>>> deviceFlowEntries = 643 Map<DeviceId, Map<FlowId, Set<StoredFlowEntry>>> deviceFlowEntries =
643 Maps.newConcurrentMap(); 644 Maps.newConcurrentMap();
644 - flowEntries.forEach((key, value) -> { 645 + deviceIds.forEach(id -> deviceFlowEntries.put(id, ImmutableMap.copyOf(getFlowTable(id))));
645 - if (deviceIds.contains(key)) {
646 - deviceFlowEntries.put(key, value);
647 - }
648 - });
649 clusterCommunicator.<Map<DeviceId, Map<FlowId, Set<StoredFlowEntry>>>, Set<DeviceId>>sendAndReceive( 646 clusterCommunicator.<Map<DeviceId, Map<FlowId, Set<StoredFlowEntry>>>, Set<DeviceId>>sendAndReceive(
650 deviceFlowEntries, 647 deviceFlowEntries,
651 FLOW_TABLE_BACKUP, 648 FLOW_TABLE_BACKUP,
...@@ -657,7 +654,8 @@ public class NewDistributedFlowRuleStore ...@@ -657,7 +654,8 @@ public class NewDistributedFlowRuleStore
657 deviceFlowEntries.keySet() : 654 deviceFlowEntries.keySet() :
658 Sets.difference(deviceFlowEntries.keySet(), backedupDevices); 655 Sets.difference(deviceFlowEntries.keySet(), backedupDevices);
659 if (devicesNotBackedup.size() > 0) { 656 if (devicesNotBackedup.size() > 0) {
660 - log.warn("Failed to backup devices: {}", devicesNotBackedup, error); 657 + log.warn("Failed to backup devices: {}. Reason: {}",
658 + devicesNotBackedup, error.getMessage());
661 } 659 }
662 if (backedupDevices != null) { 660 if (backedupDevices != null) {
663 backedupDevices.forEach(id -> { 661 backedupDevices.forEach(id -> {
......