Srikanth Vavilapalli | 0599d51 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.net.group; |
| 17 | |
Srikanth Vavilapalli | 2318191 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 18 | import java.util.Collection; |
| 19 | |
Srikanth Vavilapalli | 717361f | 2015-03-16 12:06:04 -0700 | [diff] [blame] | 20 | import org.onosproject.core.GroupId; |
Srikanth Vavilapalli | 0599d51 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 21 | import org.onosproject.net.DeviceId; |
| 22 | import org.onosproject.store.Store; |
| 23 | |
| 24 | /** |
| 25 | * Manages inventory of groups per device; not intended for direct use. |
| 26 | */ |
| 27 | public interface GroupStore extends Store<GroupEvent, GroupStoreDelegate> { |
| 28 | |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 29 | enum UpdateType { |
Srikanth Vavilapalli | 0599d51 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 30 | /** |
| 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 Vavilapalli | 717361f | 2015-03-16 12:06:04 -0700 | [diff] [blame] | 66 | * 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 Vavilapalli | 0599d51 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 75 | * 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 Vavilapalli | 45c27c8 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 88 | * @param newBuckets group buckets for updates |
| 89 | * @param newAppCookie optional new group key |
Srikanth Vavilapalli | 0599d51 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 90 | */ |
| 91 | void updateGroupDescription(DeviceId deviceId, |
| 92 | GroupKey oldAppCookie, |
| 93 | UpdateType type, |
Srikanth Vavilapalli | 45c27c8 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 94 | GroupBuckets newBuckets, |
| 95 | GroupKey newAppCookie); |
Srikanth Vavilapalli | 0599d51 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 96 | |
| 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 Vavilapalli | 45c27c8 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 119 | |
| 120 | /** |
Charles Chan | 0c7c43b | 2016-01-14 17:39:20 -0800 | [diff] [blame] | 121 | * Removes all group entries of given device from store. |
| 122 | * |
| 123 | * @param deviceId device id |
| 124 | */ |
| 125 | void purgeGroupEntry(DeviceId deviceId); |
| 126 | |
| 127 | /** |
Srikanth Vavilapalli | 45c27c8 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 128 | * A group entry that is present in switch but not in the store. |
| 129 | * |
| 130 | * @param group group entry |
| 131 | */ |
| 132 | void addOrUpdateExtraneousGroupEntry(Group group); |
| 133 | |
| 134 | /** |
| 135 | * Remove the group entry from extraneous database. |
| 136 | * |
| 137 | * @param group group entry |
| 138 | */ |
| 139 | void removeExtraneousGroupEntry(Group group); |
| 140 | |
| 141 | /** |
| 142 | * Returns the extraneous groups associated with a device. |
| 143 | * |
| 144 | * @param deviceId the device ID |
| 145 | * |
| 146 | * @return the extraneous group entries |
| 147 | */ |
| 148 | Iterable<Group> getExtraneousGroups(DeviceId deviceId); |
| 149 | |
| 150 | /** |
| 151 | * Indicates the first group audit is completed. |
| 152 | * |
| 153 | * @param deviceId the device ID |
Srikanth Vavilapalli | ed12ae5 | 2015-02-09 14:43:19 -0800 | [diff] [blame] | 154 | * @param completed initial audit status |
Srikanth Vavilapalli | 45c27c8 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 155 | */ |
Srikanth Vavilapalli | ed12ae5 | 2015-02-09 14:43:19 -0800 | [diff] [blame] | 156 | void deviceInitialAuditCompleted(DeviceId deviceId, boolean completed); |
Srikanth Vavilapalli | 45c27c8 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 157 | |
| 158 | /** |
| 159 | * Retrieves the initial group audit status for a device. |
| 160 | * |
| 161 | * @param deviceId the device ID |
| 162 | * |
| 163 | * @return initial group audit status |
| 164 | */ |
| 165 | boolean deviceInitialAuditStatus(DeviceId deviceId); |
sangho | 7ff0181 | 2015-02-09 16:21:53 -0800 | [diff] [blame] | 166 | |
| 167 | /** |
| 168 | * Indicates the group operations failed. |
| 169 | * |
| 170 | * @param deviceId the device ID |
| 171 | * @param operation the group operation failed |
| 172 | */ |
| 173 | void groupOperationFailed(DeviceId deviceId, GroupOperation operation); |
Srikanth Vavilapalli | 2318191 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 174 | |
| 175 | /** |
| 176 | * Submits the group metrics to store for a given device ID. |
| 177 | * |
| 178 | * @param deviceId the device ID |
| 179 | * @param groupEntries the group entries as received from southbound |
| 180 | */ |
| 181 | void pushGroupMetrics(DeviceId deviceId, Collection<Group> groupEntries); |
Srikanth Vavilapalli | 0599d51 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 182 | } |