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