Showing
3 changed files
with
19 additions
and
25 deletions
... | @@ -41,14 +41,6 @@ public interface LinkResourceService { | ... | @@ -41,14 +41,6 @@ public interface LinkResourceService { |
41 | Iterable<LinkResourceAllocations> getAllocations(); | 41 | Iterable<LinkResourceAllocations> getAllocations(); |
42 | 42 | ||
43 | /** | 43 | /** |
44 | - * Returns the resources allocated for an Intent. | ||
45 | - * | ||
46 | - * @param intentId the target Intent's id | ||
47 | - * @return allocated resources for Intent | ||
48 | - */ | ||
49 | - LinkResourceAllocations getAllocations(IntentId intentId); | ||
50 | - | ||
51 | - /** | ||
52 | * Returns all allocated resources to given link. | 44 | * Returns all allocated resources to given link. |
53 | * | 45 | * |
54 | * @param link a target link | 46 | * @param link a target link |
... | @@ -57,12 +49,12 @@ public interface LinkResourceService { | ... | @@ -57,12 +49,12 @@ public interface LinkResourceService { |
57 | Iterable<LinkResourceAllocations> getAllocations(Link link); | 49 | Iterable<LinkResourceAllocations> getAllocations(Link link); |
58 | 50 | ||
59 | /** | 51 | /** |
60 | - * Returns all IDs of intents using the given link. | 52 | + * Returns the resources allocated for an Intent. |
61 | * | 53 | * |
62 | - * @param link a target link | 54 | + * @param intentId the target Intent's id |
63 | - * @return IDs of intents using the link | 55 | + * @return allocated resources for Intent |
64 | */ | 56 | */ |
65 | - Iterable<IntentId> getIntents(Link link); | 57 | + LinkResourceAllocations getAllocations(IntentId intentId); |
66 | 58 | ||
67 | /** | 59 | /** |
68 | * Returns available resources for given link. | 60 | * Returns available resources for given link. |
... | @@ -70,7 +62,7 @@ public interface LinkResourceService { | ... | @@ -70,7 +62,7 @@ public interface LinkResourceService { |
70 | * @param link a target link | 62 | * @param link a target link |
71 | * @return available resources for the target link | 63 | * @return available resources for the target link |
72 | */ | 64 | */ |
73 | - ResourceRequest getAvailableResources(Link link); | 65 | + Iterable<ResourceRequest> getAvailableResources(Link link); |
74 | 66 | ||
75 | /** | 67 | /** |
76 | * Returns available resources for given link. | 68 | * Returns available resources for given link. | ... | ... |
... | @@ -26,7 +26,7 @@ public class DefaultLinkResourceAllocations implements LinkResourceAllocations { | ... | @@ -26,7 +26,7 @@ public class DefaultLinkResourceAllocations implements LinkResourceAllocations { |
26 | * @param request requested resources | 26 | * @param request requested resources |
27 | * @param allocations allocated resources | 27 | * @param allocations allocated resources |
28 | */ | 28 | */ |
29 | - protected DefaultLinkResourceAllocations(LinkResourceRequest request, | 29 | + DefaultLinkResourceAllocations(LinkResourceRequest request, |
30 | Map<Link, Set<ResourceAllocation>> allocations) { | 30 | Map<Link, Set<ResourceAllocation>> allocations) { |
31 | this.request = request; | 31 | this.request = request; |
32 | this.allocations = allocations; | 32 | this.allocations = allocations; | ... | ... |
... | @@ -3,6 +3,7 @@ package org.onlab.onos.net.resource.impl; | ... | @@ -3,6 +3,7 @@ package org.onlab.onos.net.resource.impl; |
3 | import static org.slf4j.LoggerFactory.getLogger; | 3 | import static org.slf4j.LoggerFactory.getLogger; |
4 | 4 | ||
5 | import java.util.HashMap; | 5 | import java.util.HashMap; |
6 | +import java.util.Iterator; | ||
6 | import java.util.Map; | 7 | import java.util.Map; |
7 | import java.util.Set; | 8 | import java.util.Set; |
8 | 9 | ||
... | @@ -44,12 +45,16 @@ public class LinkResourceManager implements LinkResourceService { | ... | @@ -44,12 +45,16 @@ public class LinkResourceManager implements LinkResourceService { |
44 | log.info("Stopped"); | 45 | log.info("Stopped"); |
45 | } | 46 | } |
46 | 47 | ||
48 | + private Iterable<Lambda> getAvailableLambdas(Iterable<Link> links) { | ||
49 | + return Sets.newHashSet(Lambda.valueOf(7)); | ||
50 | + } | ||
51 | + | ||
47 | @Override | 52 | @Override |
48 | public LinkResourceAllocations requestResources(LinkResourceRequest req) { | 53 | public LinkResourceAllocations requestResources(LinkResourceRequest req) { |
49 | // TODO implement it using a resource data store. | 54 | // TODO implement it using a resource data store. |
50 | 55 | ||
51 | ResourceAllocation alloc = null; | 56 | ResourceAllocation alloc = null; |
52 | - for (ResourceRequest r: req.resources()) { | 57 | + for (ResourceRequest r : req.resources()) { |
53 | switch (r.type()) { | 58 | switch (r.type()) { |
54 | case BANDWIDTH: | 59 | case BANDWIDTH: |
55 | log.info("requestResources() always returns requested bandwidth"); | 60 | log.info("requestResources() always returns requested bandwidth"); |
... | @@ -58,7 +63,10 @@ public class LinkResourceManager implements LinkResourceService { | ... | @@ -58,7 +63,10 @@ public class LinkResourceManager implements LinkResourceService { |
58 | break; | 63 | break; |
59 | case LAMBDA: | 64 | case LAMBDA: |
60 | log.info("requestResources() always returns lambda 7"); | 65 | log.info("requestResources() always returns lambda 7"); |
61 | - alloc = new LambdaResourceAllocation(Lambda.valueOf(7)); | 66 | + Iterator<Lambda> lambdaIterator = getAvailableLambdas(req.links()).iterator(); |
67 | + if (lambdaIterator.hasNext()) { | ||
68 | + alloc = new LambdaResourceAllocation(lambdaIterator.next()); | ||
69 | + } | ||
62 | break; | 70 | break; |
63 | default: | 71 | default: |
64 | break; | 72 | break; |
... | @@ -66,7 +74,7 @@ public class LinkResourceManager implements LinkResourceService { | ... | @@ -66,7 +74,7 @@ public class LinkResourceManager implements LinkResourceService { |
66 | } | 74 | } |
67 | 75 | ||
68 | Map<Link, Set<ResourceAllocation>> allocations = new HashMap<>(); | 76 | Map<Link, Set<ResourceAllocation>> allocations = new HashMap<>(); |
69 | - for (Link link: req.links()) { | 77 | + for (Link link : req.links()) { |
70 | allocations.put(link, Sets.newHashSet(alloc)); | 78 | allocations.put(link, Sets.newHashSet(alloc)); |
71 | } | 79 | } |
72 | return new DefaultLinkResourceAllocations(req, allocations); | 80 | return new DefaultLinkResourceAllocations(req, allocations); |
... | @@ -91,25 +99,19 @@ public class LinkResourceManager implements LinkResourceService { | ... | @@ -91,25 +99,19 @@ public class LinkResourceManager implements LinkResourceService { |
91 | } | 99 | } |
92 | 100 | ||
93 | @Override | 101 | @Override |
94 | - public LinkResourceAllocations getAllocations(IntentId intentId) { | ||
95 | - // TODO Auto-generated method stub | ||
96 | - return null; | ||
97 | - } | ||
98 | - | ||
99 | - @Override | ||
100 | public Iterable<LinkResourceAllocations> getAllocations(Link link) { | 102 | public Iterable<LinkResourceAllocations> getAllocations(Link link) { |
101 | // TODO Auto-generated method stub | 103 | // TODO Auto-generated method stub |
102 | return null; | 104 | return null; |
103 | } | 105 | } |
104 | 106 | ||
105 | @Override | 107 | @Override |
106 | - public Iterable<IntentId> getIntents(Link link) { | 108 | + public LinkResourceAllocations getAllocations(IntentId intentId) { |
107 | // TODO Auto-generated method stub | 109 | // TODO Auto-generated method stub |
108 | return null; | 110 | return null; |
109 | } | 111 | } |
110 | 112 | ||
111 | @Override | 113 | @Override |
112 | - public ResourceRequest getAvailableResources(Link link) { | 114 | + public Iterable<ResourceRequest> getAvailableResources(Link link) { |
113 | // TODO Auto-generated method stub | 115 | // TODO Auto-generated method stub |
114 | return null; | 116 | return null; |
115 | } | 117 | } | ... | ... |
-
Please register or login to post a comment