[ONOS-6865] enforcing same label and [ONOS-6895] minimize label swapping
- Re design label allocator to allow several opt. behavior
- Implements NO Swap algorithm in label allocator
- Implements MIN Swap algorithm in label allocator
- Improve unit tests
Change-Id: I39eb8570cb83734b9c2b106f9c48bf50a4e69499
diff --git a/core/api/src/test/java/org/onosproject/net/resource/MockResourceService.java b/core/api/src/test/java/org/onosproject/net/resource/MockResourceService.java
index 9952e46..62613e0 100644
--- a/core/api/src/test/java/org/onosproject/net/resource/MockResourceService.java
+++ b/core/api/src/test/java/org/onosproject/net/resource/MockResourceService.java
@@ -40,6 +40,7 @@
private final Map<Resource, ResourceConsumer> assignment = new HashMap<>();
public Set<Short> availableVlanLabels = new HashSet<>();
public Set<Integer> availableMplsLabels = new HashSet<>();
+ public boolean filterAssignment = false;
public MockResourceService(){}
@@ -169,7 +170,11 @@
resources.add(Resources.discrete(parent).resource().child(TributarySlot.of(6)));
resources.add(Resources.discrete(parent).resource().child(TributarySlot.of(7)));
resources.add(Resources.discrete(parent).resource().child(TributarySlot.of(8)));
- return ImmutableSet.copyOf(resources);
+ return filterAssignment ? ImmutableSet.copyOf(
+ resources.stream().filter(
+ resource -> assignment.get(resource) == null
+ ).collect(Collectors.toSet())
+ ) : ImmutableSet.copyOf(resources);
}
@Override