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