Sho SHIMIZU

Remove dependency on LinkResourceService from OpticalPathProvisioner

Change-Id: I442f781052e0d541acfd1e960bb56e51265edca2
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 */ 15 */
16 package org.onosproject.optical; 16 package org.onosproject.optical;
17 17
18 +import com.google.common.collect.ImmutableList;
18 import org.apache.felix.scr.annotations.Activate; 19 import org.apache.felix.scr.annotations.Activate;
19 import org.apache.felix.scr.annotations.Component; 20 import org.apache.felix.scr.annotations.Component;
20 import org.apache.felix.scr.annotations.Deactivate; 21 import org.apache.felix.scr.annotations.Deactivate;
...@@ -45,16 +46,16 @@ import org.onosproject.net.intent.IntentState; ...@@ -45,16 +46,16 @@ import org.onosproject.net.intent.IntentState;
45 import org.onosproject.net.intent.OpticalCircuitIntent; 46 import org.onosproject.net.intent.OpticalCircuitIntent;
46 import org.onosproject.net.intent.OpticalConnectivityIntent; 47 import org.onosproject.net.intent.OpticalConnectivityIntent;
47 import org.onosproject.net.intent.PointToPointIntent; 48 import org.onosproject.net.intent.PointToPointIntent;
49 +import org.onosproject.net.newresource.ResourceAllocation;
48 import org.onosproject.net.newresource.ResourceService; 50 import org.onosproject.net.newresource.ResourceService;
49 import org.onosproject.net.resource.device.IntentSetMultimap; 51 import org.onosproject.net.resource.device.IntentSetMultimap;
50 -import org.onosproject.net.resource.link.LinkResourceAllocations;
51 -import org.onosproject.net.resource.link.LinkResourceService;
52 import org.onosproject.net.topology.LinkWeight; 52 import org.onosproject.net.topology.LinkWeight;
53 import org.onosproject.net.topology.PathService; 53 import org.onosproject.net.topology.PathService;
54 import org.onosproject.net.topology.TopologyEdge; 54 import org.onosproject.net.topology.TopologyEdge;
55 import org.slf4j.Logger; 55 import org.slf4j.Logger;
56 import org.slf4j.LoggerFactory; 56 import org.slf4j.LoggerFactory;
57 57
58 +import java.util.Collection;
58 import java.util.Collections; 59 import java.util.Collections;
59 import java.util.Iterator; 60 import java.util.Iterator;
60 import java.util.LinkedList; 61 import java.util.LinkedList;
...@@ -101,9 +102,6 @@ public class OpticalPathProvisioner { ...@@ -101,9 +102,6 @@ public class OpticalPathProvisioner {
101 protected IntentSetMultimap intentSetMultimap; 102 protected IntentSetMultimap intentSetMultimap;
102 103
103 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 104 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
104 - protected LinkResourceService linkResourceService;
105 -
106 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
107 protected ResourceService resourceService; 105 protected ResourceService resourceService;
108 106
109 private ApplicationId appId; 107 private ApplicationId appId;
...@@ -377,17 +375,17 @@ public class OpticalPathProvisioner { ...@@ -377,17 +375,17 @@ public class OpticalPathProvisioner {
377 * @param intent the intent 375 * @param intent the intent
378 */ 376 */
379 private void releaseResources(Intent intent) { 377 private void releaseResources(Intent intent) {
380 - LinkResourceAllocations lra = linkResourceService.getAllocations(intent.id()); 378 + Collection<ResourceAllocation> allocations = resourceService.getResourceAllocations(intent.id());
381 if (intent instanceof OpticalConnectivityIntent) { 379 if (intent instanceof OpticalConnectivityIntent) {
382 resourceService.release(intent.id()); 380 resourceService.release(intent.id());
383 - if (lra != null) { 381 + if (!allocations.isEmpty()) {
384 - linkResourceService.releaseResources(lra); 382 + resourceService.release(ImmutableList.copyOf(allocations));
385 } 383 }
386 } else if (intent instanceof OpticalCircuitIntent) { 384 } else if (intent instanceof OpticalCircuitIntent) {
387 resourceService.release(intent.id()); 385 resourceService.release(intent.id());
388 intentSetMultimap.releaseMapping(intent.id()); 386 intentSetMultimap.releaseMapping(intent.id());
389 - if (lra != null) { 387 + if (!allocations.isEmpty()) {
390 - linkResourceService.releaseResources(lra); 388 + resourceService.release(ImmutableList.copyOf(allocations));
391 } 389 }
392 } 390 }
393 } 391 }
......