blob: c328a4e82e70f22e6f664b698e163ca707b15521 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
Ray Milkey0742ec92014-10-13 08:39:55 -070019package org.onlab.onos.net.intent;
20
Thomas Vachuskac96058a2014-10-20 23:00:16 -070021import com.google.common.base.MoreObjects;
Thomas Vachuskae0f804a2014-10-27 23:40:48 -070022import org.onlab.onos.core.ApplicationId;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070023import org.onlab.onos.net.ConnectPoint;
Ray Milkey0742ec92014-10-13 08:39:55 -070024import org.onlab.onos.net.Link;
25import org.onlab.onos.net.flow.TrafficSelector;
26import org.onlab.onos.net.flow.TrafficTreatment;
27
Thomas Vachuskac96058a2014-10-20 23:00:16 -070028import java.util.Set;
Ray Milkey0742ec92014-10-13 08:39:55 -070029
30/**
31 * Abstraction of a connectivity intent that is implemented by a set of path
32 * segments.
33 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070034public final class LinkCollectionIntent extends ConnectivityIntent {
Ray Milkey0742ec92014-10-13 08:39:55 -070035
36 private final Set<Link> links;
37
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070038 private final ConnectPoint egressPoint;
39
Ray Milkey0742ec92014-10-13 08:39:55 -070040 /**
Thomas Vachuska436c0762014-10-22 09:08:43 -070041 * Creates a new actionable intent capable of funneling the selected
42 * traffic along the specified convergent tree and out the given egress point.
Ray Milkey0742ec92014-10-13 08:39:55 -070043 *
Thomas Vachuskac96058a2014-10-20 23:00:16 -070044 * @param appId application identifier
Ray Milkey0742ec92014-10-13 08:39:55 -070045 * @param selector traffic match
46 * @param treatment action
47 * @param links traversed links
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070048 * @param egressPoint egress point
Ray Milkey0742ec92014-10-13 08:39:55 -070049 * @throws NullPointerException {@code path} is null
50 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070051 public LinkCollectionIntent(ApplicationId appId,
Ray Milkey0742ec92014-10-13 08:39:55 -070052 TrafficSelector selector,
53 TrafficTreatment treatment,
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070054 Set<Link> links,
55 ConnectPoint egressPoint) {
Thomas Vachuskac96058a2014-10-20 23:00:16 -070056 super(id(LinkCollectionIntent.class, selector, treatment, links, egressPoint),
57 appId, resources(links), selector, treatment);
Ray Milkey0742ec92014-10-13 08:39:55 -070058 this.links = links;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070059 this.egressPoint = egressPoint;
Ray Milkey0742ec92014-10-13 08:39:55 -070060 }
61
Thomas Vachuskac96058a2014-10-20 23:00:16 -070062 /**
63 * Constructor for serializer.
64 */
Ray Milkey0742ec92014-10-13 08:39:55 -070065 protected LinkCollectionIntent() {
66 super();
67 this.links = null;
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070068 this.egressPoint = null;
Ray Milkey0742ec92014-10-13 08:39:55 -070069 }
70
Ray Milkeye6684082014-10-16 16:59:47 -070071 /**
72 * Returns the set of links that represent the network connections needed
73 * by this intent.
74 *
75 * @return Set of links for the network hops needed by this intent
76 */
Ray Milkey0742ec92014-10-13 08:39:55 -070077 public Set<Link> links() {
78 return links;
79 }
80
Jonathan Hart6b2ffc32014-10-18 02:09:22 -070081 /**
82 * Returns the egress point of the intent.
83 *
84 * @return the egress point
85 */
86 public ConnectPoint egressPoint() {
87 return egressPoint;
88 }
89
Ray Milkey0742ec92014-10-13 08:39:55 -070090 @Override
Thomas Vachuskac96058a2014-10-20 23:00:16 -070091 public boolean isInstallable() {
92 return true;
Ray Milkey0742ec92014-10-13 08:39:55 -070093 }
94
95 @Override
96 public String toString() {
97 return MoreObjects.toStringHelper(getClass())
98 .add("id", id())
Thomas Vachuskae291c842014-10-21 02:52:38 -070099 .add("appId", appId())
100 .add("selector", selector())
101 .add("treatment", treatment())
Ray Milkey0742ec92014-10-13 08:39:55 -0700102 .add("links", links())
Jonathan Hart6b2ffc32014-10-18 02:09:22 -0700103 .add("egress", egressPoint())
Ray Milkey0742ec92014-10-13 08:39:55 -0700104 .toString();
105 }
106}