blob: 0c0c06cc33c43f12d25913c5293dc237b36fe8d6 [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 */
37 REMOVE
38 }
39
40 /**
41 * Returns the number of groups for the specified device in the store.
42 *
43 * @param deviceId the device ID
44 * @return number of groups for the specified device
45 */
46 int getGroupCount(DeviceId deviceId);
47
48 /**
49 * Returns the groups associated with a device.
50 *
51 * @param deviceId the device ID
52 * @return the group entries
53 */
54 Iterable<Group> getGroups(DeviceId deviceId);
55
56 /**
57 * Returns the stored group entry.
58 *
59 * @param deviceId the device ID
60 * @param appCookie the group key
61 * @return a group associated with the key
62 */
63 Group getGroup(DeviceId deviceId, GroupKey appCookie);
64
65 /**
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -070066 * Returns the stored group entry for an id.
67 *
68 * @param deviceId the device ID
69 * @param groupId the group identifier
70 * @return a group associated with the key
71 */
72 Group getGroup(DeviceId deviceId, GroupId groupId);
73
74 /**
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -080075 * Stores a new group entry using the information from group description.
76 *
77 * @param groupDesc group description to be used to store group entry
78 */
79 void storeGroupDescription(GroupDescription groupDesc);
80
81 /**
82 * Updates the existing group entry with the information
83 * from group description.
84 *
85 * @param deviceId the device ID
86 * @param oldAppCookie the current group key
87 * @param type update type
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -080088 * @param newBuckets group buckets for updates
89 * @param newAppCookie optional new group key
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -080090 */
91 void updateGroupDescription(DeviceId deviceId,
92 GroupKey oldAppCookie,
93 UpdateType type,
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -080094 GroupBuckets newBuckets,
95 GroupKey newAppCookie);
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -080096
97 /**
98 * Triggers deleting the existing group entry.
99 *
100 * @param deviceId the device ID
101 * @param appCookie the group key
102 */
103 void deleteGroupDescription(DeviceId deviceId,
104 GroupKey appCookie);
105
106 /**
107 * Stores a new group entry, or updates an existing entry.
108 *
109 * @param group group entry
110 */
111 void addOrUpdateGroupEntry(Group group);
112
113 /**
114 * Removes the group entry from store.
115 *
116 * @param group group entry
117 */
118 void removeGroupEntry(Group group);
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -0800119
120 /**
Charles Chan0c7c43b2016-01-14 17:39:20 -0800121 * Removes all group entries of given device from store.
122 *
123 * @param deviceId device id
124 */
125 void purgeGroupEntry(DeviceId deviceId);
126
127 /**
Victor Silva4e8b7832016-08-17 17:11:19 -0300128 * Removes all group entries from store.
129 */
Sho SHIMIZUa6285542017-01-12 15:08:24 -0800130 default void purgeGroupEntries() {}
Victor Silva4e8b7832016-08-17 17:11:19 -0300131
132 /**
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -0800133 * A group entry that is present in switch but not in the store.
134 *
135 * @param group group entry
136 */
137 void addOrUpdateExtraneousGroupEntry(Group group);
138
139 /**
140 * Remove the group entry from extraneous database.
141 *
142 * @param group group entry
143 */
144 void removeExtraneousGroupEntry(Group group);
145
146 /**
147 * Returns the extraneous groups associated with a device.
148 *
149 * @param deviceId the device ID
150 *
151 * @return the extraneous group entries
152 */
153 Iterable<Group> getExtraneousGroups(DeviceId deviceId);
154
155 /**
156 * Indicates the first group audit is completed.
157 *
158 * @param deviceId the device ID
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800159 * @param completed initial audit status
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -0800160 */
Srikanth Vavilapallied12ae52015-02-09 14:43:19 -0800161 void deviceInitialAuditCompleted(DeviceId deviceId, boolean completed);
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -0800162
163 /**
164 * Retrieves the initial group audit status for a device.
165 *
166 * @param deviceId the device ID
167 *
168 * @return initial group audit status
169 */
170 boolean deviceInitialAuditStatus(DeviceId deviceId);
sangho7ff01812015-02-09 16:21:53 -0800171
172 /**
173 * Indicates the group operations failed.
174 *
175 * @param deviceId the device ID
176 * @param operation the group operation failed
177 */
178 void groupOperationFailed(DeviceId deviceId, GroupOperation operation);
Srikanth Vavilapalli23181912015-05-04 09:48:09 -0700179
180 /**
181 * Submits the group metrics to store for a given device ID.
182 *
183 * @param deviceId the device ID
184 * @param groupEntries the group entries as received from southbound
185 */
186 void pushGroupMetrics(DeviceId deviceId, Collection<Group> groupEntries);
helenyrwu89470f12016-08-12 13:18:10 -0700187
188 /**
189 * Indicates failover within a failover group.
Ray Milkeyef794342016-11-09 16:20:29 -0800190 *
191 * @param failoverGroups groups to notify
helenyrwu89470f12016-08-12 13:18:10 -0700192 */
193 void notifyOfFailovers(Collection<Group> failoverGroups);
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -0800194}