Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 4 | * 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 Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 8 | * 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 Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 15 | */ |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 16 | package org.onlab.onos.net.intent; |
| 17 | |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 18 | import com.google.common.base.MoreObjects; |
Thomas Vachuska | e0f804a | 2014-10-27 23:40:48 -0700 | [diff] [blame] | 19 | import org.onlab.onos.core.ApplicationId; |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 20 | import org.onlab.onos.net.ConnectPoint; |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 21 | import org.onlab.onos.net.Link; |
| 22 | import org.onlab.onos.net.flow.TrafficSelector; |
| 23 | import org.onlab.onos.net.flow.TrafficTreatment; |
| 24 | |
Sho SHIMIZU | ac8f352 | 2014-11-10 12:14:50 -0800 | [diff] [blame^] | 25 | import java.util.List; |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 26 | import java.util.Set; |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 27 | |
| 28 | /** |
| 29 | * Abstraction of a connectivity intent that is implemented by a set of path |
| 30 | * segments. |
| 31 | */ |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 32 | public final class LinkCollectionIntent extends ConnectivityIntent { |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 33 | |
| 34 | private final Set<Link> links; |
| 35 | |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 36 | private final ConnectPoint egressPoint; |
| 37 | |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 38 | /** |
Thomas Vachuska | 436c076 | 2014-10-22 09:08:43 -0700 | [diff] [blame] | 39 | * Creates a new actionable intent capable of funneling the selected |
| 40 | * traffic along the specified convergent tree and out the given egress point. |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 41 | * |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 42 | * @param appId application identifier |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 43 | * @param selector traffic match |
| 44 | * @param treatment action |
| 45 | * @param links traversed links |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 46 | * @param egressPoint egress point |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 47 | * @throws NullPointerException {@code path} is null |
| 48 | */ |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 49 | public LinkCollectionIntent(ApplicationId appId, |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 50 | TrafficSelector selector, |
| 51 | TrafficTreatment treatment, |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 52 | Set<Link> links, |
| 53 | ConnectPoint egressPoint) { |
Sho SHIMIZU | ac8f352 | 2014-11-10 12:14:50 -0800 | [diff] [blame^] | 54 | 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 Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 78 | this.links = links; |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 79 | this.egressPoint = egressPoint; |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 80 | } |
| 81 | |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 82 | /** |
| 83 | * Constructor for serializer. |
| 84 | */ |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 85 | protected LinkCollectionIntent() { |
| 86 | super(); |
| 87 | this.links = null; |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 88 | this.egressPoint = null; |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 89 | } |
| 90 | |
Ray Milkey | e668408 | 2014-10-16 16:59:47 -0700 | [diff] [blame] | 91 | /** |
| 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 Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 97 | public Set<Link> links() { |
| 98 | return links; |
| 99 | } |
| 100 | |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 101 | /** |
| 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 Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 110 | @Override |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 111 | public boolean isInstallable() { |
| 112 | return true; |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | @Override |
| 116 | public String toString() { |
| 117 | return MoreObjects.toStringHelper(getClass()) |
| 118 | .add("id", id()) |
Thomas Vachuska | e291c84 | 2014-10-21 02:52:38 -0700 | [diff] [blame] | 119 | .add("appId", appId()) |
| 120 | .add("selector", selector()) |
| 121 | .add("treatment", treatment()) |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 122 | .add("links", links()) |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 123 | .add("egress", egressPoint()) |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 124 | .toString(); |
| 125 | } |
| 126 | } |