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