blob: ce1f6b18fc9ea70ad3a0248eed4e0889f68fb9dc [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 SHIMIZUc3df36b2014-11-11 18:19:29 -080025import java.util.Collections;
Sho SHIMIZUac8f3522014-11-10 12:14:50 -080026import java.util.List;
Thomas Vachuskac96058a2014-10-20 23:00:16 -070027import java.util.Set;
Ray Milkey0742ec92014-10-13 08:39:55 -070028
29/**
30 * Abstraction of a connectivity intent that is implemented by a set of path
31 * segments.
32 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070033public final class LinkCollectionIntent extends ConnectivityIntent {
Ray Milkey0742ec92014-10-13 08:39:55 -070034
35 private final Set<Link> links;
36
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070037 private final ConnectPoint egressPoint;
38
Ray Milkey0742ec92014-10-13 08:39:55 -070039 /**
Thomas Vachuska436c0762014-10-22 09:08:43 -070040 * Creates a new actionable intent capable of funneling the selected
41 * traffic along the specified convergent tree and out the given egress point.
Ray Milkey0742ec92014-10-13 08:39:55 -070042 *
Thomas Vachuskac96058a2014-10-20 23:00:16 -070043 * @param appId application identifier
Ray Milkey0742ec92014-10-13 08:39:55 -070044 * @param selector traffic match
45 * @param treatment action
46 * @param links traversed links
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070047 * @param egressPoint egress point
Ray Milkey0742ec92014-10-13 08:39:55 -070048 * @throws NullPointerException {@code path} is null
49 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070050 public LinkCollectionIntent(ApplicationId appId,
Ray Milkey0742ec92014-10-13 08:39:55 -070051 TrafficSelector selector,
52 TrafficTreatment treatment,
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070053 Set<Link> links,
54 ConnectPoint egressPoint) {
Sho SHIMIZUc3df36b2014-11-11 18:19:29 -080055 this(appId, selector , treatment, links, egressPoint, Collections.emptyList());
Sho SHIMIZUac8f3522014-11-10 12:14:50 -080056 }
57
58 /**
59 * Creates a new actionable intent capable of funneling the selected
60 * traffic along the specified convergent tree and out the given egress point
61 * satisfying the specified constraints.
62 *
63 * @param appId application identifier
64 * @param selector traffic match
65 * @param treatment action
66 * @param links traversed links
67 * @param egressPoint egress point
68 * @param constraints optional list of constraints
69 * @throws NullPointerException {@code path} is null
70 */
71 public LinkCollectionIntent(ApplicationId appId,
72 TrafficSelector selector,
73 TrafficTreatment treatment,
74 Set<Link> links,
75 ConnectPoint egressPoint,
76 List<Constraint> constraints) {
77 super(id(LinkCollectionIntent.class, selector, treatment, links, egressPoint, constraints),
78 appId, resources(links), selector, treatment, constraints);
Ray Milkey0742ec92014-10-13 08:39:55 -070079 this.links = links;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070080 this.egressPoint = egressPoint;
Ray Milkey0742ec92014-10-13 08:39:55 -070081 }
82
Thomas Vachuskac96058a2014-10-20 23:00:16 -070083 /**
84 * Constructor for serializer.
85 */
Ray Milkey0742ec92014-10-13 08:39:55 -070086 protected LinkCollectionIntent() {
87 super();
88 this.links = null;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070089 this.egressPoint = null;
Ray Milkey0742ec92014-10-13 08:39:55 -070090 }
91
Ray Milkeye6684082014-10-16 16:59:47 -070092 /**
93 * Returns the set of links that represent the network connections needed
94 * by this intent.
95 *
96 * @return Set of links for the network hops needed by this intent
97 */
Ray Milkey0742ec92014-10-13 08:39:55 -070098 public Set<Link> links() {
99 return links;
100 }
101
Jonathan Hart6b2ffc32014-10-18 02:09:22 -0700102 /**
103 * Returns the egress point of the intent.
104 *
105 * @return the egress point
106 */
107 public ConnectPoint egressPoint() {
108 return egressPoint;
109 }
110
Ray Milkey0742ec92014-10-13 08:39:55 -0700111 @Override
Thomas Vachuskac96058a2014-10-20 23:00:16 -0700112 public boolean isInstallable() {
113 return true;
Ray Milkey0742ec92014-10-13 08:39:55 -0700114 }
115
116 @Override
117 public String toString() {
118 return MoreObjects.toStringHelper(getClass())
119 .add("id", id())
Thomas Vachuskae291c842014-10-21 02:52:38 -0700120 .add("appId", appId())
121 .add("selector", selector())
122 .add("treatment", treatment())
Ray Milkey0742ec92014-10-13 08:39:55 -0700123 .add("links", links())
Jonathan Hart6b2ffc32014-10-18 02:09:22 -0700124 .add("egress", egressPoint())
Ray Milkey0742ec92014-10-13 08:39:55 -0700125 .toString();
126 }
127}