blob: 503c4cabb24a12e23028b650baa992cab408022e [file] [log] [blame]
Marc De Leenheer8c2caac2015-05-28 16:37:33 -07001/*
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 */
16package org.onosproject.net.intent;
17
18import com.google.common.base.MoreObjects;
19import org.onosproject.core.ApplicationId;
20import org.onosproject.net.ConnectPoint;
21import org.onosproject.net.OduCltPort;
22
23import java.util.Collections;
24
25import static com.google.common.base.Preconditions.checkNotNull;
26
27/**
28 * An optical layer intent for circuits between two OduClt ports.
29 * No traffic selector or traffic treatment are needed.
30 */
31public class OpticalCircuitIntent extends Intent {
32 private final ConnectPoint src;
33 private final ConnectPoint dst;
34 private final OduCltPort.SignalType signalType;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070035 private final boolean isBidirectional;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070036
37 /**
38 * Creates an optical circuit intent between the specified
39 * connection points.
40 *
41 * @param appId application identification
42 * @param key intent key
43 * @param src the source transponder port
44 * @param dst the destination transponder port
45 * @param signalType ODU signal type
Brian O'Connor85cf4da2015-06-05 23:44:28 -070046 * @param isBidirectional indicate if intent is bidirectional
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070047 * @param priority priority to use for flows from this intent
48 */
49 protected OpticalCircuitIntent(ApplicationId appId, Key key, ConnectPoint src, ConnectPoint dst,
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070050 OduCltPort.SignalType signalType, boolean isBidirectional, int priority) {
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070051 super(appId, key, Collections.emptyList(), priority);
52 this.src = checkNotNull(src);
53 this.dst = checkNotNull(dst);
54 this.signalType = checkNotNull(signalType);
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070055 this.isBidirectional = isBidirectional;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070056 }
57
58 /**
59 * Returns a new optical circuit intent builder.
60 *
61 * @return host to host intent builder
62 */
63 public static Builder builder() {
64 return new Builder();
65 }
66
67
68 /**
69 * Builder for optical circuit intents.
70 */
71 public static class Builder extends Intent.Builder {
72 private ConnectPoint src;
73 private ConnectPoint dst;
74 private OduCltPort.SignalType signalType;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070075 private boolean isBidirectional;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070076
77 @Override
78 public Builder appId(ApplicationId appId) {
79 return (Builder) super.appId(appId);
80 }
81
82 @Override
83 public Builder key(Key key) {
84 return (Builder) super.key(key);
85 }
86
87 @Override
88 public Builder priority(int priority) {
89 return (Builder) super.priority(priority);
90 }
91
92 /**
93 * Sets the source for the intent that will be built.
94 *
95 * @param src source to use for built intent
96 * @return this builder
97 */
98 public Builder src(ConnectPoint src) {
99 this.src = src;
100 return this;
101 }
102
103 /**
104 * Sets the destination for the intent that will be built.
105 *
106 * @param dst dest to use for built intent
107 * @return this builder
108 */
109 public Builder dst(ConnectPoint dst) {
110 this.dst = dst;
111 return this;
112 }
113
114 /**
115 * Sets the ODU signal type for the intent that will be built.
116 *
117 * @param signalType signal type to use for built intent
118 * @return this builder
119 */
120 public Builder signalType(OduCltPort.SignalType signalType) {
121 this.signalType = signalType;
122 return this;
123 }
124
125 /**
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700126 * Sets the directionality of the intent.
127 *
128 * @param isBidirectional true if bidirectional, false if unidirectional
129 * @return this builder
130 */
131 public Builder bidirectional(boolean isBidirectional) {
132 this.isBidirectional = isBidirectional;
133 return this;
134 }
135
136 /**
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700137 * Builds an optical circuit intent from the accumulated parameters.
138 *
139 * @return point to point intent
140 */
141 public OpticalCircuitIntent build() {
142
143 return new OpticalCircuitIntent(
144 appId,
145 key,
146 src,
147 dst,
148 signalType,
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700149 isBidirectional,
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700150 priority
151 );
152 }
153 }
154
155 /**
156 * Constructor for serializer.
157 */
158 protected OpticalCircuitIntent() {
159 super();
160 this.src = null;
161 this.dst = null;
162 this.signalType = null;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700163 this.isBidirectional = false;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700164 }
165
166 /**
167 * Returns the source transponder port.
168 *
169 * @return source transponder port
170 */
171 public ConnectPoint getSrc() {
172 return src;
173 }
174
175 /**
176 * Returns the destination transponder port.
177 *
178 * @return source transponder port
179 */
180 public ConnectPoint getDst() {
181 return dst;
182 }
183
184 /**
185 * Returns the ODU signal type.
186 *
187 * @return ODU signal type
188 */
189 public OduCltPort.SignalType getSignalType() {
190 return signalType;
191 }
192
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700193 /**
194 * Returns the directionality of the intent.
195 *
196 * @return true if bidirectional, false if unidirectional
197 */
198 public boolean isBidirectional() {
199 return isBidirectional;
200 }
201
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700202 @Override
203 public String toString() {
204 return MoreObjects.toStringHelper(this)
205 .add("id", id())
206 .add("key", key())
207 .add("appId", appId())
208 .add("priority", priority())
209 .add("resources", resources())
210 .add("src", src)
211 .add("dst", dst)
212 .add("signalType", signalType)
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700213 .add("isBidirectional", isBidirectional)
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700214 .toString();
215 }
216
217}