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