Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 52f2cd1 | 2018-11-08 21:20:04 -0800 | [diff] [blame] | 2 | * Copyright 2018-present Open Networking Foundation |
Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 3 | * |
| 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'Connor | 6de2e20 | 2015-05-21 14:30:41 -0700 | [diff] [blame] | 16 | package org.onosproject.incubator.net.resource.label; |
jcc | fff0de9 | 2015-03-28 01:40:08 -0700 | [diff] [blame] | 17 | |
| 18 | import java.util.Collection; |
| 19 | import java.util.Set; |
| 20 | |
Brian O'Connor | 893b922 | 2015-06-25 15:07:04 -0400 | [diff] [blame] | 21 | import com.google.common.annotations.Beta; |
jcc | fff0de9 | 2015-03-28 01:40:08 -0700 | [diff] [blame] | 22 | import org.onosproject.net.DeviceId; |
| 23 | import org.onosproject.store.Store; |
| 24 | |
| 25 | import com.google.common.collect.Multimap; |
| 26 | |
| 27 | /** |
| 28 | * Manages inventory of label; not intended for direct use. |
| 29 | * |
| 30 | */ |
Brian O'Connor | 893b922 | 2015-06-25 15:07:04 -0400 | [diff] [blame] | 31 | @Beta |
jcc | fff0de9 | 2015-03-28 01:40:08 -0700 | [diff] [blame] | 32 | public 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 | } |