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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.intent; |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 17 | |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 18 | import com.google.common.base.MoreObjects; |
Michele Santuari | 4a33807 | 2014-11-05 18:38:55 +0100 | [diff] [blame] | 19 | import com.google.common.collect.ImmutableSet; |
| 20 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 21 | import org.onosproject.core.ApplicationId; |
| 22 | import org.onosproject.net.ConnectPoint; |
| 23 | import org.onosproject.net.Link; |
| 24 | import org.onosproject.net.flow.TrafficSelector; |
| 25 | import org.onosproject.net.flow.TrafficTreatment; |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 26 | |
Sho SHIMIZU | c3df36b | 2014-11-11 18:19:29 -0800 | [diff] [blame] | 27 | import java.util.Collections; |
Sho SHIMIZU | ac8f352 | 2014-11-10 12:14:50 -0800 | [diff] [blame] | 28 | import java.util.List; |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 29 | import java.util.Set; |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 30 | |
| 31 | /** |
| 32 | * Abstraction of a connectivity intent that is implemented by a set of path |
| 33 | * segments. |
| 34 | */ |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 35 | public final class LinkCollectionIntent extends ConnectivityIntent { |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 36 | |
| 37 | private final Set<Link> links; |
| 38 | |
Pavlin Radoslavov | 2811c40 | 2015-02-25 14:30:17 -0800 | [diff] [blame] | 39 | private final Set<ConnectPoint> ingressPoints; |
Michele Santuari | 4a33807 | 2014-11-05 18:38:55 +0100 | [diff] [blame] | 40 | private final Set<ConnectPoint> egressPoints; |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 41 | |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 42 | /** |
Pavlin Radoslavov | 2811c40 | 2015-02-25 14:30:17 -0800 | [diff] [blame] | 43 | * Creates a new actionable intent capable of funneling the selected |
| 44 | * traffic along the specified convergent tree and out the given egress |
| 45 | * point. |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 46 | * |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 47 | * @param appId application identifier |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 48 | * @param selector traffic match |
| 49 | * @param treatment action |
| 50 | * @param links traversed links |
Pavlin Radoslavov | 2811c40 | 2015-02-25 14:30:17 -0800 | [diff] [blame] | 51 | * @param ingressPoint ingress point |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 52 | * @param egressPoint egress point |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 53 | * @throws NullPointerException {@code path} is null |
| 54 | */ |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 55 | public LinkCollectionIntent(ApplicationId appId, |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 56 | TrafficSelector selector, |
| 57 | TrafficTreatment treatment, |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 58 | Set<Link> links, |
Pavlin Radoslavov | 2811c40 | 2015-02-25 14:30:17 -0800 | [diff] [blame] | 59 | ConnectPoint ingressPoint, |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 60 | ConnectPoint egressPoint) { |
Pavlin Radoslavov | 2811c40 | 2015-02-25 14:30:17 -0800 | [diff] [blame] | 61 | this(appId, selector, treatment, links, ingressPoint, egressPoint, |
Ray Milkey | c24cde3 | 2015-03-10 18:20:18 -0700 | [diff] [blame^] | 62 | Collections.emptyList(), DEFAULT_INTENT_PRIORITY); |
Sho SHIMIZU | ac8f352 | 2014-11-10 12:14:50 -0800 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Creates a new actionable intent capable of funneling the selected |
Pavlin Radoslavov | 2811c40 | 2015-02-25 14:30:17 -0800 | [diff] [blame] | 67 | * traffic along the specified convergent tree and out the given egress |
| 68 | * point satisfying the specified constraints. |
Sho SHIMIZU | ac8f352 | 2014-11-10 12:14:50 -0800 | [diff] [blame] | 69 | * |
| 70 | * @param appId application identifier |
| 71 | * @param selector traffic match |
| 72 | * @param treatment action |
| 73 | * @param links traversed links |
Pavlin Radoslavov | 2811c40 | 2015-02-25 14:30:17 -0800 | [diff] [blame] | 74 | * @param ingressPoint ingress point |
Sho SHIMIZU | ac8f352 | 2014-11-10 12:14:50 -0800 | [diff] [blame] | 75 | * @param egressPoint egress point |
| 76 | * @param constraints optional list of constraints |
Ray Milkey | c24cde3 | 2015-03-10 18:20:18 -0700 | [diff] [blame^] | 77 | * @param priority priority to use for the flows generated by this intent |
Sho SHIMIZU | ac8f352 | 2014-11-10 12:14:50 -0800 | [diff] [blame] | 78 | * @throws NullPointerException {@code path} is null |
| 79 | */ |
| 80 | public LinkCollectionIntent(ApplicationId appId, |
| 81 | TrafficSelector selector, |
| 82 | TrafficTreatment treatment, |
| 83 | Set<Link> links, |
Pavlin Radoslavov | 2811c40 | 2015-02-25 14:30:17 -0800 | [diff] [blame] | 84 | ConnectPoint ingressPoint, |
Sho SHIMIZU | ac8f352 | 2014-11-10 12:14:50 -0800 | [diff] [blame] | 85 | ConnectPoint egressPoint, |
Ray Milkey | c24cde3 | 2015-03-10 18:20:18 -0700 | [diff] [blame^] | 86 | List<Constraint> constraints, |
| 87 | int priority) { |
| 88 | super(appId, resources(links), selector, treatment, constraints, priority); |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 89 | this.links = links; |
Pavlin Radoslavov | 2811c40 | 2015-02-25 14:30:17 -0800 | [diff] [blame] | 90 | this.ingressPoints = ImmutableSet.of(ingressPoint); |
Michele Santuari | 4a33807 | 2014-11-05 18:38:55 +0100 | [diff] [blame] | 91 | this.egressPoints = ImmutableSet.of(egressPoint); |
| 92 | } |
| 93 | |
| 94 | /** |
Pavlin Radoslavov | 2811c40 | 2015-02-25 14:30:17 -0800 | [diff] [blame] | 95 | * Creates a new actionable intent capable of funneling the selected |
| 96 | * traffic along the specified convergent tree and out the given egress |
| 97 | * point. |
Michele Santuari | 4a33807 | 2014-11-05 18:38:55 +0100 | [diff] [blame] | 98 | * |
| 99 | * @param appId application identifier |
| 100 | * @param selector traffic match |
| 101 | * @param treatment action |
| 102 | * @param links traversed links |
Pavlin Radoslavov | 2811c40 | 2015-02-25 14:30:17 -0800 | [diff] [blame] | 103 | * @param ingressPoints Set of ingress points |
| 104 | * @param egressPoints Set of egress points |
Pavlin Radoslavov | 119fd5c | 2014-11-25 19:08:19 -0800 | [diff] [blame] | 105 | * @param constraints the constraints |
Ray Milkey | c24cde3 | 2015-03-10 18:20:18 -0700 | [diff] [blame^] | 106 | * @param priority priority to use for the flows generated by this intent |
Michele Santuari | 4a33807 | 2014-11-05 18:38:55 +0100 | [diff] [blame] | 107 | * @throws NullPointerException {@code path} is null |
| 108 | */ |
| 109 | public LinkCollectionIntent(ApplicationId appId, |
| 110 | TrafficSelector selector, |
| 111 | TrafficTreatment treatment, |
| 112 | Set<Link> links, |
Pavlin Radoslavov | 2811c40 | 2015-02-25 14:30:17 -0800 | [diff] [blame] | 113 | Set<ConnectPoint> ingressPoints, |
Michele Santuari | 4a33807 | 2014-11-05 18:38:55 +0100 | [diff] [blame] | 114 | Set<ConnectPoint> egressPoints, |
Ray Milkey | c24cde3 | 2015-03-10 18:20:18 -0700 | [diff] [blame^] | 115 | List<Constraint> constraints, |
| 116 | int priority) { |
| 117 | super(appId, resources(links), selector, treatment, constraints, priority); |
Michele Santuari | 4a33807 | 2014-11-05 18:38:55 +0100 | [diff] [blame] | 118 | |
| 119 | this.links = links; |
Pavlin Radoslavov | 2811c40 | 2015-02-25 14:30:17 -0800 | [diff] [blame] | 120 | this.ingressPoints = ImmutableSet.copyOf(ingressPoints); |
Michele Santuari | 4a33807 | 2014-11-05 18:38:55 +0100 | [diff] [blame] | 121 | this.egressPoints = ImmutableSet.copyOf(egressPoints); |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 122 | } |
| 123 | |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 124 | /** |
| 125 | * Constructor for serializer. |
| 126 | */ |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 127 | protected LinkCollectionIntent() { |
| 128 | super(); |
| 129 | this.links = null; |
Pavlin Radoslavov | 2811c40 | 2015-02-25 14:30:17 -0800 | [diff] [blame] | 130 | this.ingressPoints = null; |
Michele Santuari | 4a33807 | 2014-11-05 18:38:55 +0100 | [diff] [blame] | 131 | this.egressPoints = null; |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 132 | } |
| 133 | |
Ray Milkey | e668408 | 2014-10-16 16:59:47 -0700 | [diff] [blame] | 134 | /** |
| 135 | * Returns the set of links that represent the network connections needed |
| 136 | * by this intent. |
| 137 | * |
| 138 | * @return Set of links for the network hops needed by this intent |
| 139 | */ |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 140 | public Set<Link> links() { |
| 141 | return links; |
| 142 | } |
| 143 | |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 144 | /** |
Pavlin Radoslavov | 2811c40 | 2015-02-25 14:30:17 -0800 | [diff] [blame] | 145 | * Returns the ingress points of the intent. |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 146 | * |
Pavlin Radoslavov | 2811c40 | 2015-02-25 14:30:17 -0800 | [diff] [blame] | 147 | * @return the ingress points |
| 148 | */ |
| 149 | public Set<ConnectPoint> ingressPoints() { |
| 150 | return ingressPoints; |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * Returns the egress points of the intent. |
| 155 | * |
| 156 | * @return the egress points |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 157 | */ |
Michele Santuari | 4a33807 | 2014-11-05 18:38:55 +0100 | [diff] [blame] | 158 | public Set<ConnectPoint> egressPoints() { |
| 159 | return egressPoints; |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 160 | } |
| 161 | |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 162 | @Override |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 163 | public boolean isInstallable() { |
| 164 | return true; |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | @Override |
| 168 | public String toString() { |
| 169 | return MoreObjects.toStringHelper(getClass()) |
| 170 | .add("id", id()) |
Ray Milkey | c357381 | 2015-02-09 09:18:34 -0800 | [diff] [blame] | 171 | .add("key", key()) |
Thomas Vachuska | e291c84 | 2014-10-21 02:52:38 -0700 | [diff] [blame] | 172 | .add("appId", appId()) |
Ray Milkey | c24cde3 | 2015-03-10 18:20:18 -0700 | [diff] [blame^] | 173 | .add("priority", priority()) |
Jonathan Hart | 23b5a76 | 2015-01-26 14:47:33 -0800 | [diff] [blame] | 174 | .add("resources", resources()) |
Thomas Vachuska | e291c84 | 2014-10-21 02:52:38 -0700 | [diff] [blame] | 175 | .add("selector", selector()) |
| 176 | .add("treatment", treatment()) |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 177 | .add("links", links()) |
Pavlin Radoslavov | 2811c40 | 2015-02-25 14:30:17 -0800 | [diff] [blame] | 178 | .add("ingress", ingressPoints()) |
Michele Santuari | 4a33807 | 2014-11-05 18:38:55 +0100 | [diff] [blame] | 179 | .add("egress", egressPoints()) |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 180 | .toString(); |
| 181 | } |
| 182 | } |