adding getFlowRulesByGroupId to the flowservice
Change-Id: Idfcc86277b28af99e201f3bdfdf139217d77244c
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleService.java b/core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleService.java
index f40a0f1..8561f8a 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleService.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleService.java
@@ -84,6 +84,15 @@
Iterable<FlowRule> getFlowRulesById(ApplicationId id);
/**
+ * Returns a list of rules filterd by application and group id.
+ *
+ * @param appId the application id to lookup
+ * @param groupId the groupid to lookup
+ * @return collection of flow rules
+ */
+ Iterable<FlowRule> getFlowRulesByGroupId(ApplicationId appId, short groupId);
+
+ /**
* Applies a batch operation of FlowRules.
*
* @param batch batch operation to apply
diff --git a/core/net/src/main/java/org/onlab/onos/net/flow/impl/FlowRuleManager.java b/core/net/src/main/java/org/onlab/onos/net/flow/impl/FlowRuleManager.java
index 2e53252..c1ba8af 100644
--- a/core/net/src/main/java/org/onlab/onos/net/flow/impl/FlowRuleManager.java
+++ b/core/net/src/main/java/org/onlab/onos/net/flow/impl/FlowRuleManager.java
@@ -166,6 +166,20 @@
}
@Override
+ public Iterable<FlowRule> getFlowRulesByGroupId(ApplicationId appId, short groupId) {
+ Set<FlowRule> matches = Sets.newHashSet();
+ long toLookUp = ((long) appId.id() << 16) | groupId;
+ for (Device d : deviceService.getDevices()) {
+ for (FlowEntry flowEntry : store.getFlowEntries(d.id())) {
+ if ((flowEntry.id().value() >>> 32) == toLookUp) {
+ matches.add(flowEntry);
+ }
+ }
+ }
+ return matches;
+ }
+
+ @Override
public Future<CompletedBatchOperation> applyBatch(
FlowRuleBatchOperation batch) {
Multimap<DeviceId, FlowRuleBatchEntry> perDeviceBatches =