[SDFAB-359] Allow purging flows, groups and meters by device and application ID
Change-Id: I5e507d230789979ac997dbc99697fa0483363f70
(cherry picked from commit cfd774018c0ed926873b1e171c106217cb2ac568)
diff --git a/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java b/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java
index 78aef84..2b29504 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java
@@ -115,6 +115,15 @@
void purgeFlowRules(DeviceId deviceId);
/**
+ * Purges all the flow rules on the specified device from the given application id.
+ * @param deviceId device identifier
+ * @param appId application identifier
+ */
+ default void purgeFlowRules(DeviceId deviceId, ApplicationId appId) {
+ throw new UnsupportedOperationException("purgeFlowRules not implemented!");
+ }
+
+ /**
* Removes the specified flow rules from their respective devices. If the
* device is not presently connected to the controller, these flow will
* be removed once the device reconnects.
diff --git a/core/api/src/main/java/org/onosproject/net/flow/FlowRuleStore.java b/core/api/src/main/java/org/onosproject/net/flow/FlowRuleStore.java
index 07493a8..1d9e60e 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/FlowRuleStore.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/FlowRuleStore.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.net.flow;
+import org.onosproject.core.ApplicationId;
import org.onosproject.net.DeviceId;
import org.onosproject.net.flow.oldbatch.FlowRuleBatchEvent;
import org.onosproject.net.flow.oldbatch.FlowRuleBatchOperation;
@@ -137,6 +138,15 @@
default void purgeFlowRule(DeviceId deviceId) {}
/**
+ * Removes all flow entries of given device and application ID from store.
+ *
+ * @param deviceId device id
+ * @param appId application id
+ * @return true if operation was successful, false otherwise.
+ */
+ boolean purgeFlowRules(DeviceId deviceId, ApplicationId appId);
+
+ /**
* Removes all flow entries from store.
*/
void purgeFlowRules();
diff --git a/core/api/src/main/java/org/onosproject/net/group/GroupService.java b/core/api/src/main/java/org/onosproject/net/group/GroupService.java
index 460ccb6..bf18a2e 100644
--- a/core/api/src/main/java/org/onosproject/net/group/GroupService.java
+++ b/core/api/src/main/java/org/onosproject/net/group/GroupService.java
@@ -133,6 +133,16 @@
void purgeGroupEntries(DeviceId deviceId);
/**
+ * Purges all the group entries on the specified device and application.
+ *
+ * @param deviceId device identifier
+ * @param appId application identifier
+ */
+ default void purgeGroupEntries(DeviceId deviceId, ApplicationId appId) {
+ throw new UnsupportedOperationException("purgeGroupEntries not implemented");
+ }
+
+ /**
* Purges all group entries.
*/
default void purgeGroupEntries() {}
diff --git a/core/api/src/main/java/org/onosproject/net/group/GroupStore.java b/core/api/src/main/java/org/onosproject/net/group/GroupStore.java
index 850b2ce..672bb4e 100644
--- a/core/api/src/main/java/org/onosproject/net/group/GroupStore.java
+++ b/core/api/src/main/java/org/onosproject/net/group/GroupStore.java
@@ -17,6 +17,7 @@
import java.util.Collection;
+import org.onosproject.core.ApplicationId;
import org.onosproject.core.GroupId;
import org.onosproject.net.DeviceId;
import org.onosproject.store.Store;
@@ -130,6 +131,14 @@
void purgeGroupEntry(DeviceId deviceId);
/**
+ * Removes all group entries of given device and given application from store.
+ *
+ * @param deviceId device id
+ * @param appId application id
+ */
+ void purgeGroupEntries(DeviceId deviceId, ApplicationId appId);
+
+ /**
* Removes all group entries from store.
*/
default void purgeGroupEntries() {}
diff --git a/core/api/src/main/java/org/onosproject/net/meter/MeterService.java b/core/api/src/main/java/org/onosproject/net/meter/MeterService.java
index cf99b5e..6339101 100644
--- a/core/api/src/main/java/org/onosproject/net/meter/MeterService.java
+++ b/core/api/src/main/java/org/onosproject/net/meter/MeterService.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.net.meter;
+import org.onosproject.core.ApplicationId;
import org.onosproject.event.ListenerService;
import org.onosproject.net.DeviceId;
@@ -93,8 +94,18 @@
* Purges all the meters on the specified device.
* @param deviceId device identifier
*/
- default void purgeMeters(DeviceId deviceId){
+ default void purgeMeters(DeviceId deviceId) {
//Default implementation does nothing
}
+ /**
+ * Purges all the meters on the given device and for the given application.
+ *
+ * @param deviceId device identifier
+ * @param appId application identifier
+ */
+ default void purgeMeters(DeviceId deviceId, ApplicationId appId) {
+ throw new UnsupportedOperationException("purgeMeter not implemented");
+ }
+
}
diff --git a/core/api/src/main/java/org/onosproject/net/meter/MeterStore.java b/core/api/src/main/java/org/onosproject/net/meter/MeterStore.java
index 2e632ed..811b418 100644
--- a/core/api/src/main/java/org/onosproject/net/meter/MeterStore.java
+++ b/core/api/src/main/java/org/onosproject/net/meter/MeterStore.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.net.meter;
+import org.onosproject.core.ApplicationId;
import org.onosproject.net.DeviceId;
import org.onosproject.store.Store;
@@ -196,9 +197,19 @@
/**
* Removes all meters of given device from store.
+ * This API is typically used when the device is offline.
*
* @param deviceId the device id
*/
void purgeMeter(DeviceId deviceId);
+ /**
+ * Removes all meters of given device and for the given application from store.
+ * This API is typically used when the device is offline.
+ *
+ * @param deviceId the device id
+ * @param appId the application id
+ */
+ void purgeMeters(DeviceId deviceId, ApplicationId appId);
+
}