blob: 02810094d0cdd7fe296d57fb6b58564147dea303 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
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
Srikanth Vavilapalli95810f52015-09-14 15:49:56 -070018import java.util.List;
19
Brian O'Connorabafb502014-12-02 22:26:20 -080020import org.onosproject.net.DeviceId;
21import org.onosproject.store.Store;
tombe988312014-09-19 18:38:47 -070022
23/**
tome4729872014-09-23 00:37:37 -070024 * Manages inventory of flow rules; not intended for direct use.
tombe988312014-09-19 18:38:47 -070025 */
Madan Jampani117aaae2014-10-23 10:04:05 -070026public interface FlowRuleStore extends Store<FlowRuleBatchEvent, FlowRuleStoreDelegate> {
tombe988312014-09-19 18:38:47 -070027
28 /**
tom9b4030d2014-10-06 10:39:03 -070029 * Returns the number of flow rule in the store.
30 *
31 * @return number of flow rules
32 */
33 int getFlowRuleCount();
34
35 /**
alshabiba68eb962014-09-24 20:34:13 -070036 * Returns the stored flow.
tom9b4030d2014-10-06 10:39:03 -070037 *
alshabiba68eb962014-09-24 20:34:13 -070038 * @param rule the rule to look for
39 * @return a flow rule
40 */
alshabib1c319ff2014-10-04 20:29:09 -070041 FlowEntry getFlowEntry(FlowRule rule);
alshabiba68eb962014-09-24 20:34:13 -070042
43 /**
tombe988312014-09-19 18:38:47 -070044 * Returns the flow entries associated with a device.
45 *
46 * @param deviceId the device ID
47 * @return the flow entries
48 */
alshabib1c319ff2014-10-04 20:29:09 -070049 Iterable<FlowEntry> getFlowEntries(DeviceId deviceId);
tombe988312014-09-19 18:38:47 -070050
51 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -070052 * // TODO: Better description of method behavior.
alshabib219ebaa2014-09-22 15:41:24 -070053 * Stores a new flow rule without generating events.
tombe988312014-09-19 18:38:47 -070054 *
55 * @param rule the flow rule to add
Sho SHIMIZUbe63b232015-06-30 10:57:58 -070056 * @deprecated in Cardinal Release
tombe988312014-09-19 18:38:47 -070057 */
Brian O'Connor72cb19a2015-01-16 16:14:41 -080058 @Deprecated
Madan Jampani117aaae2014-10-23 10:04:05 -070059 void storeFlowRule(FlowRule rule);
60
61 /**
62 * Stores a batch of flow rules.
Thomas Vachuska4b420772014-10-30 16:46:17 -070063 *
Madan Jampani117aaae2014-10-23 10:04:05 -070064 * @param batchOperation batch of flow rules.
Yuta HIGUCHI885868f2014-11-13 19:12:07 -080065 * A batch can contain flow rules for a single device only.
Brian O'Connor72cb19a2015-01-16 16:14:41 -080066 *
Madan Jampani117aaae2014-10-23 10:04:05 -070067 */
Brian O'Connor72cb19a2015-01-16 16:14:41 -080068 void storeBatch(FlowRuleBatchOperation batchOperation);
Madan Jampani117aaae2014-10-23 10:04:05 -070069
70 /**
71 * Invoked on the completion of a storeBatch operation.
Thomas Vachuska4b420772014-10-30 16:46:17 -070072 *
73 * @param event flow rule batch event
Madan Jampani117aaae2014-10-23 10:04:05 -070074 */
75 void batchOperationComplete(FlowRuleBatchEvent event);
alshabib219ebaa2014-09-22 15:41:24 -070076
77 /**
alshabib1c319ff2014-10-04 20:29:09 -070078 * Marks a flow rule for deletion. Actual deletion will occur
79 * when the provider indicates that the flow has been removed.
alshabib219ebaa2014-09-22 15:41:24 -070080 *
81 * @param rule the flow rule to delete
82 */
Madan Jampani117aaae2014-10-23 10:04:05 -070083 void deleteFlowRule(FlowRule rule);
tombe988312014-09-19 18:38:47 -070084
85 /**
86 * Stores a new flow rule, or updates an existing entry.
87 *
88 * @param rule the flow rule to add or update
89 * @return flow_added event, or null if just an update
90 */
alshabib1c319ff2014-10-04 20:29:09 -070091 FlowRuleEvent addOrUpdateFlowRule(FlowEntry rule);
tombe988312014-09-19 18:38:47 -070092
93 /**
alshabib1c319ff2014-10-04 20:29:09 -070094 * @param rule the flow entry to remove
tombe988312014-09-19 18:38:47 -070095 * @return flow_removed event, or null if nothing removed
96 */
alshabib1c319ff2014-10-04 20:29:09 -070097 FlowRuleEvent removeFlowRule(FlowEntry rule);
Srikanth Vavilapalli95810f52015-09-14 15:49:56 -070098
99 /**
Charles Chan93fa7272016-01-26 22:27:02 -0800100 * Marks a flow rule as PENDING_ADD during retry.
101 *
102 * Emits flow_update event if the state is changed
103 *
104 * @param rule the flow rule that is retrying
105 * @return flow_updated event, or null if nothing updated
106 */
107 FlowRuleEvent pendingFlowRule(FlowEntry rule);
108
109 /**
Charles Chan0c7c43b2016-01-14 17:39:20 -0800110 * Removes all flow entries of given device from store.
111 *
112 * @param deviceId device id
113 */
Victor Silva139bca42016-08-18 11:46:35 -0300114 default void purgeFlowRule(DeviceId deviceId) {}
115
116 /**
117 * Removes all flow entries from store.
118 */
119 void purgeFlowRules();
Charles Chan0c7c43b2016-01-14 17:39:20 -0800120
121 /**
Srikanth Vavilapalli95810f52015-09-14 15:49:56 -0700122 * Updates the flow table statistics of the specified device using
123 * the given statistics.
124 *
125 * @param deviceId device identifier
126 * @param tableStats list of table statistics
127 * @return ready to send event describing what occurred;
128 */
129 FlowRuleEvent updateTableStatistics(DeviceId deviceId,
130 List<TableStatisticsEntry> tableStats);
131
132 /**
133 * Returns the flow table statistics associated with a device.
134 *
135 * @param deviceId the device ID
136 * @return the flow table statistics
137 */
138 Iterable<TableStatisticsEntry> getTableStatistics(DeviceId deviceId);
Patryk Konopka7e40c012017-06-06 13:38:06 +0200139
140 /**
141 * Returns number of flow rules in ADDED state for specified device.
142 *
143 * @param deviceId the device ID
144 * @return number of flow rules in ADDED state
145 */
146 long getActiveFlowRuleCount(DeviceId deviceId);
tombe988312014-09-19 18:38:47 -0700147}