blob: f34b65de750820e2b839a4fee2fac044a4189e08 [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 */
Ray Milkey0742ec92014-10-13 08:39:55 -070016package org.onlab.onos.net.intent;
17
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
Thomas Vachuskae0f804a2014-10-27 23:40:48 -070021import org.onlab.onos.core.ApplicationId;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070022import org.onlab.onos.net.ConnectPoint;
Ray Milkey0742ec92014-10-13 08:39:55 -070023import org.onlab.onos.net.Link;
24import org.onlab.onos.net.flow.TrafficSelector;
25import org.onlab.onos.net.flow.TrafficTreatment;
26
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
Michele Santuari4a338072014-11-05 18:38:55 +010039 private final Set<ConnectPoint> egressPoints;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070040
Ray Milkey0742ec92014-10-13 08:39:55 -070041 /**
Michele Santuari4a338072014-11-05 18:38:55 +010042 * Creates a new actionable intent capable of funneling the selected traffic
43 * along the specified convergent tree and out the given egress point.
Ray Milkey0742ec92014-10-13 08:39:55 -070044 *
Thomas Vachuskac96058a2014-10-20 23:00:16 -070045 * @param appId application identifier
Ray Milkey0742ec92014-10-13 08:39:55 -070046 * @param selector traffic match
47 * @param treatment action
48 * @param links traversed links
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070049 * @param egressPoint egress point
Ray Milkey0742ec92014-10-13 08:39:55 -070050 * @throws NullPointerException {@code path} is null
51 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070052 public LinkCollectionIntent(ApplicationId appId,
Ray Milkey0742ec92014-10-13 08:39:55 -070053 TrafficSelector selector,
54 TrafficTreatment treatment,
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070055 Set<Link> links,
56 ConnectPoint egressPoint) {
Sho SHIMIZUc3df36b2014-11-11 18:19:29 -080057 this(appId, selector , treatment, links, egressPoint, Collections.emptyList());
Sho SHIMIZUac8f3522014-11-10 12:14:50 -080058 }
59
60 /**
61 * Creates a new actionable intent capable of funneling the selected
62 * traffic along the specified convergent tree and out the given egress point
63 * satisfying the specified constraints.
64 *
65 * @param appId application identifier
66 * @param selector traffic match
67 * @param treatment action
68 * @param links traversed links
69 * @param egressPoint egress point
70 * @param constraints optional list of constraints
71 * @throws NullPointerException {@code path} is null
72 */
73 public LinkCollectionIntent(ApplicationId appId,
74 TrafficSelector selector,
75 TrafficTreatment treatment,
76 Set<Link> links,
77 ConnectPoint egressPoint,
78 List<Constraint> constraints) {
Brian O'Connor520c0522014-11-23 23:50:47 -080079 super(appId, resources(links), selector, treatment, constraints);
Ray Milkey0742ec92014-10-13 08:39:55 -070080 this.links = links;
Michele Santuari4a338072014-11-05 18:38:55 +010081 this.egressPoints = ImmutableSet.of(egressPoint);
82 }
83
84 /**
85 * Creates a new actionable intent capable of funneling the selected traffic
86 * along the specified convergent tree and out the given egress point.
87 *
88 * @param appId application identifier
89 * @param selector traffic match
90 * @param treatment action
91 * @param links traversed links
92 * @param egressPoints Set of egress point
93 * @throws NullPointerException {@code path} is null
94 */
95 public LinkCollectionIntent(ApplicationId appId,
96 TrafficSelector selector,
97 TrafficTreatment treatment,
98 Set<Link> links,
99 Set<ConnectPoint> egressPoints,
100 List<Constraint> constraints) {
Brian O'Connor520c0522014-11-23 23:50:47 -0800101 super(appId, resources(links), selector, treatment);
Michele Santuari4a338072014-11-05 18:38:55 +0100102
103 this.links = links;
104 this.egressPoints = ImmutableSet.copyOf(egressPoints);
Ray Milkey0742ec92014-10-13 08:39:55 -0700105 }
106
Thomas Vachuskac96058a2014-10-20 23:00:16 -0700107 /**
108 * Constructor for serializer.
109 */
Ray Milkey0742ec92014-10-13 08:39:55 -0700110 protected LinkCollectionIntent() {
111 super();
112 this.links = null;
Michele Santuari4a338072014-11-05 18:38:55 +0100113 this.egressPoints = null;
Ray Milkey0742ec92014-10-13 08:39:55 -0700114 }
115
Ray Milkeye6684082014-10-16 16:59:47 -0700116 /**
117 * Returns the set of links that represent the network connections needed
118 * by this intent.
119 *
120 * @return Set of links for the network hops needed by this intent
121 */
Ray Milkey0742ec92014-10-13 08:39:55 -0700122 public Set<Link> links() {
123 return links;
124 }
125
Jonathan Hart6b2ffc32014-10-18 02:09:22 -0700126 /**
127 * Returns the egress point of the intent.
128 *
129 * @return the egress point
130 */
Michele Santuari4a338072014-11-05 18:38:55 +0100131 public Set<ConnectPoint> egressPoints() {
132 return egressPoints;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -0700133 }
134
Ray Milkey0742ec92014-10-13 08:39:55 -0700135 @Override
Thomas Vachuskac96058a2014-10-20 23:00:16 -0700136 public boolean isInstallable() {
137 return true;
Ray Milkey0742ec92014-10-13 08:39:55 -0700138 }
139
140 @Override
141 public String toString() {
142 return MoreObjects.toStringHelper(getClass())
143 .add("id", id())
Thomas Vachuskae291c842014-10-21 02:52:38 -0700144 .add("appId", appId())
145 .add("selector", selector())
146 .add("treatment", treatment())
Ray Milkey0742ec92014-10-13 08:39:55 -0700147 .add("links", links())
Michele Santuari4a338072014-11-05 18:38:55 +0100148 .add("egress", egressPoints())
Ray Milkey0742ec92014-10-13 08:39:55 -0700149 .toString();
150 }
151}