tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.flow; |
| 2 | |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 3 | import java.util.concurrent.Future; |
| 4 | |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 5 | import org.onlab.onos.ApplicationId; |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 6 | import org.onlab.onos.net.DeviceId; |
| 7 | |
| 8 | /** |
| 9 | * Service for injecting flow rules into the environment and for obtaining |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 10 | * information about flow rules already in the environment. This implements |
| 11 | * semantics of a distributed authoritative flow table where the master copy |
| 12 | * of the flow rules lies with the controller and the devices hold only the |
| 13 | * 'cached' copy. |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 14 | */ |
| 15 | public interface FlowRuleService { |
| 16 | |
| 17 | /** |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 18 | * Returns the number of flow rules in the system. |
| 19 | * |
| 20 | * @return flow rule count |
| 21 | */ |
| 22 | int getFlowRuleCount(); |
| 23 | |
| 24 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 25 | * Returns the collection of flow entries applied on the specified device. |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 26 | * This will include flow rules which may not yet have been applied to |
| 27 | * the device. |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 28 | * |
| 29 | * @param deviceId device identifier |
| 30 | * @return collection of flow rules |
| 31 | */ |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 32 | Iterable<FlowEntry> getFlowEntries(DeviceId deviceId); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 33 | |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 34 | // TODO: add createFlowRule factory method and execute operations method |
| 35 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 36 | /** |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 37 | * Applies the specified flow rules onto their respective devices. These |
| 38 | * flow rules will be retained by the system and re-applied anytime the |
| 39 | * device reconnects to the controller. |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 40 | * |
| 41 | * @param flowRules one or more flow rules |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 42 | */ |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 43 | void applyFlowRules(FlowRule... flowRules); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 44 | |
| 45 | /** |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 46 | * Removes the specified flow rules from their respective devices. If the |
| 47 | * device is not presently connected to the controller, these flow will |
| 48 | * be removed once the device reconnects. |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 49 | * |
| 50 | * @param flowRules one or more flow rules |
| 51 | * throws SomeKindOfException that indicates which ones were removed and |
| 52 | * which ones failed |
| 53 | */ |
| 54 | void removeFlowRules(FlowRule... flowRules); |
| 55 | |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 56 | /** |
| 57 | * Removes all rules by id. |
| 58 | * |
| 59 | * @param appId id to remove |
| 60 | */ |
| 61 | void removeFlowRulesById(ApplicationId appId); |
| 62 | |
| 63 | /** |
| 64 | * Returns a list of rules with this application id. |
| 65 | * |
| 66 | * @param id the id to look up |
| 67 | * @return collection of flow rules |
| 68 | */ |
| 69 | Iterable<FlowRule> getFlowRulesById(ApplicationId id); |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 70 | |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 71 | /** |
| 72 | * Applies a batch operation of FlowRules. |
| 73 | * |
| 74 | * @return future indicating the state of the batch operation |
| 75 | */ |
| 76 | Future<CompletedBatchOperation> applyBatch(FlowRuleBatchOperation batch); |
alshabib | 58747a6 | 2014-10-07 11:05:30 -0700 | [diff] [blame] | 77 | |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 78 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 79 | * Adds the specified flow rule listener. |
| 80 | * |
| 81 | * @param listener flow rule listener |
| 82 | */ |
| 83 | void addListener(FlowRuleListener listener); |
| 84 | |
| 85 | /** |
| 86 | * Removes the specified flow rule listener. |
| 87 | * |
| 88 | * @param listener flow rule listener |
| 89 | */ |
| 90 | void removeListener(FlowRuleListener listener); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 91 | } |