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