blob: d42ce992dab0dae8ff756e0b588f7a9cfb7a0232 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.intent;
weibitf32383b2014-10-22 10:17:31 -070017
Brian O'Connor9476fa12015-06-25 15:17:17 -040018import com.google.common.annotations.Beta;
Brian O'Connorabafb502014-12-02 22:26:20 -080019import org.onosproject.core.ApplicationId;
20import org.onosproject.net.ConnectPoint;
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070021import org.onosproject.net.OchSignal;
Marc De Leenheerd24420f2015-05-27 09:40:59 -070022import org.onosproject.net.OchSignalType;
Brian O'Connorabafb502014-12-02 22:26:20 -080023import org.onosproject.net.Path;
weibitf32383b2014-10-22 10:17:31 -070024
Ray Milkeye076c792015-03-24 09:38:30 -070025import com.google.common.base.MoreObjects;
26import com.google.common.collect.ImmutableSet;
Luca Prete670ac5d2017-02-03 15:55:43 -080027import org.onosproject.net.ResourceGroup;
weibitf32383b2014-10-22 10:17:31 -070028
Ray Milkeyebc5d222015-03-18 15:45:36 -070029import static com.google.common.base.Preconditions.checkNotNull;
30
Brian O'Connor9476fa12015-06-25 15:17:17 -040031/**
32 * An optical layer intent with explicitly selected path.
33 */
34@Beta
Ray Milkeybd4f0112015-03-02 17:07:09 -080035public final class OpticalPathIntent extends Intent {
Brian O'Connor086724e2014-10-23 15:47:32 -070036
37 private final ConnectPoint src;
38 private final ConnectPoint dst;
weibitf32383b2014-10-22 10:17:31 -070039 private final Path path;
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070040 private final OchSignal lambda;
Marc De Leenheerd24420f2015-05-27 09:40:59 -070041 private final OchSignalType signalType;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070042 private final boolean isBidirectional;
weibitf32383b2014-10-22 10:17:31 -070043
Ray Milkeye076c792015-03-24 09:38:30 -070044 private OpticalPathIntent(ApplicationId appId,
45 Key key,
46 ConnectPoint src,
47 ConnectPoint dst,
48 Path path,
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070049 OchSignal lambda,
Marc De Leenheerd24420f2015-05-27 09:40:59 -070050 OchSignalType signalType,
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070051 boolean isBidirectional,
Luca Prete670ac5d2017-02-03 15:55:43 -080052 int priority,
53 ResourceGroup resourceGroup) {
54 super(appId, key, ImmutableSet.copyOf(path.links()), priority, resourceGroup);
Ray Milkeyebc5d222015-03-18 15:45:36 -070055 this.src = checkNotNull(src);
56 this.dst = checkNotNull(dst);
57 this.path = checkNotNull(path);
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070058 this.lambda = checkNotNull(lambda);
Marc De Leenheerd24420f2015-05-27 09:40:59 -070059 this.signalType = checkNotNull(signalType);
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070060 this.isBidirectional = isBidirectional;
weibitf32383b2014-10-22 10:17:31 -070061 }
62
weibit9e622ac2014-10-23 13:45:44 -070063 protected OpticalPathIntent() {
Brian O'Connor086724e2014-10-23 15:47:32 -070064 this.src = null;
65 this.dst = null;
weibitf32383b2014-10-22 10:17:31 -070066 this.path = null;
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070067 this.lambda = null;
Marc De Leenheerd24420f2015-05-27 09:40:59 -070068 this.signalType = null;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070069 this.isBidirectional = true;
weibitf32383b2014-10-22 10:17:31 -070070 }
71
Ray Milkeye076c792015-03-24 09:38:30 -070072 /**
73 * Returns a new optical connectivity intent builder.
74 *
75 * @return host to host intent builder
76 */
77 public static Builder builder() {
78 return new Builder();
79 }
80
81
82 /**
83 * Builder for optical path intents.
84 */
85 public static class Builder extends Intent.Builder {
86 private ConnectPoint src;
87 private ConnectPoint dst;
88 private Path path;
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070089 private OchSignal lambda;
Marc De Leenheerd24420f2015-05-27 09:40:59 -070090 private OchSignalType signalType;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070091 private boolean isBidirectional;
Ray Milkeye076c792015-03-24 09:38:30 -070092 Key key;
93
94 @Override
95 public Builder appId(ApplicationId appId) {
96 return (Builder) super.appId(appId);
97 }
98
99 @Override
100 public Builder key(Key key) {
101 return (Builder) super.key(key);
102 }
103
104 @Override
105 public Builder priority(int priority) {
106 return (Builder) super.priority(priority);
107 }
108
Luca Prete670ac5d2017-02-03 15:55:43 -0800109 @Override
110 public Builder resourceGroup(ResourceGroup resourceGroup) {
111 return (Builder) super.resourceGroup(resourceGroup);
112 }
113
Ray Milkeye076c792015-03-24 09:38:30 -0700114 /**
115 * Sets the source for the intent that will be built.
116 *
117 * @param src source to use for built intent
118 * @return this builder
119 */
120 public Builder src(ConnectPoint src) {
121 this.src = src;
122 return this;
123 }
124
125 /**
126 * Sets the destination for the intent that will be built.
127 *
128 * @param dst dest to use for built intent
129 * @return this builder
130 */
131 public Builder dst(ConnectPoint dst) {
132 this.dst = dst;
133 return this;
134 }
135
136 /**
137 * Sets the path for the intent that will be built.
138 *
139 * @param path path to use for built intent
140 * @return this builder
141 */
142 public Builder path(Path path) {
143 this.path = path;
144 return this;
145 }
146
147 /**
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700148 * Sets the optical channel (lambda) for the intent that will be built.
149 *
150 * @param lambda the optical channel
151 * @return this builder
152 */
153 public Builder lambda(OchSignal lambda) {
154 this.lambda = lambda;
155 return this;
156 }
157
158 /**
Marc De Leenheerd24420f2015-05-27 09:40:59 -0700159 * Sets the optical signal type for the intent that will be built.
160 *
161 * @param signalType the optical signal type
162 * @return this builder
163 */
164 public Builder signalType(OchSignalType signalType) {
165 this.signalType = signalType;
166 return this;
167 }
168
169 /**
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700170 * Sets the intent's direction.
Brian O'Connor85cf4da2015-06-05 23:44:28 -0700171 *
172 * @param isBidirectional indicates if intent is bidirectional
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700173 * @return this builder
174 */
175 public Builder bidirectional(boolean isBidirectional) {
176 this.isBidirectional = isBidirectional;
177 return this;
178 }
179
180 /**
Ray Milkeye076c792015-03-24 09:38:30 -0700181 * Builds an optical path intent from the accumulated parameters.
182 *
183 * @return optical path intent
184 */
185 public OpticalPathIntent build() {
186
187 return new OpticalPathIntent(
188 appId,
189 key,
190 src,
191 dst,
192 path,
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700193 lambda,
Marc De Leenheerd24420f2015-05-27 09:40:59 -0700194 signalType,
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700195 isBidirectional,
Luca Prete670ac5d2017-02-03 15:55:43 -0800196 priority,
197 resourceGroup
Ray Milkeye076c792015-03-24 09:38:30 -0700198 );
199 }
200 }
201
202
Brian O'Connor086724e2014-10-23 15:47:32 -0700203 public ConnectPoint src() {
204 return src;
205 }
206
207 public ConnectPoint dst() {
208 return dst;
209 }
210
weibitf32383b2014-10-22 10:17:31 -0700211 public Path path() {
212 return path;
213 }
weibitf32383b2014-10-22 10:17:31 -0700214
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700215 public OchSignal lambda() {
216 return lambda;
217 }
218
Marc De Leenheerd24420f2015-05-27 09:40:59 -0700219 public OchSignalType signalType() {
220 return signalType;
221 }
222
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700223 public boolean isBidirectional() {
224 return isBidirectional;
225 }
226
weibitf32383b2014-10-22 10:17:31 -0700227 @Override
weibitf32383b2014-10-22 10:17:31 -0700228 public String toString() {
229 return MoreObjects.toStringHelper(getClass())
230 .add("id", id())
Jonathan Hart23b5a762015-01-26 14:47:33 -0800231 .add("appId", appId())
Ray Milkeyebc5d222015-03-18 15:45:36 -0700232 .add("key", key())
Jonathan Hart23b5a762015-01-26 14:47:33 -0800233 .add("resources", resources())
Brian O'Connor086724e2014-10-23 15:47:32 -0700234 .add("ingressPort", src)
235 .add("egressPort", dst)
weibitf32383b2014-10-22 10:17:31 -0700236 .add("path", path)
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700237 .add("lambda", lambda)
Marc De Leenheerd24420f2015-05-27 09:40:59 -0700238 .add("signalType", signalType)
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700239 .add("isBidirectional", isBidirectional)
weibitf32383b2014-10-22 10:17:31 -0700240 .toString();
241 }
weibitf32383b2014-10-22 10:17:31 -0700242}