alshabib

adding getFlowRulesByGroupId to the flowservice

Change-Id: Idfcc86277b28af99e201f3bdfdf139217d77244c
......@@ -84,6 +84,15 @@ public interface FlowRuleService {
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
......
......@@ -166,6 +166,20 @@ public class FlowRuleManager
}
@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 =
......