Committed by
Gerrit Code Review
Ignore replica change events if backups are disabled + Eliminate usage of Maps.filterKeys
Change-Id: I17f03e2d8f71a197f57c0dc062ef16301b80cf66
Showing
1 changed file
with
11 additions
and
8 deletions
... | @@ -608,6 +608,9 @@ public class NewDistributedFlowRuleStore | ... | @@ -608,6 +608,9 @@ public class NewDistributedFlowRuleStore |
608 | 608 | ||
609 | @Override | 609 | @Override |
610 | public void event(ReplicaInfoEvent event) { | 610 | public void event(ReplicaInfoEvent event) { |
611 | + if (!backupEnabled) { | ||
612 | + return; | ||
613 | + } | ||
611 | if (event.type() == ReplicaInfoEvent.Type.BACKUPS_CHANGED) { | 614 | if (event.type() == ReplicaInfoEvent.Type.BACKUPS_CHANGED) { |
612 | DeviceId deviceId = event.subject(); | 615 | DeviceId deviceId = event.subject(); |
613 | NodeId master = mastershipService.getMasterFor(deviceId); | 616 | NodeId master = mastershipService.getMasterFor(deviceId); |
... | @@ -767,14 +770,14 @@ public class NewDistributedFlowRuleStore | ... | @@ -767,14 +770,14 @@ public class NewDistributedFlowRuleStore |
767 | log.debug("Received flowEntries for {} to backup", flowTables.keySet()); | 770 | log.debug("Received flowEntries for {} to backup", flowTables.keySet()); |
768 | Set<DeviceId> backedupDevices = Sets.newHashSet(); | 771 | Set<DeviceId> backedupDevices = Sets.newHashSet(); |
769 | try { | 772 | try { |
770 | - Set<DeviceId> managedDevices = mastershipService.getDevicesOf(local); | 773 | + flowTables.forEach((deviceId, deviceFlowTable) -> { |
771 | - // Only process those devices are that not managed by the local node. | 774 | + // Only process those devices are that not managed by the local node. |
772 | - Maps.filterKeys(flowTables, deviceId -> !managedDevices.contains(deviceId)) | 775 | + if (!Objects.equal(local, mastershipService.getMasterFor(deviceId))) { |
773 | - .forEach((deviceId, flowTable) -> { | 776 | + Map<FlowId, Set<StoredFlowEntry>> backupFlowTable = getFlowTable(deviceId); |
774 | - Map<FlowId, Set<StoredFlowEntry>> deviceFlowTable = getFlowTable(deviceId); | 777 | + backupFlowTable.clear(); |
775 | - deviceFlowTable.clear(); | 778 | + backupFlowTable.putAll(deviceFlowTable); |
776 | - deviceFlowTable.putAll(flowTable); | 779 | + backedupDevices.add(deviceId); |
777 | - backedupDevices.add(deviceId); | 780 | + } |
778 | }); | 781 | }); |
779 | } catch (Exception e) { | 782 | } catch (Exception e) { |
780 | log.warn("Failure processing backup request", e); | 783 | log.warn("Failure processing backup request", e); | ... | ... |
-
Please register or login to post a comment