Preparing implementation of link resource data store.
diff --git a/core/net/src/main/java/org/onlab/onos/net/resource/impl/LinkResourceManager.java b/core/net/src/main/java/org/onlab/onos/net/resource/impl/LinkResourceManager.java
index 75e0818..d2d9e7e 100644
--- a/core/net/src/main/java/org/onlab/onos/net/resource/impl/LinkResourceManager.java
+++ b/core/net/src/main/java/org/onlab/onos/net/resource/impl/LinkResourceManager.java
@@ -3,6 +3,7 @@
import static org.slf4j.LoggerFactory.getLogger;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -44,12 +45,16 @@
log.info("Stopped");
}
+ private Iterable<Lambda> getAvailableLambdas(Iterable<Link> links) {
+ return Sets.newHashSet(Lambda.valueOf(7));
+ }
+
@Override
public LinkResourceAllocations requestResources(LinkResourceRequest req) {
// TODO implement it using a resource data store.
ResourceAllocation alloc = null;
- for (ResourceRequest r: req.resources()) {
+ for (ResourceRequest r : req.resources()) {
switch (r.type()) {
case BANDWIDTH:
log.info("requestResources() always returns requested bandwidth");
@@ -58,7 +63,10 @@
break;
case LAMBDA:
log.info("requestResources() always returns lambda 7");
- alloc = new LambdaResourceAllocation(Lambda.valueOf(7));
+ Iterator<Lambda> lambdaIterator = getAvailableLambdas(req.links()).iterator();
+ if (lambdaIterator.hasNext()) {
+ alloc = new LambdaResourceAllocation(lambdaIterator.next());
+ }
break;
default:
break;
@@ -66,7 +74,7 @@
}
Map<Link, Set<ResourceAllocation>> allocations = new HashMap<>();
- for (Link link: req.links()) {
+ for (Link link : req.links()) {
allocations.put(link, Sets.newHashSet(alloc));
}
return new DefaultLinkResourceAllocations(req, allocations);
@@ -91,25 +99,19 @@
}
@Override
- public LinkResourceAllocations getAllocations(IntentId intentId) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
public Iterable<LinkResourceAllocations> getAllocations(Link link) {
// TODO Auto-generated method stub
return null;
}
@Override
- public Iterable<IntentId> getIntents(Link link) {
+ public LinkResourceAllocations getAllocations(IntentId intentId) {
// TODO Auto-generated method stub
return null;
}
@Override
- public ResourceRequest getAvailableResources(Link link) {
+ public Iterable<ResourceRequest> getAvailableResources(Link link) {
// TODO Auto-generated method stub
return null;
}