blob: 55c0cfbbdf0a5e2302920cf6ed78a208c30b2f82 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska83e090e2014-10-22 14:25:35 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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
Thomas Vachuska83e090e2014-10-22 14:25:35 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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.
Thomas Vachuska83e090e2014-10-22 14:25:35 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.intent;
Ray Milkey0742ec92014-10-13 08:39:55 -070017
Thomas Vachuskac96058a2014-10-20 23:00:16 -070018import com.google.common.base.MoreObjects;
Michele Santuari4a338072014-11-05 18:38:55 +010019import com.google.common.collect.ImmutableSet;
20
Brian O'Connorabafb502014-12-02 22:26:20 -080021import org.onosproject.core.ApplicationId;
22import org.onosproject.net.ConnectPoint;
23import org.onosproject.net.Link;
24import org.onosproject.net.flow.TrafficSelector;
25import org.onosproject.net.flow.TrafficTreatment;
Ray Milkey0742ec92014-10-13 08:39:55 -070026
Sho SHIMIZUc3df36b2014-11-11 18:19:29 -080027import java.util.Collections;
Sho SHIMIZUac8f3522014-11-10 12:14:50 -080028import java.util.List;
Thomas Vachuskac96058a2014-10-20 23:00:16 -070029import java.util.Set;
Ray Milkey0742ec92014-10-13 08:39:55 -070030
31/**
32 * Abstraction of a connectivity intent that is implemented by a set of path
33 * segments.
34 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070035public final class LinkCollectionIntent extends ConnectivityIntent {
Ray Milkey0742ec92014-10-13 08:39:55 -070036
37 private final Set<Link> links;
38
Pavlin Radoslavov2811c402015-02-25 14:30:17 -080039 private final Set<ConnectPoint> ingressPoints;
Michele Santuari4a338072014-11-05 18:38:55 +010040 private final Set<ConnectPoint> egressPoints;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070041
Ray Milkey0742ec92014-10-13 08:39:55 -070042 /**
Pavlin Radoslavov2811c402015-02-25 14:30:17 -080043 * Creates a new actionable intent capable of funneling the selected
44 * traffic along the specified convergent tree and out the given egress
45 * point.
Ray Milkey0742ec92014-10-13 08:39:55 -070046 *
Thomas Vachuskac96058a2014-10-20 23:00:16 -070047 * @param appId application identifier
Ray Milkey0742ec92014-10-13 08:39:55 -070048 * @param selector traffic match
49 * @param treatment action
50 * @param links traversed links
Pavlin Radoslavov2811c402015-02-25 14:30:17 -080051 * @param ingressPoint ingress point
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070052 * @param egressPoint egress point
Ray Milkey0742ec92014-10-13 08:39:55 -070053 * @throws NullPointerException {@code path} is null
54 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070055 public LinkCollectionIntent(ApplicationId appId,
Ray Milkey0742ec92014-10-13 08:39:55 -070056 TrafficSelector selector,
57 TrafficTreatment treatment,
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070058 Set<Link> links,
Pavlin Radoslavov2811c402015-02-25 14:30:17 -080059 ConnectPoint ingressPoint,
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070060 ConnectPoint egressPoint) {
Pavlin Radoslavov2811c402015-02-25 14:30:17 -080061 this(appId, selector, treatment, links, ingressPoint, egressPoint,
62 Collections.emptyList());
Sho SHIMIZUac8f3522014-11-10 12:14:50 -080063 }
64
65 /**
66 * Creates a new actionable intent capable of funneling the selected
Pavlin Radoslavov2811c402015-02-25 14:30:17 -080067 * traffic along the specified convergent tree and out the given egress
68 * point satisfying the specified constraints.
Sho SHIMIZUac8f3522014-11-10 12:14:50 -080069 *
70 * @param appId application identifier
71 * @param selector traffic match
72 * @param treatment action
73 * @param links traversed links
Pavlin Radoslavov2811c402015-02-25 14:30:17 -080074 * @param ingressPoint ingress point
Sho SHIMIZUac8f3522014-11-10 12:14:50 -080075 * @param egressPoint egress point
76 * @param constraints optional list of constraints
77 * @throws NullPointerException {@code path} is null
78 */
79 public LinkCollectionIntent(ApplicationId appId,
80 TrafficSelector selector,
81 TrafficTreatment treatment,
82 Set<Link> links,
Pavlin Radoslavov2811c402015-02-25 14:30:17 -080083 ConnectPoint ingressPoint,
Sho SHIMIZUac8f3522014-11-10 12:14:50 -080084 ConnectPoint egressPoint,
85 List<Constraint> constraints) {
Brian O'Connor520c0522014-11-23 23:50:47 -080086 super(appId, resources(links), selector, treatment, constraints);
Ray Milkey0742ec92014-10-13 08:39:55 -070087 this.links = links;
Pavlin Radoslavov2811c402015-02-25 14:30:17 -080088 this.ingressPoints = ImmutableSet.of(ingressPoint);
Michele Santuari4a338072014-11-05 18:38:55 +010089 this.egressPoints = ImmutableSet.of(egressPoint);
90 }
91
92 /**
Pavlin Radoslavov2811c402015-02-25 14:30:17 -080093 * Creates a new actionable intent capable of funneling the selected
94 * traffic along the specified convergent tree and out the given egress
95 * point.
Michele Santuari4a338072014-11-05 18:38:55 +010096 *
97 * @param appId application identifier
98 * @param selector traffic match
99 * @param treatment action
100 * @param links traversed links
Pavlin Radoslavov2811c402015-02-25 14:30:17 -0800101 * @param ingressPoints Set of ingress points
102 * @param egressPoints Set of egress points
Pavlin Radoslavov119fd5c2014-11-25 19:08:19 -0800103 * @param constraints the constraints
Michele Santuari4a338072014-11-05 18:38:55 +0100104 * @throws NullPointerException {@code path} is null
105 */
106 public LinkCollectionIntent(ApplicationId appId,
107 TrafficSelector selector,
108 TrafficTreatment treatment,
109 Set<Link> links,
Pavlin Radoslavov2811c402015-02-25 14:30:17 -0800110 Set<ConnectPoint> ingressPoints,
Michele Santuari4a338072014-11-05 18:38:55 +0100111 Set<ConnectPoint> egressPoints,
112 List<Constraint> constraints) {
Sho SHIMIZU16ea69b2015-01-19 18:13:09 -0800113 super(appId, resources(links), selector, treatment, constraints);
Michele Santuari4a338072014-11-05 18:38:55 +0100114
115 this.links = links;
Pavlin Radoslavov2811c402015-02-25 14:30:17 -0800116 this.ingressPoints = ImmutableSet.copyOf(ingressPoints);
Michele Santuari4a338072014-11-05 18:38:55 +0100117 this.egressPoints = ImmutableSet.copyOf(egressPoints);
Ray Milkey0742ec92014-10-13 08:39:55 -0700118 }
119
Thomas Vachuskac96058a2014-10-20 23:00:16 -0700120 /**
121 * Constructor for serializer.
122 */
Ray Milkey0742ec92014-10-13 08:39:55 -0700123 protected LinkCollectionIntent() {
124 super();
125 this.links = null;
Pavlin Radoslavov2811c402015-02-25 14:30:17 -0800126 this.ingressPoints = null;
Michele Santuari4a338072014-11-05 18:38:55 +0100127 this.egressPoints = null;
Ray Milkey0742ec92014-10-13 08:39:55 -0700128 }
129
Ray Milkeye6684082014-10-16 16:59:47 -0700130 /**
131 * Returns the set of links that represent the network connections needed
132 * by this intent.
133 *
134 * @return Set of links for the network hops needed by this intent
135 */
Ray Milkey0742ec92014-10-13 08:39:55 -0700136 public Set<Link> links() {
137 return links;
138 }
139
Jonathan Hart6b2ffc32014-10-18 02:09:22 -0700140 /**
Pavlin Radoslavov2811c402015-02-25 14:30:17 -0800141 * Returns the ingress points of the intent.
Jonathan Hart6b2ffc32014-10-18 02:09:22 -0700142 *
Pavlin Radoslavov2811c402015-02-25 14:30:17 -0800143 * @return the ingress points
144 */
145 public Set<ConnectPoint> ingressPoints() {
146 return ingressPoints;
147 }
148
149 /**
150 * Returns the egress points of the intent.
151 *
152 * @return the egress points
Jonathan Hart6b2ffc32014-10-18 02:09:22 -0700153 */
Michele Santuari4a338072014-11-05 18:38:55 +0100154 public Set<ConnectPoint> egressPoints() {
155 return egressPoints;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -0700156 }
157
Ray Milkey0742ec92014-10-13 08:39:55 -0700158 @Override
Thomas Vachuskac96058a2014-10-20 23:00:16 -0700159 public boolean isInstallable() {
160 return true;
Ray Milkey0742ec92014-10-13 08:39:55 -0700161 }
162
163 @Override
164 public String toString() {
165 return MoreObjects.toStringHelper(getClass())
166 .add("id", id())
Ray Milkeyc3573812015-02-09 09:18:34 -0800167 .add("key", key())
Thomas Vachuskae291c842014-10-21 02:52:38 -0700168 .add("appId", appId())
Jonathan Hart23b5a762015-01-26 14:47:33 -0800169 .add("resources", resources())
Thomas Vachuskae291c842014-10-21 02:52:38 -0700170 .add("selector", selector())
171 .add("treatment", treatment())
Ray Milkey0742ec92014-10-13 08:39:55 -0700172 .add("links", links())
Pavlin Radoslavov2811c402015-02-25 14:30:17 -0800173 .add("ingress", ingressPoints())
Michele Santuari4a338072014-11-05 18:38:55 +0100174 .add("egress", egressPoints())
Ray Milkey0742ec92014-10-13 08:39:55 -0700175 .toString();
176 }
177}