Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020-present Open Networking Foundation |
| 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.opencord.olt.impl; |
| 17 | |
| 18 | import org.onosproject.net.DeviceId; |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 19 | import org.onosproject.net.meter.MeterId; |
Tunahan Sezen | f0843b9 | 2021-04-30 07:13:16 +0000 | [diff] [blame] | 20 | import org.opencord.olt.AccessDevicePort; |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 21 | import org.opencord.sadis.UniTagInformation; |
| 22 | |
| 23 | import java.util.Objects; |
| 24 | |
| 25 | /** |
| 26 | * Contains the mapping of a given port to flow information, including bandwidth profile. |
| 27 | */ |
| 28 | class SubscriberFlowInfo { |
| 29 | private final DeviceId devId; |
Tunahan Sezen | f0843b9 | 2021-04-30 07:13:16 +0000 | [diff] [blame] | 30 | private final AccessDevicePort nniPort; |
| 31 | private final AccessDevicePort uniPort; |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 32 | private final UniTagInformation tagInfo; |
| 33 | private MeterId downId; |
| 34 | private MeterId upId; |
yasin sapli | b4b8ee1 | 2021-06-13 18:25:20 +0000 | [diff] [blame^] | 35 | private MeterId downOltId; |
| 36 | private MeterId upOltId; |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 37 | private final String downBpInfo; |
| 38 | private final String upBpInfo; |
yasin sapli | b4b8ee1 | 2021-06-13 18:25:20 +0000 | [diff] [blame^] | 39 | private final String downOltBpInfo; |
| 40 | private final String upOltBpInfo; |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 41 | |
| 42 | /** |
| 43 | * Builds the mapper of information. |
yasin sapli | b4b8ee1 | 2021-06-13 18:25:20 +0000 | [diff] [blame^] | 44 | * @param nniPort the nni port |
| 45 | * @param uniPort the uni port |
| 46 | * @param tagInfo the tag info |
| 47 | * @param downId the downstream meter id |
| 48 | * @param upId the upstream meter id |
| 49 | * @param downOltId the downstream meter id of OLT device |
| 50 | * @param upOltId the upstream meter id of OLT device |
| 51 | * @param downBpInfo the downstream bandwidth profile |
| 52 | * @param upBpInfo the upstream bandwidth profile |
| 53 | * @param downOltBpInfo the downstream bandwidth profile of OLT device |
| 54 | * @param upOltBpInfo the upstream bandwidth profile of OLT device |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 55 | */ |
Tunahan Sezen | f0843b9 | 2021-04-30 07:13:16 +0000 | [diff] [blame] | 56 | SubscriberFlowInfo(AccessDevicePort nniPort, AccessDevicePort uniPort, |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 57 | UniTagInformation tagInfo, MeterId downId, MeterId upId, |
yasin sapli | b4b8ee1 | 2021-06-13 18:25:20 +0000 | [diff] [blame^] | 58 | MeterId downOltId, MeterId upOltId, |
| 59 | String downBpInfo, String upBpInfo, |
| 60 | String downOltBpInfo, String upOltBpInfo) { |
Tunahan Sezen | f0843b9 | 2021-04-30 07:13:16 +0000 | [diff] [blame] | 61 | this.devId = uniPort.deviceId(); |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 62 | this.nniPort = nniPort; |
| 63 | this.uniPort = uniPort; |
| 64 | this.tagInfo = tagInfo; |
| 65 | this.downId = downId; |
| 66 | this.upId = upId; |
yasin sapli | b4b8ee1 | 2021-06-13 18:25:20 +0000 | [diff] [blame^] | 67 | this.downOltId = downOltId; |
| 68 | this.upOltId = upOltId; |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 69 | this.downBpInfo = downBpInfo; |
| 70 | this.upBpInfo = upBpInfo; |
yasin sapli | b4b8ee1 | 2021-06-13 18:25:20 +0000 | [diff] [blame^] | 71 | this.downOltBpInfo = downOltBpInfo; |
| 72 | this.upOltBpInfo = upOltBpInfo; |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Gets the device id of this subscriber and flow information. |
| 77 | * |
| 78 | * @return device id |
| 79 | */ |
| 80 | DeviceId getDevId() { |
| 81 | return devId; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Gets the nni of this subscriber and flow information. |
| 86 | * |
| 87 | * @return nni port |
| 88 | */ |
Tunahan Sezen | f0843b9 | 2021-04-30 07:13:16 +0000 | [diff] [blame] | 89 | AccessDevicePort getNniPort() { |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 90 | return nniPort; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Gets the uni port of this subscriber and flow information. |
| 95 | * |
| 96 | * @return uni port |
| 97 | */ |
Tunahan Sezen | f0843b9 | 2021-04-30 07:13:16 +0000 | [diff] [blame] | 98 | AccessDevicePort getUniPort() { |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 99 | return uniPort; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Gets the tag of this subscriber and flow information. |
| 104 | * |
| 105 | * @return tag of the subscriber |
| 106 | */ |
| 107 | UniTagInformation getTagInfo() { |
| 108 | return tagInfo; |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Gets the downstream meter id of this subscriber and flow information. |
| 113 | * |
| 114 | * @return downstream meter id |
| 115 | */ |
| 116 | MeterId getDownId() { |
| 117 | return downId; |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * Gets the upstream meter id of this subscriber and flow information. |
| 122 | * |
| 123 | * @return upstream meter id |
| 124 | */ |
| 125 | MeterId getUpId() { |
| 126 | return upId; |
| 127 | } |
| 128 | |
| 129 | /** |
yasin sapli | b4b8ee1 | 2021-06-13 18:25:20 +0000 | [diff] [blame^] | 130 | * Gets the downstream meter id of this subscriber and flow information of OLT device. |
| 131 | * |
| 132 | * @return downstream olt meter id |
| 133 | */ |
| 134 | MeterId getDownOltId() { |
| 135 | return downOltId; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Gets the upstream meter id of this subscriber and flow information of OLT device. |
| 140 | * |
| 141 | * @return upstream olt meter id |
| 142 | */ |
| 143 | MeterId getUpOltId() { |
| 144 | return upOltId; |
| 145 | } |
| 146 | |
| 147 | /** |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 148 | * Gets the downstream bandwidth profile of this subscriber and flow information. |
| 149 | * |
| 150 | * @return downstream bandwidth profile |
| 151 | */ |
| 152 | String getDownBpInfo() { |
| 153 | return downBpInfo; |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * Gets the upstream bandwidth profile of this subscriber and flow information. |
| 158 | * |
| 159 | * @return upstream bandwidth profile. |
| 160 | */ |
| 161 | String getUpBpInfo() { |
| 162 | return upBpInfo; |
| 163 | } |
| 164 | |
| 165 | /** |
yasin sapli | b4b8ee1 | 2021-06-13 18:25:20 +0000 | [diff] [blame^] | 166 | * Gets the downstream bandwidth profile of this subscriber and flow information of OLT device. |
| 167 | * |
| 168 | * @return downstream OLT bandwidth profile |
| 169 | */ |
| 170 | String getDownOltBpInfo() { |
| 171 | return downOltBpInfo; |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Gets the upstream bandwidth profile of this subscriber and flow information of OLT device. |
| 176 | * |
| 177 | * @return upstream OLT bandwidth profile. |
| 178 | */ |
| 179 | String getUpOltBpInfo() { |
| 180 | return upOltBpInfo; |
| 181 | } |
| 182 | |
| 183 | /** |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 184 | * Sets the upstream meter id. |
yasin sapli | b4b8ee1 | 2021-06-13 18:25:20 +0000 | [diff] [blame^] | 185 | * |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 186 | * @param upMeterId the upstream meter id |
| 187 | */ |
| 188 | void setUpMeterId(MeterId upMeterId) { |
| 189 | this.upId = upMeterId; |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * Sets the downstream meter id. |
yasin sapli | b4b8ee1 | 2021-06-13 18:25:20 +0000 | [diff] [blame^] | 194 | * |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 195 | * @param downMeterId the downstream meter id |
| 196 | */ |
| 197 | void setDownMeterId(MeterId downMeterId) { |
| 198 | this.downId = downMeterId; |
| 199 | } |
| 200 | |
yasin sapli | b4b8ee1 | 2021-06-13 18:25:20 +0000 | [diff] [blame^] | 201 | /** |
| 202 | * Sets the upstream meter id of OLT. |
| 203 | * |
| 204 | * @param upOltMeterId the upstream meter id of OLT |
| 205 | */ |
| 206 | void setUpOltMeterId(MeterId upOltMeterId) { |
| 207 | this.upOltId = upOltMeterId; |
| 208 | } |
| 209 | |
| 210 | /** |
| 211 | * Sets the downstream meter id of OLT. |
| 212 | * |
| 213 | * @param downOltMeterId the downstream meter id of OLT |
| 214 | */ |
| 215 | void setDownOltMeterId(MeterId downOltMeterId) { |
| 216 | this.downOltId = downOltMeterId; |
| 217 | } |
| 218 | |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 219 | @Override |
| 220 | public boolean equals(Object o) { |
| 221 | if (this == o) { |
| 222 | return true; |
| 223 | } |
| 224 | if (o == null || getClass() != o.getClass()) { |
| 225 | return false; |
| 226 | } |
| 227 | SubscriberFlowInfo flowInfo = (SubscriberFlowInfo) o; |
| 228 | return devId.equals(flowInfo.devId) && |
| 229 | nniPort.equals(flowInfo.nniPort) && |
| 230 | uniPort.equals(flowInfo.uniPort) && |
| 231 | tagInfo.equals(flowInfo.tagInfo) && |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 232 | downBpInfo.equals(flowInfo.downBpInfo) && |
yasin sapli | b4b8ee1 | 2021-06-13 18:25:20 +0000 | [diff] [blame^] | 233 | upBpInfo.equals(flowInfo.upBpInfo) && |
| 234 | Objects.equals(downOltBpInfo, flowInfo.downOltBpInfo) && |
| 235 | Objects.equals(upOltBpInfo, flowInfo.upOltBpInfo); |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | @Override |
| 239 | public int hashCode() { |
yasin sapli | b4b8ee1 | 2021-06-13 18:25:20 +0000 | [diff] [blame^] | 240 | return Objects.hash(devId, nniPort, uniPort, tagInfo, downBpInfo, upBpInfo, downOltBpInfo, upOltBpInfo); |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | @Override |
| 244 | public String toString() { |
| 245 | return com.google.common.base.MoreObjects.toStringHelper(this) |
| 246 | .add("devId", devId) |
| 247 | .add("nniPort", nniPort) |
| 248 | .add("uniPort", uniPort) |
| 249 | .add("tagInfo", tagInfo) |
| 250 | .add("downId", downId) |
| 251 | .add("upId", upId) |
yasin sapli | b4b8ee1 | 2021-06-13 18:25:20 +0000 | [diff] [blame^] | 252 | .add("downOltId", downOltId) |
| 253 | .add("upOltId", upOltId) |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 254 | .add("downBpInfo", downBpInfo) |
| 255 | .add("upBpInfo", upBpInfo) |
yasin sapli | b4b8ee1 | 2021-06-13 18:25:20 +0000 | [diff] [blame^] | 256 | .add("downOltBpInfo", downOltBpInfo) |
| 257 | .add("upOltBpInfo", upOltBpInfo) |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 258 | .toString(); |
| 259 | } |
| 260 | } |