blob: 3f87b7efcdff7466bde9d3232a4a3981744ea2d8 [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
Pavlin Radoslavov119fd5c2014-11-25 19:08:19 -080093 * @param constraints the constraints
Michele Santuari4a338072014-11-05 18:38:55 +010094 * @throws NullPointerException {@code path} is null
95 */
96 public LinkCollectionIntent(ApplicationId appId,
97 TrafficSelector selector,
98 TrafficTreatment treatment,
99 Set<Link> links,
100 Set<ConnectPoint> egressPoints,
101 List<Constraint> constraints) {
Brian O'Connor520c0522014-11-23 23:50:47 -0800102 super(appId, resources(links), selector, treatment);
Michele Santuari4a338072014-11-05 18:38:55 +0100103
104 this.links = links;
105 this.egressPoints = ImmutableSet.copyOf(egressPoints);
Ray Milkey0742ec92014-10-13 08:39:55 -0700106 }
107
Thomas Vachuskac96058a2014-10-20 23:00:16 -0700108 /**
109 * Constructor for serializer.
110 */
Ray Milkey0742ec92014-10-13 08:39:55 -0700111 protected LinkCollectionIntent() {
112 super();
113 this.links = null;
Michele Santuari4a338072014-11-05 18:38:55 +0100114 this.egressPoints = null;
Ray Milkey0742ec92014-10-13 08:39:55 -0700115 }
116
Ray Milkeye6684082014-10-16 16:59:47 -0700117 /**
118 * Returns the set of links that represent the network connections needed
119 * by this intent.
120 *
121 * @return Set of links for the network hops needed by this intent
122 */
Ray Milkey0742ec92014-10-13 08:39:55 -0700123 public Set<Link> links() {
124 return links;
125 }
126
Jonathan Hart6b2ffc32014-10-18 02:09:22 -0700127 /**
128 * Returns the egress point of the intent.
129 *
130 * @return the egress point
131 */
Michele Santuari4a338072014-11-05 18:38:55 +0100132 public Set<ConnectPoint> egressPoints() {
133 return egressPoints;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -0700134 }
135
Ray Milkey0742ec92014-10-13 08:39:55 -0700136 @Override
Thomas Vachuskac96058a2014-10-20 23:00:16 -0700137 public boolean isInstallable() {
138 return true;
Ray Milkey0742ec92014-10-13 08:39:55 -0700139 }
140
141 @Override
142 public String toString() {
143 return MoreObjects.toStringHelper(getClass())
144 .add("id", id())
Thomas Vachuskae291c842014-10-21 02:52:38 -0700145 .add("appId", appId())
146 .add("selector", selector())
147 .add("treatment", treatment())
Ray Milkey0742ec92014-10-13 08:39:55 -0700148 .add("links", links())
Michele Santuari4a338072014-11-05 18:38:55 +0100149 .add("egress", egressPoints())
Ray Milkey0742ec92014-10-13 08:39:55 -0700150 .toString();
151 }
152}