blob: d080524384e4bc33b6acee8b6c3e0bbb3532ab33 [file] [log] [blame]
yoonseondc3210d2017-01-25 16:03:10 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
yoonseondc3210d2017-01-25 16:03:10 -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 */
16
17package org.onosproject.incubator.net.virtual;
18
19import org.onosproject.core.GroupId;
20import org.onosproject.net.DeviceId;
21import org.onosproject.net.group.Group;
22import org.onosproject.net.group.GroupBuckets;
23import org.onosproject.net.group.GroupDescription;
24import org.onosproject.net.group.GroupEvent;
25import org.onosproject.net.group.GroupKey;
26import org.onosproject.net.group.GroupOperation;
27import org.onosproject.net.group.GroupStoreDelegate;
28
29import java.util.Collection;
30
31/**
32 * Manages inventory of groups per virtual network and virtual device;
33 * not intended for direct use.
34 */
35public interface VirtualNetworkGroupStore
36 extends VirtualStore<GroupEvent, GroupStoreDelegate> {
37
38 enum UpdateType {
39 /**
40 * Modify existing group entry by adding provided information.
41 */
42 ADD,
43 /**
44 * Modify existing group by removing provided information from it.
45 */
46 REMOVE,
47 /**
48 * Modify existing group entry by setting the provided information,
49 * overwriting the previous group entry entirely.
50 */
51 SET
52 }
53
54 /**
55 * Returns the number of groups for the specified virtual device in the store.
56 *
57 * @param networkId the virtual network ID
58 * @param deviceId the device ID
59 * @return number of groups for the specified device
60 */
61 int getGroupCount(NetworkId networkId, DeviceId deviceId);
62
63 /**
64 * Returns the groups associated with a virtual device.
65 *
66 * @param networkId the virtual network ID
67 * @param deviceId the device ID
68 * @return the group entries
69 */
70 Iterable<Group> getGroups(NetworkId networkId, DeviceId deviceId);
71
72 /**
73 * Returns the stored group entry in a virtual network.
74 *
75 * @param networkId the virtual network ID
76 * @param deviceId the device ID
77 * @param appCookie the group key
78 * @return a group associated with the key
79 */
80 Group getGroup(NetworkId networkId, DeviceId deviceId, GroupKey appCookie);
81
82 /**
83 * Returns the stored group entry for an id.
84 *
85 * @param networkId the virtual network ID
86 * @param deviceId the device ID
87 * @param groupId the group identifier
88 * @return a group associated with the key
89 */
90 Group getGroup(NetworkId networkId, DeviceId deviceId, GroupId groupId);
91
92 /**
93 * Stores a new group entry using the information from group description
94 * for a virtual network.
95 *
96 * @param networkId the virtual network ID
97 * @param groupDesc group description to be used to store group entry
98 */
99 void storeGroupDescription(NetworkId networkId, GroupDescription groupDesc);
100
101 /**
102 * Updates the existing group entry with the information
103 * from group description.
104 *
105 * @param networkId the virtual network ID
106 * @param deviceId the device ID
107 * @param oldAppCookie the current group key
108 * @param type update type
109 * @param newBuckets group buckets for updates
110 * @param newAppCookie optional new group key
111 */
112 void updateGroupDescription(NetworkId networkId,
113 DeviceId deviceId,
114 GroupKey oldAppCookie,
115 UpdateType type,
116 GroupBuckets newBuckets,
117 GroupKey newAppCookie);
118
119 /**
120 * Triggers deleting the existing group entry.
121 *
122 * @param networkId the virtual network ID
123 * @param deviceId the device ID
124 * @param appCookie the group key
125 */
126 void deleteGroupDescription(NetworkId networkId,
127 DeviceId deviceId,
128 GroupKey appCookie);
129
130 /**
131 * Stores a new group entry, or updates an existing entry.
132 *
133 * @param networkId the virtual network ID
134 * @param group group entry
135 */
136 void addOrUpdateGroupEntry(NetworkId networkId, Group group);
137
138 /**
139 * Removes the group entry from store.
140 *
141 * @param networkId the virtual network ID
142 * @param group group entry
143 */
144 void removeGroupEntry(NetworkId networkId, Group group);
145
146 /**
147 * Removes all group entries of given device from store.
148 *
149 * @param networkId the virtual network ID
150 * @param deviceId device id
151 */
152 void purgeGroupEntry(NetworkId networkId, DeviceId deviceId);
153
154 /**
155 * Removes all group entries from store.
156 *
157 * @param networkId the virtual network ID
158 */
159 default void purgeGroupEntries(NetworkId networkId) {}
160
161 /**
162 * A group entry that is present in switch but not in the store.
163 *
164 * @param networkId the virtual network ID
165 * @param group group entry
166 */
167 void addOrUpdateExtraneousGroupEntry(NetworkId networkId, Group group);
168
169 /**
170 * Remove the group entry from extraneous database.
171 *
172 * @param networkId the virtual network ID
173 * @param group group entry
174 */
175 void removeExtraneousGroupEntry(NetworkId networkId, Group group);
176
177 /**
178 * Returns the extraneous groups associated with a device.
179 *
180 * @param networkId the virtual network ID
181 * @param deviceId the device ID
182 *
183 * @return the extraneous group entries
184 */
185 Iterable<Group> getExtraneousGroups(NetworkId networkId, DeviceId deviceId);
186
187 /**
188 * Indicates the first group audit is completed.
189 *
190 * @param networkId the virtual network ID
191 * @param deviceId the device ID
192 * @param completed initial audit status
193 */
194 void deviceInitialAuditCompleted(NetworkId networkId, DeviceId deviceId, boolean completed);
195
196 /**
197 * Retrieves the initial group audit status for a device.
198 *
199 * @param networkId the virtual network ID
200 * @param deviceId the device ID
201 *
202 * @return initial group audit status
203 */
204 boolean deviceInitialAuditStatus(NetworkId networkId, DeviceId deviceId);
205
206 /**
207 * Indicates the group operations failed.
208 *
209 * @param networkId the virtual network ID
210 * @param deviceId the device ID
211 * @param operation the group operation failed
212 */
213 void groupOperationFailed(NetworkId networkId, DeviceId deviceId, GroupOperation operation);
214
215 /**
216 * Submits the group metrics to store for a given device ID.
217 *
218 * @param networkId the virtual network ID
219 * @param deviceId the device ID
220 * @param groupEntries the group entries as received from southbound
221 */
222 void pushGroupMetrics(NetworkId networkId, DeviceId deviceId, Collection<Group> groupEntries);
223
224 /**
225 * Indicates failover within a failover group.
226 *
227 * @param networkId the virtual network ID
228 * @param failoverGroups groups to notify
229 */
230 void notifyOfFailovers(NetworkId networkId, Collection<Group> failoverGroups);
231}