blob: 1290a344a584b61d05f619f715c1392f9593e968 [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
Brian O'Connorabafb502014-12-02 22:26:20 -080018import org.onosproject.core.ApplicationId;
19import org.onosproject.net.ConnectPoint;
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070020import org.onosproject.net.OchSignal;
Marc De Leenheerd24420f2015-05-27 09:40:59 -070021import org.onosproject.net.OchSignalType;
Brian O'Connorabafb502014-12-02 22:26:20 -080022import org.onosproject.net.Path;
weibitf32383b2014-10-22 10:17:31 -070023
Ray Milkeye076c792015-03-24 09:38:30 -070024import com.google.common.base.MoreObjects;
25import com.google.common.collect.ImmutableSet;
weibitf32383b2014-10-22 10:17:31 -070026
Ray Milkeyebc5d222015-03-18 15:45:36 -070027import static com.google.common.base.Preconditions.checkNotNull;
28
Ray Milkeybd4f0112015-03-02 17:07:09 -080029public final class OpticalPathIntent extends Intent {
Brian O'Connor086724e2014-10-23 15:47:32 -070030
31 private final ConnectPoint src;
32 private final ConnectPoint dst;
weibitf32383b2014-10-22 10:17:31 -070033 private final Path path;
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070034 private final OchSignal lambda;
Marc De Leenheerd24420f2015-05-27 09:40:59 -070035 private final OchSignalType signalType;
weibitf32383b2014-10-22 10:17:31 -070036
Ray Milkeye076c792015-03-24 09:38:30 -070037 private OpticalPathIntent(ApplicationId appId,
38 Key key,
39 ConnectPoint src,
40 ConnectPoint dst,
41 Path path,
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070042 OchSignal lambda,
Marc De Leenheerd24420f2015-05-27 09:40:59 -070043 OchSignalType signalType,
Ray Milkeye076c792015-03-24 09:38:30 -070044 int priority) {
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070045 super(appId, key, ImmutableSet.copyOf(path.links()), priority);
Ray Milkeyebc5d222015-03-18 15:45:36 -070046 this.src = checkNotNull(src);
47 this.dst = checkNotNull(dst);
48 this.path = checkNotNull(path);
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070049 this.lambda = checkNotNull(lambda);
Marc De Leenheerd24420f2015-05-27 09:40:59 -070050 this.signalType = checkNotNull(signalType);
weibitf32383b2014-10-22 10:17:31 -070051 }
52
weibit9e622ac2014-10-23 13:45:44 -070053 protected OpticalPathIntent() {
Brian O'Connor086724e2014-10-23 15:47:32 -070054 this.src = null;
55 this.dst = null;
weibitf32383b2014-10-22 10:17:31 -070056 this.path = null;
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070057 this.lambda = null;
Marc De Leenheerd24420f2015-05-27 09:40:59 -070058 this.signalType = null;
weibitf32383b2014-10-22 10:17:31 -070059 }
60
Ray Milkeye076c792015-03-24 09:38:30 -070061 /**
62 * Returns a new optical connectivity intent builder.
63 *
64 * @return host to host intent builder
65 */
66 public static Builder builder() {
67 return new Builder();
68 }
69
70
71 /**
72 * Builder for optical path intents.
73 */
74 public static class Builder extends Intent.Builder {
75 private ConnectPoint src;
76 private ConnectPoint dst;
77 private Path path;
Marc De Leenheer1afa2a02015-05-13 09:18:07 -070078 private OchSignal lambda;
Marc De Leenheerd24420f2015-05-27 09:40:59 -070079 private OchSignalType signalType;
Ray Milkeye076c792015-03-24 09:38:30 -070080 Key key;
81
82 @Override
83 public Builder appId(ApplicationId appId) {
84 return (Builder) super.appId(appId);
85 }
86
87 @Override
88 public Builder key(Key key) {
89 return (Builder) super.key(key);
90 }
91
92 @Override
93 public Builder priority(int priority) {
94 return (Builder) super.priority(priority);
95 }
96
97 /**
98 * Sets the source for the intent that will be built.
99 *
100 * @param src source to use for built intent
101 * @return this builder
102 */
103 public Builder src(ConnectPoint src) {
104 this.src = src;
105 return this;
106 }
107
108 /**
109 * Sets the destination for the intent that will be built.
110 *
111 * @param dst dest to use for built intent
112 * @return this builder
113 */
114 public Builder dst(ConnectPoint dst) {
115 this.dst = dst;
116 return this;
117 }
118
119 /**
120 * Sets the path for the intent that will be built.
121 *
122 * @param path path to use for built intent
123 * @return this builder
124 */
125 public Builder path(Path path) {
126 this.path = path;
127 return this;
128 }
129
130 /**
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700131 * Sets the optical channel (lambda) for the intent that will be built.
132 *
133 * @param lambda the optical channel
134 * @return this builder
135 */
136 public Builder lambda(OchSignal lambda) {
137 this.lambda = lambda;
138 return this;
139 }
140
141 /**
Marc De Leenheerd24420f2015-05-27 09:40:59 -0700142 * Sets the optical signal type for the intent that will be built.
143 *
144 * @param signalType the optical signal type
145 * @return this builder
146 */
147 public Builder signalType(OchSignalType signalType) {
148 this.signalType = signalType;
149 return this;
150 }
151
152 /**
Ray Milkeye076c792015-03-24 09:38:30 -0700153 * Builds an optical path intent from the accumulated parameters.
154 *
155 * @return optical path intent
156 */
157 public OpticalPathIntent build() {
158
159 return new OpticalPathIntent(
160 appId,
161 key,
162 src,
163 dst,
164 path,
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700165 lambda,
Marc De Leenheerd24420f2015-05-27 09:40:59 -0700166 signalType,
Ray Milkeye076c792015-03-24 09:38:30 -0700167 priority
168 );
169 }
170 }
171
172
Brian O'Connor086724e2014-10-23 15:47:32 -0700173 public ConnectPoint src() {
174 return src;
175 }
176
177 public ConnectPoint dst() {
178 return dst;
179 }
180
weibitf32383b2014-10-22 10:17:31 -0700181 public Path path() {
182 return path;
183 }
weibitf32383b2014-10-22 10:17:31 -0700184
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700185 public OchSignal lambda() {
186 return lambda;
187 }
188
Marc De Leenheerd24420f2015-05-27 09:40:59 -0700189 public OchSignalType signalType() {
190 return signalType;
191 }
192
weibitf32383b2014-10-22 10:17:31 -0700193 @Override
weibitf32383b2014-10-22 10:17:31 -0700194 public String toString() {
195 return MoreObjects.toStringHelper(getClass())
196 .add("id", id())
Jonathan Hart23b5a762015-01-26 14:47:33 -0800197 .add("appId", appId())
Ray Milkeyebc5d222015-03-18 15:45:36 -0700198 .add("key", key())
Jonathan Hart23b5a762015-01-26 14:47:33 -0800199 .add("resources", resources())
Brian O'Connor086724e2014-10-23 15:47:32 -0700200 .add("ingressPort", src)
201 .add("egressPort", dst)
weibitf32383b2014-10-22 10:17:31 -0700202 .add("path", path)
Marc De Leenheer1afa2a02015-05-13 09:18:07 -0700203 .add("lambda", lambda)
Marc De Leenheerd24420f2015-05-27 09:40:59 -0700204 .add("signalType", signalType)
weibitf32383b2014-10-22 10:17:31 -0700205 .toString();
206 }
weibitf32383b2014-10-22 10:17:31 -0700207}