blob: 449a1fdf8bf8418f6f97160f89fd9530fd230203 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2014-present Open Networking Foundation
Thomas Vachuska83e090e2014-10-22 14:25:35 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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 Vachuska83e090e2014-10-22 14:25:35 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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 Vachuska83e090e2014-10-22 14:25:35 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.flow;
tombe988312014-09-19 18:38:47 -070017
Brian O'Connorabafb502014-12-02 22:26:20 -080018import org.onosproject.net.DeviceId;
Ray Milkey7bf273c2017-09-27 16:15:15 -070019import org.onosproject.net.flow.oldbatch.FlowRuleBatchEvent;
20import org.onosproject.net.flow.oldbatch.FlowRuleBatchOperation;
Brian O'Connorabafb502014-12-02 22:26:20 -080021import org.onosproject.store.Store;
tombe988312014-09-19 18:38:47 -070022
Thomas Vachuskaa8e74772018-02-26 11:33:35 -080023import java.util.List;
24
tombe988312014-09-19 18:38:47 -070025/**
tome4729872014-09-23 00:37:37 -070026 * Manages inventory of flow rules; not intended for direct use.
tombe988312014-09-19 18:38:47 -070027 */
Madan Jampani117aaae2014-10-23 10:04:05 -070028public interface FlowRuleStore extends Store<FlowRuleBatchEvent, FlowRuleStoreDelegate> {
tombe988312014-09-19 18:38:47 -070029
30 /**
Thomas Vachuskaa8e74772018-02-26 11:33:35 -080031 * Returns the number of flow rules in the store.
tom9b4030d2014-10-06 10:39:03 -070032 *
33 * @return number of flow rules
34 */
35 int getFlowRuleCount();
36
37 /**
Thomas Vachuskaa8e74772018-02-26 11:33:35 -080038 * Returns the number of flow rules for the given device in the store.
39 *
40 * @param deviceId device identifier
41 * @return number of flow rules for the given device
42 */
43 default int getFlowRuleCount(DeviceId deviceId) {
44 return 0;
45 }
46
47 /**
alshabiba68eb962014-09-24 20:34:13 -070048 * Returns the stored flow.
tom9b4030d2014-10-06 10:39:03 -070049 *
alshabiba68eb962014-09-24 20:34:13 -070050 * @param rule the rule to look for
51 * @return a flow rule
52 */
alshabib1c319ff2014-10-04 20:29:09 -070053 FlowEntry getFlowEntry(FlowRule rule);
alshabiba68eb962014-09-24 20:34:13 -070054
55 /**
tombe988312014-09-19 18:38:47 -070056 * Returns the flow entries associated with a device.
57 *
58 * @param deviceId the device ID
59 * @return the flow entries
60 */
alshabib1c319ff2014-10-04 20:29:09 -070061 Iterable<FlowEntry> getFlowEntries(DeviceId deviceId);
tombe988312014-09-19 18:38:47 -070062
63 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -070064 * // TODO: Better description of method behavior.
alshabib219ebaa2014-09-22 15:41:24 -070065 * Stores a new flow rule without generating events.
tombe988312014-09-19 18:38:47 -070066 *
67 * @param rule the flow rule to add
Sho SHIMIZUbe63b232015-06-30 10:57:58 -070068 * @deprecated in Cardinal Release
tombe988312014-09-19 18:38:47 -070069 */
Brian O'Connor72cb19a2015-01-16 16:14:41 -080070 @Deprecated
Madan Jampani117aaae2014-10-23 10:04:05 -070071 void storeFlowRule(FlowRule rule);
72
73 /**
74 * Stores a batch of flow rules.
Thomas Vachuska4b420772014-10-30 16:46:17 -070075 *
Madan Jampani117aaae2014-10-23 10:04:05 -070076 * @param batchOperation batch of flow rules.
Yuta HIGUCHI885868f2014-11-13 19:12:07 -080077 * A batch can contain flow rules for a single device only.
Brian O'Connor72cb19a2015-01-16 16:14:41 -080078 *
Madan Jampani117aaae2014-10-23 10:04:05 -070079 */
Brian O'Connor72cb19a2015-01-16 16:14:41 -080080 void storeBatch(FlowRuleBatchOperation batchOperation);
Madan Jampani117aaae2014-10-23 10:04:05 -070081
82 /**
83 * Invoked on the completion of a storeBatch operation.
Thomas Vachuska4b420772014-10-30 16:46:17 -070084 *
85 * @param event flow rule batch event
Madan Jampani117aaae2014-10-23 10:04:05 -070086 */
87 void batchOperationComplete(FlowRuleBatchEvent event);
alshabib219ebaa2014-09-22 15:41:24 -070088
89 /**
alshabib1c319ff2014-10-04 20:29:09 -070090 * Marks a flow rule for deletion. Actual deletion will occur
91 * when the provider indicates that the flow has been removed.
alshabib219ebaa2014-09-22 15:41:24 -070092 *
93 * @param rule the flow rule to delete
94 */
Madan Jampani117aaae2014-10-23 10:04:05 -070095 void deleteFlowRule(FlowRule rule);
tombe988312014-09-19 18:38:47 -070096
97 /**
98 * Stores a new flow rule, or updates an existing entry.
99 *
100 * @param rule the flow rule to add or update
101 * @return flow_added event, or null if just an update
102 */
alshabib1c319ff2014-10-04 20:29:09 -0700103 FlowRuleEvent addOrUpdateFlowRule(FlowEntry rule);
tombe988312014-09-19 18:38:47 -0700104
105 /**
alshabib1c319ff2014-10-04 20:29:09 -0700106 * @param rule the flow entry to remove
tombe988312014-09-19 18:38:47 -0700107 * @return flow_removed event, or null if nothing removed
108 */
alshabib1c319ff2014-10-04 20:29:09 -0700109 FlowRuleEvent removeFlowRule(FlowEntry rule);
Srikanth Vavilapalli95810f52015-09-14 15:49:56 -0700110
111 /**
Charles Chan93fa7272016-01-26 22:27:02 -0800112 * Marks a flow rule as PENDING_ADD during retry.
113 *
114 * Emits flow_update event if the state is changed
115 *
116 * @param rule the flow rule that is retrying
117 * @return flow_updated event, or null if nothing updated
118 */
119 FlowRuleEvent pendingFlowRule(FlowEntry rule);
120
121 /**
Charles Chan0c7c43b2016-01-14 17:39:20 -0800122 * Removes all flow entries of given device from store.
123 *
124 * @param deviceId device id
125 */
Victor Silva139bca42016-08-18 11:46:35 -0300126 default void purgeFlowRule(DeviceId deviceId) {}
127
128 /**
129 * Removes all flow entries from store.
130 */
131 void purgeFlowRules();
Charles Chan0c7c43b2016-01-14 17:39:20 -0800132
133 /**
Srikanth Vavilapalli95810f52015-09-14 15:49:56 -0700134 * Updates the flow table statistics of the specified device using
135 * the given statistics.
136 *
137 * @param deviceId device identifier
138 * @param tableStats list of table statistics
139 * @return ready to send event describing what occurred;
140 */
141 FlowRuleEvent updateTableStatistics(DeviceId deviceId,
142 List<TableStatisticsEntry> tableStats);
143
144 /**
145 * Returns the flow table statistics associated with a device.
146 *
147 * @param deviceId the device ID
148 * @return the flow table statistics
149 */
150 Iterable<TableStatisticsEntry> getTableStatistics(DeviceId deviceId);
Patryk Konopka7e40c012017-06-06 13:38:06 +0200151
152 /**
153 * Returns number of flow rules in ADDED state for specified device.
154 *
155 * @param deviceId the device ID
156 * @return number of flow rules in ADDED state
157 */
158 long getActiveFlowRuleCount(DeviceId deviceId);
tombe988312014-09-19 18:38:47 -0700159}