Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -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; |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 4 | import org.onlab.onos.net.HostId; |
| 5 | import org.onlab.onos.net.flow.TrafficSelector; |
| 6 | import org.onlab.onos.net.flow.TrafficTreatment; |
| 7 | |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame^] | 8 | import java.util.Objects; |
| 9 | |
| 10 | import static com.google.common.base.Preconditions.checkNotNull; |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 11 | |
| 12 | /** |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame^] | 13 | * Abstraction of end-station to end-station connectivity. |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 14 | */ |
| 15 | public class HostToHostIntent extends ConnectivityIntent { |
| 16 | |
| 17 | private final HostId src; |
| 18 | private final HostId dst; |
| 19 | |
| 20 | /** |
| 21 | * Creates a new point-to-point intent with the supplied ingress/egress |
| 22 | * ports. |
| 23 | * |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame^] | 24 | * @param intentId intent identifier |
| 25 | * @param selector action |
| 26 | * @param treatment ingress port |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 27 | * @throws NullPointerException if {@code ingressPort} or {@code egressPort} |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame^] | 28 | * is null. |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 29 | */ |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame^] | 30 | public HostToHostIntent(IntentId intentId, HostId src, HostId dst, |
| 31 | TrafficSelector selector, TrafficTreatment treatment) { |
| 32 | super(intentId, selector, treatment); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 33 | this.src = checkNotNull(src); |
| 34 | this.dst = checkNotNull(dst); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Returns the port on which the ingress traffic should be connected to the |
| 39 | * egress. |
| 40 | * |
| 41 | * @return ingress port |
| 42 | */ |
| 43 | public HostId getSrc() { |
| 44 | return src; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Returns the port on which the traffic should egress. |
| 49 | * |
| 50 | * @return egress port |
| 51 | */ |
| 52 | public HostId getDst() { |
| 53 | return dst; |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public boolean equals(Object o) { |
| 58 | if (this == o) { |
| 59 | return true; |
| 60 | } |
| 61 | if (o == null || getClass() != o.getClass()) { |
| 62 | return false; |
| 63 | } |
| 64 | if (!super.equals(o)) { |
| 65 | return false; |
| 66 | } |
| 67 | |
| 68 | HostToHostIntent that = (HostToHostIntent) o; |
| 69 | return Objects.equals(this.src, that.src) |
| 70 | && Objects.equals(this.dst, that.dst); |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | public int hashCode() { |
| 75 | return Objects.hash(super.hashCode(), src, dst); |
| 76 | } |
| 77 | |
| 78 | @Override |
| 79 | public String toString() { |
| 80 | return MoreObjects.toStringHelper(getClass()) |
| 81 | .add("id", getId()) |
| 82 | .add("selector", getTrafficSelector()) |
| 83 | .add("treatmetn", getTrafficTreatment()) |
| 84 | .add("src", src) |
| 85 | .add("dst", dst) |
| 86 | .toString(); |
| 87 | } |
| 88 | |
| 89 | } |