Committed by
Gerrit Code Review
Group subsystem Northbound and Southbound API definition
Change-Id: I1843562ff7fdf0dfdf82a8757382d494698ded3f
Showing
15 changed files
with
1131 additions
and
0 deletions
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 | + | ||
18 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
19 | +import static com.google.common.base.Preconditions.checkArgument; | ||
20 | + | ||
21 | +import org.onosproject.net.PortNumber; | ||
22 | +import org.onosproject.net.flow.TrafficTreatment; | ||
23 | +import org.onosproject.core.GroupId; | ||
24 | + | ||
25 | +/* Group bucket implementation. A group bucket is collection of | ||
26 | + * instructions that can be performed on a traffic flow. A select | ||
27 | + * Group can have one or more Buckets where traffic will be | ||
28 | + * processed by a single bucket in the group, based on device | ||
29 | + * specific selection algorithm (e.g. hash on some fields of the | ||
30 | + * incoming traffic flows or round robin) and hence can contains | ||
31 | + * optional weight field to define the weights among the buckets | ||
32 | + * in the group. A failover group bucket is associated with a | ||
33 | + * specific port or group that controls its liveness. | ||
34 | + */ | ||
35 | +public final class DefaultGroupBucket implements GroupBucket { | ||
36 | + private final GroupDescription.Type type; | ||
37 | + private final TrafficTreatment treatment; | ||
38 | + private final short weight; | ||
39 | + private final PortNumber watchPort; | ||
40 | + private final GroupId watchGroup; | ||
41 | + | ||
42 | + /** | ||
43 | + * Group bucket constructor with the parameters. | ||
44 | + * | ||
45 | + * @param type group bucket type | ||
46 | + * @param treatment traffic treatment associated with group bucket | ||
47 | + * @param weight optional weight associated with group bucket | ||
48 | + * @param watchPort port that determines the liveness of group bucket | ||
49 | + * @param watchPort group that determines the liveness of group bucket | ||
50 | + */ | ||
51 | + private DefaultGroupBucket(GroupDescription.Type type, | ||
52 | + TrafficTreatment treatment, | ||
53 | + short weight, | ||
54 | + PortNumber watchPort, | ||
55 | + GroupId watchGroup) { | ||
56 | + this.type = type; | ||
57 | + this.treatment = checkNotNull(treatment); | ||
58 | + this.weight = weight; | ||
59 | + this.watchPort = watchPort; | ||
60 | + this.watchGroup = watchGroup; | ||
61 | + } | ||
62 | + | ||
63 | + /** | ||
64 | + * Creates indirect group bucket. | ||
65 | + * | ||
66 | + * @param treatment traffic treatment associated with group bucket | ||
67 | + * | ||
68 | + * @return indirect group bucket object | ||
69 | + */ | ||
70 | + public static GroupBucket createIndirectGroupBucket( | ||
71 | + TrafficTreatment treatment) { | ||
72 | + return new DefaultGroupBucket(GroupDescription.Type.INDIRECT, | ||
73 | + treatment, | ||
74 | + (short) -1, | ||
75 | + null, | ||
76 | + null); | ||
77 | + } | ||
78 | + | ||
79 | + /** | ||
80 | + * Creates select group bucket with weight as 1. | ||
81 | + * | ||
82 | + * @param treatment traffic treatment associated with group bucket | ||
83 | + * | ||
84 | + * @return select group bucket object | ||
85 | + */ | ||
86 | + public static GroupBucket createSelectGroupBucket( | ||
87 | + TrafficTreatment treatment) { | ||
88 | + return new DefaultGroupBucket(GroupDescription.Type.SELECT, | ||
89 | + treatment, | ||
90 | + (short) 1, | ||
91 | + null, | ||
92 | + null); | ||
93 | + } | ||
94 | + | ||
95 | + /** | ||
96 | + * Creates select group bucket with specified weight. | ||
97 | + * | ||
98 | + * @param treatment traffic treatment associated with group bucket | ||
99 | + * @param weight weight associated with group bucket | ||
100 | + * | ||
101 | + * @return select group bucket object | ||
102 | + */ | ||
103 | + public static GroupBucket createSelectGroupBucket( | ||
104 | + TrafficTreatment treatment, | ||
105 | + short weight) { | ||
106 | + if (weight == 0) { | ||
107 | + return null; | ||
108 | + } | ||
109 | + | ||
110 | + return new DefaultGroupBucket(GroupDescription.Type.SELECT, | ||
111 | + treatment, | ||
112 | + weight, | ||
113 | + null, | ||
114 | + null); | ||
115 | + } | ||
116 | + | ||
117 | + /** | ||
118 | + * Creates failover group bucket with watchport or watchgroup. | ||
119 | + * | ||
120 | + * @param treatment traffic treatment associated with group bucket | ||
121 | + * @param watchPort port that determines the liveness of group bucket | ||
122 | + * @param watchPort group that determines the liveness of group bucket | ||
123 | + * | ||
124 | + * @return failover group bucket object | ||
125 | + */ | ||
126 | + public static GroupBucket createFailoverGroupBucket( | ||
127 | + TrafficTreatment treatment, | ||
128 | + PortNumber watchPort, | ||
129 | + GroupId watchGroup) { | ||
130 | + checkArgument(((watchPort != null) || (watchGroup != null))); | ||
131 | + return new DefaultGroupBucket(GroupDescription.Type.FAILOVER, | ||
132 | + treatment, | ||
133 | + (short) -1, | ||
134 | + watchPort, | ||
135 | + watchGroup); | ||
136 | + } | ||
137 | + | ||
138 | + @Override | ||
139 | + public GroupDescription.Type type() { | ||
140 | + return this.type; | ||
141 | + } | ||
142 | + | ||
143 | + /** | ||
144 | + * Return list of Traffic instructions that are part of the bucket. | ||
145 | + * | ||
146 | + * @return TrafficTreatment Traffic instruction list | ||
147 | + */ | ||
148 | + @Override | ||
149 | + public TrafficTreatment treatment() { | ||
150 | + return treatment; | ||
151 | + } | ||
152 | + | ||
153 | + /** | ||
154 | + * Return weight of select group bucket. | ||
155 | + * | ||
156 | + * @return short weight associated with a bucket | ||
157 | + */ | ||
158 | + @Override | ||
159 | + public short weight() { | ||
160 | + return weight; | ||
161 | + } | ||
162 | + | ||
163 | + /** | ||
164 | + * Return port number used for liveness detection for a | ||
165 | + * failover bucket. | ||
166 | + * | ||
167 | + * @return PortNumber port number used for liveness detection | ||
168 | + */ | ||
169 | + @Override | ||
170 | + public PortNumber watchPort() { | ||
171 | + return watchPort; | ||
172 | + } | ||
173 | + | ||
174 | + /** | ||
175 | + * Return group identifier used for liveness detection for a | ||
176 | + * failover bucket. | ||
177 | + * | ||
178 | + * @return GroupId group identifier to be used for liveness detection | ||
179 | + */ | ||
180 | + @Override | ||
181 | + public GroupId watchGroup() { | ||
182 | + return watchGroup; | ||
183 | + } | ||
184 | +} |
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 | + | ||
18 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
19 | + | ||
20 | +import org.onosproject.core.ApplicationId; | ||
21 | +import org.onosproject.net.DeviceId; | ||
22 | + | ||
23 | +public class DefaultGroupDescription implements GroupDescription { | ||
24 | + private final GroupDescription.Type type; | ||
25 | + private final GroupBuckets buckets; | ||
26 | + private final GroupKey appCookie; | ||
27 | + private final ApplicationId appId; | ||
28 | + private final DeviceId deviceId; | ||
29 | + | ||
30 | + /** | ||
31 | + * | ||
32 | + * @param deviceId device identifier | ||
33 | + * @param type type of the group | ||
34 | + * @param buckets immutable list of group bucket | ||
35 | + * @param appCookie immutable application cookie to be associated with the group | ||
36 | + * @param appId application id | ||
37 | + * | ||
38 | + * NOTE: The caller of this subsystem MUST ensure the appCookie | ||
39 | + * provided in this API is immutable | ||
40 | + */ | ||
41 | + public DefaultGroupDescription(DeviceId deviceId, | ||
42 | + GroupDescription.Type type, | ||
43 | + GroupBuckets buckets, | ||
44 | + GroupKey appCookie, | ||
45 | + ApplicationId appId) { | ||
46 | + this.type = checkNotNull(type); | ||
47 | + this.deviceId = checkNotNull(deviceId); | ||
48 | + this.buckets = checkNotNull(buckets); | ||
49 | + this.appCookie = checkNotNull(appCookie); | ||
50 | + this.appId = checkNotNull(appId); | ||
51 | + } | ||
52 | + | ||
53 | + /** | ||
54 | + * Return type of a group object. | ||
55 | + * | ||
56 | + * @return GroupType group type | ||
57 | + */ | ||
58 | + @Override | ||
59 | + public GroupDescription.Type type() { | ||
60 | + return this.type; | ||
61 | + } | ||
62 | + | ||
63 | + /** | ||
64 | + * Return device identifier on which this group object is created. | ||
65 | + * | ||
66 | + * @return DeviceId device identifier | ||
67 | + */ | ||
68 | + @Override | ||
69 | + public DeviceId deviceId() { | ||
70 | + return this.deviceId; | ||
71 | + } | ||
72 | + | ||
73 | + /** | ||
74 | + * Return application identifier that has created this group object. | ||
75 | + * | ||
76 | + * @return ApplicationId application identifier | ||
77 | + */ | ||
78 | + @Override | ||
79 | + public ApplicationId appId() { | ||
80 | + return this.appId; | ||
81 | + } | ||
82 | + | ||
83 | + /** | ||
84 | + * Return application cookie associated with a group object. | ||
85 | + * | ||
86 | + * @return GroupKey application cookie | ||
87 | + */ | ||
88 | + @Override | ||
89 | + public GroupKey appCookie() { | ||
90 | + return this.appCookie; | ||
91 | + } | ||
92 | + | ||
93 | + /** | ||
94 | + * Return group buckets of a group. | ||
95 | + * | ||
96 | + * @return GroupBuckets immutable list of group bucket | ||
97 | + */ | ||
98 | + @Override | ||
99 | + public GroupBuckets buckets() { | ||
100 | + return this.buckets; | ||
101 | + } | ||
102 | + | ||
103 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | + | ||
18 | +import org.onosproject.core.GroupId; | ||
19 | + | ||
20 | +/** | ||
21 | + * ONOS representation of group that is stored in the system. | ||
22 | + */ | ||
23 | +public interface Group extends GroupDescription { | ||
24 | + /** | ||
25 | + * State of the group object in ONOS. | ||
26 | + * PENDING_ADD: group create request is processed by ONOS and | ||
27 | + * not yet received the confirmation from data plane | ||
28 | + * ADDED: group is created in the data plane | ||
29 | + * PENDING_UPDATE: group update request is processed by ONOS and | ||
30 | + * not received the confirmation from data plane post which state | ||
31 | + * moves to ADDED state | ||
32 | + * PENDING_DELETE: group delete request is processed by ONOS and | ||
33 | + * not received the confirmation from data plane | ||
34 | + */ | ||
35 | + public enum GroupState { | ||
36 | + PENDING_ADD, | ||
37 | + ADDED, | ||
38 | + PENDING_UPDATE, | ||
39 | + PENDING_DELETE | ||
40 | + } | ||
41 | + | ||
42 | + /** | ||
43 | + * Return group identifier associated with a group object. | ||
44 | + * | ||
45 | + * @return GroupId Group Identifier | ||
46 | + */ | ||
47 | + public GroupId id(); | ||
48 | + | ||
49 | + /** | ||
50 | + * Return current state of a group object. | ||
51 | + * | ||
52 | + * @return GroupState Group State | ||
53 | + */ | ||
54 | + public GroupState state(); | ||
55 | + | ||
56 | + /** | ||
57 | + * Returns the number of milliseconds this group has been alive. | ||
58 | + * | ||
59 | + * @return number of millis | ||
60 | + */ | ||
61 | + long life(); | ||
62 | + | ||
63 | + /** | ||
64 | + * Returns the number of packets processed by this group. | ||
65 | + * | ||
66 | + * @return number of packets | ||
67 | + */ | ||
68 | + long packets(); | ||
69 | + | ||
70 | + /** | ||
71 | + * Returns the number of bytes processed by this group. | ||
72 | + * | ||
73 | + * @return number of bytes | ||
74 | + */ | ||
75 | + long bytes(); | ||
76 | +} |
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 | + | ||
18 | +import org.onosproject.net.PortNumber; | ||
19 | +import org.onosproject.net.flow.TrafficTreatment; | ||
20 | +import org.onosproject.core.GroupId; | ||
21 | + | ||
22 | +/* Group Bucket definition. A default group Bucket is collection of | ||
23 | + * Instructions that can be performed on a traffic flow. A failover | ||
24 | + * group bucket is associated with a specific port or group that | ||
25 | + * controls its liveness. A select group bucket contains optional | ||
26 | + * weight field to define the weights among the buckets in the group. | ||
27 | + */ | ||
28 | +public interface GroupBucket { | ||
29 | + /** | ||
30 | + * Return group type of the bucket. | ||
31 | + * | ||
32 | + * @return GroupType group type | ||
33 | + */ | ||
34 | + public GroupDescription.Type type(); | ||
35 | + | ||
36 | + /** | ||
37 | + * Return list of Traffic instructions that are part of the bucket. | ||
38 | + * | ||
39 | + * @return TrafficTreatment traffic instruction list | ||
40 | + */ | ||
41 | + public TrafficTreatment treatment(); | ||
42 | + | ||
43 | + /** | ||
44 | + * Return weight of select group bucket. | ||
45 | + * | ||
46 | + * @return short weight associated with a bucket | ||
47 | + */ | ||
48 | + public short weight(); | ||
49 | + | ||
50 | + /** | ||
51 | + * Return port number used for liveness detection for a | ||
52 | + * failover bucket. | ||
53 | + * | ||
54 | + * @return PortNumber port number used for liveness detection | ||
55 | + */ | ||
56 | + public PortNumber watchPort(); | ||
57 | + | ||
58 | + /** | ||
59 | + * Return group identifier used for liveness detection for a | ||
60 | + * failover bucket. | ||
61 | + * | ||
62 | + * @return GroupId group identifier to be used for liveness detection | ||
63 | + */ | ||
64 | + public GroupId watchGroup(); | ||
65 | + | ||
66 | +} |
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 | + | ||
18 | +/* Generic group bucket entry representation that is stored in a | ||
19 | + * group object. A group bucket entry provides additional info of | ||
20 | + * group bucket like statistics...etc | ||
21 | + */ | ||
22 | +public interface GroupBucketEntry extends GroupBucket { | ||
23 | + /** | ||
24 | + * Return Number of packets processed by bucket. | ||
25 | + * | ||
26 | + * @return long | ||
27 | + */ | ||
28 | + public long packets(); | ||
29 | + | ||
30 | + /** | ||
31 | + * Return Number of bytes processed by bucket. | ||
32 | + * | ||
33 | + * @return long | ||
34 | + */ | ||
35 | + public long bytes(); | ||
36 | +} |
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 | + | ||
18 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
19 | + | ||
20 | +import java.util.List; | ||
21 | + | ||
22 | + | ||
23 | +import com.google.common.collect.ImmutableList; | ||
24 | + | ||
25 | +public final class GroupBuckets { | ||
26 | + private final List<GroupBucket> buckets; | ||
27 | + | ||
28 | + /** | ||
29 | + * Creates a immutable list of group bucket. | ||
30 | + * | ||
31 | + * @param buckets list of group bucket | ||
32 | + */ | ||
33 | + public GroupBuckets(List<GroupBucket> buckets) { | ||
34 | + this.buckets = ImmutableList.copyOf(checkNotNull(buckets)); | ||
35 | + } | ||
36 | + | ||
37 | + /** | ||
38 | + * Immutable list of group buckets. | ||
39 | + * | ||
40 | + * @return list of group bucket | ||
41 | + */ | ||
42 | + public List<GroupBucket> buckets() { | ||
43 | + return buckets; | ||
44 | + } | ||
45 | + | ||
46 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | + | ||
18 | +import org.onosproject.core.ApplicationId; | ||
19 | +import org.onosproject.net.DeviceId; | ||
20 | + | ||
21 | +/** | ||
22 | + * ONOS representation of group description that is used to create | ||
23 | + * a group. It contains immutable properties of a ONOS group construct | ||
24 | + * such as "type", "DeviceId", "appCookie", "appId" and "buckets" | ||
25 | + */ | ||
26 | +public interface GroupDescription { | ||
27 | + /** | ||
28 | + * Types of the group supported by ONOS. | ||
29 | + */ | ||
30 | + public enum Type { | ||
31 | + /** | ||
32 | + * Load-balancing among different buckets in a group. | ||
33 | + */ | ||
34 | + SELECT, | ||
35 | + /** | ||
36 | + * Single Bucket Group. | ||
37 | + */ | ||
38 | + INDIRECT, | ||
39 | + /** | ||
40 | + * Multicast to all buckets in a group. | ||
41 | + */ | ||
42 | + ALL, | ||
43 | + /** | ||
44 | + * Uses the first live bucket in a group. | ||
45 | + */ | ||
46 | + FAILOVER | ||
47 | + } | ||
48 | + | ||
49 | + /** | ||
50 | + * Return type of a group object. | ||
51 | + * | ||
52 | + * @return GroupType group type | ||
53 | + */ | ||
54 | + public Type type(); | ||
55 | + | ||
56 | + /** | ||
57 | + * Return device identifier on which this group object is created. | ||
58 | + * | ||
59 | + * @return DeviceId device identifier | ||
60 | + */ | ||
61 | + public DeviceId deviceId(); | ||
62 | + | ||
63 | + /** | ||
64 | + * Return application identifier that has created this group object. | ||
65 | + * | ||
66 | + * @return ApplicationId application identifier | ||
67 | + */ | ||
68 | + public ApplicationId appId(); | ||
69 | + | ||
70 | + /** | ||
71 | + * Return application cookie associated with a group object. | ||
72 | + * | ||
73 | + * @return GroupKey application cookie | ||
74 | + */ | ||
75 | + public GroupKey appCookie(); | ||
76 | + | ||
77 | + /** | ||
78 | + * Return group buckets of a group. | ||
79 | + * | ||
80 | + * @return GroupBuckets immutable list of group bucket | ||
81 | + */ | ||
82 | + public GroupBuckets buckets(); | ||
83 | +} |
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 | + | ||
18 | +import org.onosproject.event.AbstractEvent; | ||
19 | + | ||
20 | +/** | ||
21 | + * Describes flow rule event. | ||
22 | + */ | ||
23 | +public class GroupEvent extends AbstractEvent<GroupEvent.Type, Group> { | ||
24 | + | ||
25 | + /** | ||
26 | + * Type of flow rule events. | ||
27 | + */ | ||
28 | + public enum Type { | ||
29 | + /** | ||
30 | + * Signifies that a new Group has been detected. | ||
31 | + */ | ||
32 | + GROUP_ADDED, | ||
33 | + | ||
34 | + /** | ||
35 | + * Signifies that a Group has been removed. | ||
36 | + */ | ||
37 | + GROUP_REMOVED, | ||
38 | + | ||
39 | + /** | ||
40 | + * Signifies that a Group has been updated. | ||
41 | + */ | ||
42 | + GROUP_UPDATED, | ||
43 | + | ||
44 | + // internal event between Manager <-> Store | ||
45 | + | ||
46 | + /* | ||
47 | + * Signifies that a request to create Group has been added to the store. | ||
48 | + */ | ||
49 | + GROUP_ADD_REQUESTED, | ||
50 | + /* | ||
51 | + * Signifies that a request to delete Group has been added to the store. | ||
52 | + */ | ||
53 | + GROUP_REMOVE_REQUESTED, | ||
54 | + } | ||
55 | + | ||
56 | + /** | ||
57 | + * Creates an event of a given type and for the specified Group and the | ||
58 | + * current time. | ||
59 | + * | ||
60 | + * @param type Group event type | ||
61 | + * @param group event subject | ||
62 | + */ | ||
63 | + public GroupEvent(Type type, Group group) { | ||
64 | + super(type, group); | ||
65 | + } | ||
66 | + | ||
67 | + /** | ||
68 | + * Creates an event of a given type and for the specified Group and time. | ||
69 | + * | ||
70 | + * @param type Group event type | ||
71 | + * @param group event subject | ||
72 | + * @param time occurrence time | ||
73 | + */ | ||
74 | + public GroupEvent(Type type, Group group, long time) { | ||
75 | + super(type, group, time); | ||
76 | + } | ||
77 | + | ||
78 | +} |
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 | + | ||
18 | +/* Representation of generalized Key that would be used to store | ||
19 | + * groups in <Key, Value> store. Implementation of this interface | ||
20 | + * MUST override "equals()" and "hashcode()" methods. | ||
21 | + */ | ||
22 | +public interface GroupKey { | ||
23 | +} |
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 | + | ||
18 | +import org.onosproject.event.EventListener; | ||
19 | + | ||
20 | +/** | ||
21 | + * Entity capable of receiving Group related events. | ||
22 | + */ | ||
23 | +public interface GroupListener extends EventListener<GroupEvent> { | ||
24 | +} |
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 | + | ||
18 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
19 | + | ||
20 | +import org.onosproject.core.GroupId; | ||
21 | + | ||
22 | +public final class GroupOperation { | ||
23 | + private final Type opType; | ||
24 | + private final GroupId groupId; | ||
25 | + private final GroupDescription.Type groupType; | ||
26 | + private final GroupBuckets buckets; | ||
27 | + | ||
28 | + public enum Type { | ||
29 | + /** | ||
30 | + * Create a group in a device with the specified parameters. | ||
31 | + */ | ||
32 | + ADD, | ||
33 | + /** | ||
34 | + * Modify a group in a device with the specified parameters. | ||
35 | + */ | ||
36 | + MODIFY, | ||
37 | + /** | ||
38 | + * Delete a specified group. | ||
39 | + */ | ||
40 | + DELETE | ||
41 | + } | ||
42 | + | ||
43 | + /** | ||
44 | + * Group operation constructor with the parameters. | ||
45 | + * | ||
46 | + * @param opType group operation type | ||
47 | + * @param groupId group Identifier | ||
48 | + * @param groupType type of the group | ||
49 | + * @param buckets immutable list of group buckets to be part of group | ||
50 | + */ | ||
51 | + private GroupOperation(Type opType, | ||
52 | + GroupId groupId, | ||
53 | + GroupDescription.Type groupType, | ||
54 | + GroupBuckets buckets) { | ||
55 | + this.opType = checkNotNull(opType); | ||
56 | + this.groupId = checkNotNull(groupId); | ||
57 | + this.groupType = checkNotNull(groupType); | ||
58 | + this.buckets = buckets; | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * Creates ADD group operation object. | ||
63 | + * | ||
64 | + * @param groupId group Identifier | ||
65 | + * @param groupType type of the group | ||
66 | + * @param buckets immutable list of group buckets to be part of group | ||
67 | + * | ||
68 | + * @return add group operation object | ||
69 | + */ | ||
70 | + public static GroupOperation createAddGroupOperation(GroupId groupId, | ||
71 | + GroupDescription.Type groupType, | ||
72 | + GroupBuckets buckets) { | ||
73 | + checkNotNull(buckets); | ||
74 | + return new GroupOperation(Type.ADD, groupId, groupType, buckets); | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * Creates MODIFY group operation object. | ||
79 | + * | ||
80 | + * @param groupId group Identifier | ||
81 | + * @param groupType type of the group | ||
82 | + * @param buckets immutable list of group buckets to be part of group | ||
83 | + * | ||
84 | + * @return modify group operation object | ||
85 | + */ | ||
86 | + public static GroupOperation createModifyGroupOperation(GroupId groupId, | ||
87 | + GroupDescription.Type groupType, | ||
88 | + GroupBuckets buckets) { | ||
89 | + checkNotNull(buckets); | ||
90 | + return new GroupOperation(Type.MODIFY, groupId, groupType, buckets); | ||
91 | + | ||
92 | + } | ||
93 | + | ||
94 | + /** | ||
95 | + * Creates DELETE group operation object. | ||
96 | + * | ||
97 | + * @param groupId group Identifier | ||
98 | + * @param groupType type of the group | ||
99 | + * | ||
100 | + * @return delete group operation object | ||
101 | + */ | ||
102 | + public static GroupOperation createDeleteGroupOperation(GroupId groupId, | ||
103 | + GroupDescription.Type groupType) { | ||
104 | + return new GroupOperation(Type.DELETE, groupId, groupType, null); | ||
105 | + | ||
106 | + } | ||
107 | + | ||
108 | + /** | ||
109 | + * Return group operation type. | ||
110 | + * | ||
111 | + * @return GroupOpType group operation type | ||
112 | + */ | ||
113 | + public Type opType() { | ||
114 | + return this.opType; | ||
115 | + } | ||
116 | + | ||
117 | + /** | ||
118 | + * Return group identifier attribute of the operation. | ||
119 | + * | ||
120 | + * @return GroupId group identifier | ||
121 | + */ | ||
122 | + public GroupId groupId() { | ||
123 | + return this.groupId; | ||
124 | + } | ||
125 | + | ||
126 | + /** | ||
127 | + * Return group type attribute of the operation. | ||
128 | + * | ||
129 | + * @return GroupType group type | ||
130 | + */ | ||
131 | + public GroupDescription.Type groupType() { | ||
132 | + return this.groupType; | ||
133 | + } | ||
134 | + | ||
135 | + /** | ||
136 | + * Return group buckets associated with the operation. | ||
137 | + * | ||
138 | + * @return GroupBuckets group buckets | ||
139 | + */ | ||
140 | + public GroupBuckets buckets() { | ||
141 | + return this.buckets; | ||
142 | + } | ||
143 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | + | ||
18 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
19 | + | ||
20 | +import java.util.List; | ||
21 | + | ||
22 | + | ||
23 | +import com.google.common.collect.ImmutableList; | ||
24 | + | ||
25 | +public final class GroupOperations { | ||
26 | + private final List<GroupOperation> operations; | ||
27 | + | ||
28 | + /** | ||
29 | + * Creates a immutable list of group operation. | ||
30 | + * | ||
31 | + * @param operations list of group operation | ||
32 | + */ | ||
33 | + public GroupOperations(List<GroupOperation> operations) { | ||
34 | + this.operations = ImmutableList.copyOf(checkNotNull(operations)); | ||
35 | + } | ||
36 | + | ||
37 | + /** | ||
38 | + * Immutable list of group operation. | ||
39 | + * | ||
40 | + * @return list of group operation | ||
41 | + */ | ||
42 | + public List<GroupOperation> operations() { | ||
43 | + return operations; | ||
44 | + } | ||
45 | + | ||
46 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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 | + | ||
18 | +import org.onosproject.net.DeviceId; | ||
19 | +import org.onosproject.net.provider.Provider; | ||
20 | + | ||
21 | +/** | ||
22 | + * Abstraction of a flow rule provider. | ||
23 | + */ | ||
24 | +public interface GroupProvider extends Provider { | ||
25 | + | ||
26 | + /** | ||
27 | + * Perform a group operation in the specified device with the | ||
28 | + * specified parameters. | ||
29 | + * | ||
30 | + * @param deviceId device identifier on which the batch of group | ||
31 | + * operations to be executed | ||
32 | + * @param groupOps immutable list of group operation | ||
33 | + */ | ||
34 | + void performGroupOperation(DeviceId deviceId, | ||
35 | + GroupOperations groupOps); | ||
36 | + | ||
37 | +} |
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 | + | ||
18 | +import java.util.Collection; | ||
19 | + | ||
20 | +import org.onosproject.net.DeviceId; | ||
21 | +import org.onosproject.net.provider.ProviderService; | ||
22 | + | ||
23 | +/** | ||
24 | + * Service through which Group providers can inject information into | ||
25 | + * the core. | ||
26 | + */ | ||
27 | +public interface GroupProviderService extends ProviderService<GroupProvider> { | ||
28 | + | ||
29 | + void groupOperationFailed(GroupOperation operation); | ||
30 | + | ||
31 | + /** | ||
32 | + * Pushes the collection of group detected in the data plane along | ||
33 | + * with statistics. | ||
34 | + * | ||
35 | + * @param deviceId device identifier | ||
36 | + * @param groupEntries collection of group entries as seen in data plane | ||
37 | + */ | ||
38 | + void pushGroupMetrics(DeviceId deviceId, | ||
39 | + Collection<Group> groupEntries); | ||
40 | + | ||
41 | +} |
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 | + | ||
18 | +import org.onosproject.core.ApplicationId; | ||
19 | +import org.onosproject.net.Device; | ||
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 | ||
30 | + * for all the referencing flow entries instead of modifying all of them | ||
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 | + */ | ||
36 | +public interface GroupService { | ||
37 | + | ||
38 | + /** | ||
39 | + * Create a group in the specified device with the provided buckets. | ||
40 | + * This API provides an option for application to associate a cookie | ||
41 | + * while creating a group, so that applications can look-up the | ||
42 | + * groups based on the cookies. These Groups will be retained by | ||
43 | + * the core system and re-applied if any groups found missing in the | ||
44 | + * device when it reconnects. This API would immediately return after | ||
45 | + * submitting the request locally or to a remote Master controller | ||
46 | + * instance. As a response to this API invocation, GROUP_ADDED or | ||
47 | + * GROUP_ADD_FAILED notifications would be provided along with cookie | ||
48 | + * depending on the result of the operation on the device in the | ||
49 | + * data plane. The caller may also use "getGroup" API to get the | ||
50 | + * Group object created as part of this request. | ||
51 | + * | ||
52 | + * @param groupDesc group creation parameters | ||
53 | + * | ||
54 | + */ | ||
55 | + void addGroup(GroupDescription groupDesc); | ||
56 | + | ||
57 | + /** | ||
58 | + * Return a group object associated to an application cookie. | ||
59 | + * | ||
60 | + * NOTE1: The presence of group object in the system does not | ||
61 | + * guarantee that the "group" is actually created in device. | ||
62 | + * GROUP_ADDED notification would confirm the creation of | ||
63 | + * this group in data plane | ||
64 | + * | ||
65 | + * @param deviceId device identifier | ||
66 | + * @param appCookie application cookie to be used for lookup | ||
67 | + * | ||
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 | + /** | ||
74 | + * Append buckets to existing group. The caller can optionally | ||
75 | + * associate a new cookie during this updation. GROUP_UPDATED or | ||
76 | + * GROUP_UPDATE_FAILED notifications would be provided along with | ||
77 | + * cookie depending on the result of the operation on the device | ||
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 | + /** | ||
92 | + * Remove buckets from existing group. The caller can optionally | ||
93 | + * associate a new cookie during this updation. GROUP_UPDATED or | ||
94 | + * GROUP_UPDATE_FAILED notifications would be provided along with | ||
95 | + * cookie depending on the result of the operation on the device | ||
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 | + */ | ||
103 | + void removeBucketsFromGroup(Device deviceId, | ||
104 | + GroupKey oldCookie, | ||
105 | + GroupBuckets buckets, | ||
106 | + GroupKey newCookie, | ||
107 | + ApplicationId appId); | ||
108 | + | ||
109 | + /** | ||
110 | + * Delete a group associated to an application cookie. | ||
111 | + * GROUP_DELETED or GROUP_DELETE_FAILED notifications would be | ||
112 | + * provided along with cookie depending on the result of the | ||
113 | + * operation on the device | ||
114 | + * | ||
115 | + * @param deviceId device identifier | ||
116 | + * @param appCookie application cookie to be used for lookup | ||
117 | + * @param appId Application Id | ||
118 | + */ | ||
119 | + void removeGroup(Device deviceId, GroupKey appCookie, ApplicationId appId); | ||
120 | + | ||
121 | + /** | ||
122 | + * Retrieve all groups created by an application in the specified device | ||
123 | + * as seen by current controller instance. | ||
124 | + * | ||
125 | + * @param deviceId device identifier | ||
126 | + * @param appId application id | ||
127 | + * | ||
128 | + * @return collection of immutable group objects created by the application | ||
129 | + */ | ||
130 | + Iterable<Group> getGroups(Device deviceId, ApplicationId appId); | ||
131 | + | ||
132 | + /** | ||
133 | + * Adds the specified group listener. | ||
134 | + * | ||
135 | + * @param listener group listener | ||
136 | + */ | ||
137 | + void addListener(GroupListener listener); | ||
138 | + | ||
139 | + /** | ||
140 | + * Removes the specified group listener. | ||
141 | + * | ||
142 | + * @param listener group listener | ||
143 | + */ | ||
144 | + void removeListener(GroupListener listener); | ||
145 | +} |
-
Please register or login to post a comment