Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.flow; |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 17 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 18 | import org.onosproject.core.ApplicationId; |
| 19 | import org.onosproject.net.DeviceId; |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 20 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 21 | import java.util.concurrent.Future; |
| 22 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 23 | /** |
| 24 | * Service for injecting flow rules into the environment and for obtaining |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 25 | * information about flow rules already in the environment. This implements |
| 26 | * semantics of a distributed authoritative flow table where the master copy |
| 27 | * of the flow rules lies with the controller and the devices hold only the |
| 28 | * 'cached' copy. |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 29 | */ |
| 30 | public interface FlowRuleService { |
| 31 | |
| 32 | /** |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 33 | * The topic used for obtaining globally unique ids. |
| 34 | */ |
| 35 | static String FLOW_OP_TOPIC = "flow-ops-ids"; |
| 36 | |
| 37 | /** |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 38 | * Returns the number of flow rules in the system. |
| 39 | * |
| 40 | * @return flow rule count |
| 41 | */ |
| 42 | int getFlowRuleCount(); |
| 43 | |
| 44 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 45 | * Returns the collection of flow entries applied on the specified device. |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 46 | * This will include flow rules which may not yet have been applied to |
| 47 | * the device. |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 48 | * |
| 49 | * @param deviceId device identifier |
| 50 | * @return collection of flow rules |
| 51 | */ |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 52 | Iterable<FlowEntry> getFlowEntries(DeviceId deviceId); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 53 | |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 54 | // TODO: add createFlowRule factory method and execute operations method |
| 55 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 56 | /** |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 57 | * Applies the specified flow rules onto their respective devices. These |
| 58 | * flow rules will be retained by the system and re-applied anytime the |
| 59 | * device reconnects to the controller. |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 60 | * |
| 61 | * @param flowRules one or more flow rules |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 62 | */ |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 63 | void applyFlowRules(FlowRule... flowRules); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 64 | |
| 65 | /** |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 66 | * Removes the specified flow rules from their respective devices. If the |
| 67 | * device is not presently connected to the controller, these flow will |
| 68 | * be removed once the device reconnects. |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 69 | * |
| 70 | * @param flowRules one or more flow rules |
| 71 | * throws SomeKindOfException that indicates which ones were removed and |
| 72 | * which ones failed |
| 73 | */ |
| 74 | void removeFlowRules(FlowRule... flowRules); |
| 75 | |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 76 | /** |
| 77 | * Removes all rules by id. |
| 78 | * |
| 79 | * @param appId id to remove |
| 80 | */ |
| 81 | void removeFlowRulesById(ApplicationId appId); |
| 82 | |
| 83 | /** |
| 84 | * Returns a list of rules with this application id. |
| 85 | * |
| 86 | * @param id the id to look up |
| 87 | * @return collection of flow rules |
| 88 | */ |
| 89 | Iterable<FlowRule> getFlowRulesById(ApplicationId id); |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 90 | |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 91 | /** |
alshabib | aa7e7de | 2014-11-12 19:20:44 -0800 | [diff] [blame] | 92 | * Returns a list of rules filterd by application and group id. |
| 93 | * |
| 94 | * @param appId the application id to lookup |
| 95 | * @param groupId the groupid to lookup |
| 96 | * @return collection of flow rules |
| 97 | */ |
| 98 | Iterable<FlowRule> getFlowRulesByGroupId(ApplicationId appId, short groupId); |
| 99 | |
| 100 | /** |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 101 | * Applies a batch operation of FlowRules. |
| 102 | * |
Yuta HIGUCHI | 5c94727 | 2014-11-03 21:39:21 -0800 | [diff] [blame] | 103 | * @param batch batch operation to apply |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 104 | * @return future indicating the state of the batch operation, due to the |
| 105 | * deprecation of this api the future will immediately return |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 106 | */ |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 107 | @Deprecated |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 108 | Future<CompletedBatchOperation> applyBatch(FlowRuleBatchOperation batch); |
alshabib | 58747a6 | 2014-10-07 11:05:30 -0700 | [diff] [blame] | 109 | |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 110 | /** |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 111 | * Applies a batch operation of FlowRules. |
| 112 | * |
| 113 | * @param ops batch operation to apply |
| 114 | */ |
| 115 | void apply(FlowRuleOperations ops); |
| 116 | |
| 117 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 118 | * Adds the specified flow rule listener. |
| 119 | * |
| 120 | * @param listener flow rule listener |
| 121 | */ |
| 122 | void addListener(FlowRuleListener listener); |
| 123 | |
| 124 | /** |
| 125 | * Removes the specified flow rule listener. |
| 126 | * |
| 127 | * @param listener flow rule listener |
| 128 | */ |
| 129 | void removeListener(FlowRuleListener listener); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 130 | } |