Sho SHIMIZU
Committed by Gerrit Code Review

Make ResourceService API more flexible in parameter

Change-Id: Ic8b803cc6ae3b2798de525bfd6545ac5c57e8fdd
...@@ -808,7 +808,7 @@ public class OpticalPathProvisionerTest { ...@@ -808,7 +808,7 @@ public class OpticalPathProvisionerTest {
808 private static class TestResourceService implements ResourceService { 808 private static class TestResourceService implements ResourceService {
809 809
810 @Override 810 @Override
811 - public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources) { 811 + public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<? extends Resource> resources) {
812 List<ResourceAllocation> allocations = new ArrayList<>(); 812 List<ResourceAllocation> allocations = new ArrayList<>();
813 813
814 resources.forEach(r -> allocations.add(new ResourceAllocation(r, consumer.consumerId()))); 814 resources.forEach(r -> allocations.add(new ResourceAllocation(r, consumer.consumerId())));
...@@ -955,4 +955,4 @@ public class OpticalPathProvisionerTest { ...@@ -955,4 +955,4 @@ public class OpticalPathProvisionerTest {
955 return 0; 955 return 0;
956 } 956 }
957 } 957 }
958 -}
...\ No newline at end of file ...\ No newline at end of file
958 +}
......
...@@ -300,7 +300,7 @@ public class PathComputationTest { ...@@ -300,7 +300,7 @@ public class PathComputationTest {
300 } 300 }
301 301
302 @Override 302 @Override
303 - public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources) { 303 + public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<? extends Resource> resources) {
304 for (Resource resource: resources) { 304 for (Resource resource: resources) {
305 if (resource instanceof ContinuousResource) { 305 if (resource instanceof ContinuousResource) {
306 List<ResourceAllocation> allocs = new LinkedList<>(); 306 List<ResourceAllocation> allocs = new LinkedList<>();
...@@ -1197,4 +1197,4 @@ public class PathComputationTest { ...@@ -1197,4 +1197,4 @@ public class PathComputationTest {
1197 UNKNOWN, UNKNOWN, UNKNOWN, 1197 UNKNOWN, UNKNOWN, UNKNOWN,
1198 UNKNOWN, new ChassisId(), builder.build())); 1198 UNKNOWN, new ChassisId(), builder.build()));
1199 } 1199 }
1200 -}
...\ No newline at end of file ...\ No newline at end of file
1200 +}
......
...@@ -43,7 +43,7 @@ public class ResourceServiceAdapter implements ResourceService { ...@@ -43,7 +43,7 @@ public class ResourceServiceAdapter implements ResourceService {
43 } 43 }
44 44
45 @Override 45 @Override
46 - public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources) { 46 + public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<? extends Resource> resources) {
47 // TODO Auto-generated method stub 47 // TODO Auto-generated method stub
48 return null; 48 return null;
49 } 49 }
......
...@@ -43,7 +43,7 @@ public interface ResourceAdminService { ...@@ -43,7 +43,7 @@ public interface ResourceAdminService {
43 * @return true if registration is successfully done, false otherwise. Registration 43 * @return true if registration is successfully done, false otherwise. Registration
44 * succeeds when each resource is not registered or unallocated. 44 * succeeds when each resource is not registered or unallocated.
45 */ 45 */
46 - boolean register(List<Resource> resources); 46 + boolean register(List<? extends Resource> resources);
47 47
48 /** 48 /**
49 * Unregisters the specified resources. 49 * Unregisters the specified resources.
...@@ -63,5 +63,5 @@ public interface ResourceAdminService { ...@@ -63,5 +63,5 @@ public interface ResourceAdminService {
63 * @return true if unregistration is successfully done, false otherwise. Unregistration 63 * @return true if unregistration is successfully done, false otherwise. Unregistration
64 * succeeds when each resource is not registered or unallocated. 64 * succeeds when each resource is not registered or unallocated.
65 */ 65 */
66 - boolean unregister(List<ResourceId> ids); 66 + boolean unregister(List<? extends ResourceId> ids);
67 } 67 }
......
...@@ -64,7 +64,7 @@ public interface ResourceService extends ResourceQueryService, ListenerService<R ...@@ -64,7 +64,7 @@ public interface ResourceService extends ResourceQueryService, ListenerService<R
64 * @param resources resources to be allocated 64 * @param resources resources to be allocated
65 * @return non-empty list of allocation information if succeeded, otherwise empty list 65 * @return non-empty list of allocation information if succeeded, otherwise empty list
66 */ 66 */
67 - List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources); 67 + List<ResourceAllocation> allocate(ResourceConsumer consumer, List<? extends Resource> resources);
68 68
69 /** 69 /**
70 * Transactionally allocates the specified resources to the specified user. 70 * Transactionally allocates the specified resources to the specified user.
......
...@@ -37,7 +37,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat ...@@ -37,7 +37,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat
37 * @param resources resources to be registered 37 * @param resources resources to be registered
38 * @return true if the registration succeeds, false otherwise 38 * @return true if the registration succeeds, false otherwise
39 */ 39 */
40 - boolean register(List<Resource> resources); 40 + boolean register(List<? extends Resource> resources);
41 41
42 /** 42 /**
43 * Unregisters the resources in transactional way. 43 * Unregisters the resources in transactional way.
...@@ -48,7 +48,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat ...@@ -48,7 +48,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat
48 * @param ids resources to be unregistered 48 * @param ids resources to be unregistered
49 * @return true if the registration succeeds, false otherwise 49 * @return true if the registration succeeds, false otherwise
50 */ 50 */
51 - boolean unregister(List<ResourceId> ids); 51 + boolean unregister(List<? extends ResourceId> ids);
52 52
53 /** 53 /**
54 * Allocates the specified resources to the specified consumer in transactional way. 54 * Allocates the specified resources to the specified consumer in transactional way.
...@@ -60,7 +60,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat ...@@ -60,7 +60,7 @@ public interface ResourceStore extends Store<ResourceEvent, ResourceStoreDelegat
60 * @param consumer resource consumer which the resources are allocated to 60 * @param consumer resource consumer which the resources are allocated to
61 * @return true if the allocation succeeds, false otherwise. 61 * @return true if the allocation succeeds, false otherwise.
62 */ 62 */
63 - boolean allocate(List<Resource> resources, ResourceConsumer consumer); 63 + boolean allocate(List<? extends Resource> resources, ResourceConsumer consumer);
64 64
65 /** 65 /**
66 * Releases the specified allocated resources in transactional way. 66 * Releases the specified allocated resources in transactional way.
......
...@@ -192,7 +192,7 @@ public class IntentTestsMocks { ...@@ -192,7 +192,7 @@ public class IntentTestsMocks {
192 } 192 }
193 193
194 @Override 194 @Override
195 - public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources) { 195 + public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<? extends Resource> resources) {
196 return null; 196 return null;
197 } 197 }
198 198
......
...@@ -38,7 +38,7 @@ public class MockResourceService implements ResourceService { ...@@ -38,7 +38,7 @@ public class MockResourceService implements ResourceService {
38 private final Map<Resource, ResourceConsumer> assignment = new HashMap<>(); 38 private final Map<Resource, ResourceConsumer> assignment = new HashMap<>();
39 39
40 @Override 40 @Override
41 - public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources) { 41 + public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<? extends Resource> resources) {
42 assignment.putAll( 42 assignment.putAll(
43 resources.stream().collect(Collectors.toMap(Function.identity(), x -> consumer)) 43 resources.stream().collect(Collectors.toMap(Function.identity(), x -> consumer))
44 ); 44 );
......
...@@ -84,7 +84,7 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent ...@@ -84,7 +84,7 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent
84 84
85 @Override 85 @Override
86 public List<ResourceAllocation> allocate(ResourceConsumer consumer, 86 public List<ResourceAllocation> allocate(ResourceConsumer consumer,
87 - List<Resource> resources) { 87 + List<? extends Resource> resources) {
88 checkPermission(RESOURCE_WRITE); 88 checkPermission(RESOURCE_WRITE);
89 checkNotNull(consumer); 89 checkNotNull(consumer);
90 checkNotNull(resources); 90 checkNotNull(resources);
...@@ -202,14 +202,14 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent ...@@ -202,14 +202,14 @@ public final class ResourceManager extends AbstractListenerManager<ResourceEvent
202 } 202 }
203 203
204 @Override 204 @Override
205 - public boolean register(List<Resource> resources) { 205 + public boolean register(List<? extends Resource> resources) {
206 checkNotNull(resources); 206 checkNotNull(resources);
207 207
208 return store.register(resources); 208 return store.register(resources);
209 } 209 }
210 210
211 @Override 211 @Override
212 - public boolean unregister(List<ResourceId> ids) { 212 + public boolean unregister(List<? extends ResourceId> ids) {
213 checkNotNull(ids); 213 checkNotNull(ids);
214 214
215 return store.unregister(ids); 215 return store.unregister(ids);
......
...@@ -113,7 +113,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour ...@@ -113,7 +113,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
113 } 113 }
114 114
115 @Override 115 @Override
116 - public boolean register(List<Resource> resources) { 116 + public boolean register(List<? extends Resource> resources) {
117 checkNotNull(resources); 117 checkNotNull(resources);
118 if (log.isTraceEnabled()) { 118 if (log.isTraceEnabled()) {
119 resources.forEach(r -> log.trace("registering {}", r)); 119 resources.forEach(r -> log.trace("registering {}", r));
...@@ -155,7 +155,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour ...@@ -155,7 +155,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
155 } 155 }
156 156
157 @Override 157 @Override
158 - public boolean unregister(List<ResourceId> ids) { 158 + public boolean unregister(List<? extends ResourceId> ids) {
159 checkNotNull(ids); 159 checkNotNull(ids);
160 160
161 TransactionContext tx = service.transactionContextBuilder().build(); 161 TransactionContext tx = service.transactionContextBuilder().build();
...@@ -204,7 +204,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour ...@@ -204,7 +204,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
204 } 204 }
205 205
206 @Override 206 @Override
207 - public boolean allocate(List<Resource> resources, ResourceConsumer consumer) { 207 + public boolean allocate(List<? extends Resource> resources, ResourceConsumer consumer) {
208 checkNotNull(resources); 208 checkNotNull(resources);
209 checkNotNull(consumer); 209 checkNotNull(consumer);
210 210
......
...@@ -274,7 +274,7 @@ public class BgpTopologyProviderTest { ...@@ -274,7 +274,7 @@ public class BgpTopologyProviderTest {
274 Map<ResourceId, List<Resource>> registeredRes = new HashMap<>(); 274 Map<ResourceId, List<Resource>> registeredRes = new HashMap<>();
275 275
276 @Override 276 @Override
277 - public boolean register(List<Resource> resources) { 277 + public boolean register(List<? extends Resource> resources) {
278 for (Resource res : resources) { 278 for (Resource res : resources) {
279 List<Resource> resource = new LinkedList<>(); 279 List<Resource> resource = new LinkedList<>();
280 resource.add(res); 280 resource.add(res);
...@@ -287,7 +287,7 @@ public class BgpTopologyProviderTest { ...@@ -287,7 +287,7 @@ public class BgpTopologyProviderTest {
287 } 287 }
288 288
289 @Override 289 @Override
290 - public boolean unregister(List<ResourceId> ids) { 290 + public boolean unregister(List<? extends ResourceId> ids) {
291 for (ResourceId id : ids) { 291 for (ResourceId id : ids) {
292 if (registeredRes.containsKey(id)) { 292 if (registeredRes.containsKey(id)) {
293 registeredRes.remove(id); 293 registeredRes.remove(id);
......