blob: afe95bcd56a6c6877d5fa8f0653b7200634e3432 [file] [log] [blame]
Marc De Leenheer8c2caac2015-05-28 16:37:33 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Marc De Leenheer8c2caac2015-05-28 16:37:33 -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 */
16package org.onosproject.net.intent;
17
Brian O'Connor9476fa12015-06-25 15:17:17 -040018import com.google.common.annotations.Beta;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070019import com.google.common.base.MoreObjects;
20import org.onosproject.core.ApplicationId;
Toru Furusawa72ee30c2016-01-08 13:29:04 -080021import org.onosproject.net.CltSignalType;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070022import org.onosproject.net.ConnectPoint;
Luca Prete670ac5d2017-02-03 15:55:43 -080023import org.onosproject.net.ResourceGroup;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070024
25import java.util.Collections;
26
27import static com.google.common.base.Preconditions.checkNotNull;
28
29/**
30 * An optical layer intent for circuits between two OduClt ports.
31 * No traffic selector or traffic treatment are needed.
32 */
Brian O'Connor9476fa12015-06-25 15:17:17 -040033@Beta
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070034public class OpticalCircuitIntent extends Intent {
35 private final ConnectPoint src;
36 private final ConnectPoint dst;
Toru Furusawa72ee30c2016-01-08 13:29:04 -080037 private final CltSignalType signalType;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070038 private final boolean isBidirectional;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070039
40 /**
41 * Creates an optical circuit intent between the specified
42 * connection points.
43 *
44 * @param appId application identification
45 * @param key intent key
46 * @param src the source transponder port
47 * @param dst the destination transponder port
48 * @param signalType ODU signal type
Brian O'Connor85cf4da2015-06-05 23:44:28 -070049 * @param isBidirectional indicate if intent is bidirectional
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070050 * @param priority priority to use for flows from this intent
Luca Prete670ac5d2017-02-03 15:55:43 -080051 * @deprecated 1.9.1
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070052 */
Luca Prete670ac5d2017-02-03 15:55:43 -080053 @Deprecated
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070054 protected OpticalCircuitIntent(ApplicationId appId, Key key, ConnectPoint src, ConnectPoint dst,
Toru Furusawa72ee30c2016-01-08 13:29:04 -080055 CltSignalType signalType, boolean isBidirectional, int priority) {
Luca Prete670ac5d2017-02-03 15:55:43 -080056 super(appId, key, Collections.emptyList(), priority, null);
57 this.src = checkNotNull(src);
58 this.dst = checkNotNull(dst);
59 this.signalType = checkNotNull(signalType);
60 this.isBidirectional = isBidirectional;
61 }
62
63 /**
64 * Creates an optical circuit intent between the specified
65 * connection points.
66 *
67 * @param appId application identification
68 * @param key intent key
69 * @param src the source transponder port
70 * @param dst the destination transponder port
71 * @param signalType ODU signal type
72 * @param isBidirectional indicate if intent is bidirectional
73 * @param priority priority to use for flows from this intent
74 * @param resourceGroup resource group for this intent
75 */
76 protected OpticalCircuitIntent(ApplicationId appId, Key key, ConnectPoint src, ConnectPoint dst,
77 CltSignalType signalType, boolean isBidirectional, int priority,
78 ResourceGroup resourceGroup) {
79 super(appId, key, Collections.emptyList(), priority, resourceGroup);
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070080 this.src = checkNotNull(src);
81 this.dst = checkNotNull(dst);
82 this.signalType = checkNotNull(signalType);
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070083 this.isBidirectional = isBidirectional;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070084 }
85
86 /**
87 * Returns a new optical circuit intent builder.
88 *
89 * @return host to host intent builder
90 */
91 public static Builder builder() {
92 return new Builder();
93 }
94
95
96 /**
97 * Builder for optical circuit intents.
98 */
99 public static class Builder extends Intent.Builder {
100 private ConnectPoint src;
101 private ConnectPoint dst;
Toru Furusawa72ee30c2016-01-08 13:29:04 -0800102 private CltSignalType signalType;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700103 private boolean isBidirectional;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700104
105 @Override
106 public Builder appId(ApplicationId appId) {
107 return (Builder) super.appId(appId);
108 }
109
110 @Override
111 public Builder key(Key key) {
112 return (Builder) super.key(key);
113 }
114
115 @Override
116 public Builder priority(int priority) {
117 return (Builder) super.priority(priority);
118 }
119
Luca Prete670ac5d2017-02-03 15:55:43 -0800120 @Override
121 public Builder resourceGroup(ResourceGroup resourceGroup) {
122 return (Builder) super.resourceGroup(resourceGroup);
123 }
124
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700125 /**
126 * Sets the source for the intent that will be built.
127 *
128 * @param src source to use for built intent
129 * @return this builder
130 */
131 public Builder src(ConnectPoint src) {
132 this.src = src;
133 return this;
134 }
135
136 /**
137 * Sets the destination for the intent that will be built.
138 *
139 * @param dst dest to use for built intent
140 * @return this builder
141 */
142 public Builder dst(ConnectPoint dst) {
143 this.dst = dst;
144 return this;
145 }
146
147 /**
148 * Sets the ODU signal type for the intent that will be built.
149 *
150 * @param signalType signal type to use for built intent
151 * @return this builder
152 */
Toru Furusawa72ee30c2016-01-08 13:29:04 -0800153 public Builder signalType(CltSignalType signalType) {
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700154 this.signalType = signalType;
155 return this;
156 }
157
158 /**
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700159 * Sets the directionality of the intent.
160 *
161 * @param isBidirectional true if bidirectional, false if unidirectional
162 * @return this builder
163 */
164 public Builder bidirectional(boolean isBidirectional) {
165 this.isBidirectional = isBidirectional;
166 return this;
167 }
168
169 /**
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700170 * Builds an optical circuit intent from the accumulated parameters.
171 *
172 * @return point to point intent
173 */
174 public OpticalCircuitIntent build() {
175
176 return new OpticalCircuitIntent(
177 appId,
178 key,
179 src,
180 dst,
181 signalType,
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700182 isBidirectional,
Luca Prete670ac5d2017-02-03 15:55:43 -0800183 priority,
184 resourceGroup
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700185 );
186 }
187 }
188
189 /**
190 * Constructor for serializer.
191 */
192 protected OpticalCircuitIntent() {
193 super();
194 this.src = null;
195 this.dst = null;
196 this.signalType = null;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700197 this.isBidirectional = false;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700198 }
199
200 /**
201 * Returns the source transponder port.
202 *
203 * @return source transponder port
204 */
205 public ConnectPoint getSrc() {
206 return src;
207 }
208
209 /**
210 * Returns the destination transponder port.
211 *
212 * @return source transponder port
213 */
214 public ConnectPoint getDst() {
215 return dst;
216 }
217
218 /**
219 * Returns the ODU signal type.
220 *
221 * @return ODU signal type
222 */
Toru Furusawa72ee30c2016-01-08 13:29:04 -0800223 public CltSignalType getSignalType() {
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700224 return signalType;
225 }
226
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700227 /**
228 * Returns the directionality of the intent.
229 *
230 * @return true if bidirectional, false if unidirectional
231 */
232 public boolean isBidirectional() {
233 return isBidirectional;
234 }
235
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700236 @Override
237 public String toString() {
238 return MoreObjects.toStringHelper(this)
239 .add("id", id())
240 .add("key", key())
241 .add("appId", appId())
242 .add("priority", priority())
243 .add("resources", resources())
244 .add("src", src)
245 .add("dst", dst)
246 .add("signalType", signalType)
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700247 .add("isBidirectional", isBidirectional)
Luca Prete670ac5d2017-02-03 15:55:43 -0800248 .add("resourceGroup", resourceGroup())
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700249 .toString();
250 }
251
252}