blob: 62dbe5d410fba4290e35f8a6f89b11a423a19a6d [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Thomas Vachuska58de4162015-09-10 16:15:33 -07003 *
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 */
Brian O'Connor6de2e202015-05-21 14:30:41 -070016package org.onosproject.incubator.net.resource.label;
jccfff0de92015-03-28 01:40:08 -070017
18import java.util.Collection;
19import java.util.Set;
20
Brian O'Connor893b9222015-06-25 15:07:04 -040021import com.google.common.annotations.Beta;
jccfff0de92015-03-28 01:40:08 -070022import org.onosproject.net.DeviceId;
23import org.onosproject.store.Store;
24
25import com.google.common.collect.Multimap;
26
27/**
28 * Manages inventory of label; not intended for direct use.
29 *
30 */
Brian O'Connor893b9222015-06-25 15:07:04 -040031@Beta
jccfff0de92015-03-28 01:40:08 -070032public interface LabelResourceStore
33 extends Store<LabelResourceEvent, LabelResourceDelegate> {
34
35 /**
36 * Creates a label resource of some device id from begin label to end label.
37 *
38 * @param deviceId device identifier
39 * @param beginLabel represents for the first label id in the range of label
40 * pool
41 * @param endLabel represents for the last label id in the range of label
42 * pool
43 * @return success or fail
44 */
45 boolean createDevicePool(DeviceId deviceId, LabelResourceId beginLabel,
46 LabelResourceId endLabel);
47
48 /**
49 * Creates the global label resource pool.
50 *
51 * @param beginLabel represents for the first label id in the range of label
52 * pool
53 * @param endLabel represents for the last label id in the range of label
54 * pool
55 * @return success or fail
56 */
57 boolean createGlobalPool(LabelResourceId beginLabel,
58 LabelResourceId endLabel);
59
60 /**
61 * Destroys a label resource pool of a specific device id.
62 *
63 * @param deviceId device identifier
64 * @return success or fail
65 */
66 boolean destroyDevicePool(DeviceId deviceId);
67
68 /**
69 * Destroys a the global label resource pool.
70 *
71 * @return success or fail
72 */
73 boolean destroyGlobalPool();
74
75 /**
76 * Returns labels from resource pool by a specific device id.
77 *
78 * @param deviceId device identifier
79 * @param applyNum the applying number
80 * @return collection of applying labels
81 */
82 Collection<LabelResource> applyFromDevicePool(DeviceId deviceId,
83 long applyNum);
84
85 /**
86 * Returns labels from the global label resource pool.
87 *
88 * @param applyNum apply the number of labels
89 * @return collection of labels
90 */
91 Collection<LabelResource> applyFromGlobalPool(long applyNum);
92
93 /**
94 * Releases unused labels to device pools .
95 *
96 * @param release the collection of releasing labels
97 * @return success or fail
98 */
99 boolean releaseToDevicePool(Multimap<DeviceId, LabelResource> release);
100
101 /**
102 * Releases unused labels to the global resource pool.
103 *
104 * @param release release the collection of releasing labels
105 * @return success or fail
106 */
107 boolean releaseToGlobalPool(Set<LabelResourceId> release);
108
109 /**
110 * Judges if the pool of a specific device id is full.
111 *
112 * @param deviceId device identifier
113 * @return yes or no
114 */
115 boolean isDevicePoolFull(DeviceId deviceId);
116
117 /**
118 * Judges if the global resource pool is full.
119 *
120 * @return yes or no
121 */
122 boolean isGlobalPoolFull();
123
124 /**
125 * Returns the unused label number of a label resource pool by a specific device
126 * id.
127 *
128 * @param deviceId device identifier
129 * @return number of unused labels
130 */
131 long getFreeNumOfDevicePool(DeviceId deviceId);
132
133 /**
134 * Returns the unused number of a global label resource pool.
135 *
136 * @return number of unused labels
137 */
138 long getFreeNumOfGlobalPool();
139
140 /**
141 * Returns the label resource pool by a specific device id.
142 *
143 * @param deviceId device identifier
144 * @return the device label resource pool
145 */
146 LabelResourcePool getDeviceLabelResourcePool(DeviceId deviceId);
147
148 /**
149 * Returns the global label resource pool.
150 *
151 * @return the global label resource pool
152 */
153 LabelResourcePool getGlobalLabelResourcePool();
154}