Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 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 | |
| 18 | import org.onosproject.core.ApplicationId; |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 19 | import org.onosproject.event.ListenerService; |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 20 | import org.onosproject.net.DeviceId; |
| 21 | |
| 22 | /** |
| 23 | * Service for create/update/delete "group" in the devices. |
| 24 | * Flow entries can point to a "group" defined in the devices that enables |
| 25 | * to represent additional methods of forwarding like load-balancing or |
| 26 | * failover among different group of ports or multicast to all ports |
| 27 | * specified in a group. |
| 28 | * "group" can also be used for grouping common actions of different flows, |
| 29 | * so that in some scenarios only one group entry required to be modified |
Srikanth Vavilapalli | 45c27c8 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 30 | * for all the referencing flow entries instead of modifying all of them. |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 31 | * |
| 32 | * This implements semantics of a distributed authoritative group store |
| 33 | * where the master copy of the groups lies with the controller and |
| 34 | * the devices hold only the 'cached' copy. |
| 35 | */ |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 36 | public interface GroupService |
| 37 | extends ListenerService<GroupEvent, GroupListener> { |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 38 | |
| 39 | /** |
Srikanth Vavilapalli | 0599d51 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 40 | * Creates a group in the specified device with the provided buckets. |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 41 | * This API provides an option for application to associate a cookie |
| 42 | * while creating a group, so that applications can look-up the |
| 43 | * groups based on the cookies. These Groups will be retained by |
| 44 | * the core system and re-applied if any groups found missing in the |
| 45 | * device when it reconnects. This API would immediately return after |
| 46 | * submitting the request locally or to a remote Master controller |
| 47 | * instance. As a response to this API invocation, GROUP_ADDED or |
| 48 | * GROUP_ADD_FAILED notifications would be provided along with cookie |
| 49 | * depending on the result of the operation on the device in the |
| 50 | * data plane. The caller may also use "getGroup" API to get the |
| 51 | * Group object created as part of this request. |
| 52 | * |
| 53 | * @param groupDesc group creation parameters |
| 54 | * |
| 55 | */ |
| 56 | void addGroup(GroupDescription groupDesc); |
| 57 | |
| 58 | /** |
Srikanth Vavilapalli | 0599d51 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 59 | * Returns a group object associated to an application cookie. |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 60 | * |
| 61 | * NOTE1: The presence of group object in the system does not |
| 62 | * guarantee that the "group" is actually created in device. |
| 63 | * GROUP_ADDED notification would confirm the creation of |
Srikanth Vavilapalli | 45c27c8 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 64 | * this group in data plane. |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 65 | * |
| 66 | * @param deviceId device identifier |
| 67 | * @param appCookie application cookie to be used for lookup |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 68 | * @return group associated with the application cookie or |
| 69 | * NULL if Group is not found for the provided cookie |
| 70 | */ |
| 71 | Group getGroup(DeviceId deviceId, GroupKey appCookie); |
| 72 | |
| 73 | /** |
Srikanth Vavilapalli | 0599d51 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 74 | * Appends buckets to existing group. The caller can optionally |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 75 | * associate a new cookie during this updation. GROUP_UPDATED or |
| 76 | * GROUP_UPDATE_FAILED notifications would be provided along with |
Srikanth Vavilapalli | 45c27c8 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 77 | * cookie depending on the result of the operation on the device. |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 78 | * |
| 79 | * @param deviceId device identifier |
| 80 | * @param oldCookie cookie to be used to retrieve the existing group |
| 81 | * @param buckets immutable list of group bucket to be added |
| 82 | * @param newCookie immutable cookie to be used post update operation |
| 83 | * @param appId Application Id |
| 84 | */ |
| 85 | void addBucketsToGroup(DeviceId deviceId, |
| 86 | GroupKey oldCookie, |
| 87 | GroupBuckets buckets, |
| 88 | GroupKey newCookie, |
| 89 | ApplicationId appId); |
| 90 | |
| 91 | /** |
Srikanth Vavilapalli | 0599d51 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 92 | * Removes buckets from existing group. The caller can optionally |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 93 | * associate a new cookie during this updation. GROUP_UPDATED or |
| 94 | * GROUP_UPDATE_FAILED notifications would be provided along with |
Srikanth Vavilapalli | 45c27c8 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 95 | * cookie depending on the result of the operation on the device. |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 96 | * |
| 97 | * @param deviceId device identifier |
| 98 | * @param oldCookie cookie to be used to retrieve the existing group |
| 99 | * @param buckets immutable list of group bucket to be removed |
| 100 | * @param newCookie immutable cookie to be used post update operation |
| 101 | * @param appId Application Id |
| 102 | */ |
Srikanth Vavilapalli | 45c27c8 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 103 | void removeBucketsFromGroup(DeviceId deviceId, |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 104 | GroupKey oldCookie, |
| 105 | GroupBuckets buckets, |
| 106 | GroupKey newCookie, |
| 107 | ApplicationId appId); |
| 108 | |
| 109 | /** |
Victor Silva | 0282ab8 | 2016-11-15 16:30:27 -0300 | [diff] [blame] | 110 | * Set buckets for an existing group. The caller can optionally |
| 111 | * associate a new cookie during this updation. GROUP_UPDATED or |
| 112 | * GROUP_UPDATE_FAILED notifications would be provided along with |
| 113 | * cookie depending on the result of the operation on the device. |
| 114 | * |
| 115 | * This operation overwrites the previous group buckets entirely. |
| 116 | * |
| 117 | * @param deviceId device identifier |
| 118 | * @param oldCookie cookie to be used to retrieve the existing group |
| 119 | * @param buckets immutable list of group buckets to be set |
| 120 | * @param newCookie immutable cookie to be used post update operation |
| 121 | * @param appId Application Id |
| 122 | */ |
| 123 | default void setBucketsForGroup(DeviceId deviceId, |
| 124 | GroupKey oldCookie, |
| 125 | GroupBuckets buckets, |
| 126 | GroupKey newCookie, |
| 127 | ApplicationId appId) {} |
| 128 | |
| 129 | /** |
Kavitha Alagesan | c69c66a | 2016-06-15 14:26:04 +0530 | [diff] [blame] | 130 | * Purges all the group entries on the specified device. |
| 131 | * @param deviceId device identifier |
| 132 | */ |
| 133 | void purgeGroupEntries(DeviceId deviceId); |
| 134 | |
| 135 | /** |
Daniele Moro | 641b4f1 | 2021-07-15 17:02:59 +0200 | [diff] [blame^] | 136 | * Purges all the group entries on the specified device and application. |
| 137 | * |
| 138 | * @param deviceId device identifier |
| 139 | * @param appId application identifier |
| 140 | */ |
| 141 | default void purgeGroupEntries(DeviceId deviceId, ApplicationId appId) { |
| 142 | throw new UnsupportedOperationException("purgeGroupEntries not implemented"); |
| 143 | } |
| 144 | |
| 145 | /** |
Victor Silva | 4e8b783 | 2016-08-17 17:11:19 -0300 | [diff] [blame] | 146 | * Purges all group entries. |
| 147 | */ |
Sho SHIMIZU | a628554 | 2017-01-12 15:08:24 -0800 | [diff] [blame] | 148 | default void purgeGroupEntries() {} |
Victor Silva | 4e8b783 | 2016-08-17 17:11:19 -0300 | [diff] [blame] | 149 | |
| 150 | /** |
Srikanth Vavilapalli | 0599d51 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 151 | * Deletes a group associated to an application cookie. |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 152 | * GROUP_DELETED or GROUP_DELETE_FAILED notifications would be |
| 153 | * provided along with cookie depending on the result of the |
Srikanth Vavilapalli | 45c27c8 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 154 | * operation on the device. |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 155 | * |
| 156 | * @param deviceId device identifier |
| 157 | * @param appCookie application cookie to be used for lookup |
| 158 | * @param appId Application Id |
| 159 | */ |
Srikanth Vavilapalli | 45c27c8 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 160 | void removeGroup(DeviceId deviceId, GroupKey appCookie, ApplicationId appId); |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 161 | |
| 162 | /** |
Srikanth Vavilapalli | 0599d51 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 163 | * Retrieves all groups created by an application in the specified device |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 164 | * as seen by current controller instance. |
| 165 | * |
| 166 | * @param deviceId device identifier |
| 167 | * @param appId application id |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 168 | * @return collection of immutable group objects created by the application |
| 169 | */ |
Srikanth Vavilapalli | 45c27c8 | 2015-01-30 12:57:56 -0800 | [diff] [blame] | 170 | Iterable<Group> getGroups(DeviceId deviceId, ApplicationId appId); |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 171 | |
| 172 | /** |
Jonathan Hart | 3260069 | 2015-03-09 10:38:40 -0700 | [diff] [blame] | 173 | * Returns all groups associated with the given device. |
| 174 | * |
| 175 | * @param deviceId device ID to get groups for |
| 176 | * @return iterable of device's groups |
| 177 | */ |
| 178 | Iterable<Group> getGroups(DeviceId deviceId); |
| 179 | |
Srikanth Vavilapalli | 56db94f | 2015-01-22 22:30:17 -0800 | [diff] [blame] | 180 | } |