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