Adding linkVanished to NullLinkProvider when topology changes
ONOS-1287 Change-Id: Iffd19723be4c5b88dd0e3025d729ba2cc3f3faa8
Showing
1 changed file
with
12 additions
and
6 deletions
| ... | @@ -19,7 +19,6 @@ import com.google.common.collect.HashMultimap; | ... | @@ -19,7 +19,6 @@ import com.google.common.collect.HashMultimap; |
| 19 | import com.google.common.collect.Lists; | 19 | import com.google.common.collect.Lists; |
| 20 | import com.google.common.collect.Maps; | 20 | import com.google.common.collect.Maps; |
| 21 | import com.google.common.collect.Sets; | 21 | import com.google.common.collect.Sets; |
| 22 | - | ||
| 23 | import org.apache.felix.scr.annotations.Activate; | 22 | import org.apache.felix.scr.annotations.Activate; |
| 24 | import org.apache.felix.scr.annotations.Component; | 23 | import org.apache.felix.scr.annotations.Component; |
| 25 | import org.apache.felix.scr.annotations.Deactivate; | 24 | import org.apache.felix.scr.annotations.Deactivate; |
| ... | @@ -27,6 +26,7 @@ import org.apache.felix.scr.annotations.Modified; | ... | @@ -27,6 +26,7 @@ import org.apache.felix.scr.annotations.Modified; |
| 27 | import org.apache.felix.scr.annotations.Property; | 26 | import org.apache.felix.scr.annotations.Property; |
| 28 | import org.apache.felix.scr.annotations.Reference; | 27 | import org.apache.felix.scr.annotations.Reference; |
| 29 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 28 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 29 | +import org.onlab.util.Tools; | ||
| 30 | import org.onosproject.cfg.ComponentConfigService; | 30 | import org.onosproject.cfg.ComponentConfigService; |
| 31 | import org.onosproject.cluster.ClusterService; | 31 | import org.onosproject.cluster.ClusterService; |
| 32 | import org.onosproject.cluster.NodeId; | 32 | import org.onosproject.cluster.NodeId; |
| ... | @@ -48,6 +48,11 @@ import org.onosproject.net.provider.ProviderId; | ... | @@ -48,6 +48,11 @@ import org.onosproject.net.provider.ProviderId; |
| 48 | import org.osgi.service.component.ComponentContext; | 48 | import org.osgi.service.component.ComponentContext; |
| 49 | import org.slf4j.Logger; | 49 | import org.slf4j.Logger; |
| 50 | 50 | ||
| 51 | +import java.io.BufferedReader; | ||
| 52 | +import java.io.FileReader; | ||
| 53 | +import java.io.IOException; | ||
| 54 | +import java.net.URI; | ||
| 55 | +import java.net.URISyntaxException; | ||
| 51 | import java.util.Dictionary; | 56 | import java.util.Dictionary; |
| 52 | import java.util.List; | 57 | import java.util.List; |
| 53 | import java.util.Set; | 58 | import java.util.Set; |
| ... | @@ -55,11 +60,6 @@ import java.util.concurrent.ConcurrentMap; | ... | @@ -55,11 +60,6 @@ import java.util.concurrent.ConcurrentMap; |
| 55 | import java.util.concurrent.Executors; | 60 | import java.util.concurrent.Executors; |
| 56 | import java.util.concurrent.ScheduledExecutorService; | 61 | import java.util.concurrent.ScheduledExecutorService; |
| 57 | import java.util.concurrent.TimeUnit; | 62 | import java.util.concurrent.TimeUnit; |
| 58 | -import java.io.BufferedReader; | ||
| 59 | -import java.io.FileReader; | ||
| 60 | -import java.io.IOException; | ||
| 61 | -import java.net.URI; | ||
| 62 | -import java.net.URISyntaxException; | ||
| 63 | 63 | ||
| 64 | import static com.google.common.base.Strings.isNullOrEmpty; | 64 | import static com.google.common.base.Strings.isNullOrEmpty; |
| 65 | import static org.onlab.util.Tools.groupedThreads; | 65 | import static org.onlab.util.Tools.groupedThreads; |
| ... | @@ -280,12 +280,18 @@ public class NullLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -280,12 +280,18 @@ public class NullLinkProvider extends AbstractProvider implements LinkProvider { |
| 280 | log.warn("Could not close topology file: {}", e); | 280 | log.warn("Could not close topology file: {}", e); |
| 281 | } | 281 | } |
| 282 | } | 282 | } |
| 283 | + Set<LinkDescription> removedLinks = null; | ||
| 283 | synchronized (linkDescrs) { | 284 | synchronized (linkDescrs) { |
| 284 | if (!read.isEmpty()) { | 285 | if (!read.isEmpty()) { |
| 286 | + removedLinks = Sets.difference(Sets.newHashSet(linkDescrs), read); | ||
| 285 | linkDescrs.clear(); | 287 | linkDescrs.clear(); |
| 286 | linkDescrs.addAll(read); | 288 | linkDescrs.addAll(read); |
| 287 | } | 289 | } |
| 288 | } | 290 | } |
| 291 | + if (!Tools.isNullOrEmpty(removedLinks)) { | ||
| 292 | + log.info("Removing {} old link(s)", removedLinks.size()); | ||
| 293 | + removedLinks.forEach(providerService::linkVanished); | ||
| 294 | + } | ||
| 289 | } | 295 | } |
| 290 | 296 | ||
| 291 | // parses a link descriptor to make a LinkDescription | 297 | // parses a link descriptor to make a LinkDescription | ... | ... |
-
Please register or login to post a comment