blob: 7a19613e4d0159873bc53df41e105b567a7ad1b0 [file] [log] [blame]
Ray Milkey0742ec92014-10-13 08:39:55 -07001package org.onlab.onos.net.intent;
2
Thomas Vachuskac96058a2014-10-20 23:00:16 -07003import com.google.common.base.MoreObjects;
4import org.onlab.onos.ApplicationId;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -07005import org.onlab.onos.net.ConnectPoint;
Ray Milkey0742ec92014-10-13 08:39:55 -07006import org.onlab.onos.net.Link;
7import org.onlab.onos.net.flow.TrafficSelector;
8import org.onlab.onos.net.flow.TrafficTreatment;
9
Thomas Vachuskac96058a2014-10-20 23:00:16 -070010import java.util.Set;
Ray Milkey0742ec92014-10-13 08:39:55 -070011
12/**
13 * Abstraction of a connectivity intent that is implemented by a set of path
14 * segments.
15 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070016public final class LinkCollectionIntent extends ConnectivityIntent {
Ray Milkey0742ec92014-10-13 08:39:55 -070017
18 private final Set<Link> links;
19
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070020 private final ConnectPoint egressPoint;
21
Ray Milkey0742ec92014-10-13 08:39:55 -070022 /**
23 * Creates a new point-to-point intent with the supplied ingress/egress
24 * ports and using the specified explicit path.
25 *
Thomas Vachuskac96058a2014-10-20 23:00:16 -070026 * @param appId application identifier
Ray Milkey0742ec92014-10-13 08:39:55 -070027 * @param selector traffic match
28 * @param treatment action
29 * @param links traversed links
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070030 * @param egressPoint egress point
Ray Milkey0742ec92014-10-13 08:39:55 -070031 * @throws NullPointerException {@code path} is null
32 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070033 public LinkCollectionIntent(ApplicationId appId,
Ray Milkey0742ec92014-10-13 08:39:55 -070034 TrafficSelector selector,
35 TrafficTreatment treatment,
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070036 Set<Link> links,
37 ConnectPoint egressPoint) {
Thomas Vachuskac96058a2014-10-20 23:00:16 -070038 super(id(LinkCollectionIntent.class, selector, treatment, links, egressPoint),
39 appId, resources(links), selector, treatment);
Ray Milkey0742ec92014-10-13 08:39:55 -070040 this.links = links;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070041 this.egressPoint = egressPoint;
Ray Milkey0742ec92014-10-13 08:39:55 -070042 }
43
Thomas Vachuskac96058a2014-10-20 23:00:16 -070044 /**
45 * Constructor for serializer.
46 */
Ray Milkey0742ec92014-10-13 08:39:55 -070047 protected LinkCollectionIntent() {
48 super();
49 this.links = null;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070050 this.egressPoint = null;
Ray Milkey0742ec92014-10-13 08:39:55 -070051 }
52
Ray Milkeye6684082014-10-16 16:59:47 -070053 /**
54 * Returns the set of links that represent the network connections needed
55 * by this intent.
56 *
57 * @return Set of links for the network hops needed by this intent
58 */
Ray Milkey0742ec92014-10-13 08:39:55 -070059 public Set<Link> links() {
60 return links;
61 }
62
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070063 /**
64 * Returns the egress point of the intent.
65 *
66 * @return the egress point
67 */
68 public ConnectPoint egressPoint() {
69 return egressPoint;
70 }
71
Ray Milkey0742ec92014-10-13 08:39:55 -070072 @Override
Thomas Vachuskac96058a2014-10-20 23:00:16 -070073 public boolean isInstallable() {
74 return true;
Ray Milkey0742ec92014-10-13 08:39:55 -070075 }
76
77 @Override
78 public String toString() {
79 return MoreObjects.toStringHelper(getClass())
80 .add("id", id())
81 .add("match", selector())
82 .add("action", treatment())
83 .add("links", links())
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070084 .add("egress", egressPoint())
Ray Milkey0742ec92014-10-13 08:39:55 -070085 .toString();
86 }
87}