Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
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 | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 17 | |
Srikanth Vavilapalli | 95810f5 | 2015-09-14 15:49:56 -0700 | [diff] [blame] | 18 | import java.util.List; |
| 19 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 20 | import org.onosproject.net.DeviceId; |
Ray Milkey | 7bf273c | 2017-09-27 16:15:15 -0700 | [diff] [blame] | 21 | import org.onosproject.net.flow.oldbatch.FlowRuleBatchEvent; |
| 22 | import org.onosproject.net.flow.oldbatch.FlowRuleBatchOperation; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 23 | import org.onosproject.store.Store; |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 24 | |
| 25 | /** |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 26 | * Manages inventory of flow rules; not intended for direct use. |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 27 | */ |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 28 | public interface FlowRuleStore extends Store<FlowRuleBatchEvent, FlowRuleStoreDelegate> { |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 29 | |
| 30 | /** |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 31 | * Returns the number of flow rule in the store. |
| 32 | * |
| 33 | * @return number of flow rules |
| 34 | */ |
| 35 | int getFlowRuleCount(); |
| 36 | |
| 37 | /** |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 38 | * Returns the stored flow. |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 39 | * |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 40 | * @param rule the rule to look for |
| 41 | * @return a flow rule |
| 42 | */ |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 43 | FlowEntry getFlowEntry(FlowRule rule); |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 44 | |
| 45 | /** |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 46 | * Returns the flow entries associated with a device. |
| 47 | * |
| 48 | * @param deviceId the device ID |
| 49 | * @return the flow entries |
| 50 | */ |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 51 | Iterable<FlowEntry> getFlowEntries(DeviceId deviceId); |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 52 | |
| 53 | /** |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 54 | * // TODO: Better description of method behavior. |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 55 | * Stores a new flow rule without generating events. |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 56 | * |
| 57 | * @param rule the flow rule to add |
Sho SHIMIZU | be63b23 | 2015-06-30 10:57:58 -0700 | [diff] [blame] | 58 | * @deprecated in Cardinal Release |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 59 | */ |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 60 | @Deprecated |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 61 | void storeFlowRule(FlowRule rule); |
| 62 | |
| 63 | /** |
| 64 | * Stores a batch of flow rules. |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 65 | * |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 66 | * @param batchOperation batch of flow rules. |
Yuta HIGUCHI | 885868f | 2014-11-13 19:12:07 -0800 | [diff] [blame] | 67 | * A batch can contain flow rules for a single device only. |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 68 | * |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 69 | */ |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 70 | void storeBatch(FlowRuleBatchOperation batchOperation); |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 71 | |
| 72 | /** |
| 73 | * Invoked on the completion of a storeBatch operation. |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 74 | * |
| 75 | * @param event flow rule batch event |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 76 | */ |
| 77 | void batchOperationComplete(FlowRuleBatchEvent event); |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 78 | |
| 79 | /** |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 80 | * Marks a flow rule for deletion. Actual deletion will occur |
| 81 | * when the provider indicates that the flow has been removed. |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 82 | * |
| 83 | * @param rule the flow rule to delete |
| 84 | */ |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 85 | void deleteFlowRule(FlowRule rule); |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 86 | |
| 87 | /** |
| 88 | * Stores a new flow rule, or updates an existing entry. |
| 89 | * |
| 90 | * @param rule the flow rule to add or update |
| 91 | * @return flow_added event, or null if just an update |
| 92 | */ |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 93 | FlowRuleEvent addOrUpdateFlowRule(FlowEntry rule); |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 94 | |
| 95 | /** |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 96 | * @param rule the flow entry to remove |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 97 | * @return flow_removed event, or null if nothing removed |
| 98 | */ |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 99 | FlowRuleEvent removeFlowRule(FlowEntry rule); |
Srikanth Vavilapalli | 95810f5 | 2015-09-14 15:49:56 -0700 | [diff] [blame] | 100 | |
| 101 | /** |
Charles Chan | 93fa727 | 2016-01-26 22:27:02 -0800 | [diff] [blame] | 102 | * Marks a flow rule as PENDING_ADD during retry. |
| 103 | * |
| 104 | * Emits flow_update event if the state is changed |
| 105 | * |
| 106 | * @param rule the flow rule that is retrying |
| 107 | * @return flow_updated event, or null if nothing updated |
| 108 | */ |
| 109 | FlowRuleEvent pendingFlowRule(FlowEntry rule); |
| 110 | |
| 111 | /** |
Charles Chan | 0c7c43b | 2016-01-14 17:39:20 -0800 | [diff] [blame] | 112 | * Removes all flow entries of given device from store. |
| 113 | * |
| 114 | * @param deviceId device id |
| 115 | */ |
Victor Silva | 139bca4 | 2016-08-18 11:46:35 -0300 | [diff] [blame] | 116 | default void purgeFlowRule(DeviceId deviceId) {} |
| 117 | |
| 118 | /** |
| 119 | * Removes all flow entries from store. |
| 120 | */ |
| 121 | void purgeFlowRules(); |
Charles Chan | 0c7c43b | 2016-01-14 17:39:20 -0800 | [diff] [blame] | 122 | |
| 123 | /** |
Srikanth Vavilapalli | 95810f5 | 2015-09-14 15:49:56 -0700 | [diff] [blame] | 124 | * Updates the flow table statistics of the specified device using |
| 125 | * the given statistics. |
| 126 | * |
| 127 | * @param deviceId device identifier |
| 128 | * @param tableStats list of table statistics |
| 129 | * @return ready to send event describing what occurred; |
| 130 | */ |
| 131 | FlowRuleEvent updateTableStatistics(DeviceId deviceId, |
| 132 | List<TableStatisticsEntry> tableStats); |
| 133 | |
| 134 | /** |
| 135 | * Returns the flow table statistics associated with a device. |
| 136 | * |
| 137 | * @param deviceId the device ID |
| 138 | * @return the flow table statistics |
| 139 | */ |
| 140 | Iterable<TableStatisticsEntry> getTableStatistics(DeviceId deviceId); |
Patryk Konopka | 7e40c01 | 2017-06-06 13:38:06 +0200 | [diff] [blame] | 141 | |
| 142 | /** |
| 143 | * Returns number of flow rules in ADDED state for specified device. |
| 144 | * |
| 145 | * @param deviceId the device ID |
| 146 | * @return number of flow rules in ADDED state |
| 147 | */ |
| 148 | long getActiveFlowRuleCount(DeviceId deviceId); |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 149 | } |