blob: 22914f9b37b3d3fcb6e38484cecfe4e471c7f11c [file] [log] [blame]
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -08001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
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
18import org.onosproject.net.DeviceId;
19import org.onosproject.store.Store;
20
21/**
22 * Manages inventory of groups per device; not intended for direct use.
23 */
24public interface GroupStore extends Store<GroupEvent, GroupStoreDelegate> {
25
26 public enum UpdateType {
27 /**
28 * Modify existing group entry by adding provided information.
29 */
30 ADD,
31 /**
32 * Modify existing group by removing provided information from it.
33 */
34 REMOVE
35 }
36
37 /**
38 * Returns the number of groups for the specified device in the store.
39 *
40 * @param deviceId the device ID
41 * @return number of groups for the specified device
42 */
43 int getGroupCount(DeviceId deviceId);
44
45 /**
46 * Returns the groups associated with a device.
47 *
48 * @param deviceId the device ID
49 * @return the group entries
50 */
51 Iterable<Group> getGroups(DeviceId deviceId);
52
53 /**
54 * Returns the stored group entry.
55 *
56 * @param deviceId the device ID
57 * @param appCookie the group key
58 * @return a group associated with the key
59 */
60 Group getGroup(DeviceId deviceId, GroupKey appCookie);
61
62 /**
63 * Stores a new group entry using the information from group description.
64 *
65 * @param groupDesc group description to be used to store group entry
66 */
67 void storeGroupDescription(GroupDescription groupDesc);
68
69 /**
70 * Updates the existing group entry with the information
71 * from group description.
72 *
73 * @param deviceId the device ID
74 * @param oldAppCookie the current group key
75 * @param type update type
76 * @param newGroupDesc group description with updates
77 */
78 void updateGroupDescription(DeviceId deviceId,
79 GroupKey oldAppCookie,
80 UpdateType type,
81 GroupDescription newGroupDesc);
82
83 /**
84 * Triggers deleting the existing group entry.
85 *
86 * @param deviceId the device ID
87 * @param appCookie the group key
88 */
89 void deleteGroupDescription(DeviceId deviceId,
90 GroupKey appCookie);
91
92 /**
93 * Stores a new group entry, or updates an existing entry.
94 *
95 * @param group group entry
96 */
97 void addOrUpdateGroupEntry(Group group);
98
99 /**
100 * Removes the group entry from store.
101 *
102 * @param group group entry
103 */
104 void removeGroupEntry(Group group);
105}