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 | |
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 |
Ray Milkey | 22083ae | 2015-03-25 13:02:07 -0700 | [diff] [blame] | 41 | * @param priority priority to use for flows from this intent |
Ray Milkey | 5b3717e | 2015-02-05 11:44:08 -0800 | [diff] [blame] | 42 | */ |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 43 | protected OpticalConnectivityIntent(ApplicationId appId, |
Ray Milkey | 5b3717e | 2015-02-05 11:44:08 -0800 | [diff] [blame] | 44 | Key key, |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 45 | ConnectPoint src, |
| 46 | ConnectPoint dst, |
| 47 | int priority) { |
| 48 | super(appId, key, Collections.emptyList(), priority); |
| 49 | this.src = checkNotNull(src); |
| 50 | this.dst = checkNotNull(dst); |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 51 | } |
| 52 | |
Ray Milkey | e076c79 | 2015-03-24 09:38:30 -0700 | [diff] [blame] | 53 | /** |
| 54 | * Returns a new optical connectivity intent builder. |
| 55 | * |
| 56 | * @return host to host intent builder |
| 57 | */ |
| 58 | public static Builder builder() { |
| 59 | return new Builder(); |
| 60 | } |
| 61 | |
| 62 | |
| 63 | /** |
| 64 | * Builder for optical connectivity intents. |
| 65 | */ |
| 66 | public static class Builder extends Intent.Builder { |
| 67 | private ConnectPoint src; |
| 68 | private ConnectPoint dst; |
| 69 | |
| 70 | @Override |
| 71 | public Builder appId(ApplicationId appId) { |
| 72 | return (Builder) super.appId(appId); |
| 73 | } |
| 74 | |
| 75 | @Override |
| 76 | public Builder key(Key key) { |
| 77 | return (Builder) super.key(key); |
| 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public Builder priority(int priority) { |
| 82 | return (Builder) super.priority(priority); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Sets the source for the intent that will be built. |
| 87 | * |
| 88 | * @param src source to use for built intent |
| 89 | * @return this builder |
| 90 | */ |
| 91 | public Builder src(ConnectPoint src) { |
| 92 | this.src = src; |
| 93 | return this; |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Sets the destination for the intent that will be built. |
| 98 | * |
| 99 | * @param dst dest to use for built intent |
| 100 | * @return this builder |
| 101 | */ |
| 102 | public Builder dst(ConnectPoint dst) { |
| 103 | this.dst = dst; |
| 104 | return this; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Builds an optical connectivity intent from the accumulated parameters. |
| 109 | * |
| 110 | * @return point to point intent |
| 111 | */ |
| 112 | public OpticalConnectivityIntent build() { |
| 113 | |
| 114 | return new OpticalConnectivityIntent( |
| 115 | appId, |
| 116 | key, |
| 117 | src, |
| 118 | dst, |
| 119 | priority |
| 120 | ); |
| 121 | } |
| 122 | } |
Ray Milkey | 5b3717e | 2015-02-05 11:44:08 -0800 | [diff] [blame] | 123 | |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 124 | /** |
| 125 | * Constructor for serializer. |
| 126 | */ |
| 127 | protected OpticalConnectivityIntent() { |
| 128 | super(); |
| 129 | this.src = null; |
| 130 | this.dst = null; |
| 131 | } |
| 132 | |
| 133 | /** |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 134 | * Returns the source transponder port. |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 135 | * |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 136 | * @return source transponder port |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 137 | */ |
Jonathan Hart | c9d7673 | 2014-11-18 10:52:20 -0800 | [diff] [blame] | 138 | public ConnectPoint getSrc() { |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 139 | return src; |
| 140 | } |
| 141 | |
| 142 | /** |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 143 | * Returns the destination transponder port. |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 144 | * |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 145 | * @return source transponder port |
weibit | f32383b | 2014-10-22 10:17:31 -0700 | [diff] [blame] | 146 | */ |
| 147 | public ConnectPoint getDst() { |
| 148 | return dst; |
| 149 | } |
| 150 | } |