Preparing implementation of link resource data store.
diff --git a/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceService.java b/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceService.java
index 43cc61c..2d709cb 100644
--- a/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceService.java
+++ b/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceService.java
@@ -41,14 +41,6 @@
Iterable<LinkResourceAllocations> getAllocations();
/**
- * Returns the resources allocated for an Intent.
- *
- * @param intentId the target Intent's id
- * @return allocated resources for Intent
- */
- LinkResourceAllocations getAllocations(IntentId intentId);
-
- /**
* Returns all allocated resources to given link.
*
* @param link a target link
@@ -57,12 +49,12 @@
Iterable<LinkResourceAllocations> getAllocations(Link link);
/**
- * Returns all IDs of intents using the given link.
+ * Returns the resources allocated for an Intent.
*
- * @param link a target link
- * @return IDs of intents using the link
+ * @param intentId the target Intent's id
+ * @return allocated resources for Intent
*/
- Iterable<IntentId> getIntents(Link link);
+ LinkResourceAllocations getAllocations(IntentId intentId);
/**
* Returns available resources for given link.
@@ -70,7 +62,7 @@
* @param link a target link
* @return available resources for the target link
*/
- ResourceRequest getAvailableResources(Link link);
+ Iterable<ResourceRequest> getAvailableResources(Link link);
/**
* Returns available resources for given link.
diff --git a/core/net/src/main/java/org/onlab/onos/net/resource/impl/DefaultLinkResourceAllocations.java b/core/net/src/main/java/org/onlab/onos/net/resource/impl/DefaultLinkResourceAllocations.java
index 0330821..a366a81 100644
--- a/core/net/src/main/java/org/onlab/onos/net/resource/impl/DefaultLinkResourceAllocations.java
+++ b/core/net/src/main/java/org/onlab/onos/net/resource/impl/DefaultLinkResourceAllocations.java
@@ -26,7 +26,7 @@
* @param request requested resources
* @param allocations allocated resources
*/
- protected DefaultLinkResourceAllocations(LinkResourceRequest request,
+ DefaultLinkResourceAllocations(LinkResourceRequest request,
Map<Link, Set<ResourceAllocation>> allocations) {
this.request = request;
this.allocations = allocations;
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;
}