blob: 91cdedc9bc52791d9d05af94c4cc604792d5c564 [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -07001/*
Thomas Vachuska52f2cd12018-11-08 21:20:04 -08002 * Copyright 2018-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;
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070022import org.onosproject.event.ListenerService;
jccfff0de92015-03-28 01:40:08 -070023import org.onosproject.net.DeviceId;
24
25import com.google.common.collect.Multimap;
26
27/**
28 * Service for providing label resource allocation.
29 */
Brian O'Connor893b9222015-06-25 15:07:04 -040030@Beta
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070031public interface LabelResourceService
32 extends ListenerService<LabelResourceEvent, LabelResourceListener> {
jccfff0de92015-03-28 01:40:08 -070033
34 /**
35 * Returns labels from resource pool by a specific device id.
36 *
37 * @param deviceId device identifier
38 * @param applyNum the applying number
39 * @return collection of applying labels
40 */
41 Collection<LabelResource> applyFromDevicePool(DeviceId deviceId,
42 long applyNum);
43
44 /**
45 * Returns labels from the global label resource pool.
46 *
47 * @param applyNum the applying number
48 * @return collection of applying labels
49 */
50 Collection<LabelResource> applyFromGlobalPool(long applyNum);
51
52 /**
53 * Releases unused labels to device pools .
54 *
55 * @param release the collection of releasing labels
56 * @return success or fail
57 */
58 boolean releaseToDevicePool(Multimap<DeviceId, LabelResource> release);
59
60 /**
61 * Releases unused labels to the global resource pool.
62 *
63 * @param release release the collection of releasing labels
64 * @return success or fail
65 */
66 boolean releaseToGlobalPool(Set<LabelResourceId> release);
67
68 /**
69 * Judges if the pool of a specific device id is full.
70 *
71 * @param deviceId device identifier
72 * @return yes or no
73 */
74 boolean isDevicePoolFull(DeviceId deviceId);
75
76 /**
77 * Judges if the global resource pool is full.
78 *
79 * @return yes or no
80 */
81 boolean isGlobalPoolFull();
82
83 /**
84 * Returns the unused label number of a label resource pool by a specific device
85 * id.
86 *
87 * @param deviceId device identifier
88 * @return number of unused labels
89 */
90 long getFreeNumOfDevicePool(DeviceId deviceId);
91
92 /**
93 * Returns the unused label number of a global label resource pool.
94 *
95 * @return number of unused labels
96 */
97 long getFreeNumOfGlobalPool();
98
99 /**
100 * Returns the label resource pool of a label resource by a specific device
101 * id.
102 *
103 * @param deviceId device identifier
104 * @return the device label resource pool
105 */
106 LabelResourcePool getDeviceLabelResourcePool(DeviceId deviceId);
107
108 /**
109 * Returns the global label resource pool.
110 *
111 * @return the global label resource pool
112 */
113 LabelResourcePool getGlobalLabelResourcePool();
114
jccfff0de92015-03-28 01:40:08 -0700115}