changing event posting to not post from compute.

This will probably have to change once we understand
how the mcastrib will be used.

Change-Id: Iebc2654732d1429b574c20830817d0f112249ada
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/mcast/impl/MulticastData.java b/incubator/net/src/main/java/org/onosproject/incubator/net/mcast/impl/MulticastData.java
index 1fb673e..946d8c6 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/mcast/impl/MulticastData.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/mcast/impl/MulticastData.java
@@ -22,6 +22,8 @@
 import java.util.Collections;
 import java.util.List;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * Simple entity maintaining a mapping between a source and a collection of sink
  * connect points.
@@ -30,25 +32,30 @@
 
     private final ConnectPoint source;
     private final List<ConnectPoint> sinks;
+    private final boolean isEmpty;
 
     private MulticastData() {
         this.source = null;
         this.sinks = Collections.EMPTY_LIST;
+        isEmpty = true;
     }
 
     public MulticastData(ConnectPoint source, List<ConnectPoint> sinks) {
-        this.source = source;
-        this.sinks = sinks;
+        this.source = checkNotNull(source, "Multicast source cannot be null.");
+        this.sinks = checkNotNull(sinks, "List of sinks cannot be null.");
+        isEmpty = false;
     }
 
     public MulticastData(ConnectPoint source, ConnectPoint sink) {
-        this.source = source;
-        this.sinks = Lists.newArrayList(sink);
+        this.source = checkNotNull(source, "Multicast source cannot be null.");
+        this.sinks = Lists.newArrayList(checkNotNull(sink, "Sink cannot be null."));
+        isEmpty = false;
     }
 
     public MulticastData(ConnectPoint source) {
-        this.source = source;
+        this.source = checkNotNull(source, "Multicast source cannot be null.");
         this.sinks = Lists.newArrayList();
+        isEmpty = false;
     }
 
     public ConnectPoint source() {
@@ -68,7 +75,7 @@
     }
 
     public boolean isEmpty() {
-        return source == null && sinks.size() == 0;
+        return isEmpty;
     }
 
     public static MulticastData empty() {
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/mcast/impl/MulticastRouteManager.java b/incubator/net/src/main/java/org/onosproject/incubator/net/mcast/impl/MulticastRouteManager.java
index 713383f..f73dfe4 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/mcast/impl/MulticastRouteManager.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/mcast/impl/MulticastRouteManager.java
@@ -38,6 +38,7 @@
 import org.slf4j.Logger;
 
 import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
 
 import static org.slf4j.LoggerFactory.getLogger;
 
@@ -123,28 +124,38 @@
 
     @Override
     public void addSink(McastRoute route, ConnectPoint connectPoint) {
-         mcastRoutes.compute(route, (k, v) -> {
+        AtomicReference<ConnectPoint> source = new AtomicReference<>();
+        mcastRoutes.compute(route, (k, v) -> {
             if (!v.isEmpty()) {
                 v.appendSink(connectPoint);
-                post(new McastEvent(McastEvent.Type.SINK_ADDED, route,
-                                    connectPoint, v.source()));
+                source.set(v.source());
             } else {
                 log.warn("Route {} does not exist");
             }
             return v;
         });
+
+        if (source.get() != null) {
+            post(new McastEvent(McastEvent.Type.SINK_ADDED, route,
+                                connectPoint, source.get()));
+        }
     }
 
 
     @Override
     public void removeSink(McastRoute route, ConnectPoint connectPoint) {
+        AtomicReference<ConnectPoint> source = new AtomicReference<>();
         mcastRoutes.compute(route, (k, v) -> {
             if (v.removeSink(connectPoint)) {
-                post(new McastEvent(McastEvent.Type.SINK_REMOVED, route,
-                                    connectPoint, v.source()));
+                source.set(v.source());
             }
             return v;
         });
+
+        if (source.get() != null) {
+            post(new McastEvent(McastEvent.Type.SINK_REMOVED, route,
+                                connectPoint, source.get()));
+        }
     }
 
     @Override