Madan Jampani
Committed by Gerrit Code Review

Ignore replica change events if backups are disabled + Eliminate usage of Maps.filterKeys

Change-Id: I17f03e2d8f71a197f57c0dc062ef16301b80cf66
......@@ -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<DeviceId> backedupDevices = Sets.newHashSet();
try {
Set<DeviceId> managedDevices = mastershipService.getDevicesOf(local);
flowTables.forEach((deviceId, deviceFlowTable) -> {
// Only process those devices are that not managed by the local node.
Maps.filterKeys(flowTables, deviceId -> !managedDevices.contains(deviceId))
.forEach((deviceId, flowTable) -> {
Map<FlowId, Set<StoredFlowEntry>> deviceFlowTable = getFlowTable(deviceId);
deviceFlowTable.clear();
deviceFlowTable.putAll(flowTable);
if (!Objects.equal(local, mastershipService.getMasterFor(deviceId))) {
Map<FlowId, Set<StoredFlowEntry>> backupFlowTable = getFlowTable(deviceId);
backupFlowTable.clear();
backupFlowTable.putAll(deviceFlowTable);
backedupDevices.add(deviceId);
}
});
} catch (Exception e) {
log.warn("Failure processing backup request", e);
......