jcc | fff0de9 | 2015-03-28 01:40:08 -0700 | [diff] [blame^] | 1 | package org.onosproject.net.resource; |
| 2 | |
| 3 | import java.util.Collection; |
| 4 | import java.util.Set; |
| 5 | |
| 6 | import org.onosproject.net.DeviceId; |
| 7 | |
| 8 | import com.google.common.collect.Multimap; |
| 9 | |
| 10 | /** |
| 11 | * Service for providing label resource allocation. |
| 12 | */ |
| 13 | public interface LabelResourceService { |
| 14 | |
| 15 | /** |
| 16 | * Returns labels from resource pool by a specific device id. |
| 17 | * |
| 18 | * @param deviceId device identifier |
| 19 | * @param applyNum the applying number |
| 20 | * @return collection of applying labels |
| 21 | */ |
| 22 | Collection<LabelResource> applyFromDevicePool(DeviceId deviceId, |
| 23 | long applyNum); |
| 24 | |
| 25 | /** |
| 26 | * Returns labels from the global label resource pool. |
| 27 | * |
| 28 | * @param applyNum the applying number |
| 29 | * @return collection of applying labels |
| 30 | */ |
| 31 | Collection<LabelResource> applyFromGlobalPool(long applyNum); |
| 32 | |
| 33 | /** |
| 34 | * Releases unused labels to device pools . |
| 35 | * |
| 36 | * @param release the collection of releasing labels |
| 37 | * @return success or fail |
| 38 | */ |
| 39 | boolean releaseToDevicePool(Multimap<DeviceId, LabelResource> release); |
| 40 | |
| 41 | /** |
| 42 | * Releases unused labels to the global resource pool. |
| 43 | * |
| 44 | * @param release release the collection of releasing labels |
| 45 | * @return success or fail |
| 46 | */ |
| 47 | boolean releaseToGlobalPool(Set<LabelResourceId> release); |
| 48 | |
| 49 | /** |
| 50 | * Judges if the pool of a specific device id is full. |
| 51 | * |
| 52 | * @param deviceId device identifier |
| 53 | * @return yes or no |
| 54 | */ |
| 55 | boolean isDevicePoolFull(DeviceId deviceId); |
| 56 | |
| 57 | /** |
| 58 | * Judges if the global resource pool is full. |
| 59 | * |
| 60 | * @return yes or no |
| 61 | */ |
| 62 | boolean isGlobalPoolFull(); |
| 63 | |
| 64 | /** |
| 65 | * Returns the unused label number of a label resource pool by a specific device |
| 66 | * id. |
| 67 | * |
| 68 | * @param deviceId device identifier |
| 69 | * @return number of unused labels |
| 70 | */ |
| 71 | long getFreeNumOfDevicePool(DeviceId deviceId); |
| 72 | |
| 73 | /** |
| 74 | * Returns the unused label number of a global label resource pool. |
| 75 | * |
| 76 | * @return number of unused labels |
| 77 | */ |
| 78 | long getFreeNumOfGlobalPool(); |
| 79 | |
| 80 | /** |
| 81 | * Returns the label resource pool of a label resource by a specific device |
| 82 | * id. |
| 83 | * |
| 84 | * @param deviceId device identifier |
| 85 | * @return the device label resource pool |
| 86 | */ |
| 87 | LabelResourcePool getDeviceLabelResourcePool(DeviceId deviceId); |
| 88 | |
| 89 | /** |
| 90 | * Returns the global label resource pool. |
| 91 | * |
| 92 | * @return the global label resource pool |
| 93 | */ |
| 94 | LabelResourcePool getGlobalLabelResourcePool(); |
| 95 | |
| 96 | /** |
| 97 | * Adds the specified label resource listener. |
| 98 | * |
| 99 | * @param listener label resource listener |
| 100 | */ |
| 101 | void addListener(LabelResourceListener listener); |
| 102 | |
| 103 | /** |
| 104 | * Removes the specified label resource listener. |
| 105 | * |
| 106 | * @param listener label resource listener |
| 107 | */ |
| 108 | void removeListener(LabelResourceListener listener); |
| 109 | } |