Sho SHIMIZU | a6b4dc7 | 2016-03-11 19:00:20 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Sho SHIMIZU | a6b4dc7 | 2016-03-11 19:00:20 -0800 | [diff] [blame] | 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; |
| 17 | |
| 18 | import java.util.Collection; |
| 19 | import java.util.List; |
| 20 | import java.util.Set; |
| 21 | |
| 22 | /** |
| 23 | * Service for retrieving resource information. |
| 24 | */ |
| 25 | public interface ResourceQueryService { |
| 26 | /** |
| 27 | * Returns resource allocations of the specified resource. |
| 28 | * |
| 29 | * @param id ID of the resource to check the allocation |
| 30 | * @return list of allocation information. |
| 31 | * If the resource is not allocated, the return value is an empty list. |
| 32 | */ |
| 33 | List<ResourceAllocation> getResourceAllocations(ResourceId id); |
| 34 | |
| 35 | /** |
| 36 | * Returns allocated resources being as children of the specified parent and being the specified resource type. |
| 37 | * |
| 38 | * @param parent parent resource ID |
| 39 | * @param cls class to specify a type of resource |
| 40 | * @param <T> type of the resource |
| 41 | * @return non-empty collection of resource allocations if resources are allocated with the subject and type, |
| 42 | * empty collection if no resource is allocated with the subject and type |
| 43 | */ |
| 44 | <T> Collection<ResourceAllocation> getResourceAllocations(DiscreteResourceId parent, Class<T> cls); |
| 45 | |
| 46 | /** |
| 47 | * Returns resources allocated to the specified consumer. |
| 48 | * |
| 49 | * @param consumer consumer whose allocated resources are to be returned |
| 50 | * @return resources allocated to the consumer |
| 51 | */ |
| 52 | Collection<ResourceAllocation> getResourceAllocations(ResourceConsumer consumer); |
| 53 | |
| 54 | /** |
| 55 | * Returns resources that point available child resources under the specified resource. |
| 56 | * |
| 57 | * @param parent parent resource ID |
| 58 | * @return available resources under the specified resource |
| 59 | */ |
| 60 | Set<Resource> getAvailableResources(DiscreteResourceId parent); |
| 61 | |
| 62 | /** |
| 63 | * Returns available resources which are child resources of the specified parent and |
| 64 | * whose type is the specified type. |
| 65 | * |
| 66 | * @param parent parent resource ID |
| 67 | * @param cls class to specify a type of resource |
| 68 | * @param <T> type of the resource |
| 69 | * @return available resources of the specified type under the specified parent resource |
| 70 | */ |
| 71 | <T> Set<Resource> getAvailableResources(DiscreteResourceId parent, Class<T> cls); |
| 72 | |
| 73 | /** |
| 74 | * Returns available resource values which are the values of the child resource of |
| 75 | * the specified parent and whose type is the specified type. |
| 76 | * |
| 77 | * @param parent parent resource ID |
| 78 | * @param cls class to specify a type of resource |
| 79 | * @param <T> type of the resource |
| 80 | * @return available resource value of the specified type under the specified parent resource |
| 81 | */ |
| 82 | <T> Set<T> getAvailableResourceValues(DiscreteResourceId parent, Class<T> cls); |
| 83 | |
| 84 | /** |
| 85 | * Returns resources registered under the specified resource. |
| 86 | * |
| 87 | * @param parent parent resource ID |
| 88 | * @return registered resources under the specified resource |
| 89 | */ |
| 90 | Set<Resource> getRegisteredResources(DiscreteResourceId parent); |
| 91 | |
| 92 | /** |
| 93 | * Returns the availability of the specified resource. |
| 94 | * |
| 95 | * @param resource resource to check the availability |
| 96 | * @return true if available, otherwise false |
| 97 | */ |
| 98 | boolean isAvailable(Resource resource); |
| 99 | } |