blob: ec885423c4fbca094a0d165e8e8847e71bf77cab [file] [log] [blame]
Rimon Ashkenazy27438ff2016-03-22 15:57:45 +02001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Rimon Ashkenazy27438ff2016-03-22 15:57:45 +02003 *
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
18import com.google.common.annotations.Beta;
19import com.google.common.base.MoreObjects;
20import org.onosproject.core.ApplicationId;
21import org.onosproject.net.CltSignalType;
22import org.onosproject.net.ConnectPoint;
Luca Prete670ac5d2017-02-03 15:55:43 -080023import org.onosproject.net.ResourceGroup;
Rimon Ashkenazy27438ff2016-03-22 15:57:45 +020024
25import java.util.Collections;
26
27import static com.google.common.base.Preconditions.checkNotNull;
28
29/**
30 * An optical layer intent between two OduClt ports - in an OTN Topology.
31 * No traffic selector or traffic treatment are needed.
32 */
33@Beta
34public final class OpticalOduIntent extends Intent {
35 private final ConnectPoint src;
36 private final ConnectPoint dst;
37 private final CltSignalType signalType;
38 private final boolean isBidirectional;
39
40 /**
41 * Creates an optical ODU intent between the specified connection points.
42 *
43 * @param appId application identification
44 * @param key intent key
45 * @param src the source transponder port
46 * @param dst the destination transponder port
47 * @param signalType CltSignalType signal type
48 * @param isBidirectional indicate if intent is bidirectional
49 * @param priority priority to use for flows from this intent
Luca Prete670ac5d2017-02-03 15:55:43 -080050 * @deprecated 1.9.1
51 */
52 @Deprecated
53 protected OpticalOduIntent(ApplicationId appId,
54 Key key,
55 ConnectPoint src,
56 ConnectPoint dst,
57 CltSignalType signalType,
58 boolean isBidirectional,
59 int priority) {
60 super(appId, key, Collections.emptyList(), priority, null);
61 this.src = checkNotNull(src);
62 this.dst = checkNotNull(dst);
63 this.signalType = checkNotNull(signalType);
64 this.isBidirectional = isBidirectional;
65 }
66
67 /**
68 * Creates an optical ODU intent between the specified connection points.
69 *
70 * @param appId application identification
71 * @param key intent key
72 * @param src the source transponder port
73 * @param dst the destination transponder port
74 * @param signalType CltSignalType signal type
75 * @param isBidirectional indicate if intent is bidirectional
76 * @param priority priority to use for flows from this intent
77 * @param resourceGroup resource group for this intent
Rimon Ashkenazy27438ff2016-03-22 15:57:45 +020078 */
79 protected OpticalOduIntent(ApplicationId appId,
Luca Prete670ac5d2017-02-03 15:55:43 -080080 Key key,
81 ConnectPoint src,
82 ConnectPoint dst,
83 CltSignalType signalType,
84 boolean isBidirectional,
85 int priority,
86 ResourceGroup resourceGroup) {
87 super(appId, key, Collections.emptyList(), priority, resourceGroup);
Rimon Ashkenazy27438ff2016-03-22 15:57:45 +020088 this.src = checkNotNull(src);
89 this.dst = checkNotNull(dst);
90 this.signalType = checkNotNull(signalType);
91 this.isBidirectional = isBidirectional;
92 }
93
94 /**
95 * Returns a new optical ODU intent builder.
96 *
97 * @return intent builder
98 */
99 public static Builder builder() {
100 return new Builder();
101 }
102
103
104 /**
105 * Builder for optical ODU intents.
106 */
107 public static class Builder extends Intent.Builder {
108 private ConnectPoint src;
109 private ConnectPoint dst;
110 private CltSignalType signalType;
111 private boolean isBidirectional;
112
113 @Override
114 public Builder appId(ApplicationId appId) {
115 return (Builder) super.appId(appId);
116 }
117
118 @Override
119 public Builder key(Key key) {
120 return (Builder) super.key(key);
121 }
122
123 @Override
124 public Builder priority(int priority) {
125 return (Builder) super.priority(priority);
126 }
127
Luca Prete670ac5d2017-02-03 15:55:43 -0800128 @Override
129 public Builder resourceGroup(ResourceGroup resourceGroup) {
130 return (Builder) super.resourceGroup(resourceGroup);
131 }
132
Rimon Ashkenazy27438ff2016-03-22 15:57:45 +0200133 /**
134 * Sets the source for the intent that will be built.
135 *
136 * @param src source to use for built intent
137 * @return this builder
138 */
139 public Builder src(ConnectPoint src) {
140 this.src = src;
141 return this;
142 }
143
144 /**
145 * Sets the destination for the intent that will be built.
146 *
147 * @param dst dest to use for built intent
148 * @return this builder
149 */
150 public Builder dst(ConnectPoint dst) {
151 this.dst = dst;
152 return this;
153 }
154
155 /**
156 * Sets the ODU signal type for the intent that will be built.
157 *
158 * @param signalType signal type to use for built intent
159 * @return this builder
160 */
161 public Builder signalType(CltSignalType signalType) {
162 this.signalType = signalType;
163 return this;
164 }
165
166 /**
167 * Sets the directionality of the intent.
168 *
169 * @param isBidirectional true if bidirectional, false if unidirectional
170 * @return this builder
171 */
172 public Builder bidirectional(boolean isBidirectional) {
173 this.isBidirectional = isBidirectional;
174 return this;
175 }
176
177 /**
178 * Builds an optical ODU intent from the accumulated parameters.
179 *
180 * @return point to point intent
181 */
182 public OpticalOduIntent build() {
183
184 return new OpticalOduIntent(
185 appId,
186 key,
187 src,
188 dst,
189 signalType,
190 isBidirectional,
Luca Prete670ac5d2017-02-03 15:55:43 -0800191 priority,
192 resourceGroup
Rimon Ashkenazy27438ff2016-03-22 15:57:45 +0200193 );
194 }
195 }
196
197 /**
198 * Constructor for serializer.
199 */
200 protected OpticalOduIntent() {
201 super();
202 this.src = null;
203 this.dst = null;
204 this.signalType = null;
205 this.isBidirectional = false;
206 }
207
208 /**
209 * Returns the source transponder port.
210 *
211 * @return source transponder port
212 */
213 public ConnectPoint getSrc() {
214 return src;
215 }
216
217 /**
218 * Returns the destination transponder port.
219 *
220 * @return source transponder port
221 */
222 public ConnectPoint getDst() {
223 return dst;
224 }
225
226 /**
227 * Returns the CltSignalType signal type.
228 *
229 * @return CltSignalType signal type
230 */
231 public CltSignalType getSignalType() {
232 return signalType;
233 }
234
235 /**
236 * Returns the directionality of the intent.
237 *
238 * @return true if bidirectional, false if unidirectional
239 */
240 public boolean isBidirectional() {
241 return isBidirectional;
242 }
243
244 @Override
245 public String toString() {
246 return MoreObjects.toStringHelper(this)
247 .add("id", id())
248 .add("key", key())
249 .add("appId", appId())
250 .add("priority", priority())
251 .add("resources", resources())
252 .add("src", src)
253 .add("dst", dst)
254 .add("signalType", signalType)
255 .add("isBidirectional", isBidirectional)
Luca Prete670ac5d2017-02-03 15:55:43 -0800256 .add("resourceGroup", resourceGroup())
Rimon Ashkenazy27438ff2016-03-22 15:57:45 +0200257 .toString();
258 }
259
260}