Victor Silva
Committed by Gerrit Code Review

[ONOS-5171] FlowRuleStore: add purgeFlowEntries

The FlowRuleStore exposes purgeFlowEntry(DeviceId),
which purges from the store by a specific device.

Add purgeFlowEntries, to purge entries from all devices.

Change-Id: I0ec50d2bbb8b39097189f9e332dc3efd281bc811
......@@ -111,7 +111,12 @@ public interface FlowRuleStore extends Store<FlowRuleBatchEvent, FlowRuleStoreDe
*
* @param deviceId device id
*/
void purgeFlowRule(DeviceId deviceId);
default void purgeFlowRule(DeviceId deviceId) {}
/**
* Removes all flow entries from store.
*/
void purgeFlowRules();
/**
* Updates the flow table statistics of the specified device using
......
......@@ -316,6 +316,11 @@ public class SimpleFlowRuleStore
}
@Override
public void purgeFlowRules() {
flowEntries.clear();
}
@Override
public void storeBatch(
FlowRuleBatchOperation operation) {
List<FlowRuleBatchEntry> toAdd = new ArrayList<>();
......
......@@ -624,6 +624,11 @@ public class DistributedFlowRuleStore
}
@Override
public void purgeFlowRules() {
flowTable.purgeFlowRules();
}
@Override
public void batchOperationComplete(FlowRuleBatchEvent event) {
//FIXME: need a per device pending response
NodeId nodeId = pendingResponses.remove(event.subject().batchId());
......@@ -872,6 +877,10 @@ public class DistributedFlowRuleStore
flowEntries.remove(deviceId);
}
public void purgeFlowRules() {
flowEntries.clear();
}
private List<NodeId> getBackupNodes(DeviceId deviceId) {
// The returned backup node list is in the order of preference i.e. next likely master first.
List<NodeId> allPossibleBackupNodes = replicaInfoManager.getReplicaInfoFor(deviceId).backups();
......