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