1 package org.onosproject.incubator.net.resource.label;
3 import java.util.Collection;
6 import com.google.common.annotations.Beta;
7 import org.onosproject.net.DeviceId;
8 import org.onosproject.store.Store;
10 import com.google.common.collect.Multimap;
13 * Manages inventory of label; not intended for direct use.
17 public interface LabelResourceStore
18 extends Store<LabelResourceEvent, LabelResourceDelegate> {
21 * Creates a label resource of some device id from begin label to end label.
23 * @param deviceId device identifier
24 * @param beginLabel represents for the first label id in the range of label
26 * @param endLabel represents for the last label id in the range of label
28 * @return success or fail
30 boolean createDevicePool(DeviceId deviceId, LabelResourceId beginLabel,
31 LabelResourceId endLabel);
34 * Creates the global label resource pool.
36 * @param beginLabel represents for the first label id in the range of label
38 * @param endLabel represents for the last label id in the range of label
40 * @return success or fail
42 boolean createGlobalPool(LabelResourceId beginLabel,
43 LabelResourceId endLabel);
46 * Destroys a label resource pool of a specific device id.
48 * @param deviceId device identifier
49 * @return success or fail
51 boolean destroyDevicePool(DeviceId deviceId);
54 * Destroys a the global label resource pool.
56 * @return success or fail
58 boolean destroyGlobalPool();
61 * Returns labels from resource pool by a specific device id.
63 * @param deviceId device identifier
64 * @param applyNum the applying number
65 * @return collection of applying labels
67 Collection<LabelResource> applyFromDevicePool(DeviceId deviceId,
71 * Returns labels from the global label resource pool.
73 * @param applyNum apply the number of labels
74 * @return collection of labels
76 Collection<LabelResource> applyFromGlobalPool(long applyNum);
79 * Releases unused labels to device pools .
81 * @param release the collection of releasing labels
82 * @return success or fail
84 boolean releaseToDevicePool(Multimap<DeviceId, LabelResource> release);
87 * Releases unused labels to the global resource pool.
89 * @param release release the collection of releasing labels
90 * @return success or fail
92 boolean releaseToGlobalPool(Set<LabelResourceId> release);
95 * Judges if the pool of a specific device id is full.
97 * @param deviceId device identifier
100 boolean isDevicePoolFull(DeviceId deviceId);
103 * Judges if the global resource pool is full.
107 boolean isGlobalPoolFull();
110 * Returns the unused label number of a label resource pool by a specific device
113 * @param deviceId device identifier
114 * @return number of unused labels
116 long getFreeNumOfDevicePool(DeviceId deviceId);
119 * Returns the unused number of a global label resource pool.
121 * @return number of unused labels
123 long getFreeNumOfGlobalPool();
126 * Returns the label resource pool by a specific device id.
128 * @param deviceId device identifier
129 * @return the device label resource pool
131 LabelResourcePool getDeviceLabelResourcePool(DeviceId deviceId);
134 * Returns the global label resource pool.
136 * @return the global label resource pool
138 LabelResourcePool getGlobalLabelResourcePool();