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