blob: 17451cbaaa30e00780f700f03d4f59390fa6aefa [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,
Ray Milkeyc24cde32015-03-10 18:20:18 -070062 Collections.emptyList(), DEFAULT_INTENT_PRIORITY);
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
Ray Milkeyc24cde32015-03-10 18:20:18 -070077 * @param priority priority to use for the flows generated by this intent
Sho SHIMIZUac8f3522014-11-10 12:14:50 -080078 * @throws NullPointerException {@code path} is null
79 */
80 public LinkCollectionIntent(ApplicationId appId,
81 TrafficSelector selector,
82 TrafficTreatment treatment,
83 Set<Link> links,
Pavlin Radoslavov2811c402015-02-25 14:30:17 -080084 ConnectPoint ingressPoint,
Sho SHIMIZUac8f3522014-11-10 12:14:50 -080085 ConnectPoint egressPoint,
Ray Milkeyc24cde32015-03-10 18:20:18 -070086 List<Constraint> constraints,
87 int priority) {
88 super(appId, resources(links), selector, treatment, constraints, priority);
Ray Milkey0742ec92014-10-13 08:39:55 -070089 this.links = links;
Pavlin Radoslavov2811c402015-02-25 14:30:17 -080090 this.ingressPoints = ImmutableSet.of(ingressPoint);
Michele Santuari4a338072014-11-05 18:38:55 +010091 this.egressPoints = ImmutableSet.of(egressPoint);
92 }
93
94 /**
Pavlin Radoslavov2811c402015-02-25 14:30:17 -080095 * Creates a new actionable intent capable of funneling the selected
96 * traffic along the specified convergent tree and out the given egress
97 * point.
Michele Santuari4a338072014-11-05 18:38:55 +010098 *
99 * @param appId application identifier
100 * @param selector traffic match
101 * @param treatment action
102 * @param links traversed links
Pavlin Radoslavov2811c402015-02-25 14:30:17 -0800103 * @param ingressPoints Set of ingress points
104 * @param egressPoints Set of egress points
Pavlin Radoslavov119fd5c2014-11-25 19:08:19 -0800105 * @param constraints the constraints
Ray Milkeyc24cde32015-03-10 18:20:18 -0700106 * @param priority priority to use for the flows generated by this intent
Michele Santuari4a338072014-11-05 18:38:55 +0100107 * @throws NullPointerException {@code path} is null
108 */
109 public LinkCollectionIntent(ApplicationId appId,
110 TrafficSelector selector,
111 TrafficTreatment treatment,
112 Set<Link> links,
Pavlin Radoslavov2811c402015-02-25 14:30:17 -0800113 Set<ConnectPoint> ingressPoints,
Michele Santuari4a338072014-11-05 18:38:55 +0100114 Set<ConnectPoint> egressPoints,
Ray Milkeyc24cde32015-03-10 18:20:18 -0700115 List<Constraint> constraints,
116 int priority) {
117 super(appId, resources(links), selector, treatment, constraints, priority);
Michele Santuari4a338072014-11-05 18:38:55 +0100118
119 this.links = links;
Pavlin Radoslavov2811c402015-02-25 14:30:17 -0800120 this.ingressPoints = ImmutableSet.copyOf(ingressPoints);
Michele Santuari4a338072014-11-05 18:38:55 +0100121 this.egressPoints = ImmutableSet.copyOf(egressPoints);
Ray Milkey0742ec92014-10-13 08:39:55 -0700122 }
123
Thomas Vachuskac96058a2014-10-20 23:00:16 -0700124 /**
125 * Constructor for serializer.
126 */
Ray Milkey0742ec92014-10-13 08:39:55 -0700127 protected LinkCollectionIntent() {
128 super();
129 this.links = null;
Pavlin Radoslavov2811c402015-02-25 14:30:17 -0800130 this.ingressPoints = null;
Michele Santuari4a338072014-11-05 18:38:55 +0100131 this.egressPoints = null;
Ray Milkey0742ec92014-10-13 08:39:55 -0700132 }
133
Ray Milkeye6684082014-10-16 16:59:47 -0700134 /**
135 * Returns the set of links that represent the network connections needed
136 * by this intent.
137 *
138 * @return Set of links for the network hops needed by this intent
139 */
Ray Milkey0742ec92014-10-13 08:39:55 -0700140 public Set<Link> links() {
141 return links;
142 }
143
Jonathan Hart6b2ffc32014-10-18 02:09:22 -0700144 /**
Pavlin Radoslavov2811c402015-02-25 14:30:17 -0800145 * Returns the ingress points of the intent.
Jonathan Hart6b2ffc32014-10-18 02:09:22 -0700146 *
Pavlin Radoslavov2811c402015-02-25 14:30:17 -0800147 * @return the ingress points
148 */
149 public Set<ConnectPoint> ingressPoints() {
150 return ingressPoints;
151 }
152
153 /**
154 * Returns the egress points of the intent.
155 *
156 * @return the egress points
Jonathan Hart6b2ffc32014-10-18 02:09:22 -0700157 */
Michele Santuari4a338072014-11-05 18:38:55 +0100158 public Set<ConnectPoint> egressPoints() {
159 return egressPoints;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -0700160 }
161
Ray Milkey0742ec92014-10-13 08:39:55 -0700162 @Override
Thomas Vachuskac96058a2014-10-20 23:00:16 -0700163 public boolean isInstallable() {
164 return true;
Ray Milkey0742ec92014-10-13 08:39:55 -0700165 }
166
167 @Override
168 public String toString() {
169 return MoreObjects.toStringHelper(getClass())
170 .add("id", id())
Ray Milkeyc3573812015-02-09 09:18:34 -0800171 .add("key", key())
Thomas Vachuskae291c842014-10-21 02:52:38 -0700172 .add("appId", appId())
Ray Milkeyc24cde32015-03-10 18:20:18 -0700173 .add("priority", priority())
Jonathan Hart23b5a762015-01-26 14:47:33 -0800174 .add("resources", resources())
Thomas Vachuskae291c842014-10-21 02:52:38 -0700175 .add("selector", selector())
176 .add("treatment", treatment())
Ray Milkey0742ec92014-10-13 08:39:55 -0700177 .add("links", links())
Pavlin Radoslavov2811c402015-02-25 14:30:17 -0800178 .add("ingress", ingressPoints())
Michele Santuari4a338072014-11-05 18:38:55 +0100179 .add("egress", egressPoints())
Ray Milkey0742ec92014-10-13 08:39:55 -0700180 .toString();
181 }
182}