From a98bf9395ec5e2a193daa966b914a86f8f5ab11c Mon Sep 17 00:00:00 2001 From: Madan Jampani Date: Tue, 2 Jun 2015 12:01:36 -0700 Subject: [PATCH] Ignore replica change events if backups are disabled + Eliminate usage of Maps.filterKeys Change-Id: I17f03e2d8f71a197f57c0dc062ef16301b80cf66 --- .../impl/NewDistributedFlowRuleStore.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java index b2e3d5b81b..249cdf8903 100644 --- a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java +++ b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java @@ -608,6 +608,9 @@ public class NewDistributedFlowRuleStore @Override public void event(ReplicaInfoEvent event) { + if (!backupEnabled) { + return; + } if (event.type() == ReplicaInfoEvent.Type.BACKUPS_CHANGED) { DeviceId deviceId = event.subject(); NodeId master = mastershipService.getMasterFor(deviceId); @@ -767,14 +770,14 @@ public class NewDistributedFlowRuleStore log.debug("Received flowEntries for {} to backup", flowTables.keySet()); Set backedupDevices = Sets.newHashSet(); try { - Set managedDevices = mastershipService.getDevicesOf(local); - // Only process those devices are that not managed by the local node. - Maps.filterKeys(flowTables, deviceId -> !managedDevices.contains(deviceId)) - .forEach((deviceId, flowTable) -> { - Map> deviceFlowTable = getFlowTable(deviceId); - deviceFlowTable.clear(); - deviceFlowTable.putAll(flowTable); - backedupDevices.add(deviceId); + flowTables.forEach((deviceId, deviceFlowTable) -> { + // Only process those devices are that not managed by the local node. + if (!Objects.equal(local, mastershipService.getMasterFor(deviceId))) { + Map> backupFlowTable = getFlowTable(deviceId); + backupFlowTable.clear(); + backupFlowTable.putAll(deviceFlowTable); + backedupDevices.add(deviceId); + } }); } catch (Exception e) { log.warn("Failure processing backup request", e);