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 | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 16 | package org.onlab.onos.net.intent; |
| 17 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 18 | import com.google.common.base.MoreObjects; |
Thomas Vachuska | edc944c | 2014-11-04 15:42:25 -0800 | [diff] [blame] | 19 | import com.google.common.collect.ImmutableList; |
Thomas Vachuska | e0f804a | 2014-10-27 23:40:48 -0700 | [diff] [blame] | 20 | import org.onlab.onos.core.ApplicationId; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 21 | import org.onlab.onos.net.ConnectPoint; |
Thomas Vachuska | edc944c | 2014-11-04 15:42:25 -0800 | [diff] [blame] | 22 | import org.onlab.onos.net.Link; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 23 | import org.onlab.onos.net.flow.TrafficSelector; |
| 24 | import org.onlab.onos.net.flow.TrafficTreatment; |
Thomas Vachuska | edc944c | 2014-11-04 15:42:25 -0800 | [diff] [blame] | 25 | import org.onlab.onos.net.intent.constraint.LinkTypeConstraint; |
| 26 | |
| 27 | import java.util.List; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 28 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 29 | import static com.google.common.base.Preconditions.checkNotNull; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 30 | |
| 31 | /** |
| 32 | * Abstraction of point-to-point connectivity. |
| 33 | */ |
| 34 | public class PointToPointIntent extends ConnectivityIntent { |
| 35 | |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 36 | private final ConnectPoint ingressPoint; |
| 37 | private final ConnectPoint egressPoint; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * Creates a new point-to-point intent with the supplied ingress/egress |
Thomas Vachuska | edc944c | 2014-11-04 15:42:25 -0800 | [diff] [blame] | 41 | * ports and with built-in link type constraint to avoid optical links. |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 42 | * |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 43 | * @param appId application identifier |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 44 | * @param selector traffic selector |
| 45 | * @param treatment treatment |
| 46 | * @param ingressPoint ingress port |
| 47 | * @param egressPoint egress port |
| 48 | * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null. |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 49 | */ |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 50 | public PointToPointIntent(ApplicationId appId, TrafficSelector selector, |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 51 | TrafficTreatment treatment, |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 52 | ConnectPoint ingressPoint, |
| 53 | ConnectPoint egressPoint) { |
Thomas Vachuska | edc944c | 2014-11-04 15:42:25 -0800 | [diff] [blame] | 54 | this(appId, selector, treatment, ingressPoint, egressPoint, |
| 55 | ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL))); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Creates a new point-to-point intent with the supplied ingress/egress |
| 60 | * ports and constraints. |
| 61 | * |
| 62 | * @param appId application identifier |
| 63 | * @param selector traffic selector |
| 64 | * @param treatment treatment |
| 65 | * @param ingressPoint ingress port |
| 66 | * @param egressPoint egress port |
| 67 | * @param constraints optional list of constraints |
| 68 | * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null. |
| 69 | */ |
| 70 | public PointToPointIntent(ApplicationId appId, TrafficSelector selector, |
| 71 | TrafficTreatment treatment, |
| 72 | ConnectPoint ingressPoint, |
| 73 | ConnectPoint egressPoint, |
| 74 | List<Constraint> constraints) { |
| 75 | super(id(PointToPointIntent.class, selector, treatment, |
| 76 | ingressPoint, egressPoint, constraints), |
| 77 | appId, null, selector, treatment, constraints); |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 78 | this.ingressPoint = checkNotNull(ingressPoint); |
| 79 | this.egressPoint = checkNotNull(egressPoint); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Constructor for serializer. |
| 84 | */ |
| 85 | protected PointToPointIntent() { |
| 86 | super(); |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 87 | this.ingressPoint = null; |
| 88 | this.egressPoint = null; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Returns the port on which the ingress traffic should be connected to |
| 93 | * the egress. |
| 94 | * |
| 95 | * @return ingress port |
| 96 | */ |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 97 | public ConnectPoint ingressPoint() { |
| 98 | return ingressPoint; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Returns the port on which the traffic should egress. |
| 103 | * |
| 104 | * @return egress port |
| 105 | */ |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 106 | public ConnectPoint egressPoint() { |
| 107 | return egressPoint; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | @Override |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 111 | public String toString() { |
| 112 | return MoreObjects.toStringHelper(getClass()) |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 113 | .add("id", id()) |
Thomas Vachuska | e291c84 | 2014-10-21 02:52:38 -0700 | [diff] [blame] | 114 | .add("appId", appId()) |
| 115 | .add("selector", selector()) |
| 116 | .add("treatment", treatment()) |
| 117 | .add("ingress", ingressPoint) |
| 118 | .add("egress", egressPoint) |
Thomas Vachuska | edc944c | 2014-11-04 15:42:25 -0800 | [diff] [blame] | 119 | .add("constraints", constraints()) |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 120 | .toString(); |
| 121 | } |
| 122 | |
| 123 | } |