[CORD-2834] Handling of dual-homed sinks
Includes also McastUtils to move some code out of the McastHandler
Change-Id: I101637ee600c9d524f17e9f3fc29d63256844956
diff --git a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastCacheKey.java b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastCacheKey.java
index b0875ca..930432d 100644
--- a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastCacheKey.java
+++ b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/mcast/McastCacheKey.java
@@ -18,6 +18,7 @@
import org.onlab.packet.IpAddress;
import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.HostId;
import java.util.Objects;
@@ -31,6 +32,8 @@
class McastCacheKey {
// The group ip
private final IpAddress mcastIp;
+ // The sink id
+ private final HostId sinkHost;
// The sink connect point
private final ConnectPoint sink;
@@ -39,6 +42,8 @@
*
* @param mcastIp multicast group IP address
* @param sink connect point of the sink
+ *
+ * @deprecated in 1.12 ("Magpie") release.
*/
public McastCacheKey(IpAddress mcastIp, ConnectPoint sink) {
checkNotNull(mcastIp, "mcastIp cannot be null");
@@ -46,6 +51,22 @@
checkArgument(mcastIp.isMulticast(), "mcastIp must be a multicast address");
this.mcastIp = mcastIp;
this.sink = sink;
+ this.sinkHost = null;
+ }
+
+ /**
+ * Constructs a key for multicast event cache.
+ *
+ * @param mcastIp multicast group IP address
+ * @param hostId id of the sink
+ */
+ public McastCacheKey(IpAddress mcastIp, HostId hostId) {
+ checkNotNull(mcastIp, "mcastIp cannot be null");
+ checkNotNull(hostId, "sink cannot be null");
+ checkArgument(mcastIp.isMulticast(), "mcastIp must be a multicast address");
+ this.mcastIp = mcastIp;
+ this.sinkHost = hostId;
+ this.sink = null;
}
/**
@@ -61,11 +82,22 @@
* Returns the sink of this key.
*
* @return connect point of the sink
+ *
+ * @deprecated in 1.12 ("Magpie") release.
*/
public ConnectPoint sink() {
return sink;
}
+ /**
+ * Returns the sink of this key.
+ *
+ * @return host id of the sink
+ */
+ public HostId sinkHost() {
+ return sinkHost;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -77,7 +109,8 @@
McastCacheKey that =
(McastCacheKey) o;
return (Objects.equals(this.mcastIp, that.mcastIp) &&
- Objects.equals(this.sink, that.sink));
+ Objects.equals(this.sink, that.sink) &&
+ Objects.equals(this.sinkHost, that.sinkHost));
}
@Override
@@ -90,6 +123,7 @@
return toStringHelper(getClass())
.add("mcastIp", mcastIp)
.add("sink", sink)
+ .add("sinkHost", sinkHost)
.toString();
}
}