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 | */ |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 16 | package org.onlab.onos.net.flow; |
| 17 | |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 18 | import java.util.concurrent.Future; |
| 19 | |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 20 | import org.onlab.onos.net.DeviceId; |
tom | c78acee | 2014-09-24 15:16:55 -0700 | [diff] [blame] | 21 | import org.onlab.onos.store.Store; |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 22 | |
| 23 | /** |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 24 | * Manages inventory of flow rules; not intended for direct use. |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 25 | */ |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 26 | public interface FlowRuleStore extends Store<FlowRuleBatchEvent, FlowRuleStoreDelegate> { |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 27 | |
| 28 | /** |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 29 | * Returns the number of flow rule in the store. |
| 30 | * |
| 31 | * @return number of flow rules |
| 32 | */ |
| 33 | int getFlowRuleCount(); |
| 34 | |
| 35 | /** |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 36 | * Returns the stored flow. |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 37 | * |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 38 | * @param rule the rule to look for |
| 39 | * @return a flow rule |
| 40 | */ |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 41 | FlowEntry getFlowEntry(FlowRule rule); |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 42 | |
| 43 | /** |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 44 | * Returns the flow entries associated with a device. |
| 45 | * |
| 46 | * @param deviceId the device ID |
| 47 | * @return the flow entries |
| 48 | */ |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 49 | Iterable<FlowEntry> getFlowEntries(DeviceId deviceId); |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 50 | |
| 51 | /** |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 52 | * // TODO: Better description of method behavior. |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 53 | * Stores a new flow rule without generating events. |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 54 | * |
| 55 | * @param rule the flow rule to add |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 56 | */ |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 57 | void storeFlowRule(FlowRule rule); |
| 58 | |
| 59 | /** |
| 60 | * Stores a batch of flow rules. |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 61 | * |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 62 | * @param batchOperation batch of flow rules. |
Yuta HIGUCHI | 885868f | 2014-11-13 19:12:07 -0800 | [diff] [blame] | 63 | * A batch can contain flow rules for a single device only. |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 64 | * @return Future response indicating success/failure of the batch operation |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 65 | * all the way down to the device. |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 66 | */ |
| 67 | Future<CompletedBatchOperation> storeBatch(FlowRuleBatchOperation batchOperation); |
| 68 | |
| 69 | /** |
| 70 | * Invoked on the completion of a storeBatch operation. |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 71 | * |
| 72 | * @param event flow rule batch event |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 73 | */ |
| 74 | void batchOperationComplete(FlowRuleBatchEvent event); |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 75 | |
| 76 | /** |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 77 | * Marks a flow rule for deletion. Actual deletion will occur |
| 78 | * when the provider indicates that the flow has been removed. |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 79 | * |
| 80 | * @param rule the flow rule to delete |
| 81 | */ |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 82 | void deleteFlowRule(FlowRule rule); |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 83 | |
| 84 | /** |
| 85 | * Stores a new flow rule, or updates an existing entry. |
| 86 | * |
| 87 | * @param rule the flow rule to add or update |
| 88 | * @return flow_added event, or null if just an update |
| 89 | */ |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 90 | FlowRuleEvent addOrUpdateFlowRule(FlowEntry rule); |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 91 | |
| 92 | /** |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 93 | * @param rule the flow entry to remove |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 94 | * @return flow_removed event, or null if nothing removed |
| 95 | */ |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 96 | FlowRuleEvent removeFlowRule(FlowEntry rule); |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 97 | } |