Sho SHIMIZU

Fix the issue of ONOS-3423

Change-Id: I60c3105149f6ef46e2effb7de6d8f40152027ec7
......@@ -121,10 +121,10 @@ public abstract class ResourcePath {
public List<Object> components() {
LinkedList<Object> components = new LinkedList<>();
Optional<Discrete> parentPath = Optional.ofNullable(parent);
while (parentPath.isPresent()) {
components.addFirst(last);
parentPath = parent.parent();
ResourcePath current = this;
while (current.parent().isPresent()) {
components.addFirst(current.last);
current = current.parent;
}
return components;
......
......@@ -26,6 +26,7 @@ import org.onosproject.net.PortNumber;
import java.util.Optional;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
......@@ -63,6 +64,13 @@ public class ResourcePathTest {
}
@Test
public void testComponents() {
ResourcePath port = ResourcePath.discrete(D1, P1);
assertThat(port.components(), contains(D1, P1));
}
@Test
public void testThereIsParent() {
ResourcePath path = ResourcePath.discrete(LinkKey.linkKey(CP1_1, CP2_1), VLAN1);
ResourcePath parent = ResourcePath.discrete(LinkKey.linkKey(CP1_1, CP2_1));
......
......@@ -59,17 +59,15 @@ public final class ResourceRegistrar {
@Activate
public void activate() {
// FIXME there is a loop causing high resource utilization on device registration
// deviceListener = new ResourceDeviceListener(adminService, executor);
// deviceService.addListener(deviceListener);
// linkListener = new ResourceLinkListener(adminService, driverService, executor);
// linkService.addListener(linkListener);
deviceListener = new ResourceDeviceListener(adminService, executor);
deviceService.addListener(deviceListener);
linkListener = new ResourceLinkListener(adminService, driverService, executor);
linkService.addListener(linkListener);
}
@Deactivate
public void deactivate() {
// FIXME there is a loop causing high resource utilization on device registration
// deviceService.removeListener(deviceListener);
// linkService.removeListener(linkListener);
deviceService.removeListener(deviceListener);
linkService.removeListener(linkListener);
}
}
......