blob: 2a29a31751efe5b4a71725868f4d37b4199d4785 [file] [log] [blame]
Marc De Leenheer8c2caac2015-05-28 16:37:33 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
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 * @param resourceGroup resource group for this intent
52 */
53 protected OpticalCircuitIntent(ApplicationId appId, Key key, ConnectPoint src, ConnectPoint dst,
54 CltSignalType signalType, boolean isBidirectional, int priority,
55 ResourceGroup resourceGroup) {
56 super(appId, key, Collections.emptyList(), priority, resourceGroup);
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070057 this.src = checkNotNull(src);
58 this.dst = checkNotNull(dst);
59 this.signalType = checkNotNull(signalType);
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070060 this.isBidirectional = isBidirectional;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070061 }
62
63 /**
64 * Returns a new optical circuit intent builder.
65 *
66 * @return host to host intent builder
67 */
68 public static Builder builder() {
69 return new Builder();
70 }
71
72
73 /**
74 * Builder for optical circuit intents.
75 */
76 public static class Builder extends Intent.Builder {
77 private ConnectPoint src;
78 private ConnectPoint dst;
Toru Furusawa72ee30c2016-01-08 13:29:04 -080079 private CltSignalType signalType;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070080 private boolean isBidirectional;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070081
82 @Override
83 public Builder appId(ApplicationId appId) {
84 return (Builder) super.appId(appId);
85 }
86
87 @Override
88 public Builder key(Key key) {
89 return (Builder) super.key(key);
90 }
91
92 @Override
93 public Builder priority(int priority) {
94 return (Builder) super.priority(priority);
95 }
96
Luca Prete670ac5d2017-02-03 15:55:43 -080097 @Override
98 public Builder resourceGroup(ResourceGroup resourceGroup) {
99 return (Builder) super.resourceGroup(resourceGroup);
100 }
101
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700102 /**
103 * Sets the source for the intent that will be built.
104 *
105 * @param src source to use for built intent
106 * @return this builder
107 */
108 public Builder src(ConnectPoint src) {
109 this.src = src;
110 return this;
111 }
112
113 /**
114 * Sets the destination for the intent that will be built.
115 *
116 * @param dst dest to use for built intent
117 * @return this builder
118 */
119 public Builder dst(ConnectPoint dst) {
120 this.dst = dst;
121 return this;
122 }
123
124 /**
125 * Sets the ODU signal type for the intent that will be built.
126 *
127 * @param signalType signal type to use for built intent
128 * @return this builder
129 */
Toru Furusawa72ee30c2016-01-08 13:29:04 -0800130 public Builder signalType(CltSignalType signalType) {
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700131 this.signalType = signalType;
132 return this;
133 }
134
135 /**
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700136 * Sets the directionality of the intent.
137 *
138 * @param isBidirectional true if bidirectional, false if unidirectional
139 * @return this builder
140 */
141 public Builder bidirectional(boolean isBidirectional) {
142 this.isBidirectional = isBidirectional;
143 return this;
144 }
145
146 /**
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700147 * Builds an optical circuit intent from the accumulated parameters.
148 *
149 * @return point to point intent
150 */
151 public OpticalCircuitIntent build() {
152
153 return new OpticalCircuitIntent(
154 appId,
155 key,
156 src,
157 dst,
158 signalType,
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700159 isBidirectional,
Luca Prete670ac5d2017-02-03 15:55:43 -0800160 priority,
161 resourceGroup
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700162 );
163 }
164 }
165
166 /**
167 * Constructor for serializer.
168 */
169 protected OpticalCircuitIntent() {
170 super();
171 this.src = null;
172 this.dst = null;
173 this.signalType = null;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700174 this.isBidirectional = false;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700175 }
176
177 /**
178 * Returns the source transponder port.
179 *
180 * @return source transponder port
181 */
182 public ConnectPoint getSrc() {
183 return src;
184 }
185
186 /**
187 * Returns the destination transponder port.
188 *
189 * @return source transponder port
190 */
191 public ConnectPoint getDst() {
192 return dst;
193 }
194
195 /**
196 * Returns the ODU signal type.
197 *
198 * @return ODU signal type
199 */
Toru Furusawa72ee30c2016-01-08 13:29:04 -0800200 public CltSignalType getSignalType() {
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700201 return signalType;
202 }
203
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700204 /**
205 * Returns the directionality of the intent.
206 *
207 * @return true if bidirectional, false if unidirectional
208 */
209 public boolean isBidirectional() {
210 return isBidirectional;
211 }
212
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700213 @Override
214 public String toString() {
215 return MoreObjects.toStringHelper(this)
216 .add("id", id())
217 .add("key", key())
218 .add("appId", appId())
219 .add("priority", priority())
220 .add("resources", resources())
221 .add("src", src)
222 .add("dst", dst)
223 .add("signalType", signalType)
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700224 .add("isBidirectional", isBidirectional)
Luca Prete670ac5d2017-02-03 15:55:43 -0800225 .add("resourceGroup", resourceGroup())
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700226 .toString();
227 }
228
229}