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 | 717361f | 2015-03-16 12:06:04 -0700 | [diff] [blame] | 18 | import org.onosproject.core.GroupId; |
Srikanth Vavilapalli | 0599d51 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 19 | import org.onosproject.net.DeviceId; |
| 20 | import org.onosproject.store.Store; |
| 21 | |
| 22 | /** |
| 23 | * Manages inventory of groups per device; not intended for direct use. |
| 24 | */ |
| 25 | public interface GroupStore extends Store<GroupEvent, GroupStoreDelegate> { |
| 26 | |
| 27 | public enum UpdateType { |
| 28 | /** |
| 29 | * Modify existing group entry by adding provided information. |
| 30 | */ |
| 31 | ADD, |
| 32 | /** |
| 33 | * Modify existing group by removing provided information from it. |
| 34 | */ |
| 35 | REMOVE |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Returns the number of groups for the specified device in the store. |
| 40 | * |
| 41 | * @param deviceId the device ID |
| 42 | * @return number of groups for the specified device |
| 43 | */ |
| 44 | int getGroupCount(DeviceId deviceId); |
| 45 | |
| 46 | /** |
| 47 | * Returns the groups associated with a device. |
| 48 | * |
| 49 | * @param deviceId the device ID |
| 50 | * @return the group entries |
| 51 | */ |
| 52 | Iterable<Group> getGroups(DeviceId deviceId); |
| 53 | |
| 54 | /** |
| 55 | * Returns the stored group entry. |
| 56 | * |
| 57 | * @param deviceId the device ID |
| 58 | * @param appCookie the group key |
| 59 | * @return a group associated with the key |
| 60 | */ |
| 61 | Group getGroup(DeviceId deviceId, GroupKey appCookie); |
| 62 | |
| 63 | /** |
Srikanth Vavilapalli | 717361f | 2015-03-16 12:06:04 -0700 | [diff] [blame] | 64 | * Returns the stored group entry for an id. |
| 65 | * |
| 66 | * @param deviceId the device ID |
| 67 | * @param groupId the group identifier |
| 68 | * @return a group associated with the key |
| 69 | */ |
| 70 | Group getGroup(DeviceId deviceId, GroupId groupId); |
| 71 | |
| 72 | /** |
Srikanth Vavilapalli | 0599d51 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 73 | * Stores a new group entry using the information from group description. |
| 74 | * |
| 75 | * @param groupDesc group description to be used to store group entry |
| 76 | */ |
| 77 | void storeGroupDescription(GroupDescription groupDesc); |
| 78 | |
| 79 | /** |
| 80 | * Updates the existing group entry with the information |
| 81 | * from group description. |
| 82 | * |
| 83 | * @param deviceId the device ID |
| 84 | * @param oldAppCookie the current group key |
| 85 | * @param type update type |
Srikanth Vavilapalli | 45c27c8 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 86 | * @param newBuckets group buckets for updates |
| 87 | * @param newAppCookie optional new group key |
Srikanth Vavilapalli | 0599d51 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 88 | */ |
| 89 | void updateGroupDescription(DeviceId deviceId, |
| 90 | GroupKey oldAppCookie, |
| 91 | UpdateType type, |
Srikanth Vavilapalli | 45c27c8 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 92 | GroupBuckets newBuckets, |
| 93 | GroupKey newAppCookie); |
Srikanth Vavilapalli | 0599d51 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 94 | |
| 95 | /** |
| 96 | * Triggers deleting the existing group entry. |
| 97 | * |
| 98 | * @param deviceId the device ID |
| 99 | * @param appCookie the group key |
| 100 | */ |
| 101 | void deleteGroupDescription(DeviceId deviceId, |
| 102 | GroupKey appCookie); |
| 103 | |
| 104 | /** |
| 105 | * Stores a new group entry, or updates an existing entry. |
| 106 | * |
| 107 | * @param group group entry |
| 108 | */ |
| 109 | void addOrUpdateGroupEntry(Group group); |
| 110 | |
| 111 | /** |
| 112 | * Removes the group entry from store. |
| 113 | * |
| 114 | * @param group group entry |
| 115 | */ |
| 116 | void removeGroupEntry(Group group); |
Srikanth Vavilapalli | 45c27c8 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 117 | |
| 118 | /** |
| 119 | * A group entry that is present in switch but not in the store. |
| 120 | * |
| 121 | * @param group group entry |
| 122 | */ |
| 123 | void addOrUpdateExtraneousGroupEntry(Group group); |
| 124 | |
| 125 | /** |
| 126 | * Remove the group entry from extraneous database. |
| 127 | * |
| 128 | * @param group group entry |
| 129 | */ |
| 130 | void removeExtraneousGroupEntry(Group group); |
| 131 | |
| 132 | /** |
| 133 | * Returns the extraneous groups associated with a device. |
| 134 | * |
| 135 | * @param deviceId the device ID |
| 136 | * |
| 137 | * @return the extraneous group entries |
| 138 | */ |
| 139 | Iterable<Group> getExtraneousGroups(DeviceId deviceId); |
| 140 | |
| 141 | /** |
| 142 | * Indicates the first group audit is completed. |
| 143 | * |
| 144 | * @param deviceId the device ID |
Srikanth Vavilapalli | ed12ae5 | 2015-02-09 14:43:19 -0800 | [diff] [blame] | 145 | * @param completed initial audit status |
Srikanth Vavilapalli | 45c27c8 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 146 | */ |
Srikanth Vavilapalli | ed12ae5 | 2015-02-09 14:43:19 -0800 | [diff] [blame] | 147 | void deviceInitialAuditCompleted(DeviceId deviceId, boolean completed); |
Srikanth Vavilapalli | 45c27c8 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 148 | |
| 149 | /** |
| 150 | * Retrieves the initial group audit status for a device. |
| 151 | * |
| 152 | * @param deviceId the device ID |
| 153 | * |
| 154 | * @return initial group audit status |
| 155 | */ |
| 156 | boolean deviceInitialAuditStatus(DeviceId deviceId); |
sangho | 7ff0181 | 2015-02-09 16:21:53 -0800 | [diff] [blame] | 157 | |
| 158 | /** |
| 159 | * Indicates the group operations failed. |
| 160 | * |
| 161 | * @param deviceId the device ID |
| 162 | * @param operation the group operation failed |
| 163 | */ |
| 164 | void groupOperationFailed(DeviceId deviceId, GroupOperation operation); |
Srikanth Vavilapalli | 0599d51 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 165 | } |