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 | |
Michele Santuari | 4a33807 | 2014-11-05 18:38:55 +0100 | [diff] [blame] | 39 | private final Set<ConnectPoint> egressPoints; |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 40 | |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 41 | /** |
Michele Santuari | 4a33807 | 2014-11-05 18:38:55 +0100 | [diff] [blame] | 42 | * Creates a new actionable intent capable of funneling the selected traffic |
| 43 | * along the specified convergent tree and out the given egress point. |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 44 | * |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 45 | * @param appId application identifier |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 46 | * @param selector traffic match |
| 47 | * @param treatment action |
| 48 | * @param links traversed links |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 49 | * @param egressPoint egress point |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 50 | * @throws NullPointerException {@code path} is null |
| 51 | */ |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 52 | public LinkCollectionIntent(ApplicationId appId, |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 53 | TrafficSelector selector, |
| 54 | TrafficTreatment treatment, |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 55 | Set<Link> links, |
| 56 | ConnectPoint egressPoint) { |
Jonathan Hart | ab17b27 | 2014-12-18 15:01:17 -0800 | [diff] [blame] | 57 | this(appId, selector, treatment, links, egressPoint, Collections.emptyList()); |
Sho SHIMIZU | ac8f352 | 2014-11-10 12:14:50 -0800 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Creates a new actionable intent capable of funneling the selected |
| 62 | * traffic along the specified convergent tree and out the given egress point |
| 63 | * satisfying the specified constraints. |
| 64 | * |
| 65 | * @param appId application identifier |
| 66 | * @param selector traffic match |
| 67 | * @param treatment action |
| 68 | * @param links traversed links |
| 69 | * @param egressPoint egress point |
| 70 | * @param constraints optional list of constraints |
| 71 | * @throws NullPointerException {@code path} is null |
| 72 | */ |
| 73 | public LinkCollectionIntent(ApplicationId appId, |
| 74 | TrafficSelector selector, |
| 75 | TrafficTreatment treatment, |
| 76 | Set<Link> links, |
| 77 | ConnectPoint egressPoint, |
| 78 | List<Constraint> constraints) { |
Brian O'Connor | 520c052 | 2014-11-23 23:50:47 -0800 | [diff] [blame] | 79 | super(appId, resources(links), selector, treatment, constraints); |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 80 | this.links = links; |
Michele Santuari | 4a33807 | 2014-11-05 18:38:55 +0100 | [diff] [blame] | 81 | this.egressPoints = ImmutableSet.of(egressPoint); |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Creates a new actionable intent capable of funneling the selected traffic |
| 86 | * along the specified convergent tree and out the given egress point. |
| 87 | * |
| 88 | * @param appId application identifier |
| 89 | * @param selector traffic match |
| 90 | * @param treatment action |
| 91 | * @param links traversed links |
| 92 | * @param egressPoints Set of egress point |
Pavlin Radoslavov | 119fd5c | 2014-11-25 19:08:19 -0800 | [diff] [blame] | 93 | * @param constraints the constraints |
Michele Santuari | 4a33807 | 2014-11-05 18:38:55 +0100 | [diff] [blame] | 94 | * @throws NullPointerException {@code path} is null |
| 95 | */ |
| 96 | public LinkCollectionIntent(ApplicationId appId, |
| 97 | TrafficSelector selector, |
| 98 | TrafficTreatment treatment, |
| 99 | Set<Link> links, |
| 100 | Set<ConnectPoint> egressPoints, |
| 101 | List<Constraint> constraints) { |
Brian O'Connor | 520c052 | 2014-11-23 23:50:47 -0800 | [diff] [blame] | 102 | super(appId, resources(links), selector, treatment); |
Michele Santuari | 4a33807 | 2014-11-05 18:38:55 +0100 | [diff] [blame] | 103 | |
| 104 | this.links = links; |
| 105 | this.egressPoints = ImmutableSet.copyOf(egressPoints); |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 108 | /** |
| 109 | * Constructor for serializer. |
| 110 | */ |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 111 | protected LinkCollectionIntent() { |
| 112 | super(); |
| 113 | this.links = null; |
Michele Santuari | 4a33807 | 2014-11-05 18:38:55 +0100 | [diff] [blame] | 114 | this.egressPoints = null; |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 115 | } |
| 116 | |
Ray Milkey | e668408 | 2014-10-16 16:59:47 -0700 | [diff] [blame] | 117 | /** |
| 118 | * Returns the set of links that represent the network connections needed |
| 119 | * by this intent. |
| 120 | * |
| 121 | * @return Set of links for the network hops needed by this intent |
| 122 | */ |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 123 | public Set<Link> links() { |
| 124 | return links; |
| 125 | } |
| 126 | |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 127 | /** |
| 128 | * Returns the egress point of the intent. |
| 129 | * |
| 130 | * @return the egress point |
| 131 | */ |
Michele Santuari | 4a33807 | 2014-11-05 18:38:55 +0100 | [diff] [blame] | 132 | public Set<ConnectPoint> egressPoints() { |
| 133 | return egressPoints; |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 134 | } |
| 135 | |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 136 | @Override |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 137 | public boolean isInstallable() { |
| 138 | return true; |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | @Override |
| 142 | public String toString() { |
| 143 | return MoreObjects.toStringHelper(getClass()) |
| 144 | .add("id", id()) |
Thomas Vachuska | e291c84 | 2014-10-21 02:52:38 -0700 | [diff] [blame] | 145 | .add("appId", appId()) |
| 146 | .add("selector", selector()) |
| 147 | .add("treatment", treatment()) |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 148 | .add("links", links()) |
Michele Santuari | 4a33807 | 2014-11-05 18:38:55 +0100 | [diff] [blame] | 149 | .add("egress", egressPoints()) |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 150 | .toString(); |
| 151 | } |
| 152 | } |