blob: 05efb150f6343744f5630462f0c327d373f59a31 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.intent;
weibitf32383b2014-10-22 10:17:31 -070017
Brian O'Connor9476fa12015-06-25 15:17:17 -040018import com.google.common.annotations.Beta;
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +090019import com.google.common.base.MoreObjects;
Brian O'Connorabafb502014-12-02 22:26:20 -080020import org.onosproject.core.ApplicationId;
21import org.onosproject.net.ConnectPoint;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070022import org.onosproject.net.OduSignalType;
Luca Prete670ac5d2017-02-03 15:55:43 -080023import org.onosproject.net.ResourceGroup;
weibitf32383b2014-10-22 10:17:31 -070024
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +090025import java.util.Collections;
26
Ray Milkeye076c792015-03-24 09:38:30 -070027import static com.google.common.base.Preconditions.checkNotNull;
Sho SHIMIZUd7d18002015-01-21 14:37:14 -080028
weibitf32383b2014-10-22 10:17:31 -070029/**
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070030 * An optical layer intent for connectivity between two OCh ports.
31 * No traffic selector or traffic treatment are needed.
weibitf32383b2014-10-22 10:17:31 -070032 */
Brian O'Connor9476fa12015-06-25 15:17:17 -040033@Beta
Ray Milkeybd4f0112015-03-02 17:07:09 -080034public final class OpticalConnectivityIntent extends Intent {
35 private final ConnectPoint src;
36 private final ConnectPoint dst;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070037 private final OduSignalType signalType;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070038 private final boolean isBidirectional;
weibitf32383b2014-10-22 10:17:31 -070039
40 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -070041 * Creates an optical connectivity intent between the specified
42 * connection points.
weibitf32383b2014-10-22 10:17:31 -070043 *
Thomas Vachuska4b420772014-10-30 16:46:17 -070044 * @param appId application identification
Ray Milkey5b3717e2015-02-05 11:44:08 -080045 * @param key intent key
46 * @param src the source transponder port
47 * @param dst the destination transponder port
Brian O'Connor85cf4da2015-06-05 23:44:28 -070048 * @param signalType signal type
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070049 * @param isBidirectional indicates if intent is unidirectional
Ray Milkey22083ae2015-03-25 13:02:07 -070050 * @param priority priority to use for flows from this intent
Luca Prete670ac5d2017-02-03 15:55:43 -080051 * @deprecated 1.9.1
Ray Milkey5b3717e2015-02-05 11:44:08 -080052 */
Luca Prete670ac5d2017-02-03 15:55:43 -080053 @Deprecated
Ray Milkeye076c792015-03-24 09:38:30 -070054 protected OpticalConnectivityIntent(ApplicationId appId,
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070055 Key key,
56 ConnectPoint src,
57 ConnectPoint dst,
58 OduSignalType signalType,
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070059 boolean isBidirectional,
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070060 int priority) {
Luca Prete670ac5d2017-02-03 15:55:43 -080061 super(appId, key, Collections.emptyList(), priority, null);
62 this.src = checkNotNull(src);
63 this.dst = checkNotNull(dst);
64 this.signalType = checkNotNull(signalType);
65 this.isBidirectional = isBidirectional;
66 }
67
68 /**
69 * Creates an optical connectivity intent between the specified
70 * connection points.
71 *
72 * @param appId application identification
73 * @param key intent key
74 * @param src the source transponder port
75 * @param dst the destination transponder port
76 * @param signalType signal type
77 * @param isBidirectional indicates if intent is unidirectional
78 * @param priority priority to use for flows from this intent
79 * @param resourceGroup resource group of this intent
80 */
81 protected OpticalConnectivityIntent(ApplicationId appId,
82 Key key,
83 ConnectPoint src,
84 ConnectPoint dst,
85 OduSignalType signalType,
86 boolean isBidirectional,
87 int priority,
88 ResourceGroup resourceGroup) {
89 super(appId, key, Collections.emptyList(), priority, resourceGroup);
Ray Milkeye076c792015-03-24 09:38:30 -070090 this.src = checkNotNull(src);
91 this.dst = checkNotNull(dst);
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070092 this.signalType = checkNotNull(signalType);
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070093 this.isBidirectional = isBidirectional;
weibitf32383b2014-10-22 10:17:31 -070094 }
95
Ray Milkeye076c792015-03-24 09:38:30 -070096 /**
97 * Returns a new optical connectivity intent builder.
98 *
99 * @return host to host intent builder
100 */
101 public static Builder builder() {
102 return new Builder();
103 }
104
105
106 /**
107 * Builder for optical connectivity intents.
108 */
109 public static class Builder extends Intent.Builder {
110 private ConnectPoint src;
111 private ConnectPoint dst;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700112 private OduSignalType signalType;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700113 private boolean isBidirectional;
Ray Milkeye076c792015-03-24 09:38:30 -0700114
115 @Override
116 public Builder appId(ApplicationId appId) {
117 return (Builder) super.appId(appId);
118 }
119
120 @Override
121 public Builder key(Key key) {
122 return (Builder) super.key(key);
123 }
124
125 @Override
126 public Builder priority(int priority) {
127 return (Builder) super.priority(priority);
128 }
129
Luca Prete670ac5d2017-02-03 15:55:43 -0800130 @Override
131 public Builder resourceGroup(ResourceGroup resourceGroup) {
132 return (Builder) super.resourceGroup(resourceGroup);
133 }
134
Ray Milkeye076c792015-03-24 09:38:30 -0700135 /**
136 * Sets the source for the intent that will be built.
137 *
138 * @param src source to use for built intent
139 * @return this builder
140 */
141 public Builder src(ConnectPoint src) {
142 this.src = src;
143 return this;
144 }
145
146 /**
147 * Sets the destination for the intent that will be built.
148 *
149 * @param dst dest to use for built intent
150 * @return this builder
151 */
152 public Builder dst(ConnectPoint dst) {
153 this.dst = dst;
154 return this;
155 }
156
157 /**
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700158 * Sets the ODU signal type for the intent that will be built.
159 *
160 * @param signalType ODU signal type
161 * @return this builder
162 */
163 public Builder signalType(OduSignalType signalType) {
164 this.signalType = signalType;
165 return this;
166 }
167
168 /**
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700169 * Sets the directionality of the intent.
170 *
171 * @param isBidirectional true if bidirectional, false if unidirectional
172 * @return this builder
173 */
174 public Builder bidirectional(boolean isBidirectional) {
175 this.isBidirectional = isBidirectional;
176 return this;
177 }
178
179 /**
Ray Milkeye076c792015-03-24 09:38:30 -0700180 * Builds an optical connectivity intent from the accumulated parameters.
181 *
182 * @return point to point intent
183 */
184 public OpticalConnectivityIntent build() {
185
186 return new OpticalConnectivityIntent(
187 appId,
188 key,
189 src,
190 dst,
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700191 signalType,
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700192 isBidirectional,
Luca Prete670ac5d2017-02-03 15:55:43 -0800193 priority,
194 resourceGroup
Ray Milkeye076c792015-03-24 09:38:30 -0700195 );
196 }
197 }
Ray Milkey5b3717e2015-02-05 11:44:08 -0800198
weibitf32383b2014-10-22 10:17:31 -0700199 /**
200 * Constructor for serializer.
201 */
202 protected OpticalConnectivityIntent() {
203 super();
204 this.src = null;
205 this.dst = null;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700206 this.signalType = null;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700207 this.isBidirectional = false;
weibitf32383b2014-10-22 10:17:31 -0700208 }
209
210 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -0700211 * Returns the source transponder port.
weibitf32383b2014-10-22 10:17:31 -0700212 *
Thomas Vachuska4b420772014-10-30 16:46:17 -0700213 * @return source transponder port
weibitf32383b2014-10-22 10:17:31 -0700214 */
Jonathan Hartc9d76732014-11-18 10:52:20 -0800215 public ConnectPoint getSrc() {
weibitf32383b2014-10-22 10:17:31 -0700216 return src;
217 }
218
219 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -0700220 * Returns the destination transponder port.
weibitf32383b2014-10-22 10:17:31 -0700221 *
Thomas Vachuska4b420772014-10-30 16:46:17 -0700222 * @return source transponder port
weibitf32383b2014-10-22 10:17:31 -0700223 */
224 public ConnectPoint getDst() {
225 return dst;
226 }
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +0900227
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700228 /**
229 * Returns the ODU signal type.
230 *
231 * @return ODU signal type
232 */
233 public OduSignalType getSignalType() {
234 return signalType;
235 }
236
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700237 /**
238 * Returns the directionality of the intent.
239 *
240 * @return true if bidirectional, false if unidirectional
241 */
242 public boolean isBidirectional() {
243 return isBidirectional;
244 }
245
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +0900246 @Override
247 public String toString() {
248 return MoreObjects.toStringHelper(this)
249 .add("id", id())
250 .add("key", key())
251 .add("appId", appId())
252 .add("priority", priority())
253 .add("resources", resources())
254 .add("src", src)
255 .add("dst", dst)
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700256 .add("signalType", signalType)
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700257 .add("isBidirectional", isBidirectional)
Luca Prete670ac5d2017-02-03 15:55:43 -0800258 .add("resourceGroup", resourceGroup())
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +0900259 .toString();
260 }
weibitf32383b2014-10-22 10:17:31 -0700261}