6dc04dfc5f6be3aeb17862511b5d45971933f417
[onosfw.git] /
1 /*
2  * Copyright 2014 Open Networking Laboratory
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onosproject.net.resource.link;
17
18 import org.onosproject.event.ListenerService;
19 import org.onosproject.net.Link;
20 import org.onosproject.net.intent.IntentId;
21 import org.onosproject.net.resource.ResourceRequest;
22
23 /**
24  * Service for providing link resource allocation.
25  */
26 public interface LinkResourceService
27     extends ListenerService<LinkResourceEvent, LinkResourceListener> {
28
29     /**
30      * Requests resources.
31      *
32      * @param req resources to be allocated
33      * @return allocated resources
34      */
35     LinkResourceAllocations requestResources(LinkResourceRequest req);
36
37     /**
38      * Releases resources.
39      *
40      * @param allocations resources to be released
41      */
42     void releaseResources(LinkResourceAllocations allocations);
43
44     /**
45      * Updates previously made allocations with a new resource request.
46      *
47      * @param req            updated resource request
48      * @param oldAllocations old resource allocations
49      * @return new resource allocations
50      */
51     LinkResourceAllocations updateResources(LinkResourceRequest req,
52                                             LinkResourceAllocations oldAllocations);
53
54     /**
55      * Returns all allocated resources.
56      *
57      * @return allocated resources
58      */
59     Iterable<LinkResourceAllocations> getAllocations();
60
61     /**
62      * Returns all allocated resources to given link.
63      *
64      * @param link a target link
65      * @return allocated resources
66      */
67     Iterable<LinkResourceAllocations> getAllocations(Link link);
68
69     /**
70      * Returns the resources allocated for an Intent.
71      *
72      * @param intentId the target Intent's id
73      * @return allocated resources for Intent
74      */
75     LinkResourceAllocations getAllocations(IntentId intentId);
76
77     /**
78      * Returns available resources for given link.
79      *
80      * @param link a target link
81      * @return available resources for the target link
82      */
83     Iterable<ResourceRequest> getAvailableResources(Link link);
84
85     /**
86      * Returns available resources for given link.
87      *
88      * @param link        a target link
89      * @param allocations allocations to be included as available
90      * @return available resources for the target link
91      */
92     Iterable<ResourceRequest> getAvailableResources(Link link,
93                                                     LinkResourceAllocations allocations);
94
95 }