blob: b4fdcfb8c8ec69d430c89709d0fa5d8721ab665e [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;
Thomas Vachuskae0f804a2014-10-27 23:40:48 -070019import org.onlab.onos.core.ApplicationId;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070020import org.onlab.onos.net.ConnectPoint;
Ray Milkey0742ec92014-10-13 08:39:55 -070021import org.onlab.onos.net.Link;
22import org.onlab.onos.net.flow.TrafficSelector;
23import org.onlab.onos.net.flow.TrafficTreatment;
24
Sho SHIMIZUac8f3522014-11-10 12:14:50 -080025import java.util.List;
Thomas Vachuskac96058a2014-10-20 23:00:16 -070026import java.util.Set;
Ray Milkey0742ec92014-10-13 08:39:55 -070027
28/**
29 * Abstraction of a connectivity intent that is implemented by a set of path
30 * segments.
31 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070032public final class LinkCollectionIntent extends ConnectivityIntent {
Ray Milkey0742ec92014-10-13 08:39:55 -070033
34 private final Set<Link> links;
35
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070036 private final ConnectPoint egressPoint;
37
Ray Milkey0742ec92014-10-13 08:39:55 -070038 /**
Thomas Vachuska436c0762014-10-22 09:08:43 -070039 * Creates a new actionable intent capable of funneling the selected
40 * traffic along the specified convergent tree and out the given egress point.
Ray Milkey0742ec92014-10-13 08:39:55 -070041 *
Thomas Vachuskac96058a2014-10-20 23:00:16 -070042 * @param appId application identifier
Ray Milkey0742ec92014-10-13 08:39:55 -070043 * @param selector traffic match
44 * @param treatment action
45 * @param links traversed links
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070046 * @param egressPoint egress point
Ray Milkey0742ec92014-10-13 08:39:55 -070047 * @throws NullPointerException {@code path} is null
48 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070049 public LinkCollectionIntent(ApplicationId appId,
Ray Milkey0742ec92014-10-13 08:39:55 -070050 TrafficSelector selector,
51 TrafficTreatment treatment,
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070052 Set<Link> links,
53 ConnectPoint egressPoint) {
Sho SHIMIZUac8f3522014-11-10 12:14:50 -080054 this(appId, selector , treatment, links, egressPoint, null);
55 }
56
57 /**
58 * Creates a new actionable intent capable of funneling the selected
59 * traffic along the specified convergent tree and out the given egress point
60 * satisfying the specified constraints.
61 *
62 * @param appId application identifier
63 * @param selector traffic match
64 * @param treatment action
65 * @param links traversed links
66 * @param egressPoint egress point
67 * @param constraints optional list of constraints
68 * @throws NullPointerException {@code path} is null
69 */
70 public LinkCollectionIntent(ApplicationId appId,
71 TrafficSelector selector,
72 TrafficTreatment treatment,
73 Set<Link> links,
74 ConnectPoint egressPoint,
75 List<Constraint> constraints) {
76 super(id(LinkCollectionIntent.class, selector, treatment, links, egressPoint, constraints),
77 appId, resources(links), selector, treatment, constraints);
Ray Milkey0742ec92014-10-13 08:39:55 -070078 this.links = links;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070079 this.egressPoint = egressPoint;
Ray Milkey0742ec92014-10-13 08:39:55 -070080 }
81
Thomas Vachuskac96058a2014-10-20 23:00:16 -070082 /**
83 * Constructor for serializer.
84 */
Ray Milkey0742ec92014-10-13 08:39:55 -070085 protected LinkCollectionIntent() {
86 super();
87 this.links = null;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070088 this.egressPoint = null;
Ray Milkey0742ec92014-10-13 08:39:55 -070089 }
90
Ray Milkeye6684082014-10-16 16:59:47 -070091 /**
92 * Returns the set of links that represent the network connections needed
93 * by this intent.
94 *
95 * @return Set of links for the network hops needed by this intent
96 */
Ray Milkey0742ec92014-10-13 08:39:55 -070097 public Set<Link> links() {
98 return links;
99 }
100
Jonathan Hart6b2ffc32014-10-18 02:09:22 -0700101 /**
102 * Returns the egress point of the intent.
103 *
104 * @return the egress point
105 */
106 public ConnectPoint egressPoint() {
107 return egressPoint;
108 }
109
Ray Milkey0742ec92014-10-13 08:39:55 -0700110 @Override
Thomas Vachuskac96058a2014-10-20 23:00:16 -0700111 public boolean isInstallable() {
112 return true;
Ray Milkey0742ec92014-10-13 08:39:55 -0700113 }
114
115 @Override
116 public String toString() {
117 return MoreObjects.toStringHelper(getClass())
118 .add("id", id())
Thomas Vachuskae291c842014-10-21 02:52:38 -0700119 .add("appId", appId())
120 .add("selector", selector())
121 .add("treatment", treatment())
Ray Milkey0742ec92014-10-13 08:39:55 -0700122 .add("links", links())
Jonathan Hart6b2ffc32014-10-18 02:09:22 -0700123 .add("egress", egressPoint())
Ray Milkey0742ec92014-10-13 08:39:55 -0700124 .toString();
125 }
126}