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