Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 19 | package org.onlab.onos.net.flow; |
| 20 | |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 21 | import java.util.concurrent.Future; |
| 22 | |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 23 | import org.onlab.onos.net.DeviceId; |
tom | c78acee | 2014-09-24 15:16:55 -0700 | [diff] [blame] | 24 | import org.onlab.onos.store.Store; |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 25 | |
| 26 | /** |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 27 | * Manages inventory of flow rules; not intended for direct use. |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 28 | */ |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 29 | public interface FlowRuleStore extends Store<FlowRuleBatchEvent, FlowRuleStoreDelegate> { |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 30 | |
| 31 | /** |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 32 | * Returns the number of flow rule in the store. |
| 33 | * |
| 34 | * @return number of flow rules |
| 35 | */ |
| 36 | int getFlowRuleCount(); |
| 37 | |
| 38 | /** |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 39 | * Returns the stored flow. |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 40 | * |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 41 | * @param rule the rule to look for |
| 42 | * @return a flow rule |
| 43 | */ |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 44 | FlowEntry getFlowEntry(FlowRule rule); |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 45 | |
| 46 | /** |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 47 | * Returns the flow entries associated with a device. |
| 48 | * |
| 49 | * @param deviceId the device ID |
| 50 | * @return the flow entries |
| 51 | */ |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 52 | Iterable<FlowEntry> getFlowEntries(DeviceId deviceId); |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 53 | |
| 54 | /** |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 55 | // TODO: Better description of method behavior. |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 56 | * Stores a new flow rule without generating events. |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 57 | * |
| 58 | * @param rule the flow rule to add |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 59 | */ |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 60 | void storeFlowRule(FlowRule rule); |
| 61 | |
| 62 | /** |
| 63 | * Stores a batch of flow rules. |
| 64 | * @param batchOperation batch of flow rules. |
| 65 | * @return Future response indicating success/failure of the batch operation |
| 66 | * all the way down to the device. |
| 67 | */ |
| 68 | Future<CompletedBatchOperation> storeBatch(FlowRuleBatchOperation batchOperation); |
| 69 | |
| 70 | /** |
| 71 | * Invoked on the completion of a storeBatch operation. |
| 72 | * @param result |
| 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 |
Yuta HIGUCHI | f3d51bd | 2014-10-21 01:05:33 -0700 | [diff] [blame] | 81 | * @return true if the rule should be handled locally |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 82 | */ |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 83 | void deleteFlowRule(FlowRule rule); |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 84 | |
| 85 | /** |
| 86 | * Stores a new flow rule, or updates an existing entry. |
| 87 | * |
| 88 | * @param rule the flow rule to add or update |
| 89 | * @return flow_added event, or null if just an update |
| 90 | */ |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 91 | FlowRuleEvent addOrUpdateFlowRule(FlowEntry rule); |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 92 | |
| 93 | /** |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 94 | * @param rule the flow entry to remove |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 95 | * @return flow_removed event, or null if nothing removed |
| 96 | */ |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 97 | FlowRuleEvent removeFlowRule(FlowEntry rule); |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 98 | } |