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