blob: 1e515c8c1cbd27eaad328d583be4c3cd878be45f [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
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;
21import org.onosproject.net.ConnectPoint;
22import org.onosproject.net.OduCltPort;
23
24import java.util.Collections;
25
26import static com.google.common.base.Preconditions.checkNotNull;
27
28/**
29 * An optical layer intent for circuits between two OduClt ports.
30 * No traffic selector or traffic treatment are needed.
31 */
Brian O'Connor9476fa12015-06-25 15:17:17 -040032@Beta
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070033public class OpticalCircuitIntent extends Intent {
34 private final ConnectPoint src;
35 private final ConnectPoint dst;
36 private final OduCltPort.SignalType signalType;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070037 private final boolean isBidirectional;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070038
39 /**
40 * Creates an optical circuit intent between the specified
41 * 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 ODU signal type
Brian O'Connor85cf4da2015-06-05 23:44:28 -070048 * @param isBidirectional indicate if intent is bidirectional
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070049 * @param priority priority to use for flows from this intent
50 */
51 protected OpticalCircuitIntent(ApplicationId appId, Key key, ConnectPoint src, ConnectPoint dst,
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070052 OduCltPort.SignalType signalType, boolean isBidirectional, int priority) {
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070053 super(appId, key, Collections.emptyList(), priority);
54 this.src = checkNotNull(src);
55 this.dst = checkNotNull(dst);
56 this.signalType = checkNotNull(signalType);
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070057 this.isBidirectional = isBidirectional;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070058 }
59
60 /**
61 * Returns a new optical circuit intent builder.
62 *
63 * @return host to host intent builder
64 */
65 public static Builder builder() {
66 return new Builder();
67 }
68
69
70 /**
71 * Builder for optical circuit intents.
72 */
73 public static class Builder extends Intent.Builder {
74 private ConnectPoint src;
75 private ConnectPoint dst;
76 private OduCltPort.SignalType signalType;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070077 private boolean isBidirectional;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070078
79 @Override
80 public Builder appId(ApplicationId appId) {
81 return (Builder) super.appId(appId);
82 }
83
84 @Override
85 public Builder key(Key key) {
86 return (Builder) super.key(key);
87 }
88
89 @Override
90 public Builder priority(int priority) {
91 return (Builder) super.priority(priority);
92 }
93
94 /**
95 * Sets the source for the intent that will be built.
96 *
97 * @param src source to use for built intent
98 * @return this builder
99 */
100 public Builder src(ConnectPoint src) {
101 this.src = src;
102 return this;
103 }
104
105 /**
106 * Sets the destination for the intent that will be built.
107 *
108 * @param dst dest to use for built intent
109 * @return this builder
110 */
111 public Builder dst(ConnectPoint dst) {
112 this.dst = dst;
113 return this;
114 }
115
116 /**
117 * Sets the ODU signal type for the intent that will be built.
118 *
119 * @param signalType signal type to use for built intent
120 * @return this builder
121 */
122 public Builder signalType(OduCltPort.SignalType signalType) {
123 this.signalType = signalType;
124 return this;
125 }
126
127 /**
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700128 * Sets the directionality of the intent.
129 *
130 * @param isBidirectional true if bidirectional, false if unidirectional
131 * @return this builder
132 */
133 public Builder bidirectional(boolean isBidirectional) {
134 this.isBidirectional = isBidirectional;
135 return this;
136 }
137
138 /**
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700139 * Builds an optical circuit intent from the accumulated parameters.
140 *
141 * @return point to point intent
142 */
143 public OpticalCircuitIntent build() {
144
145 return new OpticalCircuitIntent(
146 appId,
147 key,
148 src,
149 dst,
150 signalType,
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700151 isBidirectional,
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700152 priority
153 );
154 }
155 }
156
157 /**
158 * Constructor for serializer.
159 */
160 protected OpticalCircuitIntent() {
161 super();
162 this.src = null;
163 this.dst = null;
164 this.signalType = null;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700165 this.isBidirectional = false;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700166 }
167
168 /**
169 * Returns the source transponder port.
170 *
171 * @return source transponder port
172 */
173 public ConnectPoint getSrc() {
174 return src;
175 }
176
177 /**
178 * Returns the destination transponder port.
179 *
180 * @return source transponder port
181 */
182 public ConnectPoint getDst() {
183 return dst;
184 }
185
186 /**
187 * Returns the ODU signal type.
188 *
189 * @return ODU signal type
190 */
191 public OduCltPort.SignalType getSignalType() {
192 return signalType;
193 }
194
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700195 /**
196 * Returns the directionality of the intent.
197 *
198 * @return true if bidirectional, false if unidirectional
199 */
200 public boolean isBidirectional() {
201 return isBidirectional;
202 }
203
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700204 @Override
205 public String toString() {
206 return MoreObjects.toStringHelper(this)
207 .add("id", id())
208 .add("key", key())
209 .add("appId", appId())
210 .add("priority", priority())
211 .add("resources", resources())
212 .add("src", src)
213 .add("dst", dst)
214 .add("signalType", signalType)
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700215 .add("isBidirectional", isBidirectional)
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700216 .toString();
217 }
218
219}