blob: f28fd29fdf9c4353a39c282a60c197958937c33a [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 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
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +090018import com.google.common.base.MoreObjects;
Brian O'Connorabafb502014-12-02 22:26:20 -080019import org.onosproject.core.ApplicationId;
20import org.onosproject.net.ConnectPoint;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070021import org.onosproject.net.OduSignalType;
weibitf32383b2014-10-22 10:17:31 -070022
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +090023import java.util.Collections;
24
Ray Milkeye076c792015-03-24 09:38:30 -070025import static com.google.common.base.Preconditions.checkNotNull;
Sho SHIMIZUd7d18002015-01-21 14:37:14 -080026
weibitf32383b2014-10-22 10:17:31 -070027/**
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070028 * An optical layer intent for connectivity between two OCh ports.
29 * No traffic selector or traffic treatment are needed.
weibitf32383b2014-10-22 10:17:31 -070030 */
Ray Milkeybd4f0112015-03-02 17:07:09 -080031public final class OpticalConnectivityIntent extends Intent {
32 private final ConnectPoint src;
33 private final ConnectPoint dst;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070034 private final OduSignalType signalType;
weibitf32383b2014-10-22 10:17:31 -070035
36 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -070037 * Creates an optical connectivity intent between the specified
38 * connection points.
weibitf32383b2014-10-22 10:17:31 -070039 *
Thomas Vachuska4b420772014-10-30 16:46:17 -070040 * @param appId application identification
Ray Milkey5b3717e2015-02-05 11:44:08 -080041 * @param key intent key
42 * @param src the source transponder port
43 * @param dst the destination transponder port
Ray Milkey22083ae2015-03-25 13:02:07 -070044 * @param priority priority to use for flows from this intent
Ray Milkey5b3717e2015-02-05 11:44:08 -080045 */
Ray Milkeye076c792015-03-24 09:38:30 -070046 protected OpticalConnectivityIntent(ApplicationId appId,
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070047 Key key,
48 ConnectPoint src,
49 ConnectPoint dst,
50 OduSignalType signalType,
51 int priority) {
Ray Milkeye076c792015-03-24 09:38:30 -070052 super(appId, key, Collections.emptyList(), priority);
53 this.src = checkNotNull(src);
54 this.dst = checkNotNull(dst);
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070055 this.signalType = checkNotNull(signalType);
weibitf32383b2014-10-22 10:17:31 -070056 }
57
Ray Milkeye076c792015-03-24 09:38:30 -070058 /**
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 Leenheer8c2caac2015-05-28 16:37:33 -070074 private OduSignalType signalType;
Ray Milkeye076c792015-03-24 09:38:30 -070075
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 Leenheer8c2caac2015-05-28 16:37:33 -0700114 * 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 Milkeye076c792015-03-24 09:38:30 -0700125 * 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 Leenheer8c2caac2015-05-28 16:37:33 -0700136 signalType,
Ray Milkeye076c792015-03-24 09:38:30 -0700137 priority
138 );
139 }
140 }
Ray Milkey5b3717e2015-02-05 11:44:08 -0800141
weibitf32383b2014-10-22 10:17:31 -0700142 /**
143 * Constructor for serializer.
144 */
145 protected OpticalConnectivityIntent() {
146 super();
147 this.src = null;
148 this.dst = null;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700149 this.signalType = null;
weibitf32383b2014-10-22 10:17:31 -0700150 }
151
152 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -0700153 * Returns the source transponder port.
weibitf32383b2014-10-22 10:17:31 -0700154 *
Thomas Vachuska4b420772014-10-30 16:46:17 -0700155 * @return source transponder port
weibitf32383b2014-10-22 10:17:31 -0700156 */
Jonathan Hartc9d76732014-11-18 10:52:20 -0800157 public ConnectPoint getSrc() {
weibitf32383b2014-10-22 10:17:31 -0700158 return src;
159 }
160
161 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -0700162 * Returns the destination transponder port.
weibitf32383b2014-10-22 10:17:31 -0700163 *
Thomas Vachuska4b420772014-10-30 16:46:17 -0700164 * @return source transponder port
weibitf32383b2014-10-22 10:17:31 -0700165 */
166 public ConnectPoint getDst() {
167 return dst;
168 }
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +0900169
Marc De Leenheer8c2caac2015-05-28 16:37:33 -0700170 /**
171 * Returns the ODU signal type.
172 *
173 * @return ODU signal type
174 */
175 public OduSignalType getSignalType() {
176 return signalType;
177 }
178
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +0900179 @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 Leenheer8c2caac2015-05-28 16:37:33 -0700189 .add("signalType", signalType)
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +0900190 .toString();
191 }
weibitf32383b2014-10-22 10:17:31 -0700192}