yoonseon | 6b972c3 | 2016-12-06 16:45:03 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 3 | * |
| 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 |
| 7 | * |
| 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. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.incubator.net.virtual; |
| 18 | |
| 19 | import org.onosproject.net.DeviceId; |
| 20 | import org.onosproject.net.flow.FlowEntry; |
| 21 | import org.onosproject.net.flow.FlowRule; |
| 22 | import org.onosproject.net.flow.FlowRuleBatchEvent; |
| 23 | import org.onosproject.net.flow.FlowRuleBatchOperation; |
| 24 | import org.onosproject.net.flow.FlowRuleEvent; |
| 25 | import org.onosproject.net.flow.FlowRuleStoreDelegate; |
| 26 | import org.onosproject.net.flow.TableStatisticsEntry; |
yoonseon | 6b972c3 | 2016-12-06 16:45:03 -0800 | [diff] [blame] | 27 | |
| 28 | import java.util.List; |
| 29 | |
yoonseon | dc3210d | 2017-01-25 16:03:10 -0800 | [diff] [blame] | 30 | /** |
| 31 | * Manages inventory of flow rules for virtual networks; |
| 32 | * not intended for direct use. |
| 33 | */ |
yoonseon | 6b972c3 | 2016-12-06 16:45:03 -0800 | [diff] [blame] | 34 | public interface VirtualNetworkFlowRuleStore |
yoonseon | bd8a93d | 2016-12-07 15:51:21 -0800 | [diff] [blame] | 35 | extends VirtualStore<FlowRuleBatchEvent, FlowRuleStoreDelegate> { |
yoonseon | 6b972c3 | 2016-12-06 16:45:03 -0800 | [diff] [blame] | 36 | /** |
| 37 | * Returns the number of flow rule in the store. |
| 38 | * |
| 39 | * @param networkId virtual network identifier |
| 40 | * @return number of flow rules |
| 41 | */ |
| 42 | int getFlowRuleCount(NetworkId networkId); |
| 43 | |
| 44 | /** |
| 45 | * Returns the stored flow. |
| 46 | * |
| 47 | * @param networkId virtual network identifier |
| 48 | * @param rule the rule to look for |
| 49 | * @return a flow rule |
| 50 | */ |
| 51 | FlowEntry getFlowEntry(NetworkId networkId, FlowRule rule); |
| 52 | |
| 53 | /** |
| 54 | * Returns the flow entries associated with a device. |
| 55 | * |
| 56 | * @param networkId virtual network identifier |
| 57 | * @param deviceId the device ID |
| 58 | * @return the flow entries |
| 59 | */ |
| 60 | Iterable<FlowEntry> getFlowEntries(NetworkId networkId, DeviceId deviceId); |
| 61 | |
| 62 | /** |
yoonseon | 6b972c3 | 2016-12-06 16:45:03 -0800 | [diff] [blame] | 63 | * Stores a batch of flow rules. |
| 64 | * |
| 65 | * @param networkId virtual network identifier |
| 66 | * @param batchOperation batch of flow rules. |
| 67 | * A batch can contain flow rules for a single device only. |
| 68 | * |
| 69 | */ |
| 70 | void storeBatch(NetworkId networkId, FlowRuleBatchOperation batchOperation); |
| 71 | |
| 72 | /** |
| 73 | * Invoked on the completion of a storeBatch operation. |
| 74 | * |
| 75 | * @param networkId virtual network identifier |
| 76 | * @param event flow rule batch event |
| 77 | */ |
| 78 | void batchOperationComplete(NetworkId networkId, FlowRuleBatchEvent event); |
| 79 | |
| 80 | /** |
| 81 | * Marks a flow rule for deletion. Actual deletion will occur |
| 82 | * when the provider indicates that the flow has been removed. |
| 83 | * |
| 84 | * @param networkId virtual network identifier |
| 85 | * @param rule the flow rule to delete |
| 86 | */ |
| 87 | void deleteFlowRule(NetworkId networkId, FlowRule rule); |
| 88 | |
| 89 | /** |
| 90 | * Stores a new flow rule, or updates an existing entry. |
| 91 | * |
| 92 | * @param networkId virtual network identifier |
| 93 | * @param rule the flow rule to add or update |
| 94 | * @return flow_added event, or null if just an update |
| 95 | */ |
| 96 | FlowRuleEvent addOrUpdateFlowRule(NetworkId networkId, FlowEntry rule); |
| 97 | |
| 98 | /** |
| 99 | * Removes an existing flow entry. |
| 100 | * |
| 101 | * @param rule the flow entry to remove |
| 102 | * @param networkId virtual network identifier |
| 103 | * @return flow_removed event, or null if nothing removed |
| 104 | */ |
| 105 | FlowRuleEvent removeFlowRule(NetworkId networkId, FlowEntry rule); |
| 106 | |
| 107 | /** |
| 108 | * Marks a flow rule as PENDING_ADD during retry. |
| 109 | * |
| 110 | * Emits flow_update event if the state is changed |
| 111 | * |
| 112 | * @param networkId virtual network identifier |
| 113 | * @param rule the flow rule that is retrying |
| 114 | * @return flow_updated event, or null if nothing updated |
| 115 | */ |
| 116 | FlowRuleEvent pendingFlowRule(NetworkId networkId, FlowEntry rule); |
| 117 | |
| 118 | /** |
| 119 | * Removes all flow entries of given device from store. |
| 120 | * |
| 121 | * @param networkId virtual network identifier |
| 122 | * @param deviceId device id |
| 123 | */ |
| 124 | default void purgeFlowRule(NetworkId networkId, DeviceId deviceId) {} |
| 125 | |
| 126 | /** |
| 127 | * Removes all flow entries from store. |
| 128 | * |
| 129 | * @param networkId virtual network identifier |
| 130 | */ |
| 131 | void purgeFlowRules(NetworkId networkId); |
| 132 | |
| 133 | /** |
| 134 | * Updates the flow table statistics of the specified device using |
| 135 | * the given statistics. |
| 136 | * |
| 137 | * @param networkId virtual network identifier |
| 138 | * @param deviceId device identifier |
| 139 | * @param tableStats list of table statistics |
| 140 | * @return ready to send event describing what occurred; |
| 141 | */ |
| 142 | FlowRuleEvent updateTableStatistics(NetworkId networkId, DeviceId deviceId, |
| 143 | List<TableStatisticsEntry> tableStats); |
| 144 | |
| 145 | /** |
| 146 | * Returns the flow table statistics associated with a device. |
| 147 | * |
| 148 | * @param networkId virtual network identifier |
| 149 | * @param deviceId the device ID |
| 150 | * @return the flow table statistics |
| 151 | */ |
| 152 | Iterable<TableStatisticsEntry> getTableStatistics(NetworkId networkId, DeviceId deviceId); |
| 153 | } |