blob: 1d1e697975850b81b55bf7b4e5702ee02bf2a3cb [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.resource;
Toshio Koidec9051db2014-10-20 15:18:37 -070017
Brian O'Connorabafb502014-12-02 22:26:20 -080018import org.onosproject.net.Link;
19import org.onosproject.net.intent.IntentId;
Toshio Koidec9051db2014-10-20 15:18:37 -070020
21/**
22 * Service for providing link resource allocation.
23 */
24public interface LinkResourceService {
25
26 /**
Toshio Koide485b4782014-10-20 19:34:21 -070027 * Requests resources.
Toshio Koidec9051db2014-10-20 15:18:37 -070028 *
Toshio Koide485b4782014-10-20 19:34:21 -070029 * @param req resources to be allocated
30 * @return allocated resources
Toshio Koidec9051db2014-10-20 15:18:37 -070031 */
Toshio Koide485b4782014-10-20 19:34:21 -070032 LinkResourceAllocations requestResources(LinkResourceRequest req);
Toshio Koidec9051db2014-10-20 15:18:37 -070033
34 /**
Toshio Koide485b4782014-10-20 19:34:21 -070035 * Releases resources.
Toshio Koidec9051db2014-10-20 15:18:37 -070036 *
Toshio Koide485b4782014-10-20 19:34:21 -070037 * @param allocations resources to be released
Toshio Koidec9051db2014-10-20 15:18:37 -070038 */
Toshio Koide485b4782014-10-20 19:34:21 -070039 void releaseResources(LinkResourceAllocations allocations);
Toshio Koidec9051db2014-10-20 15:18:37 -070040
41 /**
Thomas Vachuskaf9976952014-10-24 11:55:05 -070042 * Updates previously made allocations with a new resource request.
43 *
44 * @param req updated resource request
45 * @param oldAllocations old resource allocations
46 * @return new resource allocations
47 */
48 LinkResourceAllocations updateResources(LinkResourceRequest req,
49 LinkResourceAllocations oldAllocations);
50
51 /**
Toshio Koide485b4782014-10-20 19:34:21 -070052 * Returns all allocated resources.
Toshio Koidec9051db2014-10-20 15:18:37 -070053 *
Toshio Koide485b4782014-10-20 19:34:21 -070054 * @return allocated resources
Toshio Koidec9051db2014-10-20 15:18:37 -070055 */
Toshio Koide485b4782014-10-20 19:34:21 -070056 Iterable<LinkResourceAllocations> getAllocations();
Toshio Koidec9051db2014-10-20 15:18:37 -070057
Brian O'Connor55153ce2014-10-23 13:44:05 -070058 /**
Toshio Koidec9051db2014-10-20 15:18:37 -070059 * Returns all allocated resources to given link.
60 *
61 * @param link a target link
Toshio Koide485b4782014-10-20 19:34:21 -070062 * @return allocated resources
Toshio Koidec9051db2014-10-20 15:18:37 -070063 */
Toshio Koide485b4782014-10-20 19:34:21 -070064 Iterable<LinkResourceAllocations> getAllocations(Link link);
Toshio Koidec9051db2014-10-20 15:18:37 -070065
66 /**
Toshio Koide9be539e2014-10-23 18:43:30 -070067 * Returns the resources allocated for an Intent.
Toshio Koidec9051db2014-10-20 15:18:37 -070068 *
Toshio Koide9be539e2014-10-23 18:43:30 -070069 * @param intentId the target Intent's id
70 * @return allocated resources for Intent
Toshio Koidec9051db2014-10-20 15:18:37 -070071 */
Toshio Koide9be539e2014-10-23 18:43:30 -070072 LinkResourceAllocations getAllocations(IntentId intentId);
Toshio Koidec9051db2014-10-20 15:18:37 -070073
74 /**
75 * Returns available resources for given link.
Toshio Koide485b4782014-10-20 19:34:21 -070076 *
Toshio Koidec9051db2014-10-20 15:18:37 -070077 * @param link a target link
78 * @return available resources for the target link
79 */
Toshio Koide9be539e2014-10-23 18:43:30 -070080 Iterable<ResourceRequest> getAvailableResources(Link link);
Thomas Vachuskaf9976952014-10-24 11:55:05 -070081
82 /**
83 * Returns available resources for given link.
84 *
85 * @param link a target link
86 * @param allocations allocations to be included as available
87 * @return available resources for the target link
88 */
weibit00c94f52014-11-16 07:09:05 -080089 Iterable<ResourceRequest> getAvailableResources(Link link,
Thomas Vachuskaf9976952014-10-24 11:55:05 -070090 LinkResourceAllocations allocations);
91
Ray Milkeye97ede92014-11-20 10:43:12 -080092 /**
93 * Adds a listener for resource related events.
94 *
95 * @param listener listener to add
96 */
97 void addListener(LinkResourceListener listener);
98
99 /**
100 * Removes a listener for resource related events.
101 *
102 * @param listener listener to remove.
103 */
104 void removeListener(LinkResourceListener listener);
105
Toshio Koidec9051db2014-10-20 15:18:37 -0700106}