Thomas Vachuska

Added normalization of HostToHost id fingerprint to allow host one/two to come in either order.

...@@ -17,26 +17,33 @@ public final class HostToHostIntent extends ConnectivityIntent { ...@@ -17,26 +17,33 @@ public final class HostToHostIntent extends ConnectivityIntent {
17 private final HostId two; 17 private final HostId two;
18 18
19 /** 19 /**
20 - * Creates a new point-to-point intent with the supplied ingress/egress 20 + * Creates a new host-to-host intent with the supplied host pair.
21 - * ports.
22 * 21 *
23 * @param appId application identifier 22 * @param appId application identifier
24 * @param one first host 23 * @param one first host
25 * @param two second host 24 * @param two second host
26 * @param selector action 25 * @param selector action
27 * @param treatment ingress port 26 * @param treatment ingress port
28 - * @throws NullPointerException if {@code ingressPort} or {@code egressPort} 27 + * @throws NullPointerException if {@code one} or {@code two} is null.
29 - * is null.
30 */ 28 */
31 public HostToHostIntent(ApplicationId appId, HostId one, HostId two, 29 public HostToHostIntent(ApplicationId appId, HostId one, HostId two,
32 TrafficSelector selector, 30 TrafficSelector selector,
33 TrafficTreatment treatment) { 31 TrafficTreatment treatment) {
34 - super(id(HostToHostIntent.class, one, two, selector, treatment), 32 + super(id(HostToHostIntent.class, min(one, two), max(one, two),
33 + selector, treatment),
35 appId, null, selector, treatment); 34 appId, null, selector, treatment);
36 this.one = checkNotNull(one); 35 this.one = checkNotNull(one);
37 this.two = checkNotNull(two); 36 this.two = checkNotNull(two);
38 } 37 }
39 38
39 + private static HostId min(HostId one, HostId two) {
40 + return one.hashCode() < two.hashCode() ? one : two;
41 + }
42 +
43 + private static HostId max(HostId one, HostId two) {
44 + return one.hashCode() > two.hashCode() ? one : two;
45 + }
46 +
40 /** 47 /**
41 * Returns identifier of the first host. 48 * Returns identifier of the first host.
42 * 49 *
......