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; |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame^] | 4 | import org.onlab.onos.ApplicationId; |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 5 | import org.onlab.onos.net.HostId; |
| 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 | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 10 | |
| 11 | /** |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 12 | * Abstraction of end-station to end-station bidirectional connectivity. |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 13 | */ |
Ray Milkey | e668408 | 2014-10-16 16:59:47 -0700 | [diff] [blame] | 14 | public final class HostToHostIntent extends ConnectivityIntent { |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 15 | |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 16 | private final HostId one; |
| 17 | private final HostId two; |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -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 | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 24 | * @param one first host |
| 25 | * @param two second host |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 26 | * @param selector action |
| 27 | * @param treatment ingress port |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 28 | * @throws NullPointerException if {@code ingressPort} or {@code egressPort} |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 29 | * is null. |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 30 | */ |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame^] | 31 | public HostToHostIntent(ApplicationId appId, HostId one, HostId two, |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 32 | TrafficSelector selector, |
| 33 | TrafficTreatment treatment) { |
Thomas Vachuska | c96058a | 2014-10-20 23:00:16 -0700 | [diff] [blame^] | 34 | super(id(HostToHostIntent.class, one, two, selector, treatment), |
| 35 | appId, null, selector, treatment); |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 36 | this.one = checkNotNull(one); |
| 37 | this.two = checkNotNull(two); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | /** |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 41 | * Returns identifier of the first host. |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 42 | * |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 43 | * @return first host identifier |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 44 | */ |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 45 | public HostId one() { |
| 46 | return one; |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | /** |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 50 | * Returns identifier of the second host. |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 51 | * |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 52 | * @return second host identifier |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 53 | */ |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 54 | public HostId two() { |
| 55 | return two; |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | @Override |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 59 | public String toString() { |
| 60 | return MoreObjects.toStringHelper(getClass()) |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 61 | .add("id", id()) |
| 62 | .add("selector", selector()) |
| 63 | .add("treatment", treatment()) |
tom | f5c9d92 | 2014-10-03 15:22:03 -0700 | [diff] [blame] | 64 | .add("one", one) |
| 65 | .add("two", two) |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 66 | .toString(); |
| 67 | } |
| 68 | |
| 69 | } |