Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.intent; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 17 | |
Brian O'Connor | 9476fa1 | 2015-06-25 15:17:17 -0400 | [diff] [blame] | 18 | import com.google.common.annotations.Beta; |
Sho SHIMIZU | f1fa96c | 2015-04-22 15:21:53 +0900 | [diff] [blame] | 19 | import com.google.common.base.MoreObjects; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 20 | import org.onosproject.core.ApplicationId; |
| 21 | import org.onosproject.net.ConnectPoint; |
Marc De Leenheer | adfeffd | 2017-06-22 16:05:34 -0700 | [diff] [blame] | 22 | import org.onosproject.net.OchSignal; |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 23 | import org.onosproject.net.OduSignalType; |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 24 | import org.onosproject.net.ResourceGroup; |
alessio | 3039bdb | 2018-11-29 14:12:32 +0100 | [diff] [blame] | 25 | import org.onosproject.net.Path; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 26 | |
Sho SHIMIZU | f1fa96c | 2015-04-22 15:21:53 +0900 | [diff] [blame] | 27 | import java.util.Collections; |
Marc De Leenheer | adfeffd | 2017-06-22 16:05:34 -0700 | [diff] [blame] | 28 | import java.util.Optional; |
Sho SHIMIZU | f1fa96c | 2015-04-22 15:21:53 +0900 | [diff] [blame] | 29 | |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 30 | import static com.google.common.base.Preconditions.checkNotNull; |
Sho SHIMIZU | d7d1800 | 2015-01-21 14:37:14 -0800 | [diff] [blame] | 31 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 32 | /** |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 33 | * An optical layer intent for connectivity between two OCh ports. |
| 34 | * No traffic selector or traffic treatment are needed. |
alessio | 3039bdb | 2018-11-29 14:12:32 +0100 | [diff] [blame] | 35 | * OchSignal and suggestedPath are optional. |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 36 | */ |
Brian O'Connor | 9476fa1 | 2015-06-25 15:17:17 -0400 | [diff] [blame] | 37 | @Beta |
Ray Milkey | bd4f011 | 2015-03-02 17:07:09 -0800 | [diff] [blame] | 38 | public final class OpticalConnectivityIntent extends Intent { |
| 39 | private final ConnectPoint src; |
| 40 | private final ConnectPoint dst; |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 41 | private final OduSignalType signalType; |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 42 | private final boolean isBidirectional; |
alessio | 3039bdb | 2018-11-29 14:12:32 +0100 | [diff] [blame] | 43 | |
Marc De Leenheer | adfeffd | 2017-06-22 16:05:34 -0700 | [diff] [blame] | 44 | private final Optional<OchSignal> ochSignal; |
alessio | 3039bdb | 2018-11-29 14:12:32 +0100 | [diff] [blame] | 45 | private final Optional<Path> suggestedPath; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 46 | |
| 47 | /** |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 48 | * Creates an optical connectivity intent between the specified |
| 49 | * connection points. |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 50 | * |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 51 | * @param appId application identification |
Ray Milkey | 5b3717e | 2015-02-05 11:44:08 -0800 | [diff] [blame] | 52 | * @param key intent key |
| 53 | * @param src the source transponder port |
| 54 | * @param dst the destination transponder port |
Brian O'Connor | 85cf4da | 2015-06-05 23:44:28 -0700 | [diff] [blame] | 55 | * @param signalType signal type |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 56 | * @param isBidirectional indicates if intent is unidirectional |
Marc De Leenheer | adfeffd | 2017-06-22 16:05:34 -0700 | [diff] [blame] | 57 | * @param ochSignal optional OCh signal |
alessio | 3039bdb | 2018-11-29 14:12:32 +0100 | [diff] [blame] | 58 | * @param suggestedPath optional suggested path |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 59 | * @param priority priority to use for flows from this intent |
| 60 | * @param resourceGroup resource group of this intent |
| 61 | */ |
| 62 | protected OpticalConnectivityIntent(ApplicationId appId, |
| 63 | Key key, |
| 64 | ConnectPoint src, |
| 65 | ConnectPoint dst, |
| 66 | OduSignalType signalType, |
| 67 | boolean isBidirectional, |
Marc De Leenheer | adfeffd | 2017-06-22 16:05:34 -0700 | [diff] [blame] | 68 | Optional<OchSignal> ochSignal, |
alessio | 3039bdb | 2018-11-29 14:12:32 +0100 | [diff] [blame] | 69 | Optional<Path> suggestedPath, |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 70 | int priority, |
| 71 | ResourceGroup resourceGroup) { |
| 72 | super(appId, key, Collections.emptyList(), priority, resourceGroup); |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 73 | this.src = checkNotNull(src); |
| 74 | this.dst = checkNotNull(dst); |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 75 | this.signalType = checkNotNull(signalType); |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 76 | this.isBidirectional = isBidirectional; |
Marc De Leenheer | adfeffd | 2017-06-22 16:05:34 -0700 | [diff] [blame] | 77 | this.ochSignal = ochSignal; |
alessio | 3039bdb | 2018-11-29 14:12:32 +0100 | [diff] [blame] | 78 | this.suggestedPath = suggestedPath; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 79 | } |
| 80 | |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 81 | /** |
| 82 | * Returns a new optical connectivity intent builder. |
| 83 | * |
| 84 | * @return host to host intent builder |
| 85 | */ |
| 86 | public static Builder builder() { |
| 87 | return new Builder(); |
| 88 | } |
| 89 | |
| 90 | |
| 91 | /** |
| 92 | * Builder for optical connectivity intents. |
| 93 | */ |
| 94 | public static class Builder extends Intent.Builder { |
| 95 | private ConnectPoint src; |
| 96 | private ConnectPoint dst; |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 97 | private OduSignalType signalType; |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 98 | private boolean isBidirectional; |
Marc De Leenheer | adfeffd | 2017-06-22 16:05:34 -0700 | [diff] [blame] | 99 | private Optional<OchSignal> ochSignal = Optional.empty(); |
alessio | 3039bdb | 2018-11-29 14:12:32 +0100 | [diff] [blame] | 100 | private Optional<Path> suggestedPath = Optional.empty(); |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 101 | |
| 102 | @Override |
| 103 | public Builder appId(ApplicationId appId) { |
| 104 | return (Builder) super.appId(appId); |
| 105 | } |
| 106 | |
| 107 | @Override |
| 108 | public Builder key(Key key) { |
| 109 | return (Builder) super.key(key); |
| 110 | } |
| 111 | |
| 112 | @Override |
| 113 | public Builder priority(int priority) { |
| 114 | return (Builder) super.priority(priority); |
| 115 | } |
| 116 | |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 117 | @Override |
| 118 | public Builder resourceGroup(ResourceGroup resourceGroup) { |
| 119 | return (Builder) super.resourceGroup(resourceGroup); |
| 120 | } |
| 121 | |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 122 | /** |
| 123 | * Sets the source for the intent that will be built. |
| 124 | * |
| 125 | * @param src source to use for built intent |
| 126 | * @return this builder |
| 127 | */ |
| 128 | public Builder src(ConnectPoint src) { |
| 129 | this.src = src; |
| 130 | return this; |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * Sets the destination for the intent that will be built. |
| 135 | * |
| 136 | * @param dst dest to use for built intent |
| 137 | * @return this builder |
| 138 | */ |
| 139 | public Builder dst(ConnectPoint dst) { |
| 140 | this.dst = dst; |
| 141 | return this; |
| 142 | } |
| 143 | |
| 144 | /** |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 145 | * Sets the ODU signal type for the intent that will be built. |
| 146 | * |
| 147 | * @param signalType ODU signal type |
| 148 | * @return this builder |
| 149 | */ |
| 150 | public Builder signalType(OduSignalType signalType) { |
| 151 | this.signalType = signalType; |
| 152 | return this; |
| 153 | } |
| 154 | |
| 155 | /** |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 156 | * Sets the directionality of the intent. |
| 157 | * |
| 158 | * @param isBidirectional true if bidirectional, false if unidirectional |
| 159 | * @return this builder |
| 160 | */ |
| 161 | public Builder bidirectional(boolean isBidirectional) { |
| 162 | this.isBidirectional = isBidirectional; |
| 163 | return this; |
| 164 | } |
| 165 | |
| 166 | /** |
Marc De Leenheer | adfeffd | 2017-06-22 16:05:34 -0700 | [diff] [blame] | 167 | * Sets the OCh signal of the intent. |
| 168 | * |
| 169 | * @param ochSignal the lambda |
| 170 | * @return this builder |
| 171 | */ |
alessio | da025c4 | 2020-07-17 13:00:28 +0200 | [diff] [blame] | 172 | public Builder ochSignal(Optional<OchSignal> ochSignal) { |
| 173 | this.ochSignal = ochSignal; |
Marc De Leenheer | adfeffd | 2017-06-22 16:05:34 -0700 | [diff] [blame] | 174 | return this; |
| 175 | } |
| 176 | |
| 177 | /** |
alessio | 3039bdb | 2018-11-29 14:12:32 +0100 | [diff] [blame] | 178 | * Sets the suggestedPath of the intent. |
| 179 | * |
| 180 | * @param suggestedPath the path |
| 181 | * @return this builder |
| 182 | */ |
alessio | da025c4 | 2020-07-17 13:00:28 +0200 | [diff] [blame] | 183 | public Builder suggestedPath(Optional<Path> suggestedPath) { |
| 184 | this.suggestedPath = suggestedPath; |
alessio | 3039bdb | 2018-11-29 14:12:32 +0100 | [diff] [blame] | 185 | return this; |
| 186 | } |
| 187 | |
| 188 | /** |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 189 | * Builds an optical connectivity intent from the accumulated parameters. |
| 190 | * |
| 191 | * @return point to point intent |
| 192 | */ |
| 193 | public OpticalConnectivityIntent build() { |
| 194 | |
| 195 | return new OpticalConnectivityIntent( |
| 196 | appId, |
| 197 | key, |
| 198 | src, |
| 199 | dst, |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 200 | signalType, |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 201 | isBidirectional, |
Marc De Leenheer | adfeffd | 2017-06-22 16:05:34 -0700 | [diff] [blame] | 202 | ochSignal, |
alessio | 3039bdb | 2018-11-29 14:12:32 +0100 | [diff] [blame] | 203 | suggestedPath, |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 204 | priority, |
| 205 | resourceGroup |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 206 | ); |
| 207 | } |
| 208 | } |
Ray Milkey | 5b3717e | 2015-02-05 11:44:08 -0800 | [diff] [blame] | 209 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 210 | /** |
| 211 | * Constructor for serializer. |
| 212 | */ |
| 213 | protected OpticalConnectivityIntent() { |
| 214 | super(); |
| 215 | this.src = null; |
| 216 | this.dst = null; |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 217 | this.signalType = null; |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 218 | this.isBidirectional = false; |
Marc De Leenheer | adfeffd | 2017-06-22 16:05:34 -0700 | [diff] [blame] | 219 | this.ochSignal = null; |
alessio | 3039bdb | 2018-11-29 14:12:32 +0100 | [diff] [blame] | 220 | this.suggestedPath = null; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | /** |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 224 | * Returns the source transponder port. |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 225 | * |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 226 | * @return source transponder port |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 227 | */ |
Jonathan Hart | c9d7673 | 2014-11-18 10:52:20 -0800 | [diff] [blame] | 228 | public ConnectPoint getSrc() { |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 229 | return src; |
| 230 | } |
| 231 | |
| 232 | /** |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 233 | * Returns the destination transponder port. |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 234 | * |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 235 | * @return source transponder port |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 236 | */ |
| 237 | public ConnectPoint getDst() { |
| 238 | return dst; |
| 239 | } |
Sho SHIMIZU | f1fa96c | 2015-04-22 15:21:53 +0900 | [diff] [blame] | 240 | |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 241 | /** |
| 242 | * Returns the ODU signal type. |
| 243 | * |
| 244 | * @return ODU signal type |
| 245 | */ |
| 246 | public OduSignalType getSignalType() { |
| 247 | return signalType; |
| 248 | } |
| 249 | |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 250 | /** |
| 251 | * Returns the directionality of the intent. |
| 252 | * |
| 253 | * @return true if bidirectional, false if unidirectional |
| 254 | */ |
| 255 | public boolean isBidirectional() { |
| 256 | return isBidirectional; |
| 257 | } |
| 258 | |
Marc De Leenheer | adfeffd | 2017-06-22 16:05:34 -0700 | [diff] [blame] | 259 | /** |
| 260 | * Returns the OCh signal of the intent. |
| 261 | * |
| 262 | * @return the lambda |
| 263 | */ |
alessio | 3039bdb | 2018-11-29 14:12:32 +0100 | [diff] [blame] | 264 | |
Marc De Leenheer | adfeffd | 2017-06-22 16:05:34 -0700 | [diff] [blame] | 265 | public Optional<OchSignal> ochSignal() { |
| 266 | return ochSignal; |
| 267 | } |
| 268 | |
alessio | 3039bdb | 2018-11-29 14:12:32 +0100 | [diff] [blame] | 269 | /** |
| 270 | * Returns the suggestedPath of the intent. |
| 271 | * |
| 272 | * @return the suggestedPath |
| 273 | */ |
| 274 | public Optional<Path> suggestedPath() { |
| 275 | return suggestedPath; |
| 276 | } |
| 277 | |
Sho SHIMIZU | f1fa96c | 2015-04-22 15:21:53 +0900 | [diff] [blame] | 278 | @Override |
| 279 | public String toString() { |
| 280 | return MoreObjects.toStringHelper(this) |
| 281 | .add("id", id()) |
| 282 | .add("key", key()) |
| 283 | .add("appId", appId()) |
| 284 | .add("priority", priority()) |
| 285 | .add("resources", resources()) |
| 286 | .add("src", src) |
| 287 | .add("dst", dst) |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 288 | .add("signalType", signalType) |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 289 | .add("isBidirectional", isBidirectional) |
Marc De Leenheer | adfeffd | 2017-06-22 16:05:34 -0700 | [diff] [blame] | 290 | .add("ochSignal", ochSignal) |
alessio | 3039bdb | 2018-11-29 14:12:32 +0100 | [diff] [blame] | 291 | .add("suggestedPath", suggestedPath) |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 292 | .add("resourceGroup", resourceGroup()) |
Sho SHIMIZU | f1fa96c | 2015-04-22 15:21:53 +0900 | [diff] [blame] | 293 | .toString(); |
| 294 | } |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 295 | } |