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