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