adding getFlowRulesByGroupId to the flowservice
Change-Id: Idfcc86277b28af99e201f3bdfdf139217d77244c
Showing
2 changed files
with
23 additions
and
0 deletions
| ... | @@ -84,6 +84,15 @@ public interface FlowRuleService { | ... | @@ -84,6 +84,15 @@ public interface FlowRuleService { |
| 84 | Iterable<FlowRule> getFlowRulesById(ApplicationId id); | 84 | Iterable<FlowRule> getFlowRulesById(ApplicationId id); |
| 85 | 85 | ||
| 86 | /** | 86 | /** |
| 87 | + * Returns a list of rules filterd by application and group id. | ||
| 88 | + * | ||
| 89 | + * @param appId the application id to lookup | ||
| 90 | + * @param groupId the groupid to lookup | ||
| 91 | + * @return collection of flow rules | ||
| 92 | + */ | ||
| 93 | + Iterable<FlowRule> getFlowRulesByGroupId(ApplicationId appId, short groupId); | ||
| 94 | + | ||
| 95 | + /** | ||
| 87 | * Applies a batch operation of FlowRules. | 96 | * Applies a batch operation of FlowRules. |
| 88 | * | 97 | * |
| 89 | * @param batch batch operation to apply | 98 | * @param batch batch operation to apply | ... | ... |
| ... | @@ -166,6 +166,20 @@ public class FlowRuleManager | ... | @@ -166,6 +166,20 @@ public class FlowRuleManager |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | @Override | 168 | @Override |
| 169 | + public Iterable<FlowRule> getFlowRulesByGroupId(ApplicationId appId, short groupId) { | ||
| 170 | + Set<FlowRule> matches = Sets.newHashSet(); | ||
| 171 | + long toLookUp = ((long) appId.id() << 16) | groupId; | ||
| 172 | + for (Device d : deviceService.getDevices()) { | ||
| 173 | + for (FlowEntry flowEntry : store.getFlowEntries(d.id())) { | ||
| 174 | + if ((flowEntry.id().value() >>> 32) == toLookUp) { | ||
| 175 | + matches.add(flowEntry); | ||
| 176 | + } | ||
| 177 | + } | ||
| 178 | + } | ||
| 179 | + return matches; | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + @Override | ||
| 169 | public Future<CompletedBatchOperation> applyBatch( | 183 | public Future<CompletedBatchOperation> applyBatch( |
| 170 | FlowRuleBatchOperation batch) { | 184 | FlowRuleBatchOperation batch) { |
| 171 | Multimap<DeviceId, FlowRuleBatchEntry> perDeviceBatches = | 185 | Multimap<DeviceId, FlowRuleBatchEntry> perDeviceBatches = | ... | ... |
-
Please register or login to post a comment