Committed by
Yuta Higuchi
ONOS-197: Ignore Link with missing Device
- Catch, log, and skip Link edge creation failure. - log topology error details Change-Id: I3cd44a86ed6641c49923f6ed4d2dbaf1f97511d0
Showing
4 changed files
with
20 additions
and
2 deletions
... | @@ -15,14 +15,18 @@ | ... | @@ -15,14 +15,18 @@ |
15 | */ | 15 | */ |
16 | package org.onlab.onos.net.topology; | 16 | package org.onlab.onos.net.topology; |
17 | 17 | ||
18 | +import static org.slf4j.LoggerFactory.getLogger; | ||
19 | + | ||
18 | import com.google.common.collect.ImmutableSet; | 20 | import com.google.common.collect.ImmutableSet; |
19 | import com.google.common.collect.Maps; | 21 | import com.google.common.collect.Maps; |
22 | + | ||
20 | import org.onlab.onos.net.AbstractDescription; | 23 | import org.onlab.onos.net.AbstractDescription; |
21 | import org.onlab.onos.net.ConnectPoint; | 24 | import org.onlab.onos.net.ConnectPoint; |
22 | import org.onlab.onos.net.Device; | 25 | import org.onlab.onos.net.Device; |
23 | import org.onlab.onos.net.DeviceId; | 26 | import org.onlab.onos.net.DeviceId; |
24 | import org.onlab.onos.net.Link; | 27 | import org.onlab.onos.net.Link; |
25 | import org.onlab.onos.net.SparseAnnotations; | 28 | import org.onlab.onos.net.SparseAnnotations; |
29 | +import org.slf4j.Logger; | ||
26 | 30 | ||
27 | import java.util.Map; | 31 | import java.util.Map; |
28 | 32 | ||
... | @@ -32,6 +36,8 @@ import java.util.Map; | ... | @@ -32,6 +36,8 @@ import java.util.Map; |
32 | public class DefaultGraphDescription extends AbstractDescription | 36 | public class DefaultGraphDescription extends AbstractDescription |
33 | implements GraphDescription { | 37 | implements GraphDescription { |
34 | 38 | ||
39 | + private static final Logger log = getLogger(DefaultGraphDescription.class); | ||
40 | + | ||
35 | private final long nanos; | 41 | private final long nanos; |
36 | private final ImmutableSet<TopologyVertex> vertexes; | 42 | private final ImmutableSet<TopologyVertex> vertexes; |
37 | private final ImmutableSet<TopologyEdge> edges; | 43 | private final ImmutableSet<TopologyEdge> edges; |
... | @@ -87,8 +93,12 @@ public class DefaultGraphDescription extends AbstractDescription | ... | @@ -87,8 +93,12 @@ public class DefaultGraphDescription extends AbstractDescription |
87 | private ImmutableSet<TopologyEdge> buildEdges(Iterable<Link> links) { | 93 | private ImmutableSet<TopologyEdge> buildEdges(Iterable<Link> links) { |
88 | ImmutableSet.Builder<TopologyEdge> edges = ImmutableSet.builder(); | 94 | ImmutableSet.Builder<TopologyEdge> edges = ImmutableSet.builder(); |
89 | for (Link link : links) { | 95 | for (Link link : links) { |
96 | + try { | ||
90 | edges.add(new DefaultTopologyEdge(vertexOf(link.src()), | 97 | edges.add(new DefaultTopologyEdge(vertexOf(link.src()), |
91 | vertexOf(link.dst()), link)); | 98 | vertexOf(link.dst()), link)); |
99 | + } catch (IllegalArgumentException e) { | ||
100 | + log.debug("Ignoring {}, missing vertex", link, e); | ||
101 | + } | ||
92 | } | 102 | } |
93 | return edges.build(); | 103 | return edges.build(); |
94 | } | 104 | } | ... | ... |
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
16 | package org.onlab.onos.net.topology; | 16 | package org.onlab.onos.net.topology; |
17 | 17 | ||
18 | import com.google.common.collect.ImmutableSet; | 18 | import com.google.common.collect.ImmutableSet; |
19 | + | ||
19 | import org.junit.Test; | 20 | import org.junit.Test; |
20 | import org.onlab.onos.net.DefaultDevice; | 21 | import org.onlab.onos.net.DefaultDevice; |
21 | import org.onlab.onos.net.Device; | 22 | import org.onlab.onos.net.Device; |
... | @@ -47,9 +48,13 @@ public class DefaultGraphDescriptionTest { | ... | @@ -47,9 +48,13 @@ public class DefaultGraphDescriptionTest { |
47 | assertEquals("incorrect edge count", 2, desc.edges().size()); | 48 | assertEquals("incorrect edge count", 2, desc.edges().size()); |
48 | } | 49 | } |
49 | 50 | ||
50 | - @Test(expected = IllegalArgumentException.class) | 51 | + @Test |
51 | public void missingVertex() { | 52 | public void missingVertex() { |
52 | - new DefaultGraphDescription(4321L, ImmutableSet.of(DEV1, DEV3), | 53 | + GraphDescription desc = new DefaultGraphDescription(4321L, |
54 | + ImmutableSet.of(DEV1, DEV3), | ||
53 | ImmutableSet.of(L1, L2)); | 55 | ImmutableSet.of(L1, L2)); |
56 | + assertEquals("incorrect time", 4321L, desc.timestamp()); | ||
57 | + assertEquals("incorrect vertex count", 2, desc.vertexes().size()); | ||
58 | + assertEquals("incorrect edge count", 0, desc.edges().size()); | ||
54 | } | 59 | } |
55 | } | 60 | } | ... | ... |
... | @@ -48,7 +48,9 @@ public class DefaultTopologyEdgeTest { | ... | @@ -48,7 +48,9 @@ public class DefaultTopologyEdgeTest { |
48 | 48 | ||
49 | static final ProviderId PID = new ProviderId("foo", "bar"); | 49 | static final ProviderId PID = new ProviderId("foo", "bar"); |
50 | 50 | ||
51 | + /** D1:P1 -> D2:P1. */ | ||
51 | static final Link L1 = new DefaultLink(PID, CP1, CP2, Link.Type.INDIRECT); | 52 | static final Link L1 = new DefaultLink(PID, CP1, CP2, Link.Type.INDIRECT); |
53 | + /** D2:P1 -> D1:P2. */ | ||
52 | static final Link L2 = new DefaultLink(PID, CP3, CP4, Link.Type.INDIRECT); | 54 | static final Link L2 = new DefaultLink(PID, CP3, CP4, Link.Type.INDIRECT); |
53 | 55 | ||
54 | @Test | 56 | @Test | ... | ... |
... | @@ -203,6 +203,7 @@ public class DefaultTopologyProvider extends AbstractProvider | ... | @@ -203,6 +203,7 @@ public class DefaultTopologyProvider extends AbstractProvider |
203 | buildTopology(reasons); | 203 | buildTopology(reasons); |
204 | } catch (Exception e) { | 204 | } catch (Exception e) { |
205 | log.warn("Unable to compute topology due to: {}", e.getMessage()); | 205 | log.warn("Unable to compute topology due to: {}", e.getMessage()); |
206 | + log.debug("Unable to compute topology", e); | ||
206 | } | 207 | } |
207 | } | 208 | } |
208 | } | 209 | } | ... | ... |
-
Please register or login to post a comment