Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.intent; |
| 2 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 3 | import com.google.common.base.MoreObjects; |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 4 | import org.onlab.onos.ApplicationId; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 5 | import org.onlab.onos.net.ConnectPoint; |
| 6 | import org.onlab.onos.net.flow.TrafficSelector; |
| 7 | import org.onlab.onos.net.flow.TrafficTreatment; |
| 8 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 9 | import static com.google.common.base.Preconditions.checkNotNull; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 10 | |
| 11 | /** |
| 12 | * Abstraction of point-to-point connectivity. |
| 13 | */ |
| 14 | public class PointToPointIntent extends ConnectivityIntent { |
| 15 | |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 16 | private final ConnectPoint ingressPoint; |
| 17 | private final ConnectPoint egressPoint; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 18 | |
| 19 | /** |
| 20 | * Creates a new point-to-point intent with the supplied ingress/egress |
| 21 | * ports. |
| 22 | * |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 23 | * @param appId application identifier |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 24 | * @param selector traffic selector |
| 25 | * @param treatment treatment |
| 26 | * @param ingressPoint ingress port |
| 27 | * @param egressPoint egress port |
| 28 | * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null. |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 29 | */ |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 30 | public PointToPointIntent(ApplicationId appId, TrafficSelector selector, |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 31 | TrafficTreatment treatment, |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 32 | ConnectPoint ingressPoint, |
| 33 | ConnectPoint egressPoint) { |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame] | 34 | super(id(PointToPointIntent.class, selector, treatment, ingressPoint, egressPoint), |
| 35 | appId, null, selector, treatment); |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 36 | this.ingressPoint = checkNotNull(ingressPoint); |
| 37 | this.egressPoint = checkNotNull(egressPoint); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Constructor for serializer. |
| 42 | */ |
| 43 | protected PointToPointIntent() { |
| 44 | super(); |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 45 | this.ingressPoint = null; |
| 46 | this.egressPoint = null; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Returns the port on which the ingress traffic should be connected to |
| 51 | * the egress. |
| 52 | * |
| 53 | * @return ingress port |
| 54 | */ |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 55 | public ConnectPoint ingressPoint() { |
| 56 | return ingressPoint; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Returns the port on which the traffic should egress. |
| 61 | * |
| 62 | * @return egress port |
| 63 | */ |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 64 | public ConnectPoint egressPoint() { |
| 65 | return egressPoint; |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | @Override |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 69 | public String toString() { |
| 70 | return MoreObjects.toStringHelper(getClass()) |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 71 | .add("id", id()) |
| 72 | .add("match", selector()) |
| 73 | .add("action", treatment()) |
| 74 | .add("ingressPoint", ingressPoint) |
| 75 | .add("egressPoints", egressPoint) |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 76 | .toString(); |
| 77 | } |
| 78 | |
| 79 | } |