From d03a56e02d2f26ac9a7e819d5aeffef5cbe978ed Mon Sep 17 00:00:00 2001 From: Thomas Vachuska Date: Tue, 21 Oct 2014 00:51:07 -0700 Subject: [PATCH] Added normalization of HostToHost id fingerprint to allow host one/two to come in either order. --- .../onlab/onos/net/intent/HostToHostIntent.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/HostToHostIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/HostToHostIntent.java index 92b148d121..7177d3f9d3 100644 --- a/core/api/src/main/java/org/onlab/onos/net/intent/HostToHostIntent.java +++ b/core/api/src/main/java/org/onlab/onos/net/intent/HostToHostIntent.java @@ -17,26 +17,33 @@ public final class HostToHostIntent extends ConnectivityIntent { private final HostId two; /** - * Creates a new point-to-point intent with the supplied ingress/egress - * ports. + * Creates a new host-to-host intent with the supplied host pair. * * @param appId application identifier * @param one first host * @param two second host * @param selector action * @param treatment ingress port - * @throws NullPointerException if {@code ingressPort} or {@code egressPort} - * is null. + * @throws NullPointerException if {@code one} or {@code two} is null. */ public HostToHostIntent(ApplicationId appId, HostId one, HostId two, TrafficSelector selector, TrafficTreatment treatment) { - super(id(HostToHostIntent.class, one, two, selector, treatment), + super(id(HostToHostIntent.class, min(one, two), max(one, two), + selector, treatment), appId, null, selector, treatment); this.one = checkNotNull(one); this.two = checkNotNull(two); } + private static HostId min(HostId one, HostId two) { + return one.hashCode() < two.hashCode() ? one : two; + } + + private static HostId max(HostId one, HostId two) { + return one.hashCode() > two.hashCode() ? one : two; + } + /** * Returns identifier of the first host. *