Fix the compilation error introduced by be394c82
Change-Id: I9104d91541f0f2fcd8476264772a920b59626003
Showing
1 changed file
with
8 additions
and
5 deletions
... | @@ -37,6 +37,7 @@ import org.onosproject.net.device.DeviceListener; | ... | @@ -37,6 +37,7 @@ import org.onosproject.net.device.DeviceListener; |
37 | import org.onosproject.net.device.DeviceService; | 37 | import org.onosproject.net.device.DeviceService; |
38 | import org.onosproject.net.driver.DriverHandler; | 38 | import org.onosproject.net.driver.DriverHandler; |
39 | import org.onosproject.net.driver.DriverService; | 39 | import org.onosproject.net.driver.DriverService; |
40 | +import org.onosproject.net.newresource.DiscreteResource; | ||
40 | import org.onosproject.net.newresource.ResourceAdminService; | 41 | import org.onosproject.net.newresource.ResourceAdminService; |
41 | import org.onosproject.net.newresource.BandwidthCapacity; | 42 | import org.onosproject.net.newresource.BandwidthCapacity; |
42 | import org.onosproject.net.newresource.Resource; | 43 | import org.onosproject.net.newresource.Resource; |
... | @@ -130,7 +131,7 @@ final class ResourceDeviceListener implements DeviceListener { | ... | @@ -130,7 +131,7 @@ final class ResourceDeviceListener implements DeviceListener { |
130 | 131 | ||
131 | private void unregisterDeviceResource(Device device) { | 132 | private void unregisterDeviceResource(Device device) { |
132 | executor.submit(() -> { | 133 | executor.submit(() -> { |
133 | - Resource devResource = Resources.discrete(device.id()).resource(); | 134 | + DiscreteResource devResource = Resources.discrete(device.id()).resource(); |
134 | List<Resource> allResources = getDescendantResources(devResource); | 135 | List<Resource> allResources = getDescendantResources(devResource); |
135 | adminService.unregisterResources(allResources); | 136 | adminService.unregisterResources(allResources); |
136 | }); | 137 | }); |
... | @@ -186,25 +187,27 @@ final class ResourceDeviceListener implements DeviceListener { | ... | @@ -186,25 +187,27 @@ final class ResourceDeviceListener implements DeviceListener { |
186 | 187 | ||
187 | private void unregisterPortResource(Device device, Port port) { | 188 | private void unregisterPortResource(Device device, Port port) { |
188 | executor.submit(() -> { | 189 | executor.submit(() -> { |
189 | - Resource portResource = Resources.discrete(device.id(), port.number()).resource(); | 190 | + DiscreteResource portResource = Resources.discrete(device.id(), port.number()).resource(); |
190 | List<Resource> allResources = getDescendantResources(portResource); | 191 | List<Resource> allResources = getDescendantResources(portResource); |
191 | adminService.unregisterResources(allResources); | 192 | adminService.unregisterResources(allResources); |
192 | }); | 193 | }); |
193 | } | 194 | } |
194 | 195 | ||
195 | // Returns list of all descendant resources of given resource, including itself. | 196 | // Returns list of all descendant resources of given resource, including itself. |
196 | - private List<Resource> getDescendantResources(Resource parent) { | 197 | + private List<Resource> getDescendantResources(DiscreteResource parent) { |
197 | LinkedList<Resource> allResources = new LinkedList<>(); | 198 | LinkedList<Resource> allResources = new LinkedList<>(); |
198 | allResources.add(parent); | 199 | allResources.add(parent); |
199 | 200 | ||
200 | - Set<Resource> nextResources = resourceService.getRegisteredResources(parent); | 201 | + Set<Resource> nextResources = resourceService.getRegisteredResources(parent.id()); |
201 | while (!nextResources.isEmpty()) { | 202 | while (!nextResources.isEmpty()) { |
202 | Set<Resource> currentResources = nextResources; | 203 | Set<Resource> currentResources = nextResources; |
203 | // resource list should be ordered from leaf to root | 204 | // resource list should be ordered from leaf to root |
204 | allResources.addAll(0, currentResources); | 205 | allResources.addAll(0, currentResources); |
205 | 206 | ||
206 | nextResources = currentResources.stream() | 207 | nextResources = currentResources.stream() |
207 | - .flatMap(r -> resourceService.getRegisteredResources(r).stream()) | 208 | + .filter(r -> r instanceof DiscreteResource) |
209 | + .map(r -> (DiscreteResource) r) | ||
210 | + .flatMap(r -> resourceService.getRegisteredResources(r.id()).stream()) | ||
208 | .collect(Collectors.toSet()); | 211 | .collect(Collectors.toSet()); |
209 | } | 212 | } |
210 | 213 | ... | ... |
-
Please register or login to post a comment