Fix the issue of ONOS-3423
Change-Id: I60c3105149f6ef46e2effb7de6d8f40152027ec7
Showing
3 changed files
with
18 additions
and
12 deletions
... | @@ -121,10 +121,10 @@ public abstract class ResourcePath { | ... | @@ -121,10 +121,10 @@ public abstract class ResourcePath { |
121 | public List<Object> components() { | 121 | public List<Object> components() { |
122 | LinkedList<Object> components = new LinkedList<>(); | 122 | LinkedList<Object> components = new LinkedList<>(); |
123 | 123 | ||
124 | - Optional<Discrete> parentPath = Optional.ofNullable(parent); | 124 | + ResourcePath current = this; |
125 | - while (parentPath.isPresent()) { | 125 | + while (current.parent().isPresent()) { |
126 | - components.addFirst(last); | 126 | + components.addFirst(current.last); |
127 | - parentPath = parent.parent(); | 127 | + current = current.parent; |
128 | } | 128 | } |
129 | 129 | ||
130 | return components; | 130 | return components; | ... | ... |
... | @@ -26,6 +26,7 @@ import org.onosproject.net.PortNumber; | ... | @@ -26,6 +26,7 @@ import org.onosproject.net.PortNumber; |
26 | 26 | ||
27 | import java.util.Optional; | 27 | import java.util.Optional; |
28 | 28 | ||
29 | +import static org.hamcrest.Matchers.contains; | ||
29 | import static org.hamcrest.Matchers.is; | 30 | import static org.hamcrest.Matchers.is; |
30 | import static org.junit.Assert.assertThat; | 31 | import static org.junit.Assert.assertThat; |
31 | 32 | ||
... | @@ -63,6 +64,13 @@ public class ResourcePathTest { | ... | @@ -63,6 +64,13 @@ public class ResourcePathTest { |
63 | } | 64 | } |
64 | 65 | ||
65 | @Test | 66 | @Test |
67 | + public void testComponents() { | ||
68 | + ResourcePath port = ResourcePath.discrete(D1, P1); | ||
69 | + | ||
70 | + assertThat(port.components(), contains(D1, P1)); | ||
71 | + } | ||
72 | + | ||
73 | + @Test | ||
66 | public void testThereIsParent() { | 74 | public void testThereIsParent() { |
67 | ResourcePath path = ResourcePath.discrete(LinkKey.linkKey(CP1_1, CP2_1), VLAN1); | 75 | ResourcePath path = ResourcePath.discrete(LinkKey.linkKey(CP1_1, CP2_1), VLAN1); |
68 | ResourcePath parent = ResourcePath.discrete(LinkKey.linkKey(CP1_1, CP2_1)); | 76 | ResourcePath parent = ResourcePath.discrete(LinkKey.linkKey(CP1_1, CP2_1)); | ... | ... |
... | @@ -59,17 +59,15 @@ public final class ResourceRegistrar { | ... | @@ -59,17 +59,15 @@ public final class ResourceRegistrar { |
59 | 59 | ||
60 | @Activate | 60 | @Activate |
61 | public void activate() { | 61 | public void activate() { |
62 | - // FIXME there is a loop causing high resource utilization on device registration | 62 | + deviceListener = new ResourceDeviceListener(adminService, executor); |
63 | -// deviceListener = new ResourceDeviceListener(adminService, executor); | 63 | + deviceService.addListener(deviceListener); |
64 | -// deviceService.addListener(deviceListener); | 64 | + linkListener = new ResourceLinkListener(adminService, driverService, executor); |
65 | -// linkListener = new ResourceLinkListener(adminService, driverService, executor); | 65 | + linkService.addListener(linkListener); |
66 | -// linkService.addListener(linkListener); | ||
67 | } | 66 | } |
68 | 67 | ||
69 | @Deactivate | 68 | @Deactivate |
70 | public void deactivate() { | 69 | public void deactivate() { |
71 | - // FIXME there is a loop causing high resource utilization on device registration | 70 | + deviceService.removeListener(deviceListener); |
72 | -// deviceService.removeListener(deviceListener); | 71 | + linkService.removeListener(linkListener); |
73 | -// linkService.removeListener(linkListener); | ||
74 | } | 72 | } |
75 | } | 73 | } | ... | ... |
-
Please register or login to post a comment