Rimon Ashkenazy | 27438ff | 2016-03-22 15:57:45 +0200 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Rimon Ashkenazy | 27438ff | 2016-03-22 15:57:45 +0200 | [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 | */ |
| 16 | package org.onosproject.net.intent; |
| 17 | |
| 18 | import com.google.common.annotations.Beta; |
| 19 | import com.google.common.base.MoreObjects; |
| 20 | import org.onosproject.core.ApplicationId; |
| 21 | import org.onosproject.net.CltSignalType; |
| 22 | import org.onosproject.net.ConnectPoint; |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 23 | import org.onosproject.net.ResourceGroup; |
Rimon Ashkenazy | 27438ff | 2016-03-22 15:57:45 +0200 | [diff] [blame] | 24 | |
| 25 | import java.util.Collections; |
| 26 | |
| 27 | import static com.google.common.base.Preconditions.checkNotNull; |
| 28 | |
| 29 | /** |
| 30 | * An optical layer intent between two OduClt ports - in an OTN Topology. |
| 31 | * No traffic selector or traffic treatment are needed. |
| 32 | */ |
| 33 | @Beta |
| 34 | public final class OpticalOduIntent extends Intent { |
| 35 | private final ConnectPoint src; |
| 36 | private final ConnectPoint dst; |
| 37 | private final CltSignalType signalType; |
| 38 | private final boolean isBidirectional; |
| 39 | |
| 40 | /** |
| 41 | * Creates an optical ODU intent between the specified connection points. |
| 42 | * |
| 43 | * @param appId application identification |
| 44 | * @param key intent key |
| 45 | * @param src the source transponder port |
| 46 | * @param dst the destination transponder port |
| 47 | * @param signalType CltSignalType signal type |
| 48 | * @param isBidirectional indicate if intent is bidirectional |
| 49 | * @param priority priority to use for flows from this intent |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 50 | * @param resourceGroup resource group for this intent |
Rimon Ashkenazy | 27438ff | 2016-03-22 15:57:45 +0200 | [diff] [blame] | 51 | */ |
| 52 | protected OpticalOduIntent(ApplicationId appId, |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 53 | Key key, |
| 54 | ConnectPoint src, |
| 55 | ConnectPoint dst, |
| 56 | CltSignalType signalType, |
| 57 | boolean isBidirectional, |
| 58 | int priority, |
| 59 | ResourceGroup resourceGroup) { |
| 60 | super(appId, key, Collections.emptyList(), priority, resourceGroup); |
Rimon Ashkenazy | 27438ff | 2016-03-22 15:57:45 +0200 | [diff] [blame] | 61 | this.src = checkNotNull(src); |
| 62 | this.dst = checkNotNull(dst); |
| 63 | this.signalType = checkNotNull(signalType); |
| 64 | this.isBidirectional = isBidirectional; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Returns a new optical ODU intent builder. |
| 69 | * |
| 70 | * @return intent builder |
| 71 | */ |
| 72 | public static Builder builder() { |
| 73 | return new Builder(); |
| 74 | } |
| 75 | |
| 76 | |
| 77 | /** |
| 78 | * Builder for optical ODU intents. |
| 79 | */ |
| 80 | public static class Builder extends Intent.Builder { |
| 81 | private ConnectPoint src; |
| 82 | private ConnectPoint dst; |
| 83 | private CltSignalType signalType; |
| 84 | private boolean isBidirectional; |
| 85 | |
| 86 | @Override |
| 87 | public Builder appId(ApplicationId appId) { |
| 88 | return (Builder) super.appId(appId); |
| 89 | } |
| 90 | |
| 91 | @Override |
| 92 | public Builder key(Key key) { |
| 93 | return (Builder) super.key(key); |
| 94 | } |
| 95 | |
| 96 | @Override |
| 97 | public Builder priority(int priority) { |
| 98 | return (Builder) super.priority(priority); |
| 99 | } |
| 100 | |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 101 | @Override |
| 102 | public Builder resourceGroup(ResourceGroup resourceGroup) { |
| 103 | return (Builder) super.resourceGroup(resourceGroup); |
| 104 | } |
| 105 | |
Rimon Ashkenazy | 27438ff | 2016-03-22 15:57:45 +0200 | [diff] [blame] | 106 | /** |
| 107 | * Sets the source for the intent that will be built. |
| 108 | * |
| 109 | * @param src source to use for built intent |
| 110 | * @return this builder |
| 111 | */ |
| 112 | public Builder src(ConnectPoint src) { |
| 113 | this.src = src; |
| 114 | return this; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Sets the destination for the intent that will be built. |
| 119 | * |
| 120 | * @param dst dest to use for built intent |
| 121 | * @return this builder |
| 122 | */ |
| 123 | public Builder dst(ConnectPoint dst) { |
| 124 | this.dst = dst; |
| 125 | return this; |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Sets the ODU signal type for the intent that will be built. |
| 130 | * |
| 131 | * @param signalType signal type to use for built intent |
| 132 | * @return this builder |
| 133 | */ |
| 134 | public Builder signalType(CltSignalType signalType) { |
| 135 | this.signalType = signalType; |
| 136 | return this; |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Sets the directionality of the intent. |
| 141 | * |
| 142 | * @param isBidirectional true if bidirectional, false if unidirectional |
| 143 | * @return this builder |
| 144 | */ |
| 145 | public Builder bidirectional(boolean isBidirectional) { |
| 146 | this.isBidirectional = isBidirectional; |
| 147 | return this; |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * Builds an optical ODU intent from the accumulated parameters. |
| 152 | * |
| 153 | * @return point to point intent |
| 154 | */ |
| 155 | public OpticalOduIntent build() { |
| 156 | |
| 157 | return new OpticalOduIntent( |
| 158 | appId, |
| 159 | key, |
| 160 | src, |
| 161 | dst, |
| 162 | signalType, |
| 163 | isBidirectional, |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 164 | priority, |
| 165 | resourceGroup |
Rimon Ashkenazy | 27438ff | 2016-03-22 15:57:45 +0200 | [diff] [blame] | 166 | ); |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * Constructor for serializer. |
| 172 | */ |
| 173 | protected OpticalOduIntent() { |
| 174 | super(); |
| 175 | this.src = null; |
| 176 | this.dst = null; |
| 177 | this.signalType = null; |
| 178 | this.isBidirectional = false; |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * Returns the source transponder port. |
| 183 | * |
| 184 | * @return source transponder port |
| 185 | */ |
| 186 | public ConnectPoint getSrc() { |
| 187 | return src; |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * Returns the destination transponder port. |
| 192 | * |
| 193 | * @return source transponder port |
| 194 | */ |
| 195 | public ConnectPoint getDst() { |
| 196 | return dst; |
| 197 | } |
| 198 | |
| 199 | /** |
| 200 | * Returns the CltSignalType signal type. |
| 201 | * |
| 202 | * @return CltSignalType signal type |
| 203 | */ |
| 204 | public CltSignalType getSignalType() { |
| 205 | return signalType; |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * Returns the directionality of the intent. |
| 210 | * |
| 211 | * @return true if bidirectional, false if unidirectional |
| 212 | */ |
| 213 | public boolean isBidirectional() { |
| 214 | return isBidirectional; |
| 215 | } |
| 216 | |
| 217 | @Override |
| 218 | public String toString() { |
| 219 | return MoreObjects.toStringHelper(this) |
| 220 | .add("id", id()) |
| 221 | .add("key", key()) |
| 222 | .add("appId", appId()) |
| 223 | .add("priority", priority()) |
| 224 | .add("resources", resources()) |
| 225 | .add("src", src) |
| 226 | .add("dst", dst) |
| 227 | .add("signalType", signalType) |
| 228 | .add("isBidirectional", isBidirectional) |
Luca Prete | 670ac5d | 2017-02-03 15:55:43 -0800 | [diff] [blame] | 229 | .add("resourceGroup", resourceGroup()) |
Rimon Ashkenazy | 27438ff | 2016-03-22 15:57:45 +0200 | [diff] [blame] | 230 | .toString(); |
| 231 | } |
| 232 | |
| 233 | } |