blob: a207dbcc24c8fe489737c6350762886edc7ba2b0 [file] [log] [blame]
Toshio Koide50df38d2014-10-23 10:36:51 -07001package org.onlab.onos.net.resource;
2
3import static org.slf4j.LoggerFactory.getLogger;
4
Toshio Koideca0fcff2014-10-23 14:08:36 -07005import java.util.HashMap;
6import java.util.Map;
7import java.util.Set;
8
Toshio Koide50df38d2014-10-23 10:36:51 -07009import org.apache.felix.scr.annotations.Activate;
10import org.apache.felix.scr.annotations.Component;
11import org.apache.felix.scr.annotations.Deactivate;
12import org.apache.felix.scr.annotations.Service;
13import org.onlab.onos.net.Link;
14import org.onlab.onos.net.intent.IntentId;
15import org.slf4j.Logger;
16
Toshio Koideca0fcff2014-10-23 14:08:36 -070017import com.google.common.collect.Sets;
18
Toshio Koide50df38d2014-10-23 10:36:51 -070019/**
20 * Provides basic implementation of link resources allocation.
21 */
22@Component(immediate = true)
23@Service
24public class LinkResourceManager implements LinkResourceService {
25
26 private final Logger log = getLogger(getClass());
27
28 @Activate
29 public void activate() {
30 log.info("Started");
31 }
32
33 @Deactivate
34 public void deactivate() {
35 log.info("Stopped");
36 }
37
38 @Override
39 public LinkResourceAllocations requestResources(LinkResourceRequest req) {
Toshio Koideca0fcff2014-10-23 14:08:36 -070040 // TODO implement it using a resource data store.
41
42 ResourceAllocation alloc = null;
43 for (ResourceRequest r: req.resources()) {
44 switch (r.type()) {
45 case BANDWIDTH:
46 log.info("requestResources() always returns requested bandwidth");
47 BandwidthResourceRequest br = (BandwidthResourceRequest) r;
48 alloc = new BandwidthResourceAllocation(br.bandwidth());
49 break;
50 case LAMBDA:
51 log.info("requestResources() always returns lambda 7");
52 alloc = new LambdaResourceAllocation(Lambda.valueOf(7));
53 break;
54 default:
55 break;
56 }
57 }
58
59 Map<Link, Set<ResourceAllocation>> allocations = new HashMap<>();
60 for (Link link: req.links()) {
61 allocations.put(link, Sets.newHashSet(alloc));
62 }
63 return new DefaultLinkResourceAllocations(req, allocations);
Toshio Koide50df38d2014-10-23 10:36:51 -070064 }
65
66 @Override
67 public void releaseResources(LinkResourceAllocations allocations) {
68 // TODO Auto-generated method stub
69
70 }
71
72 @Override
73 public Iterable<LinkResourceAllocations> getAllocations() {
74 // TODO Auto-generated method stub
75 return null;
76 }
77
78 @Override
Brian O'Connore7e4bd52014-10-23 13:36:23 -070079 public LinkResourceAllocations getAllocation(IntentId intentId) {
80 // TODO Auto-generated method stub
81 return null;
82 }
83
84 @Override
Toshio Koide50df38d2014-10-23 10:36:51 -070085 public Iterable<LinkResourceAllocations> getAllocations(Link link) {
86 // TODO Auto-generated method stub
87 return null;
88 }
89
90 @Override
91 public Iterable<IntentId> getIntents(Link link) {
92 // TODO Auto-generated method stub
93 return null;
94 }
95
96 @Override
97 public ResourceRequest getAvailableResources(Link link) {
98 // TODO Auto-generated method stub
99 return null;
100 }
101
102}