blob: 36c4dded36b6a3eb7885fe77e19571cc11e31852 [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;
23
24import java.util.Collections;
25
26import static com.google.common.base.Preconditions.checkNotNull;
27
28/**
29 * An optical layer intent between two OduClt ports - in an OTN Topology.
30 * No traffic selector or traffic treatment are needed.
31 */
32@Beta
33public final class OpticalOduIntent extends Intent {
34 private final ConnectPoint src;
35 private final ConnectPoint dst;
36 private final CltSignalType signalType;
37 private final boolean isBidirectional;
38
39 /**
40 * Creates an optical ODU intent between the specified connection points.
41 *
42 * @param appId application identification
43 * @param key intent key
44 * @param src the source transponder port
45 * @param dst the destination transponder port
46 * @param signalType CltSignalType signal type
47 * @param isBidirectional indicate if intent is bidirectional
48 * @param priority priority to use for flows from this intent
49 */
50 protected OpticalOduIntent(ApplicationId appId,
51 Key key,
52 ConnectPoint src,
53 ConnectPoint dst,
54 CltSignalType signalType,
55 boolean isBidirectional,
56 int priority) {
57 super(appId, key, Collections.emptyList(), priority);
58 this.src = checkNotNull(src);
59 this.dst = checkNotNull(dst);
60 this.signalType = checkNotNull(signalType);
61 this.isBidirectional = isBidirectional;
62 }
63
64 /**
65 * Returns a new optical ODU intent builder.
66 *
67 * @return intent builder
68 */
69 public static Builder builder() {
70 return new Builder();
71 }
72
73
74 /**
75 * Builder for optical ODU intents.
76 */
77 public static class Builder extends Intent.Builder {
78 private ConnectPoint src;
79 private ConnectPoint dst;
80 private CltSignalType signalType;
81 private boolean isBidirectional;
82
83 @Override
84 public Builder appId(ApplicationId appId) {
85 return (Builder) super.appId(appId);
86 }
87
88 @Override
89 public Builder key(Key key) {
90 return (Builder) super.key(key);
91 }
92
93 @Override
94 public Builder priority(int priority) {
95 return (Builder) super.priority(priority);
96 }
97
98 /**
99 * Sets the source for the intent that will be built.
100 *
101 * @param src source to use for built intent
102 * @return this builder
103 */
104 public Builder src(ConnectPoint src) {
105 this.src = src;
106 return this;
107 }
108
109 /**
110 * Sets the destination for the intent that will be built.
111 *
112 * @param dst dest to use for built intent
113 * @return this builder
114 */
115 public Builder dst(ConnectPoint dst) {
116 this.dst = dst;
117 return this;
118 }
119
120 /**
121 * Sets the ODU signal type for the intent that will be built.
122 *
123 * @param signalType signal type to use for built intent
124 * @return this builder
125 */
126 public Builder signalType(CltSignalType signalType) {
127 this.signalType = signalType;
128 return this;
129 }
130
131 /**
132 * Sets the directionality of the intent.
133 *
134 * @param isBidirectional true if bidirectional, false if unidirectional
135 * @return this builder
136 */
137 public Builder bidirectional(boolean isBidirectional) {
138 this.isBidirectional = isBidirectional;
139 return this;
140 }
141
142 /**
143 * Builds an optical ODU intent from the accumulated parameters.
144 *
145 * @return point to point intent
146 */
147 public OpticalOduIntent build() {
148
149 return new OpticalOduIntent(
150 appId,
151 key,
152 src,
153 dst,
154 signalType,
155 isBidirectional,
156 priority
157 );
158 }
159 }
160
161 /**
162 * Constructor for serializer.
163 */
164 protected OpticalOduIntent() {
165 super();
166 this.src = null;
167 this.dst = null;
168 this.signalType = null;
169 this.isBidirectional = false;
170 }
171
172 /**
173 * Returns the source transponder port.
174 *
175 * @return source transponder port
176 */
177 public ConnectPoint getSrc() {
178 return src;
179 }
180
181 /**
182 * Returns the destination transponder port.
183 *
184 * @return source transponder port
185 */
186 public ConnectPoint getDst() {
187 return dst;
188 }
189
190 /**
191 * Returns the CltSignalType signal type.
192 *
193 * @return CltSignalType signal type
194 */
195 public CltSignalType getSignalType() {
196 return signalType;
197 }
198
199 /**
200 * Returns the directionality of the intent.
201 *
202 * @return true if bidirectional, false if unidirectional
203 */
204 public boolean isBidirectional() {
205 return isBidirectional;
206 }
207
208 @Override
209 public String toString() {
210 return MoreObjects.toStringHelper(this)
211 .add("id", id())
212 .add("key", key())
213 .add("appId", appId())
214 .add("priority", priority())
215 .add("resources", resources())
216 .add("src", src)
217 .add("dst", dst)
218 .add("signalType", signalType)
219 .add("isBidirectional", isBidirectional)
220 .toString();
221 }
222
223}