blob: 651ba0207dae6980bd6576675f6d7efcaa365f3c [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
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'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.intent;
weibitf32383b2014-10-22 10:17:31 -070017
Brian O'Connor9476fa12015-06-25 15:17:17 -040018import com.google.common.annotations.Beta;
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +090019import com.google.common.base.MoreObjects;
Brian O'Connorabafb502014-12-02 22:26:20 -080020import org.onosproject.core.ApplicationId;
21import org.onosproject.net.ConnectPoint;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070022import org.onosproject.net.OduSignalType;
weibitf32383b2014-10-22 10:17:31 -070023
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +090024import java.util.Collections;
25
Ray Milkeye076c792015-03-24 09:38:30 -070026import static com.google.common.base.Preconditions.checkNotNull;
Sho SHIMIZUd7d18002015-01-21 14:37:14 -080027
weibitf32383b2014-10-22 10:17:31 -070028/**
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070029 * An optical layer intent for connectivity between two OCh ports.
30 * No traffic selector or traffic treatment are needed.
weibitf32383b2014-10-22 10:17:31 -070031 */
Brian O'Connor9476fa12015-06-25 15:17:17 -040032@Beta
Ray Milkeybd4f0112015-03-02 17:07:09 -080033public final class OpticalConnectivityIntent extends Intent {
34 private final ConnectPoint src;
35 private final ConnectPoint dst;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070036 private final OduSignalType signalType;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070037 private final boolean isBidirectional;
weibitf32383b2014-10-22 10:17:31 -070038
39 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -070040 * Creates an optical connectivity intent between the specified
41 * connection points.
weibitf32383b2014-10-22 10:17:31 -070042 *
Thomas Vachuska4b420772014-10-30 16:46:17 -070043 * @param appId application identification
Ray Milkey5b3717e2015-02-05 11:44:08 -080044 * @param key intent key
45 * @param src the source transponder port
46 * @param dst the destination transponder port
Brian O'Connor85cf4da2015-06-05 23:44:28 -070047 * @param signalType signal type
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070048 * @param isBidirectional indicates if intent is unidirectional
Ray Milkey22083ae2015-03-25 13:02:07 -070049 * @param priority priority to use for flows from this intent
Ray Milkey5b3717e2015-02-05 11:44:08 -080050 */
Ray Milkeye076c792015-03-24 09:38:30 -070051 protected OpticalConnectivityIntent(ApplicationId appId,
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070052 Key key,
53 ConnectPoint src,
54 ConnectPoint dst,
55 OduSignalType signalType,
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070056 boolean isBidirectional,
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070057 int priority) {
Ray Milkeye076c792015-03-24 09:38:30 -070058 super(appId, key, Collections.emptyList(), priority);
59 this.src = checkNotNull(src);
60 this.dst = checkNotNull(dst);
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070061 this.signalType = checkNotNull(signalType);
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070062 this.isBidirectional = isBidirectional;
weibitf32383b2014-10-22 10:17:31 -070063 }
64
Ray Milkeye076c792015-03-24 09:38:30 -070065 /**
66 * Returns a new optical connectivity intent builder.
67 *
68 * @return host to host intent builder
69 */
70 public static Builder builder() {
71 return new Builder();
72 }
73
74
75 /**
76 * Builder for optical connectivity intents.
77 */
78 public static class Builder extends Intent.Builder {
79 private ConnectPoint src;
80 private ConnectPoint dst;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070081 private OduSignalType signalType;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -070082 private boolean isBidirectional;
Ray Milkeye076c792015-03-24 09:38:30 -070083
84 @Override
85 public Builder appId(ApplicationId appId) {
86 return (Builder) super.appId(appId);
87 }
88
89 @Override
90 public Builder key(Key key) {
91 return (Builder) super.key(key);
92 }
93
94 @Override
95 public Builder priority(int priority) {
96 return (Builder) super.priority(priority);
97 }
98
99 /**
100 * Sets the source for the intent that will be built.
101 *
102 * @param src source to use for built intent
103 * @return this builder
104 */
105 public Builder src(ConnectPoint src) {
106 this.src = src;
107 return this;
108 }
109
110 /**
111 * Sets the destination for the intent that will be built.
112 *
113 * @param dst dest to use for built intent
114 * @return this builder
115 */
116 public Builder dst(ConnectPoint dst) {
117 this.dst = dst;
118 return this;
119 }
120
121 /**
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700122 * Sets the ODU signal type for the intent that will be built.
123 *
124 * @param signalType ODU signal type
125 * @return this builder
126 */
127 public Builder signalType(OduSignalType signalType) {
128 this.signalType = signalType;
129 return this;
130 }
131
132 /**
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700133 * Sets the directionality of the intent.
134 *
135 * @param isBidirectional true if bidirectional, false if unidirectional
136 * @return this builder
137 */
138 public Builder bidirectional(boolean isBidirectional) {
139 this.isBidirectional = isBidirectional;
140 return this;
141 }
142
143 /**
Ray Milkeye076c792015-03-24 09:38:30 -0700144 * Builds an optical connectivity intent from the accumulated parameters.
145 *
146 * @return point to point intent
147 */
148 public OpticalConnectivityIntent build() {
149
150 return new OpticalConnectivityIntent(
151 appId,
152 key,
153 src,
154 dst,
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700155 signalType,
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700156 isBidirectional,
Ray Milkeye076c792015-03-24 09:38:30 -0700157 priority
158 );
159 }
160 }
Ray Milkey5b3717e2015-02-05 11:44:08 -0800161
weibitf32383b2014-10-22 10:17:31 -0700162 /**
163 * Constructor for serializer.
164 */
165 protected OpticalConnectivityIntent() {
166 super();
167 this.src = null;
168 this.dst = null;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700169 this.signalType = null;
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700170 this.isBidirectional = false;
weibitf32383b2014-10-22 10:17:31 -0700171 }
172
173 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -0700174 * Returns the source transponder port.
weibitf32383b2014-10-22 10:17:31 -0700175 *
Thomas Vachuska4b420772014-10-30 16:46:17 -0700176 * @return source transponder port
weibitf32383b2014-10-22 10:17:31 -0700177 */
Jonathan Hartc9d76732014-11-18 10:52:20 -0800178 public ConnectPoint getSrc() {
weibitf32383b2014-10-22 10:17:31 -0700179 return src;
180 }
181
182 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -0700183 * Returns the destination transponder port.
weibitf32383b2014-10-22 10:17:31 -0700184 *
Thomas Vachuska4b420772014-10-30 16:46:17 -0700185 * @return source transponder port
weibitf32383b2014-10-22 10:17:31 -0700186 */
187 public ConnectPoint getDst() {
188 return dst;
189 }
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +0900190
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700191 /**
192 * Returns the ODU signal type.
193 *
194 * @return ODU signal type
195 */
196 public OduSignalType getSignalType() {
197 return signalType;
198 }
199
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700200 /**
201 * Returns the directionality of the intent.
202 *
203 * @return true if bidirectional, false if unidirectional
204 */
205 public boolean isBidirectional() {
206 return isBidirectional;
207 }
208
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +0900209 @Override
210 public String toString() {
211 return MoreObjects.toStringHelper(this)
212 .add("id", id())
213 .add("key", key())
214 .add("appId", appId())
215 .add("priority", priority())
216 .add("resources", resources())
217 .add("src", src)
218 .add("dst", dst)
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700219 .add("signalType", signalType)
Marc De Leenheer4a1c1fa2015-06-01 18:08:56 -0700220 .add("isBidirectional", isBidirectional)
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +0900221 .toString();
222 }
weibitf32383b2014-10-22 10:17:31 -0700223}