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; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 35 | |
| 36 | /** |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 37 | * Creates an optical connectivity intent between the specified |
| 38 | * connection points. |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 39 | * |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 40 | * @param appId application identification |
Ray Milkey | 5b3717e | 2015-02-05 11:44:08 -0800 | [diff] [blame] | 41 | * @param key intent key |
| 42 | * @param src the source transponder port |
| 43 | * @param dst the destination transponder port |
Ray Milkey | 22083ae | 2015-03-25 13:02:07 -0700 | [diff] [blame] | 44 | * @param priority priority to use for flows from this intent |
Ray Milkey | 5b3717e | 2015-02-05 11:44:08 -0800 | [diff] [blame] | 45 | */ |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 46 | protected OpticalConnectivityIntent(ApplicationId appId, |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame^] | 47 | Key key, |
| 48 | ConnectPoint src, |
| 49 | ConnectPoint dst, |
| 50 | OduSignalType signalType, |
| 51 | int priority) { |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 52 | super(appId, key, Collections.emptyList(), priority); |
| 53 | this.src = checkNotNull(src); |
| 54 | this.dst = checkNotNull(dst); |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame^] | 55 | this.signalType = checkNotNull(signalType); |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 56 | } |
| 57 | |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 58 | /** |
| 59 | * Returns a new optical connectivity intent builder. |
| 60 | * |
| 61 | * @return host to host intent builder |
| 62 | */ |
| 63 | public static Builder builder() { |
| 64 | return new Builder(); |
| 65 | } |
| 66 | |
| 67 | |
| 68 | /** |
| 69 | * Builder for optical connectivity intents. |
| 70 | */ |
| 71 | public static class Builder extends Intent.Builder { |
| 72 | private ConnectPoint src; |
| 73 | private ConnectPoint dst; |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame^] | 74 | private OduSignalType signalType; |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 75 | |
| 76 | @Override |
| 77 | public Builder appId(ApplicationId appId) { |
| 78 | return (Builder) super.appId(appId); |
| 79 | } |
| 80 | |
| 81 | @Override |
| 82 | public Builder key(Key key) { |
| 83 | return (Builder) super.key(key); |
| 84 | } |
| 85 | |
| 86 | @Override |
| 87 | public Builder priority(int priority) { |
| 88 | return (Builder) super.priority(priority); |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Sets the source for the intent that will be built. |
| 93 | * |
| 94 | * @param src source to use for built intent |
| 95 | * @return this builder |
| 96 | */ |
| 97 | public Builder src(ConnectPoint src) { |
| 98 | this.src = src; |
| 99 | return this; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Sets the destination for the intent that will be built. |
| 104 | * |
| 105 | * @param dst dest to use for built intent |
| 106 | * @return this builder |
| 107 | */ |
| 108 | public Builder dst(ConnectPoint dst) { |
| 109 | this.dst = dst; |
| 110 | return this; |
| 111 | } |
| 112 | |
| 113 | /** |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame^] | 114 | * Sets the ODU signal type for the intent that will be built. |
| 115 | * |
| 116 | * @param signalType ODU signal type |
| 117 | * @return this builder |
| 118 | */ |
| 119 | public Builder signalType(OduSignalType signalType) { |
| 120 | this.signalType = signalType; |
| 121 | return this; |
| 122 | } |
| 123 | |
| 124 | /** |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 125 | * Builds an optical connectivity intent from the accumulated parameters. |
| 126 | * |
| 127 | * @return point to point intent |
| 128 | */ |
| 129 | public OpticalConnectivityIntent build() { |
| 130 | |
| 131 | return new OpticalConnectivityIntent( |
| 132 | appId, |
| 133 | key, |
| 134 | src, |
| 135 | dst, |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame^] | 136 | signalType, |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 137 | priority |
| 138 | ); |
| 139 | } |
| 140 | } |
Ray Milkey | 5b3717e | 2015-02-05 11:44:08 -0800 | [diff] [blame] | 141 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 142 | /** |
| 143 | * Constructor for serializer. |
| 144 | */ |
| 145 | protected OpticalConnectivityIntent() { |
| 146 | super(); |
| 147 | this.src = null; |
| 148 | this.dst = null; |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame^] | 149 | this.signalType = null; |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | /** |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 153 | * Returns the source transponder port. |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 154 | * |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 155 | * @return source transponder port |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 156 | */ |
Jonathan Hart | c9d7673 | 2014-11-18 10:52:20 -0800 | [diff] [blame] | 157 | public ConnectPoint getSrc() { |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 158 | return src; |
| 159 | } |
| 160 | |
| 161 | /** |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 162 | * Returns the destination transponder port. |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 163 | * |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 164 | * @return source transponder port |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 165 | */ |
| 166 | public ConnectPoint getDst() { |
| 167 | return dst; |
| 168 | } |
Sho SHIMIZU | f1fa96c | 2015-04-22 15:21:53 +0900 | [diff] [blame] | 169 | |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame^] | 170 | /** |
| 171 | * Returns the ODU signal type. |
| 172 | * |
| 173 | * @return ODU signal type |
| 174 | */ |
| 175 | public OduSignalType getSignalType() { |
| 176 | return signalType; |
| 177 | } |
| 178 | |
Sho SHIMIZU | f1fa96c | 2015-04-22 15:21:53 +0900 | [diff] [blame] | 179 | @Override |
| 180 | public String toString() { |
| 181 | return MoreObjects.toStringHelper(this) |
| 182 | .add("id", id()) |
| 183 | .add("key", key()) |
| 184 | .add("appId", appId()) |
| 185 | .add("priority", priority()) |
| 186 | .add("resources", resources()) |
| 187 | .add("src", src) |
| 188 | .add("dst", dst) |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame^] | 189 | .add("signalType", signalType) |
Sho SHIMIZU | f1fa96c | 2015-04-22 15:21:53 +0900 | [diff] [blame] | 190 | .toString(); |
| 191 | } |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 192 | } |