Frank Wang | e11a98d | 2016-10-26 17:04:03 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Laboratory |
| 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 | */ |
| 16 | package org.onosproject.net.behaviour; |
| 17 | |
| 18 | import com.google.common.annotations.Beta; |
| 19 | import org.onlab.util.Bandwidth; |
| 20 | import org.onosproject.net.Annotated; |
| 21 | import org.onosproject.net.Description; |
| 22 | |
| 23 | import java.util.EnumSet; |
| 24 | import java.util.Optional; |
| 25 | |
| 26 | /** |
| 27 | * Default implementation of immutable Queue description. |
| 28 | */ |
| 29 | @Beta |
| 30 | public interface QueueDescription extends Description, Annotated { |
| 31 | |
| 32 | /** |
| 33 | * Denotes the type of the Queue. |
| 34 | */ |
| 35 | enum Type { |
| 36 | /** |
| 37 | * Support min rate. |
| 38 | */ |
| 39 | MIN, |
| 40 | |
| 41 | /** |
| 42 | * Support max rate. |
| 43 | */ |
| 44 | MAX, |
| 45 | |
| 46 | /** |
| 47 | * Support priority. |
| 48 | */ |
| 49 | PRIORITY, |
| 50 | |
| 51 | /** |
| 52 | * Support burst. |
| 53 | */ |
| 54 | BURST |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Returns queue identifier. |
| 59 | * |
| 60 | * @return queue identifier |
| 61 | */ |
| 62 | QueueId queueId(); |
| 63 | |
| 64 | /** |
| 65 | * Returns dscp in range 0 to 63. |
| 66 | * |
| 67 | * @return dscp |
| 68 | */ |
| 69 | Optional<Integer> dscp(); |
| 70 | |
| 71 | /** |
| 72 | * Returns type. |
| 73 | * |
| 74 | * @return type |
| 75 | */ |
| 76 | EnumSet<Type> type(); |
| 77 | |
| 78 | /** |
| 79 | * Returns max rate, Valid only in specific type. |
| 80 | * |
| 81 | * @return Maximum allowed bandwidth, in bit/s. |
| 82 | */ |
| 83 | Optional<Bandwidth> maxRate(); |
| 84 | |
| 85 | /** |
| 86 | * Returns min rate, Valid only in specific type. |
| 87 | * |
| 88 | * @return Minimum guaranteed bandwidth, in bit/s. |
| 89 | */ |
| 90 | Optional<Bandwidth> minRate(); |
| 91 | |
| 92 | /** |
| 93 | * Returns burst, Valid only in specific type. |
| 94 | * |
| 95 | * @return Burst size, in bits |
| 96 | */ |
| 97 | Optional<Long> burst(); |
| 98 | |
| 99 | /** |
| 100 | * Returns priority, Valid only in specific type. |
| 101 | * small number have higher priority, in range 0 to 0xFFFFFFFF |
| 102 | * @return priority |
| 103 | */ |
| 104 | Optional<Long> priority(); |
| 105 | |
| 106 | |
| 107 | |
| 108 | interface Builder { |
| 109 | |
| 110 | /** |
| 111 | * Returns queue description builder with given name. |
| 112 | * |
| 113 | * @param queueId queue identifier |
| 114 | * @return queue description builder |
| 115 | */ |
| 116 | Builder queueId(QueueId queueId); |
| 117 | |
| 118 | /** |
| 119 | * Returns queue description builder with given dscp. |
| 120 | * |
| 121 | * @param dscp dscp |
| 122 | * @return queue description builder |
| 123 | */ |
| 124 | Builder dscp(Integer dscp); |
| 125 | |
| 126 | /** |
| 127 | * Returns queue description builder with given type. |
| 128 | * |
| 129 | * @param type type |
| 130 | * @return queue description builder |
| 131 | */ |
| 132 | Builder type(EnumSet<Type> type); |
| 133 | |
| 134 | /** |
| 135 | * Returns queue description builder with max rate. |
| 136 | * @param maxRate Maximum allowed bandwidth |
| 137 | * @return queue description builder |
| 138 | */ |
| 139 | Builder maxRate(Bandwidth maxRate); |
| 140 | |
| 141 | /** |
| 142 | * Returns queue description builder with a given min rate. |
| 143 | * |
| 144 | * @param minRate Minimum guaranteed bandwidth |
| 145 | * @return queue description builder |
| 146 | */ |
| 147 | Builder minRate(Bandwidth minRate); |
| 148 | |
| 149 | /** |
| 150 | * Returns queue description builder with a given burst. |
| 151 | * |
| 152 | * @param burst burst size |
| 153 | * @return queue description builder |
| 154 | */ |
| 155 | Builder burst(Long burst); |
| 156 | |
| 157 | /** |
| 158 | * Returns queue description builder with a given priority. |
| 159 | * small number have higher priority, in range 0 to 0xFFFFFFFF |
| 160 | * @param priority priority |
| 161 | * @return queue description builder |
| 162 | */ |
| 163 | Builder priority(Long priority); |
| 164 | |
| 165 | /** |
| 166 | * Builds an immutable bridge description. |
| 167 | * |
| 168 | * @return queue description |
| 169 | */ |
| 170 | QueueDescription build(); |
| 171 | } |
| 172 | } |