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 | |
Sho SHIMIZU | f1fa96c | 2015-04-22 15:21:53 +0900 | [diff] [blame] | 18 | import com.google.common.base.MoreObjects; |
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 | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 21 | import org.onosproject.net.OduSignalType; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 22 | |
Sho SHIMIZU | f1fa96c | 2015-04-22 15:21:53 +0900 | [diff] [blame] | 23 | import java.util.Collections; |
| 24 | |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 25 | import static com.google.common.base.Preconditions.checkNotNull; |
Sho SHIMIZU | d7d1800 | 2015-01-21 14:37:14 -0800 | [diff] [blame] | 26 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 27 | /** |
Marc De Leenheer | 1afa2a0 | 2015-05-13 09:18:07 -0700 | [diff] [blame] | 28 | * An optical layer intent for connectivity between two OCh ports. |
| 29 | * No traffic selector or traffic treatment are needed. |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 30 | */ |
Ray Milkey | bd4f011 | 2015-03-02 17:07:09 -0800 | [diff] [blame] | 31 | public final class OpticalConnectivityIntent extends Intent { |
| 32 | private final ConnectPoint src; |
| 33 | private final ConnectPoint dst; |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 34 | private final OduSignalType signalType; |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 35 | private final boolean isBidirectional; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 36 | |
| 37 | /** |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 38 | * Creates an optical connectivity intent between the specified |
| 39 | * connection points. |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 40 | * |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 41 | * @param appId application identification |
Ray Milkey | 5b3717e | 2015-02-05 11:44:08 -0800 | [diff] [blame] | 42 | * @param key intent key |
| 43 | * @param src the source transponder port |
| 44 | * @param dst the destination transponder port |
Brian O'Connor | 85cf4da | 2015-06-05 23:44:28 -0700 | [diff] [blame] | 45 | * @param signalType signal type |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 46 | * @param isBidirectional indicates if intent is unidirectional |
Ray Milkey | 22083ae | 2015-03-25 13:02:07 -0700 | [diff] [blame] | 47 | * @param priority priority to use for flows from this intent |
Ray Milkey | 5b3717e | 2015-02-05 11:44:08 -0800 | [diff] [blame] | 48 | */ |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 49 | protected OpticalConnectivityIntent(ApplicationId appId, |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 50 | Key key, |
| 51 | ConnectPoint src, |
| 52 | ConnectPoint dst, |
| 53 | OduSignalType signalType, |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 54 | boolean isBidirectional, |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 55 | int priority) { |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 56 | super(appId, key, Collections.emptyList(), priority); |
| 57 | this.src = checkNotNull(src); |
| 58 | this.dst = checkNotNull(dst); |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -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 | |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 63 | /** |
| 64 | * Returns a new optical connectivity intent builder. |
| 65 | * |
| 66 | * @return host to host intent builder |
| 67 | */ |
| 68 | public static Builder builder() { |
| 69 | return new Builder(); |
| 70 | } |
| 71 | |
| 72 | |
| 73 | /** |
| 74 | * Builder for optical connectivity intents. |
| 75 | */ |
| 76 | public static class Builder extends Intent.Builder { |
| 77 | private ConnectPoint src; |
| 78 | private ConnectPoint dst; |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 79 | private OduSignalType signalType; |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 80 | private boolean isBidirectional; |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 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 | /** |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 120 | * Sets the ODU signal type for the intent that will be built. |
| 121 | * |
| 122 | * @param signalType ODU signal type |
| 123 | * @return this builder |
| 124 | */ |
| 125 | public Builder signalType(OduSignalType signalType) { |
| 126 | this.signalType = signalType; |
| 127 | return this; |
| 128 | } |
| 129 | |
| 130 | /** |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 131 | * Sets the directionality of the intent. |
| 132 | * |
| 133 | * @param isBidirectional true if bidirectional, false if unidirectional |
| 134 | * @return this builder |
| 135 | */ |
| 136 | public Builder bidirectional(boolean isBidirectional) { |
| 137 | this.isBidirectional = isBidirectional; |
| 138 | return this; |
| 139 | } |
| 140 | |
| 141 | /** |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 142 | * Builds an optical connectivity intent from the accumulated parameters. |
| 143 | * |
| 144 | * @return point to point intent |
| 145 | */ |
| 146 | public OpticalConnectivityIntent build() { |
| 147 | |
| 148 | return new OpticalConnectivityIntent( |
| 149 | appId, |
| 150 | key, |
| 151 | src, |
| 152 | dst, |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 153 | signalType, |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 154 | isBidirectional, |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 155 | priority |
| 156 | ); |
| 157 | } |
| 158 | } |
Ray Milkey | 5b3717e | 2015-02-05 11:44:08 -0800 | [diff] [blame] | 159 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 160 | /** |
| 161 | * Constructor for serializer. |
| 162 | */ |
| 163 | protected OpticalConnectivityIntent() { |
| 164 | super(); |
| 165 | this.src = null; |
| 166 | this.dst = null; |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 167 | this.signalType = null; |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 168 | this.isBidirectional = false; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | /** |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 172 | * Returns the source transponder port. |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 173 | * |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 174 | * @return source transponder port |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 175 | */ |
Jonathan Hart | c9d7673 | 2014-11-18 10:52:20 -0800 | [diff] [blame] | 176 | public ConnectPoint getSrc() { |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 177 | return src; |
| 178 | } |
| 179 | |
| 180 | /** |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 181 | * Returns the destination transponder port. |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 182 | * |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 183 | * @return source transponder port |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 184 | */ |
| 185 | public ConnectPoint getDst() { |
| 186 | return dst; |
| 187 | } |
Sho SHIMIZU | f1fa96c | 2015-04-22 15:21:53 +0900 | [diff] [blame] | 188 | |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 189 | /** |
| 190 | * Returns the ODU signal type. |
| 191 | * |
| 192 | * @return ODU signal type |
| 193 | */ |
| 194 | public OduSignalType getSignalType() { |
| 195 | return signalType; |
| 196 | } |
| 197 | |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 198 | /** |
| 199 | * Returns the directionality of the intent. |
| 200 | * |
| 201 | * @return true if bidirectional, false if unidirectional |
| 202 | */ |
| 203 | public boolean isBidirectional() { |
| 204 | return isBidirectional; |
| 205 | } |
| 206 | |
Sho SHIMIZU | f1fa96c | 2015-04-22 15:21:53 +0900 | [diff] [blame] | 207 | @Override |
| 208 | public String toString() { |
| 209 | return MoreObjects.toStringHelper(this) |
| 210 | .add("id", id()) |
| 211 | .add("key", key()) |
| 212 | .add("appId", appId()) |
| 213 | .add("priority", priority()) |
| 214 | .add("resources", resources()) |
| 215 | .add("src", src) |
| 216 | .add("dst", dst) |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 217 | .add("signalType", signalType) |
Marc De Leenheer | 4a1c1fa | 2015-06-01 18:08:56 -0700 | [diff] [blame] | 218 | .add("isBidirectional", isBidirectional) |
Sho SHIMIZU | f1fa96c | 2015-04-22 15:21:53 +0900 | [diff] [blame] | 219 | .toString(); |
| 220 | } |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 221 | } |