Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
| 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 Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 19 | package org.onlab.onos.net.intent; |
| 20 | |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 21 | import com.google.common.base.MoreObjects; |
Thomas Vachuska | e0f804a | 2014-10-27 23:40:48 -0700 | [diff] [blame^] | 22 | import org.onlab.onos.core.ApplicationId; |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 23 | import org.onlab.onos.net.ConnectPoint; |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 24 | import org.onlab.onos.net.Link; |
| 25 | import org.onlab.onos.net.flow.TrafficSelector; |
| 26 | import org.onlab.onos.net.flow.TrafficTreatment; |
| 27 | |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 28 | import java.util.Set; |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 29 | |
| 30 | /** |
| 31 | * Abstraction of a connectivity intent that is implemented by a set of path |
| 32 | * segments. |
| 33 | */ |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 34 | public final class LinkCollectionIntent extends ConnectivityIntent { |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 35 | |
| 36 | private final Set<Link> links; |
| 37 | |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 38 | private final ConnectPoint egressPoint; |
| 39 | |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 40 | /** |
Thomas Vachuska | 436c076 | 2014-10-22 09:08:43 -0700 | [diff] [blame] | 41 | * Creates a new actionable intent capable of funneling the selected |
| 42 | * traffic along the specified convergent tree and out the given egress point. |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 43 | * |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 44 | * @param appId application identifier |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 45 | * @param selector traffic match |
| 46 | * @param treatment action |
| 47 | * @param links traversed links |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 48 | * @param egressPoint egress point |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 49 | * @throws NullPointerException {@code path} is null |
| 50 | */ |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 51 | public LinkCollectionIntent(ApplicationId appId, |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 52 | TrafficSelector selector, |
| 53 | TrafficTreatment treatment, |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 54 | Set<Link> links, |
| 55 | ConnectPoint egressPoint) { |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 56 | super(id(LinkCollectionIntent.class, selector, treatment, links, egressPoint), |
| 57 | appId, resources(links), selector, treatment); |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 58 | this.links = links; |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 59 | this.egressPoint = egressPoint; |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 60 | } |
| 61 | |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 62 | /** |
| 63 | * Constructor for serializer. |
| 64 | */ |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 65 | protected LinkCollectionIntent() { |
| 66 | super(); |
| 67 | this.links = null; |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 68 | this.egressPoint = null; |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 69 | } |
| 70 | |
Ray Milkey | e668408 | 2014-10-16 16:59:47 -0700 | [diff] [blame] | 71 | /** |
| 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 Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 77 | public Set<Link> links() { |
| 78 | return links; |
| 79 | } |
| 80 | |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 81 | /** |
| 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 Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 90 | @Override |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 91 | public boolean isInstallable() { |
| 92 | return true; |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | @Override |
| 96 | public String toString() { |
| 97 | return MoreObjects.toStringHelper(getClass()) |
| 98 | .add("id", id()) |
Thomas Vachuska | e291c84 | 2014-10-21 02:52:38 -0700 | [diff] [blame] | 99 | .add("appId", appId()) |
| 100 | .add("selector", selector()) |
| 101 | .add("treatment", treatment()) |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 102 | .add("links", links()) |
Jonathan Hart | 6b2ffc3 | 2014-10-18 02:09:22 -0700 | [diff] [blame] | 103 | .add("egress", egressPoint()) |
Ray Milkey | 0742ec9 | 2014-10-13 08:39:55 -0700 | [diff] [blame] | 104 | .toString(); |
| 105 | } |
| 106 | } |