blob: 4559e646462789b342d0eb2a243149af8d0e4301 [file] [log] [blame]
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
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
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -070020import org.onosproject.core.GroupId;
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -080021import org.onosproject.net.DeviceId;
22import org.onosproject.store.Store;
23
24/**
25 * Manages inventory of groups per device; not intended for direct use.
26 */
27public interface GroupStore extends Store<GroupEvent, GroupStoreDelegate> {
28
Sho SHIMIZU3310a342015-05-13 12:14:05 -070029 enum UpdateType {
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -080030 /**
31 * Modify existing group entry by adding provided information.
32 */
33 ADD,
34 /**
35 * Modify existing group by removing provided information from it.
36 */
Victor Silva0282ab82016-11-15 16:30:27 -030037 REMOVE,
38 /**
39 * Modify existing group entry by setting the provided information,
40 * overwriting the previous group entry entirely.
41 */
42 SET
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -080043 }
44
45 /**
46 * Returns the number of groups for the specified device in the store.
47 *
48 * @param deviceId the device ID
49 * @return number of groups for the specified device
50 */
51 int getGroupCount(DeviceId deviceId);
52
53 /**
54 * Returns the groups associated with a device.
55 *
56 * @param deviceId the device ID
57 * @return the group entries
58 */
59 Iterable<Group> getGroups(DeviceId deviceId);
60
61 /**
62 * Returns the stored group entry.
63 *
64 * @param deviceId the device ID
65 * @param appCookie the group key
66 * @return a group associated with the key
67 */
68 Group getGroup(DeviceId deviceId, GroupKey appCookie);
69
70 /**
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -070071 * Returns the stored group entry for an id.
72 *
73 * @param deviceId the device ID
74 * @param groupId the group identifier
75 * @return a group associated with the key
76 */
77 Group getGroup(DeviceId deviceId, GroupId groupId);
78
79 /**
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -080080 * Stores a new group entry using the information from group description.
81 *
82 * @param groupDesc group description to be used to store group entry
83 */
84 void storeGroupDescription(GroupDescription groupDesc);
85
86 /**
87 * Updates the existing group entry with the information
88 * from group description.
89 *
90 * @param deviceId the device ID
91 * @param oldAppCookie the current group key
92 * @param type update type
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -080093 * @param newBuckets group buckets for updates
94 * @param newAppCookie optional new group key
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -080095 */
96 void updateGroupDescription(DeviceId deviceId,
97 GroupKey oldAppCookie,
98 UpdateType type,
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -080099 GroupBuckets newBuckets,
100 GroupKey newAppCookie);
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -0800101
102 /**
103 * Triggers deleting the existing group entry.
104 *
105 * @param deviceId the device ID
106 * @param appCookie the group key
107 */
108 void deleteGroupDescription(DeviceId deviceId,
109 GroupKey appCookie);
110
111 /**
112 * Stores a new group entry, or updates an existing entry.
113 *
114 * @param group group entry
115 */
116 void addOrUpdateGroupEntry(Group group);
117
118 /**
119 * Removes the group entry from store.
120 *
121 * @param group group entry
122 */
123 void removeGroupEntry(Group group);
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -0800124
125 /**
Charles Chan0c7c43b2016-01-14 17:39:20 -0800126 * Removes all group entries of given device from store.
127 *
128 * @param deviceId device id
129 */
130 void purgeGroupEntry(DeviceId deviceId);
131
132 /**
Victor Silva4e8b7832016-08-17 17:11:19 -0300133 * Removes all group entries from store.
134 */
Sho SHIMIZUa6285542017-01-12 15:08:24 -0800135 default void purgeGroupEntries() {}
Victor Silva4e8b7832016-08-17 17:11:19 -0300136
137 /**
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -0800138 * A group entry that is present in switch but not in the store.
139 *
140 * @param group group entry
141 */
142 void addOrUpdateExtraneousGroupEntry(Group group);
143
144 /**
145 * Remove the group entry from extraneous database.
146 *
147 * @param group group entry
148 */
149 void removeExtraneousGroupEntry(Group group);
150
151 /**
152 * Returns the extraneous groups associated with a device.
153 *
154 * @param deviceId the device ID
155 *
156 * @return the extraneous group entries
157 */
158 Iterable<Group> getExtraneousGroups(DeviceId deviceId);
159
160 /**
161 * Indicates the first group audit is completed.
162 *
163 * @param deviceId the device ID
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800164 * @param completed initial audit status
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -0800165 */
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800166 void deviceInitialAuditCompleted(DeviceId deviceId, boolean completed);
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -0800167
168 /**
169 * Retrieves the initial group audit status for a device.
170 *
171 * @param deviceId the device ID
172 *
173 * @return initial group audit status
174 */
175 boolean deviceInitialAuditStatus(DeviceId deviceId);
sangho7ff01812015-02-09 16:21:53 -0800176
177 /**
178 * Indicates the group operations failed.
179 *
180 * @param deviceId the device ID
181 * @param operation the group operation failed
182 */
183 void groupOperationFailed(DeviceId deviceId, GroupOperation operation);
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700184
185 /**
186 * Submits the group metrics to store for a given device ID.
187 *
188 * @param deviceId the device ID
189 * @param groupEntries the group entries as received from southbound
190 */
191 void pushGroupMetrics(DeviceId deviceId, Collection<Group> groupEntries);
helenyrwu89470f12016-08-12 13:18:10 -0700192
193 /**
194 * Indicates failover within a failover group.
Ray Milkeyef794342016-11-09 16:20:29 -0800195 *
196 * @param failoverGroups groups to notify
helenyrwu89470f12016-08-12 13:18:10 -0700197 */
198 void notifyOfFailovers(Collection<Group> failoverGroups);
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -0800199}