Toshio Koide

Preparing implementation of link resource data store.

......@@ -41,14 +41,6 @@ public interface LinkResourceService {
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 @@ public interface LinkResourceService {
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 @@ public interface LinkResourceService {
* @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.
......
......@@ -26,7 +26,7 @@ public class DefaultLinkResourceAllocations implements LinkResourceAllocations {
* @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;
......
......@@ -3,6 +3,7 @@ package org.onlab.onos.net.resource.impl;
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 @@ public class LinkResourceManager implements LinkResourceService {
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 @@ public class LinkResourceManager implements LinkResourceService {
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 @@ public class LinkResourceManager implements LinkResourceService {
}
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 @@ public class LinkResourceManager implements LinkResourceService {
}
@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;
}
......