blob: 89403401149b33781ef3742f1569986a99fe9cff [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
Thomas Vachuskac96058a2014-10-20 23:00:16 -070025import java.util.Set;
Ray Milkey0742ec92014-10-13 08:39:55 -070026
27/**
28 * Abstraction of a connectivity intent that is implemented by a set of path
29 * segments.
30 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070031public final class LinkCollectionIntent extends ConnectivityIntent {
Ray Milkey0742ec92014-10-13 08:39:55 -070032
33 private final Set<Link> links;
34
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070035 private final ConnectPoint egressPoint;
36
Ray Milkey0742ec92014-10-13 08:39:55 -070037 /**
Thomas Vachuska436c0762014-10-22 09:08:43 -070038 * Creates a new actionable intent capable of funneling the selected
39 * traffic along the specified convergent tree and out the given egress point.
Ray Milkey0742ec92014-10-13 08:39:55 -070040 *
Thomas Vachuskac96058a2014-10-20 23:00:16 -070041 * @param appId application identifier
Ray Milkey0742ec92014-10-13 08:39:55 -070042 * @param selector traffic match
43 * @param treatment action
44 * @param links traversed links
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070045 * @param egressPoint egress point
Ray Milkey0742ec92014-10-13 08:39:55 -070046 * @throws NullPointerException {@code path} is null
47 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070048 public LinkCollectionIntent(ApplicationId appId,
Ray Milkey0742ec92014-10-13 08:39:55 -070049 TrafficSelector selector,
50 TrafficTreatment treatment,
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070051 Set<Link> links,
52 ConnectPoint egressPoint) {
Thomas Vachuskac96058a2014-10-20 23:00:16 -070053 super(id(LinkCollectionIntent.class, selector, treatment, links, egressPoint),
54 appId, resources(links), selector, treatment);
Ray Milkey0742ec92014-10-13 08:39:55 -070055 this.links = links;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070056 this.egressPoint = egressPoint;
Ray Milkey0742ec92014-10-13 08:39:55 -070057 }
58
Thomas Vachuskac96058a2014-10-20 23:00:16 -070059 /**
60 * Constructor for serializer.
61 */
Ray Milkey0742ec92014-10-13 08:39:55 -070062 protected LinkCollectionIntent() {
63 super();
64 this.links = null;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070065 this.egressPoint = null;
Ray Milkey0742ec92014-10-13 08:39:55 -070066 }
67
Ray Milkeye6684082014-10-16 16:59:47 -070068 /**
69 * Returns the set of links that represent the network connections needed
70 * by this intent.
71 *
72 * @return Set of links for the network hops needed by this intent
73 */
Ray Milkey0742ec92014-10-13 08:39:55 -070074 public Set<Link> links() {
75 return links;
76 }
77
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070078 /**
79 * Returns the egress point of the intent.
80 *
81 * @return the egress point
82 */
83 public ConnectPoint egressPoint() {
84 return egressPoint;
85 }
86
Ray Milkey0742ec92014-10-13 08:39:55 -070087 @Override
Thomas Vachuskac96058a2014-10-20 23:00:16 -070088 public boolean isInstallable() {
89 return true;
Ray Milkey0742ec92014-10-13 08:39:55 -070090 }
91
92 @Override
93 public String toString() {
94 return MoreObjects.toStringHelper(getClass())
95 .add("id", id())
Thomas Vachuskae291c842014-10-21 02:52:38 -070096 .add("appId", appId())
97 .add("selector", selector())
98 .add("treatment", treatment())
Ray Milkey0742ec92014-10-13 08:39:55 -070099 .add("links", links())
Jonathan Hart6b2ffc32014-10-18 02:09:22 -0700100 .add("egress", egressPoint())
Ray Milkey0742ec92014-10-13 08:39:55 -0700101 .toString();
102 }
103}