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