blob: cdd56c78aca56bd114edc2dcabef97de4291f9c0 [file] [log] [blame]
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -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.core.ApplicationId;
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -080019import org.onosproject.net.DeviceId;
20
21/**
22 * Service for create/update/delete "group" in the devices.
23 * Flow entries can point to a "group" defined in the devices that enables
24 * to represent additional methods of forwarding like load-balancing or
25 * failover among different group of ports or multicast to all ports
26 * specified in a group.
27 * "group" can also be used for grouping common actions of different flows,
28 * so that in some scenarios only one group entry required to be modified
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -080029 * for all the referencing flow entries instead of modifying all of them.
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -080030 *
31 * This implements semantics of a distributed authoritative group store
32 * where the master copy of the groups lies with the controller and
33 * the devices hold only the 'cached' copy.
34 */
35public interface GroupService {
36
37 /**
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -080038 * Creates a group in the specified device with the provided buckets.
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -080039 * This API provides an option for application to associate a cookie
40 * while creating a group, so that applications can look-up the
41 * groups based on the cookies. These Groups will be retained by
42 * the core system and re-applied if any groups found missing in the
43 * device when it reconnects. This API would immediately return after
44 * submitting the request locally or to a remote Master controller
45 * instance. As a response to this API invocation, GROUP_ADDED or
46 * GROUP_ADD_FAILED notifications would be provided along with cookie
47 * depending on the result of the operation on the device in the
48 * data plane. The caller may also use "getGroup" API to get the
49 * Group object created as part of this request.
50 *
51 * @param groupDesc group creation parameters
52 *
53 */
54 void addGroup(GroupDescription groupDesc);
55
56 /**
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -080057 * Returns a group object associated to an application cookie.
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -080058 *
59 * NOTE1: The presence of group object in the system does not
60 * guarantee that the "group" is actually created in device.
61 * GROUP_ADDED notification would confirm the creation of
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -080062 * this group in data plane.
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -080063 *
64 * @param deviceId device identifier
65 * @param appCookie application cookie to be used for lookup
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -080066 * @return group associated with the application cookie or
67 * NULL if Group is not found for the provided cookie
68 */
69 Group getGroup(DeviceId deviceId, GroupKey appCookie);
70
71 /**
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -080072 * Appends buckets to existing group. The caller can optionally
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -080073 * associate a new cookie during this updation. GROUP_UPDATED or
74 * GROUP_UPDATE_FAILED notifications would be provided along with
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -080075 * cookie depending on the result of the operation on the device.
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -080076 *
77 * @param deviceId device identifier
78 * @param oldCookie cookie to be used to retrieve the existing group
79 * @param buckets immutable list of group bucket to be added
80 * @param newCookie immutable cookie to be used post update operation
81 * @param appId Application Id
82 */
83 void addBucketsToGroup(DeviceId deviceId,
84 GroupKey oldCookie,
85 GroupBuckets buckets,
86 GroupKey newCookie,
87 ApplicationId appId);
88
89 /**
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -080090 * Removes buckets from existing group. The caller can optionally
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -080091 * associate a new cookie during this updation. GROUP_UPDATED or
92 * GROUP_UPDATE_FAILED notifications would be provided along with
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -080093 * cookie depending on the result of the operation on the device.
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -080094 *
95 * @param deviceId device identifier
96 * @param oldCookie cookie to be used to retrieve the existing group
97 * @param buckets immutable list of group bucket to be removed
98 * @param newCookie immutable cookie to be used post update operation
99 * @param appId Application Id
100 */
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -0800101 void removeBucketsFromGroup(DeviceId deviceId,
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -0800102 GroupKey oldCookie,
103 GroupBuckets buckets,
104 GroupKey newCookie,
105 ApplicationId appId);
106
107 /**
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -0800108 * Deletes a group associated to an application cookie.
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -0800109 * GROUP_DELETED or GROUP_DELETE_FAILED notifications would be
110 * provided along with cookie depending on the result of the
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -0800111 * operation on the device.
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -0800112 *
113 * @param deviceId device identifier
114 * @param appCookie application cookie to be used for lookup
115 * @param appId Application Id
116 */
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -0800117 void removeGroup(DeviceId deviceId, GroupKey appCookie, ApplicationId appId);
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -0800118
119 /**
Srikanth Vavilapalli0599d512015-01-30 12:57:56 -0800120 * Retrieves all groups created by an application in the specified device
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -0800121 * as seen by current controller instance.
122 *
123 * @param deviceId device identifier
124 * @param appId application id
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -0800125 * @return collection of immutable group objects created by the application
126 */
Srikanth Vavilapalli45c27c82015-01-30 12:57:56 -0800127 Iterable<Group> getGroups(DeviceId deviceId, ApplicationId appId);
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -0800128
129 /**
Jonathan Hart32600692015-03-09 10:38:40 -0700130 * Returns all groups associated with the given device.
131 *
132 * @param deviceId device ID to get groups for
133 * @return iterable of device's groups
134 */
135 Iterable<Group> getGroups(DeviceId deviceId);
136
137 /**
Srikanth Vavilapalli56db94f2015-01-22 22:30:17 -0800138 * Adds the specified group listener.
139 *
140 * @param listener group listener
141 */
142 void addListener(GroupListener listener);
143
144 /**
145 * Removes the specified group listener.
146 *
147 * @param listener group listener
148 */
149 void removeListener(GroupListener listener);
150}