Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame] | 2 | * Copyright 2014-2015 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 | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 18 | import org.onosproject.core.ApplicationId; |
| 19 | import org.onosproject.net.ConnectPoint; |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 20 | import org.onosproject.net.OchSignal; |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 21 | import org.onosproject.net.OchSignalType; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 22 | import org.onosproject.net.Path; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 23 | |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 24 | import com.google.common.base.MoreObjects; |
| 25 | import com.google.common.collect.ImmutableSet; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 26 | |
Ray Milkey | ebc5d22 | 2015-03-18 15:45:36 -0700 | [diff] [blame] | 27 | import static com.google.common.base.Preconditions.checkNotNull; |
| 28 | |
Ray Milkey | bd4f011 | 2015-03-02 17:07:09 -0800 | [diff] [blame] | 29 | public final class OpticalPathIntent extends Intent { |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 30 | |
| 31 | private final ConnectPoint src; |
| 32 | private final ConnectPoint dst; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 33 | private final Path path; |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 34 | private final OchSignal lambda; |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 35 | private final OchSignalType signalType; |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 36 | private final boolean isBidirectional; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 37 | |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 38 | private OpticalPathIntent(ApplicationId appId, |
| 39 | Key key, |
| 40 | ConnectPoint src, |
| 41 | ConnectPoint dst, |
| 42 | Path path, |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 43 | OchSignal lambda, |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 44 | OchSignalType signalType, |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 45 | boolean isBidirectional, |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 46 | int priority) { |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 47 | super(appId, key, ImmutableSet.copyOf(path.links()), priority); |
Ray Milkey | ebc5d22 | 2015-03-18 15:45:36 -0700 | [diff] [blame] | 48 | this.src = checkNotNull(src); |
| 49 | this.dst = checkNotNull(dst); |
| 50 | this.path = checkNotNull(path); |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 51 | this.lambda = checkNotNull(lambda); |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 52 | this.signalType = checkNotNull(signalType); |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 53 | this.isBidirectional = isBidirectional; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 54 | } |
| 55 | |
weibit | 9e622ac | 2014-10-23 13:45:44 -0700 | [diff] [blame] | 56 | protected OpticalPathIntent() { |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 57 | this.src = null; |
| 58 | this.dst = null; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 59 | this.path = null; |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 60 | this.lambda = null; |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 61 | this.signalType = null; |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 62 | this.isBidirectional = true; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 63 | } |
| 64 | |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 65 | /** |
| 66 | * Returns a new optical connectivity intent builder. |
| 67 | * |
| 68 | * @return host to host intent builder |
| 69 | */ |
| 70 | public static Builder builder() { |
| 71 | return new Builder(); |
| 72 | } |
| 73 | |
| 74 | |
| 75 | /** |
| 76 | * Builder for optical path intents. |
| 77 | */ |
| 78 | public static class Builder extends Intent.Builder { |
| 79 | private ConnectPoint src; |
| 80 | private ConnectPoint dst; |
| 81 | private Path path; |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 82 | private OchSignal lambda; |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 83 | private OchSignalType signalType; |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 84 | private boolean isBidirectional; |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 85 | Key key; |
| 86 | |
| 87 | @Override |
| 88 | public Builder appId(ApplicationId appId) { |
| 89 | return (Builder) super.appId(appId); |
| 90 | } |
| 91 | |
| 92 | @Override |
| 93 | public Builder key(Key key) { |
| 94 | return (Builder) super.key(key); |
| 95 | } |
| 96 | |
| 97 | @Override |
| 98 | public Builder priority(int priority) { |
| 99 | return (Builder) super.priority(priority); |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Sets the source for the intent that will be built. |
| 104 | * |
| 105 | * @param src source to use for built intent |
| 106 | * @return this builder |
| 107 | */ |
| 108 | public Builder src(ConnectPoint src) { |
| 109 | this.src = src; |
| 110 | return this; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * Sets the destination for the intent that will be built. |
| 115 | * |
| 116 | * @param dst dest to use for built intent |
| 117 | * @return this builder |
| 118 | */ |
| 119 | public Builder dst(ConnectPoint dst) { |
| 120 | this.dst = dst; |
| 121 | return this; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Sets the path for the intent that will be built. |
| 126 | * |
| 127 | * @param path path to use for built intent |
| 128 | * @return this builder |
| 129 | */ |
| 130 | public Builder path(Path path) { |
| 131 | this.path = path; |
| 132 | return this; |
| 133 | } |
| 134 | |
| 135 | /** |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 136 | * Sets the optical channel (lambda) for the intent that will be built. |
| 137 | * |
| 138 | * @param lambda the optical channel |
| 139 | * @return this builder |
| 140 | */ |
| 141 | public Builder lambda(OchSignal lambda) { |
| 142 | this.lambda = lambda; |
| 143 | return this; |
| 144 | } |
| 145 | |
| 146 | /** |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 147 | * Sets the optical signal type for the intent that will be built. |
| 148 | * |
| 149 | * @param signalType the optical signal type |
| 150 | * @return this builder |
| 151 | */ |
| 152 | public Builder signalType(OchSignalType signalType) { |
| 153 | this.signalType = signalType; |
| 154 | return this; |
| 155 | } |
| 156 | |
| 157 | /** |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 158 | * Sets the intent's direction. |
| 159 | * @return this builder |
| 160 | */ |
| 161 | public Builder bidirectional(boolean isBidirectional) { |
| 162 | this.isBidirectional = isBidirectional; |
| 163 | return this; |
| 164 | } |
| 165 | |
| 166 | /** |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 167 | * Builds an optical path intent from the accumulated parameters. |
| 168 | * |
| 169 | * @return optical path intent |
| 170 | */ |
| 171 | public OpticalPathIntent build() { |
| 172 | |
| 173 | return new OpticalPathIntent( |
| 174 | appId, |
| 175 | key, |
| 176 | src, |
| 177 | dst, |
| 178 | path, |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 179 | lambda, |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 180 | signalType, |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 181 | isBidirectional, |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 182 | priority |
| 183 | ); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 188 | public ConnectPoint src() { |
| 189 | return src; |
| 190 | } |
| 191 | |
| 192 | public ConnectPoint dst() { |
| 193 | return dst; |
| 194 | } |
| 195 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 196 | public Path path() { |
| 197 | return path; |
| 198 | } |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 199 | |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 200 | public OchSignal lambda() { |
| 201 | return lambda; |
| 202 | } |
| 203 | |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 204 | public OchSignalType signalType() { |
| 205 | return signalType; |
| 206 | } |
| 207 | |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 208 | public boolean isBidirectional() { |
| 209 | return isBidirectional; |
| 210 | } |
| 211 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 212 | @Override |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 213 | public String toString() { |
| 214 | return MoreObjects.toStringHelper(getClass()) |
| 215 | .add("id", id()) |
Jonathan Hart | 23b5a76 | 2015-01-26 14:47:33 -0800 | [diff] [blame] | 216 | .add("appId", appId()) |
Ray Milkey | ebc5d22 | 2015-03-18 15:45:36 -0700 | [diff] [blame] | 217 | .add("key", key()) |
Jonathan Hart | 23b5a76 | 2015-01-26 14:47:33 -0800 | [diff] [blame] | 218 | .add("resources", resources()) |
Brian O'Connor | 086724e | 2014-10-23 15:47:32 -0700 | [diff] [blame] | 219 | .add("ingressPort", src) |
| 220 | .add("egressPort", dst) |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 221 | .add("path", path) |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 222 | .add("lambda", lambda) |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 223 | .add("signalType", signalType) |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 224 | .add("isBidirectional", isBidirectional) |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 225 | .toString(); |
| 226 | } |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 227 | } |