Sho SHIMIZU
Committed by Gerrit Code Review

Rename Lambda in org.onosproject.net.resource to LambdaResource

To avoid naming conflict with Lambda in org.onosproject.net

Change-Id: Ic8a670e7e2fb022f44f5a83cf4805f3ce0f29694
Showing 17 changed files with 52 additions and 52 deletions
......@@ -16,7 +16,7 @@
package org.onosproject.net.intent.constraint;
import org.onosproject.net.Link;
import org.onosproject.net.resource.Lambda;
import org.onosproject.net.resource.LambdaResource;
import org.onosproject.net.resource.LinkResourceService;
import org.onosproject.net.resource.ResourceRequest;
import org.onosproject.net.resource.ResourceType;
......@@ -30,14 +30,14 @@ import static com.google.common.base.MoreObjects.toStringHelper;
*/
public class LambdaConstraint extends BooleanConstraint {
private final Lambda lambda;
private final LambdaResource lambda;
/**
* Creates a new optical lambda constraint.
*
* @param lambda optional lambda to indicate a specific lambda
*/
public LambdaConstraint(Lambda lambda) {
public LambdaConstraint(LambdaResource lambda) {
this.lambda = lambda;
}
......@@ -61,7 +61,7 @@ public class LambdaConstraint extends BooleanConstraint {
*
* @return required lambda
*/
public Lambda lambda() {
public LambdaResource lambda() {
return lambda;
}
......
......@@ -20,7 +20,7 @@ import java.util.Objects;
/**
* Representation of lambda resource.
*/
public final class Lambda extends LinkResource {
public final class LambdaResource extends LinkResource {
private final int lambda;
......@@ -29,12 +29,12 @@ public final class Lambda extends LinkResource {
*
* @param lambda lambda value to be assigned
*/
private Lambda(int lambda) {
private LambdaResource(int lambda) {
this.lambda = lambda;
}
// Constructor for serialization
private Lambda() {
private LambdaResource() {
this.lambda = 0;
}
......@@ -42,10 +42,10 @@ public final class Lambda extends LinkResource {
* Creates a new instance with given lambda.
*
* @param lambda lambda value to be assigned
* @return {@link Lambda} instance with given lambda
* @return {@link LambdaResource} instance with given lambda
*/
public static Lambda valueOf(int lambda) {
return new Lambda(lambda);
public static LambdaResource valueOf(int lambda) {
return new LambdaResource(lambda);
}
/**
......@@ -59,8 +59,8 @@ public final class Lambda extends LinkResource {
@Override
public boolean equals(Object obj) {
if (obj instanceof Lambda) {
Lambda that = (Lambda) obj;
if (obj instanceof LambdaResource) {
LambdaResource that = (LambdaResource) obj;
return Objects.equals(this.lambda, that.lambda);
}
return false;
......
......@@ -24,7 +24,7 @@ import java.util.Objects;
*/
public class LambdaResourceAllocation extends LambdaResourceRequest
implements ResourceAllocation {
private final Lambda lambda;
private final LambdaResource lambda;
@Override
public ResourceType type() {
......@@ -32,12 +32,12 @@ public class LambdaResourceAllocation extends LambdaResourceRequest
}
/**
* Creates a new {@link LambdaResourceAllocation} with {@link Lambda}
* Creates a new {@link LambdaResourceAllocation} with {@link LambdaResource}
* object.
*
* @param lambda allocated lambda
*/
public LambdaResourceAllocation(Lambda lambda) {
public LambdaResourceAllocation(LambdaResource lambda) {
this.lambda = lambda;
}
......@@ -46,7 +46,7 @@ public class LambdaResourceAllocation extends LambdaResourceRequest
*
* @return the lambda resource
*/
public Lambda lambda() {
public LambdaResource lambda() {
return lambda;
}
......
......@@ -37,7 +37,7 @@ import org.onosproject.net.flow.instructions.Instruction;
import org.onosproject.net.flow.instructions.Instructions;
import org.onosproject.net.resource.Bandwidth;
import org.onosproject.net.resource.BandwidthResourceRequest;
import org.onosproject.net.resource.Lambda;
import org.onosproject.net.resource.LambdaResource;
import org.onosproject.net.resource.LambdaResourceAllocation;
import org.onosproject.net.resource.LambdaResourceRequest;
import org.onosproject.net.resource.LinkResourceAllocations;
......@@ -179,7 +179,7 @@ public class IntentTestsMocks {
@Override
public Set<ResourceAllocation> getResourceAllocation(Link link) {
return ImmutableSet.of(
new LambdaResourceAllocation(Lambda.valueOf(77)),
new LambdaResourceAllocation(LambdaResource.valueOf(77)),
new MplsLabelResourceAllocation(MplsLabel.valueOf(10)));
}
......
......@@ -26,7 +26,7 @@ import org.onosproject.net.Link;
import org.onosproject.net.NetTestTools;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.intent.constraint.LambdaConstraint;
import org.onosproject.net.resource.Lambda;
import org.onosproject.net.resource.LambdaResource;
import com.google.common.collect.ImmutableSet;
import com.google.common.testing.EqualsTester;
......@@ -132,7 +132,7 @@ public class LinkCollectionIntentTest extends IntentTest {
final LinkedList<Constraint> constraints = new LinkedList<>();
links1.add(link("src", 1, "dst", 2));
constraints.add(new LambdaConstraint(Lambda.valueOf(23)));
constraints.add(new LambdaConstraint(LambdaResource.valueOf(23)));
final LinkCollectionIntent collectionIntent =
LinkCollectionIntent.builder()
.appId(APP_ID)
......
......@@ -18,7 +18,7 @@ package org.onosproject.net.intent.constraint;
import org.junit.Test;
import org.onosproject.net.Link;
import org.onosproject.net.resource.Bandwidth;
import org.onosproject.net.resource.Lambda;
import org.onosproject.net.resource.LambdaResource;
import com.google.common.testing.EqualsTester;
......@@ -65,11 +65,11 @@ public class ConstraintObjectsTest {
// Lambda Constraint
final LambdaConstraint lambdaConstraint1 =
new LambdaConstraint(Lambda.valueOf(100));
new LambdaConstraint(LambdaResource.valueOf(100));
final LambdaConstraint lambdaConstraintSameAs1 =
new LambdaConstraint(Lambda.valueOf(100));
new LambdaConstraint(LambdaResource.valueOf(100));
final LambdaConstraint lambdaConstraint2 =
new LambdaConstraint(Lambda.valueOf(200));
new LambdaConstraint(LambdaResource.valueOf(200));
/**
* Checks that the objects were created properly.
......
......@@ -47,7 +47,7 @@ import org.onosproject.net.intent.constraint.LatencyConstraint;
import org.onosproject.net.intent.constraint.ObstacleConstraint;
import org.onosproject.net.intent.constraint.WaypointConstraint;
import org.onosproject.net.resource.Bandwidth;
import org.onosproject.net.resource.Lambda;
import org.onosproject.net.resource.LambdaResource;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.ImmutableList;
......@@ -146,7 +146,7 @@ public class IntentCodecTest extends AbstractIntentTest {
final List<Constraint> constraints =
ImmutableList.of(
new BandwidthConstraint(Bandwidth.bps(1.0)),
new LambdaConstraint(Lambda.valueOf(3)),
new LambdaConstraint(LambdaResource.valueOf(3)),
new AnnotationConstraint("key", 33.0),
new AsymmetricPathConstraint(),
new LatencyConstraint(Duration.ofSeconds(2)),
......
......@@ -37,7 +37,7 @@ import org.onosproject.net.intent.IntentExtensionService;
import org.onosproject.net.intent.OpticalPathIntent;
import org.onosproject.net.intent.impl.IntentCompilationException;
import org.onosproject.net.resource.DefaultLinkResourceRequest;
import org.onosproject.net.resource.Lambda;
import org.onosproject.net.resource.LambdaResource;
import org.onosproject.net.resource.LambdaResourceAllocation;
import org.onosproject.net.resource.LinkResourceAllocations;
import org.onosproject.net.resource.LinkResourceRequest;
......@@ -110,7 +110,7 @@ public class OpticalPathIntentCompiler implements IntentCompiler<OpticalPathInte
.filter(x -> x.type() == ResourceType.LAMBDA)
.findFirst()
.orElseThrow(() -> new IntentCompilationException("Lambda was not assigned successfully"));
Lambda la = ((LambdaResourceAllocation) allocation).lambda();
LambdaResource la = ((LambdaResourceAllocation) allocation).lambda();
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
treatmentBuilder.setLambda((short) la.toInt());
......
......@@ -28,7 +28,7 @@ import org.onosproject.net.intent.IntentId;
import org.onosproject.net.resource.BandwidthResourceAllocation;
import org.onosproject.net.resource.BandwidthResourceRequest;
import org.onosproject.net.resource.DefaultLinkResourceAllocations;
import org.onosproject.net.resource.Lambda;
import org.onosproject.net.resource.LambdaResource;
import org.onosproject.net.resource.LambdaResourceAllocation;
import org.onosproject.net.resource.LambdaResourceRequest;
import org.onosproject.net.resource.LinkResourceAllocations;
......@@ -92,13 +92,13 @@ public class LinkResourceManager implements LinkResourceService {
* @param link the link
* @return available lambdas on specified link
*/
private Set<Lambda> getAvailableLambdas(Link link) {
private Set<LambdaResource> getAvailableLambdas(Link link) {
checkNotNull(link);
Set<ResourceAllocation> resAllocs = store.getFreeResources(link);
if (resAllocs == null) {
return Collections.emptySet();
}
Set<Lambda> lambdas = new HashSet<>();
Set<LambdaResource> lambdas = new HashSet<>();
for (ResourceAllocation res : resAllocs) {
if (res.type() == ResourceType.LAMBDA) {
lambdas.add(((LambdaResourceAllocation) res).lambda());
......@@ -114,11 +114,11 @@ public class LinkResourceManager implements LinkResourceService {
* @param links the links
* @return available lambdas on specified links
*/
private Iterable<Lambda> getAvailableLambdas(Iterable<Link> links) {
private Iterable<LambdaResource> getAvailableLambdas(Iterable<Link> links) {
checkNotNull(links);
Iterator<Link> i = links.iterator();
checkArgument(i.hasNext());
Set<Lambda> lambdas = new HashSet<>(getAvailableLambdas(i.next()));
Set<LambdaResource> lambdas = new HashSet<>(getAvailableLambdas(i.next()));
while (i.hasNext()) {
lambdas.retainAll(getAvailableLambdas(i.next()));
}
......@@ -162,7 +162,7 @@ public class LinkResourceManager implements LinkResourceService {
allocs.add(new BandwidthResourceAllocation(br.bandwidth()));
break;
case LAMBDA:
Iterator<Lambda> lambdaIterator =
Iterator<LambdaResource> lambdaIterator =
getAvailableLambdas(req.links()).iterator();
if (lambdaIterator.hasNext()) {
allocs.add(new LambdaResourceAllocation(lambdaIterator.next()));
......
......@@ -34,7 +34,7 @@ import org.onosproject.net.intent.constraint.BandwidthConstraint;
import org.onosproject.net.intent.constraint.LambdaConstraint;
import org.onosproject.net.intent.impl.PathNotFoundException;
import org.onosproject.net.resource.Bandwidth;
import org.onosproject.net.resource.Lambda;
import org.onosproject.net.resource.LambdaResource;
import org.onosproject.net.resource.LinkResourceService;
import java.util.Arrays;
......@@ -271,7 +271,7 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest {
@Test
public void testLambdaConstrainedIntentSuccess() {
final List<Constraint> constraints = Arrays.asList(new LambdaConstraint(Lambda.valueOf(1)));
final List<Constraint> constraints = Arrays.asList(new LambdaConstraint(LambdaResource.valueOf(1)));
final LinkResourceService resourceService =
IntentTestsMocks.MockResourceService.makeLambdaResourceService(1);
......@@ -294,7 +294,7 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest {
@Test
public void testLambdaConstrainedIntentFailure() {
final List<Constraint> constraints = Arrays.asList(new LambdaConstraint(Lambda.valueOf(1)));
final List<Constraint> constraints = Arrays.asList(new LambdaConstraint(LambdaResource.valueOf(1)));
final LinkResourceService resourceService =
IntentTestsMocks.MockResourceService.makeBandwidthResourceService(10.0);
try {
......
......@@ -25,7 +25,7 @@ import org.onosproject.net.intent.IntentId;
import org.onosproject.net.link.LinkService;
import org.onosproject.net.resource.Bandwidth;
import org.onosproject.net.resource.BandwidthResourceAllocation;
import org.onosproject.net.resource.Lambda;
import org.onosproject.net.resource.LambdaResource;
import org.onosproject.net.resource.LambdaResourceAllocation;
import org.onosproject.net.resource.LinkResourceAllocations;
import org.onosproject.net.resource.LinkResourceEvent;
......@@ -138,7 +138,7 @@ public class ConsistentLinkResourceStore extends
try {
final int waves = Integer.parseInt(link.annotations().value(OPTICAL_WAVES));
for (int i = 1; i <= waves; i++) {
allocations.add(new LambdaResourceAllocation(Lambda.valueOf(i)));
allocations.add(new LambdaResourceAllocation(LambdaResource.valueOf(i)));
}
} catch (NumberFormatException e) {
log.debug("No {} annotation on link {}", OPTICAL_WAVES, link);
......
......@@ -38,7 +38,7 @@ import org.onosproject.net.intent.IntentId;
import org.onosproject.net.link.LinkService;
import org.onosproject.net.resource.Bandwidth;
import org.onosproject.net.resource.BandwidthResourceAllocation;
import org.onosproject.net.resource.Lambda;
import org.onosproject.net.resource.LambdaResource;
import org.onosproject.net.resource.LambdaResourceAllocation;
import org.onosproject.net.resource.LinkResourceAllocations;
import org.onosproject.net.resource.LinkResourceEvent;
......@@ -157,7 +157,7 @@ public class HazelcastLinkResourceStore
try {
final int waves = Integer.parseInt(link.annotations().value(wavesAnnotation));
for (int i = 1; i <= waves; i++) {
allocations.add(new LambdaResourceAllocation(Lambda.valueOf(i)));
allocations.add(new LambdaResourceAllocation(LambdaResource.valueOf(i)));
}
} catch (NumberFormatException e) {
log.debug("No {} annotation on link %s", wavesAnnotation, link);
......
......@@ -33,7 +33,7 @@ import org.onosproject.net.resource.Bandwidth;
import org.onosproject.net.resource.BandwidthResourceAllocation;
import org.onosproject.net.resource.DefaultLinkResourceAllocations;
import org.onosproject.net.resource.DefaultLinkResourceRequest;
import org.onosproject.net.resource.Lambda;
import org.onosproject.net.resource.LambdaResource;
import org.onosproject.net.resource.LambdaResourceAllocation;
import org.onosproject.net.resource.LinkResourceAllocations;
import org.onosproject.net.resource.LinkResourceRequest;
......@@ -279,7 +279,7 @@ public class HazelcastLinkResourceStoreTest {
ImmutableSet.of(link))
.build();
final ResourceAllocation allocation =
new LambdaResourceAllocation(Lambda.valueOf(33));
new LambdaResourceAllocation(LambdaResource.valueOf(33));
final Set<ResourceAllocation> allocationSet = ImmutableSet.of(allocation);
final LinkResourceAllocations allocations =
......
......@@ -152,7 +152,7 @@ import org.onosproject.net.resource.BandwidthResourceAllocation;
import org.onosproject.net.resource.BandwidthResourceRequest;
import org.onosproject.net.resource.DefaultLinkResourceAllocations;
import org.onosproject.net.resource.DefaultLinkResourceRequest;
import org.onosproject.net.resource.Lambda;
import org.onosproject.net.resource.LambdaResource;
import org.onosproject.net.resource.LambdaResourceAllocation;
import org.onosproject.net.resource.LambdaResourceRequest;
import org.onosproject.net.resource.LinkResourceRequest;
......@@ -355,7 +355,7 @@ public final class KryoNamespaces {
DefaultLinkResourceRequest.class,
BandwidthResourceRequest.class,
LambdaResourceRequest.class,
Lambda.class,
LambdaResource.class,
Bandwidth.class,
DefaultLinkResourceAllocations.class,
BandwidthResourceAllocation.class,
......
......@@ -62,7 +62,7 @@ import org.onosproject.net.resource.Bandwidth;
import org.onosproject.net.resource.BandwidthResourceAllocation;
import org.onosproject.net.resource.DefaultLinkResourceAllocations;
import org.onosproject.net.resource.DefaultLinkResourceRequest;
import org.onosproject.net.resource.Lambda;
import org.onosproject.net.resource.LambdaResource;
import org.onosproject.net.resource.LambdaResourceAllocation;
import org.onosproject.net.resource.LinkResourceRequest;
import org.onosproject.net.resource.ResourceAllocation;
......@@ -355,7 +355,7 @@ public class KryoSerializerTest {
Map<Link, Set<ResourceAllocation>> allocations = new HashMap<>();
allocations.put(new DefaultLink(PID, CP1, CP2, Type.DIRECT),
ImmutableSet.of(new BandwidthResourceAllocation(Bandwidth.bps(10.0)),
new LambdaResourceAllocation(Lambda.valueOf(1))));
new LambdaResourceAllocation(LambdaResource.valueOf(1))));
testSerializable(new DefaultLinkResourceAllocations(request, allocations));
}
......@@ -367,7 +367,7 @@ public class KryoSerializerTest {
@Test
public void testLambdaConstraint() {
testSerializable(new LambdaConstraint(Lambda.valueOf(1)));
testSerializable(new LambdaConstraint(LambdaResource.valueOf(1)));
}
@Test
......
......@@ -33,7 +33,7 @@ import org.onosproject.net.Link;
import org.onosproject.net.intent.IntentId;
import org.onosproject.net.resource.Bandwidth;
import org.onosproject.net.resource.BandwidthResourceAllocation;
import org.onosproject.net.resource.Lambda;
import org.onosproject.net.resource.LambdaResource;
import org.onosproject.net.resource.LambdaResourceAllocation;
import org.onosproject.net.resource.LinkResourceAllocations;
import org.onosproject.net.resource.LinkResourceEvent;
......@@ -90,7 +90,7 @@ public class SimpleLinkResourceStore implements LinkResourceStore {
try {
int waves = Integer.parseInt(annotations.value(AnnotationKeys.OPTICAL_WAVES));
for (int i = 1; i <= waves; i++) {
allocations.add(new LambdaResourceAllocation(Lambda.valueOf(i)));
allocations.add(new LambdaResourceAllocation(LambdaResource.valueOf(i)));
}
} catch (NumberFormatException e) {
log.debug("No optical.wave annotation on link %s", link);
......
......@@ -32,7 +32,7 @@ import org.onosproject.net.intent.IntentId;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.resource.Bandwidth;
import org.onosproject.net.resource.BandwidthResourceAllocation;
import org.onosproject.net.resource.Lambda;
import org.onosproject.net.resource.LambdaResource;
import org.onosproject.net.resource.LambdaResourceAllocation;
import org.onosproject.net.resource.LinkResourceAllocations;
import org.onosproject.net.resource.LinkResourceStore;
......@@ -220,7 +220,7 @@ public class SimpleLinkResourceStoreTest {
@Override
public Set<ResourceAllocation> getResourceAllocation(Link link) {
final ResourceAllocation allocation =
new LambdaResourceAllocation(Lambda.valueOf(allocatedLambda));
new LambdaResourceAllocation(LambdaResource.valueOf(allocatedLambda));
final Set<ResourceAllocation> allocations = new HashSet<>();
allocations.add(allocation);
return allocations;
......