Brian O'Connor | 6de2e20 | 2015-05-21 14:30:41 -0700 | [diff] [blame] | 1 | package org.onosproject.incubator.net.resource.label; |
jcc | fff0de9 | 2015-03-28 01:40:08 -0700 | [diff] [blame] | 2 | |
| 3 | import java.util.Collection; |
| 4 | import java.util.Set; |
| 5 | |
Brian O'Connor | 893b922 | 2015-06-25 15:07:04 -0400 | [diff] [blame] | 6 | import com.google.common.annotations.Beta; |
jcc | fff0de9 | 2015-03-28 01:40:08 -0700 | [diff] [blame] | 7 | import org.onosproject.net.DeviceId; |
| 8 | import org.onosproject.store.Store; |
| 9 | |
| 10 | import com.google.common.collect.Multimap; |
| 11 | |
| 12 | /** |
| 13 | * Manages inventory of label; not intended for direct use. |
| 14 | * |
| 15 | */ |
Brian O'Connor | 893b922 | 2015-06-25 15:07:04 -0400 | [diff] [blame] | 16 | @Beta |
jcc | fff0de9 | 2015-03-28 01:40:08 -0700 | [diff] [blame] | 17 | public interface LabelResourceStore |
| 18 | extends Store<LabelResourceEvent, LabelResourceDelegate> { |
| 19 | |
| 20 | /** |
| 21 | * Creates a label resource of some device id from begin label to end label. |
| 22 | * |
| 23 | * @param deviceId device identifier |
| 24 | * @param beginLabel represents for the first label id in the range of label |
| 25 | * pool |
| 26 | * @param endLabel represents for the last label id in the range of label |
| 27 | * pool |
| 28 | * @return success or fail |
| 29 | */ |
| 30 | boolean createDevicePool(DeviceId deviceId, LabelResourceId beginLabel, |
| 31 | LabelResourceId endLabel); |
| 32 | |
| 33 | /** |
| 34 | * Creates the global label resource pool. |
| 35 | * |
| 36 | * @param beginLabel represents for the first label id in the range of label |
| 37 | * pool |
| 38 | * @param endLabel represents for the last label id in the range of label |
| 39 | * pool |
| 40 | * @return success or fail |
| 41 | */ |
| 42 | boolean createGlobalPool(LabelResourceId beginLabel, |
| 43 | LabelResourceId endLabel); |
| 44 | |
| 45 | /** |
| 46 | * Destroys a label resource pool of a specific device id. |
| 47 | * |
| 48 | * @param deviceId device identifier |
| 49 | * @return success or fail |
| 50 | */ |
| 51 | boolean destroyDevicePool(DeviceId deviceId); |
| 52 | |
| 53 | /** |
| 54 | * Destroys a the global label resource pool. |
| 55 | * |
| 56 | * @return success or fail |
| 57 | */ |
| 58 | boolean destroyGlobalPool(); |
| 59 | |
| 60 | /** |
| 61 | * Returns labels from resource pool by a specific device id. |
| 62 | * |
| 63 | * @param deviceId device identifier |
| 64 | * @param applyNum the applying number |
| 65 | * @return collection of applying labels |
| 66 | */ |
| 67 | Collection<LabelResource> applyFromDevicePool(DeviceId deviceId, |
| 68 | long applyNum); |
| 69 | |
| 70 | /** |
| 71 | * Returns labels from the global label resource pool. |
| 72 | * |
| 73 | * @param applyNum apply the number of labels |
| 74 | * @return collection of labels |
| 75 | */ |
| 76 | Collection<LabelResource> applyFromGlobalPool(long applyNum); |
| 77 | |
| 78 | /** |
| 79 | * Releases unused labels to device pools . |
| 80 | * |
| 81 | * @param release the collection of releasing labels |
| 82 | * @return success or fail |
| 83 | */ |
| 84 | boolean releaseToDevicePool(Multimap<DeviceId, LabelResource> release); |
| 85 | |
| 86 | /** |
| 87 | * Releases unused labels to the global resource pool. |
| 88 | * |
| 89 | * @param release release the collection of releasing labels |
| 90 | * @return success or fail |
| 91 | */ |
| 92 | boolean releaseToGlobalPool(Set<LabelResourceId> release); |
| 93 | |
| 94 | /** |
| 95 | * Judges if the pool of a specific device id is full. |
| 96 | * |
| 97 | * @param deviceId device identifier |
| 98 | * @return yes or no |
| 99 | */ |
| 100 | boolean isDevicePoolFull(DeviceId deviceId); |
| 101 | |
| 102 | /** |
| 103 | * Judges if the global resource pool is full. |
| 104 | * |
| 105 | * @return yes or no |
| 106 | */ |
| 107 | boolean isGlobalPoolFull(); |
| 108 | |
| 109 | /** |
| 110 | * Returns the unused label number of a label resource pool by a specific device |
| 111 | * id. |
| 112 | * |
| 113 | * @param deviceId device identifier |
| 114 | * @return number of unused labels |
| 115 | */ |
| 116 | long getFreeNumOfDevicePool(DeviceId deviceId); |
| 117 | |
| 118 | /** |
| 119 | * Returns the unused number of a global label resource pool. |
| 120 | * |
| 121 | * @return number of unused labels |
| 122 | */ |
| 123 | long getFreeNumOfGlobalPool(); |
| 124 | |
| 125 | /** |
| 126 | * Returns the label resource pool by a specific device id. |
| 127 | * |
| 128 | * @param deviceId device identifier |
| 129 | * @return the device label resource pool |
| 130 | */ |
| 131 | LabelResourcePool getDeviceLabelResourcePool(DeviceId deviceId); |
| 132 | |
| 133 | /** |
| 134 | * Returns the global label resource pool. |
| 135 | * |
| 136 | * @return the global label resource pool |
| 137 | */ |
| 138 | LabelResourcePool getGlobalLabelResourcePool(); |
| 139 | } |