blob: 672bb4e81a0845fdca92c8f375b7e3c72e67cba7 [file] [log] [blame]
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -08003 *
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 */
16package org.onosproject.net.group;
17
Srikanth Vavilapalli23181912015-05-04 09:48:09 -070018import java.util.Collection;
19
Daniele Moro43ac2892021-07-15 17:02:59 +020020import org.onosproject.core.ApplicationId;
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -070021import org.onosproject.core.GroupId;
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -080022import org.onosproject.net.DeviceId;
23import org.onosproject.store.Store;
24
25/**
26 * Manages inventory of groups per device; not intended for direct use.
27 */
28public interface GroupStore extends Store<GroupEvent, GroupStoreDelegate> {
29
Sho SHIMIZU3310a342015-05-13 12:14:05 -070030 enum UpdateType {
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -080031 /**
32 * Modify existing group entry by adding provided information.
33 */
34 ADD,
35 /**
36 * Modify existing group by removing provided information from it.
37 */
Victor Silva0282ab82016-11-15 16:30:27 -030038 REMOVE,
39 /**
40 * Modify existing group entry by setting the provided information,
41 * overwriting the previous group entry entirely.
42 */
43 SET
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -080044 }
45
46 /**
47 * Returns the number of groups for the specified device in the store.
48 *
49 * @param deviceId the device ID
50 * @return number of groups for the specified device
51 */
52 int getGroupCount(DeviceId deviceId);
53
54 /**
55 * Returns the groups associated with a device.
56 *
57 * @param deviceId the device ID
58 * @return the group entries
59 */
60 Iterable<Group> getGroups(DeviceId deviceId);
61
62 /**
63 * Returns the stored group entry.
64 *
65 * @param deviceId the device ID
66 * @param appCookie the group key
67 * @return a group associated with the key
68 */
69 Group getGroup(DeviceId deviceId, GroupKey appCookie);
70
71 /**
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -070072 * Returns the stored group entry for an id.
73 *
74 * @param deviceId the device ID
75 * @param groupId the group identifier
76 * @return a group associated with the key
77 */
78 Group getGroup(DeviceId deviceId, GroupId groupId);
79
80 /**
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -080081 * Stores a new group entry using the information from group description.
82 *
83 * @param groupDesc group description to be used to store group entry
84 */
85 void storeGroupDescription(GroupDescription groupDesc);
86
87 /**
88 * Updates the existing group entry with the information
89 * from group description.
90 *
91 * @param deviceId the device ID
92 * @param oldAppCookie the current group key
93 * @param type update type
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -080094 * @param newBuckets group buckets for updates
95 * @param newAppCookie optional new group key
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -080096 */
97 void updateGroupDescription(DeviceId deviceId,
98 GroupKey oldAppCookie,
99 UpdateType type,
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -0800100 GroupBuckets newBuckets,
101 GroupKey newAppCookie);
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -0800102
103 /**
104 * Triggers deleting the existing group entry.
105 *
106 * @param deviceId the device ID
107 * @param appCookie the group key
108 */
109 void deleteGroupDescription(DeviceId deviceId,
110 GroupKey appCookie);
111
112 /**
113 * Stores a new group entry, or updates an existing entry.
114 *
115 * @param group group entry
116 */
117 void addOrUpdateGroupEntry(Group group);
118
119 /**
120 * Removes the group entry from store.
121 *
122 * @param group group entry
123 */
124 void removeGroupEntry(Group group);
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -0800125
126 /**
Charles Chan0c7c43b2016-01-14 17:39:20 -0800127 * Removes all group entries of given device from store.
128 *
129 * @param deviceId device id
130 */
131 void purgeGroupEntry(DeviceId deviceId);
132
133 /**
Daniele Moro43ac2892021-07-15 17:02:59 +0200134 * Removes all group entries of given device and given application from store.
135 *
136 * @param deviceId device id
137 * @param appId application id
138 */
139 void purgeGroupEntries(DeviceId deviceId, ApplicationId appId);
140
141 /**
Victor Silva4e8b7832016-08-17 17:11:19 -0300142 * Removes all group entries from store.
143 */
Sho SHIMIZUa6285542017-01-12 15:08:24 -0800144 default void purgeGroupEntries() {}
Victor Silva4e8b7832016-08-17 17:11:19 -0300145
146 /**
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -0800147 * A group entry that is present in switch but not in the store.
148 *
149 * @param group group entry
150 */
151 void addOrUpdateExtraneousGroupEntry(Group group);
152
153 /**
154 * Remove the group entry from extraneous database.
155 *
156 * @param group group entry
157 */
158 void removeExtraneousGroupEntry(Group group);
159
160 /**
161 * Returns the extraneous groups associated with a device.
162 *
163 * @param deviceId the device ID
164 *
165 * @return the extraneous group entries
166 */
167 Iterable<Group> getExtraneousGroups(DeviceId deviceId);
168
169 /**
170 * Indicates the first group audit is completed.
171 *
172 * @param deviceId the device ID
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800173 * @param completed initial audit status
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -0800174 */
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800175 void deviceInitialAuditCompleted(DeviceId deviceId, boolean completed);
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -0800176
177 /**
178 * Retrieves the initial group audit status for a device.
179 *
180 * @param deviceId the device ID
181 *
182 * @return initial group audit status
183 */
184 boolean deviceInitialAuditStatus(DeviceId deviceId);
sangho7ff01812015-02-09 16:21:53 -0800185
186 /**
187 * Indicates the group operations failed.
188 *
189 * @param deviceId the device ID
190 * @param operation the group operation failed
191 */
192 void groupOperationFailed(DeviceId deviceId, GroupOperation operation);
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700193
194 /**
195 * Submits the group metrics to store for a given device ID.
196 *
197 * @param deviceId the device ID
198 * @param groupEntries the group entries as received from southbound
199 */
200 void pushGroupMetrics(DeviceId deviceId, Collection<Group> groupEntries);
helenyrwu89470f12016-08-12 13:18:10 -0700201
202 /**
203 * Indicates failover within a failover group.
Ray Milkeyef794342016-11-09 16:20:29 -0800204 *
205 * @param failoverGroups groups to notify
helenyrwu89470f12016-08-12 13:18:10 -0700206 */
207 void notifyOfFailovers(Collection<Group> failoverGroups);
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -0800208}