blob: 6b48b00a1d2e91ab228ee5c01dd3e4cea7613dd9 [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;
weibitf32383b2014-10-22 10:17:31 -070021
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +090022import java.util.Collections;
23
Ray Milkeye076c792015-03-24 09:38:30 -070024import static com.google.common.base.Preconditions.checkNotNull;
Sho SHIMIZUd7d18002015-01-21 14:37:14 -080025
weibitf32383b2014-10-22 10:17:31 -070026/**
Jonathan Hartc9d76732014-11-18 10:52:20 -080027 * An optical layer intent for connectivity from one transponder port to another
28 * transponder port. No traffic selector or traffic treatment are needed.
weibitf32383b2014-10-22 10:17:31 -070029 */
Ray Milkeybd4f0112015-03-02 17:07:09 -080030public final class OpticalConnectivityIntent extends Intent {
31 private final ConnectPoint src;
32 private final ConnectPoint dst;
weibitf32383b2014-10-22 10:17:31 -070033
34 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -070035 * Creates an optical connectivity intent between the specified
36 * connection points.
weibitf32383b2014-10-22 10:17:31 -070037 *
Thomas Vachuska4b420772014-10-30 16:46:17 -070038 * @param appId application identification
Ray Milkey5b3717e2015-02-05 11:44:08 -080039 * @param key intent key
40 * @param src the source transponder port
41 * @param dst the destination transponder port
Ray Milkey22083ae2015-03-25 13:02:07 -070042 * @param priority priority to use for flows from this intent
Ray Milkey5b3717e2015-02-05 11:44:08 -080043 */
Ray Milkeye076c792015-03-24 09:38:30 -070044 protected OpticalConnectivityIntent(ApplicationId appId,
Ray Milkey5b3717e2015-02-05 11:44:08 -080045 Key key,
Ray Milkeye076c792015-03-24 09:38:30 -070046 ConnectPoint src,
47 ConnectPoint dst,
48 int priority) {
49 super(appId, key, Collections.emptyList(), priority);
50 this.src = checkNotNull(src);
51 this.dst = checkNotNull(dst);
weibitf32383b2014-10-22 10:17:31 -070052 }
53
Ray Milkeye076c792015-03-24 09:38:30 -070054 /**
55 * Returns a new optical connectivity intent builder.
56 *
57 * @return host to host intent builder
58 */
59 public static Builder builder() {
60 return new Builder();
61 }
62
63
64 /**
65 * Builder for optical connectivity intents.
66 */
67 public static class Builder extends Intent.Builder {
68 private ConnectPoint src;
69 private ConnectPoint dst;
70
71 @Override
72 public Builder appId(ApplicationId appId) {
73 return (Builder) super.appId(appId);
74 }
75
76 @Override
77 public Builder key(Key key) {
78 return (Builder) super.key(key);
79 }
80
81 @Override
82 public Builder priority(int priority) {
83 return (Builder) super.priority(priority);
84 }
85
86 /**
87 * Sets the source for the intent that will be built.
88 *
89 * @param src source to use for built intent
90 * @return this builder
91 */
92 public Builder src(ConnectPoint src) {
93 this.src = src;
94 return this;
95 }
96
97 /**
98 * Sets the destination for the intent that will be built.
99 *
100 * @param dst dest to use for built intent
101 * @return this builder
102 */
103 public Builder dst(ConnectPoint dst) {
104 this.dst = dst;
105 return this;
106 }
107
108 /**
109 * Builds an optical connectivity intent from the accumulated parameters.
110 *
111 * @return point to point intent
112 */
113 public OpticalConnectivityIntent build() {
114
115 return new OpticalConnectivityIntent(
116 appId,
117 key,
118 src,
119 dst,
120 priority
121 );
122 }
123 }
Ray Milkey5b3717e2015-02-05 11:44:08 -0800124
weibitf32383b2014-10-22 10:17:31 -0700125 /**
126 * Constructor for serializer.
127 */
128 protected OpticalConnectivityIntent() {
129 super();
130 this.src = null;
131 this.dst = null;
132 }
133
134 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -0700135 * Returns the source transponder port.
weibitf32383b2014-10-22 10:17:31 -0700136 *
Thomas Vachuska4b420772014-10-30 16:46:17 -0700137 * @return source transponder port
weibitf32383b2014-10-22 10:17:31 -0700138 */
Jonathan Hartc9d76732014-11-18 10:52:20 -0800139 public ConnectPoint getSrc() {
weibitf32383b2014-10-22 10:17:31 -0700140 return src;
141 }
142
143 /**
Thomas Vachuska4b420772014-10-30 16:46:17 -0700144 * Returns the destination transponder port.
weibitf32383b2014-10-22 10:17:31 -0700145 *
Thomas Vachuska4b420772014-10-30 16:46:17 -0700146 * @return source transponder port
weibitf32383b2014-10-22 10:17:31 -0700147 */
148 public ConnectPoint getDst() {
149 return dst;
150 }
Sho SHIMIZUf1fa96c2015-04-22 15:21:53 +0900151
152 @Override
153 public String toString() {
154 return MoreObjects.toStringHelper(this)
155 .add("id", id())
156 .add("key", key())
157 .add("appId", appId())
158 .add("priority", priority())
159 .add("resources", resources())
160 .add("src", src)
161 .add("dst", dst)
162 .toString();
163 }
weibitf32383b2014-10-22 10:17:31 -0700164}