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; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 19 | import org.onosproject.core.ApplicationId; |
| 20 | import org.onosproject.net.ConnectPoint; |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 21 | import org.onosproject.net.OchSignal; |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 22 | import org.onosproject.net.OchSignalType; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 23 | import org.onosproject.net.Path; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 24 | |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 25 | import com.google.common.base.MoreObjects; |
| 26 | import com.google.common.collect.ImmutableSet; |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 27 | import org.onosproject.net.ResourceGroup; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 28 | |
Ray Milkey | ebc5d22 | 2015-03-18 15:45:36 -0700 | [diff] [blame] | 29 | import static com.google.common.base.Preconditions.checkNotNull; |
| 30 | |
Brian O'Connor | 9476fa1 | 2015-06-25 15:17:17 -0400 | [diff] [blame] | 31 | /** |
| 32 | * An optical layer intent with explicitly selected path. |
| 33 | */ |
| 34 | @Beta |
Ray Milkey | bd4f011 | 2015-03-02 17:07:09 -0800 | [diff] [blame] | 35 | public final class OpticalPathIntent extends Intent { |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 36 | |
| 37 | private final ConnectPoint src; |
| 38 | private final ConnectPoint dst; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 39 | private final Path path; |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 40 | private final OchSignal lambda; |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 41 | private final OchSignalType signalType; |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 42 | private final boolean isBidirectional; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 43 | |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 44 | private OpticalPathIntent(ApplicationId appId, |
| 45 | Key key, |
| 46 | ConnectPoint src, |
| 47 | ConnectPoint dst, |
| 48 | Path path, |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 49 | OchSignal lambda, |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 50 | OchSignalType signalType, |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 51 | boolean isBidirectional, |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 52 | int priority, |
| 53 | ResourceGroup resourceGroup) { |
| 54 | super(appId, key, ImmutableSet.copyOf(path.links()), priority, resourceGroup); |
Ray Milkey | ebc5d22 | 2015-03-18 15:45:36 -0700 | [diff] [blame] | 55 | this.src = checkNotNull(src); |
| 56 | this.dst = checkNotNull(dst); |
| 57 | this.path = checkNotNull(path); |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 58 | this.lambda = checkNotNull(lambda); |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 59 | this.signalType = checkNotNull(signalType); |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 60 | this.isBidirectional = isBidirectional; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 61 | } |
| 62 | |
weibit | 9e622ac | 2014-10-23 13:45:44 -0700 | [diff] [blame] | 63 | protected OpticalPathIntent() { |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 64 | this.src = null; |
| 65 | this.dst = null; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 66 | this.path = null; |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 67 | this.lambda = null; |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 68 | this.signalType = null; |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 69 | this.isBidirectional = true; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 70 | } |
| 71 | |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 72 | /** |
| 73 | * Returns a new optical connectivity intent builder. |
| 74 | * |
| 75 | * @return host to host intent builder |
| 76 | */ |
| 77 | public static Builder builder() { |
| 78 | return new Builder(); |
| 79 | } |
| 80 | |
| 81 | |
| 82 | /** |
| 83 | * Builder for optical path intents. |
| 84 | */ |
| 85 | public static class Builder extends Intent.Builder { |
| 86 | private ConnectPoint src; |
| 87 | private ConnectPoint dst; |
| 88 | private Path path; |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 89 | private OchSignal lambda; |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 90 | private OchSignalType signalType; |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 91 | private boolean isBidirectional; |
Yuta HIGUCHI | b7a1f8e | 2017-03-01 17:11:52 -0800 | [diff] [blame] | 92 | private Key key; |
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 | /** |
| 137 | * Sets the path for the intent that will be built. |
| 138 | * |
| 139 | * @param path path to use for built intent |
| 140 | * @return this builder |
| 141 | */ |
| 142 | public Builder path(Path path) { |
| 143 | this.path = path; |
| 144 | return this; |
| 145 | } |
| 146 | |
| 147 | /** |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 148 | * Sets the optical channel (lambda) for the intent that will be built. |
| 149 | * |
| 150 | * @param lambda the optical channel |
| 151 | * @return this builder |
| 152 | */ |
| 153 | public Builder lambda(OchSignal lambda) { |
| 154 | this.lambda = lambda; |
| 155 | return this; |
| 156 | } |
| 157 | |
| 158 | /** |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 159 | * Sets the optical signal type for the intent that will be built. |
| 160 | * |
| 161 | * @param signalType the optical signal type |
| 162 | * @return this builder |
| 163 | */ |
| 164 | public Builder signalType(OchSignalType signalType) { |
| 165 | this.signalType = signalType; |
| 166 | return this; |
| 167 | } |
| 168 | |
| 169 | /** |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 170 | * Sets the intent's direction. |
Brian O'Connor | 85cf4da | 2015-06-05 23:44:28 -0700 | [diff] [blame] | 171 | * |
| 172 | * @param isBidirectional indicates if intent is bidirectional |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 173 | * @return this builder |
| 174 | */ |
| 175 | public Builder bidirectional(boolean isBidirectional) { |
| 176 | this.isBidirectional = isBidirectional; |
| 177 | return this; |
| 178 | } |
| 179 | |
| 180 | /** |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 181 | * Builds an optical path intent from the accumulated parameters. |
| 182 | * |
| 183 | * @return optical path intent |
| 184 | */ |
| 185 | public OpticalPathIntent build() { |
| 186 | |
| 187 | return new OpticalPathIntent( |
| 188 | appId, |
| 189 | key, |
| 190 | src, |
| 191 | dst, |
| 192 | path, |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 193 | lambda, |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 194 | signalType, |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 195 | isBidirectional, |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 196 | priority, |
| 197 | resourceGroup |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 198 | ); |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 203 | public ConnectPoint src() { |
| 204 | return src; |
| 205 | } |
| 206 | |
| 207 | public ConnectPoint dst() { |
| 208 | return dst; |
| 209 | } |
| 210 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 211 | public Path path() { |
| 212 | return path; |
| 213 | } |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 214 | |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 215 | public OchSignal lambda() { |
| 216 | return lambda; |
| 217 | } |
| 218 | |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 219 | public OchSignalType signalType() { |
| 220 | return signalType; |
| 221 | } |
| 222 | |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 223 | public boolean isBidirectional() { |
| 224 | return isBidirectional; |
| 225 | } |
| 226 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 227 | @Override |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 228 | public String toString() { |
| 229 | return MoreObjects.toStringHelper(getClass()) |
| 230 | .add("id", id()) |
Jonathan Hart | 23b5a76 | 2015-01-26 14:47:33 -0800 | [diff] [blame] | 231 | .add("appId", appId()) |
Ray Milkey | ebc5d22 | 2015-03-18 15:45:36 -0700 | [diff] [blame] | 232 | .add("key", key()) |
Jonathan Hart | 23b5a76 | 2015-01-26 14:47:33 -0800 | [diff] [blame] | 233 | .add("resources", resources()) |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 234 | .add("ingressPort", src) |
| 235 | .add("egressPort", dst) |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 236 | .add("path", path) |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 237 | .add("lambda", lambda) |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 238 | .add("signalType", signalType) |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 239 | .add("isBidirectional", isBidirectional) |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 240 | .toString(); |
| 241 | } |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 242 | } |